まとめ
明示的に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!
参考
- nfcpyでapple payのエクスプレスカードを扱う