LoginSignup
0
1

More than 5 years have passed since last update.

nfcpyでgoogle payを扱うとidmが出ない件の対処法

Posted at

まとめ

明示的にSuicaを読み取るようにしよう。
おしまい


kagisysを改造した際に、google payだとidmが正常に取れない(088ff みたいになる)問題があったので対応した話です。
基本的に apple payのエクスプレスカード と一緒で、suicaのみ明示的に読んであげれば治ります。

これ↓を

old.py
def on_connect(tag):
    if isinstance(tag,nfc.tag.tt3.Type3Tag)
        idm = binascii.hexlify(tag.idm)
        print(idm)
with nfc.ContactlessFrontend('usb') as clf
    clf.connect(rdwr={'on-connect': on_connect})

こう↓

new.py
with nfc.ContactlessFrontend('usb') as clf:
    target_req = nfc.clf.RemoteTarget("212F")
    target_req.sensf_req = bytearray.fromhex("0000030000")
    while 1:
        target_res = clf.sense(target_req,iterations=10,interval=0.01)
        if target_res != None:
            #idmを取るだけならactivateしなくていい
            tag = nfc.tag.activate(clf,target_res)
            tag.sys = 3
            idm = binascii.hexlify(tag.idm)
            print(idm)
            break

これでみんなもlet's nfcpy!

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1