adafruit / Adafruit_CircuitPython_PN532

CircuitPython driver for the PN532 NFC/RFID Breakout and PN532 NFC/RFID Shield
MIT License
91 stars 47 forks source link

Faster way to detect when a card disconnects #50

Closed dimpolo closed 1 year ago

dimpolo commented 2 years ago

Is ther a faster way to detect when a card disconnects other than continuously calling pn532.read_passive_target() until it times out? _COMMAND_INLISTPASSIVETARGET can be rather slow to respond (sometimes >100ms).

I tried this: pn532.call_function(_COMMAND_GETGENERALSTATUS, 8)

It reports the number of targets connected, but it doesn't update until I run some other target command. Does someone know if there's a different command for this?

dimpolo commented 2 years ago

I found a way:

pn532.call_function(_COMMAND_INDESELECT, 1, [1])
pn532.call_function(_COMMAND_INSELECT, 1, [1])

Feel free to close this. Feel free to add a check_if_target_still_there method