android - How can I reconnect to IsoDep tag? -
i'm trying send apdu commands android phone nfc tag , answers. type of used technology isodep. works fine, sometimes, when time between sending commands large, tag switches disabled state , after every reconnection fails.
my code:
public byte[] transfercommand(byte[] command) throws exception { byte[] result = null; if (iso == null) { iso = isodep.get(tag); iso.connect(); } if (!iso.isconnected()) { try { iso.close(); iso.connect(); result = iso.transceive(command); } catch (exception ex) { iso.close(); } } return result; }
could me please? thank much.
the connect
, related commands managing logical connection tag. is: grant thread , application exclusive access tag object. don't physical tag connection. (at least far know, it's been while since last read nfcservice code).
therefore connecting , reconnecting not once tag stops answer requests. can in case physically remove tag , present reader again.
if run timeout problems try raising timeout value calling settimeout
on tag object.
Comments
Post a Comment