0

I'm using an NTAG I2C plus 2k memory tag and am able to successfully perform a FAST_READ for a particular page address range, but just beyond the range I'm getting an error.

iOS

Start address 0x04 and end address 0x46 reads successfully

await cmd([0x3a, 0x04, 0x46]);

while, start address 0x04 and end address 0x47 fails with

await cmd([0x3a, 0x04, 0x47]);

Error

input bytes: 3A0C0C
input bytes: 3A0447
[CoreNFC] 00000002 816c6760 -[NFCTagReaderSession transceive:tagUpdate:error:]:771  Error Domain=NFCError Code=100 "Tag connection lost" UserInfo={NSLocalizedDescription=Tag connection lost}

Android

Start address 0x04 and end address 0x49 reads successfully

await cmd([0x3a, 0x04, 0x49]);

while, start address 0x04 and end address 0x4b fails with

await cmd([0x3a, 0x04, 0x4b]);

Error

D/NfcService: Transceive start
D/NfcService: Transceive End, Result: 0 mTransceiveSuccess: 1 mTransceiveFail: 0
D/NfcService: Transceive start
D/NfcService: Transceive End, Result: 2 mTransceiveSuccess: 1 mTransceiveFail: 1
D/ReactNativeNfcManager: transceive fail: android.nfc.TagLostException: Tag was lost.
I/ReactNativeJS: Error: transceive fail

Thanks in advance.

calcrisk33
  • 437
  • 1
  • 6
  • 15

1 Answers1

1

From the Tag's datasheet

Remark: The FAST_READ command is able to read out the entire memory of one sector with one command. Nevertheless, the receive buffer of the NFC device must be able to handle the requested amount of data as no chaining is possible

When I do a FAST_READ on a similar Tag type on Android in native code I do a getMaxTransceiveLength to find out how big the buffer is and divide that by 4 and round down to find the max number of pages a FAST_READ can do at once and break up in to multiple FAST_READ's if necessary.

Generally the max Transceive length is 253 bytes on Android or 63 pages.

The react-native-nfc-manager API for Android also has getMaxTransceiveLength in it's API so you can do the same calculation of the maximum pages a FAST_READ can do on your hardware.

I've not done FAST_READ's on iOS but expect there is a similar limit (it does have an error code for transceive packet too large but I've not seen a way to ask it the max transceive length before you send a command)

While probably getMaxTransceiveLength is meant for size of sending command this amount of bytes should be able to be returned before the transceive timeout is hit, as the send and receive data rate is identical.

The transceive timeout can set but not got using react-native-nfc-manager API

Again no options on changing any timeout values in iOS but there is an error to indicate that the communication to the Tag has timed out.

So you could try increasing the timeout value on Android instead of breaking up in to a number of FAST_READ's but working out how long the timeout should be could be difficult and might have a negative impact if you set it too big.

For Android it's probably easier to assume the max send size is safe to receive as well. For iOS assume a max receive size from your experiments or handle the error and re-read with a back off algorithm.

Andrew
  • 8,198
  • 2
  • 15
  • 35