I was wondering how to change the length of the timeout for receiving a reply from a NfcA type card in Android. I saw how to chan开发者_Python百科ge it on a Iso-Dep type card, but not on the NfcA type card. Also, does anyone know how long the timeout is for a NfcA card? I am using a custom card and want to know how much processing time I have on the card before I have to reply.
NfcA is just a subtype of IsoDep, so the IsoDep timeout will work for NfcA and NfcB.
The NFC-Stack should negotiate a suitable time-out values with the tag and use it. However, if you connect to a smartcard that has an applications which exceed the timing constraints (Warning: bad programmer alert!) raising the time-out may be necessary to get things working.
In this case use the IsoDep command and extend the time-out.
If you have contact to the guys who wrote the smartcard code you may even get an answer about how long certain commands (cryptographic hash calculation is one common problem) may take at max.. If you don't have contact you can only experiment.
Another thing: Judging from the Android API it looks like you have full control about the time-out value. This is not true! If you extend it beyond what is allowed by the high level protocols you will run into lots of trouble. In this case you can expect anything from unreliable functionality to a total crash of the NFC-subsystem. (Just saying..)
Since API level 14, there is also a setTimeout() for NfcA. Before that API level, the timeout is fixed and is about 300ms.
精彩评论