question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Different UIDs on iOS / Android with ISO15693 Tag

See original GitHub issue

I’m using the following code to read out the UID in iOS / Android within an ionic app. With the most NFC Tags everything is working as expected.

But with ISO15693 Tags I get the wrong UID for iOS. I checked the UID with the iOS/Android App NFC-Tools. There both UIDs are the same.

With the plugin I get an other UID. Any Idea, what I am doing wrong?

if (this.platform.is('ios')) {
  // Handling iOS
  try {
    const nfcTag = await this.nfc.scanTag();
    return this.nfc.bytesToHexString(nfcTag.id);
  } catch (e) {
    // ...
  }
} else {
  // Handling Android
  return new Promise((resolve, reject) => {
    let flags = this.nfc.FLAG_READER_NFC_A | this.nfc.FLAG_READER_NFC_V;
    const subscription = this.nfc.readerMode(flags).subscribe(
      nfcTag => {
        const uid = this.nfc.bytesToHexString(nfcTag.id);
        subscription.unsubscribe();
        resolve(uid);
      },
      err => {
        // ...
      }
    );
  });
}

Example for the same ISO15693 Tag:

// ios
// Raw: [224, 4, 1, 80, 118, 210, 129, 5]
// nfc.bytesToHexString: e004015076d28105

// android
// Raw: [5, -127, -46, 118, 80, 1, 4, -32]
// nfc.bytesToHexString: 0581d276500104e0

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
aaronbachcommented, Feb 28, 2021

I wrapped my code with the following function to gather the correct uid. Not every NFC-tag used with our app is ISO conform, so I think the function should do the trick:

getUid (byteArray: number[]) {
  const uid = this.nfc.bytesToHexString(byteArray);
  // If UID is not starting with 'e0' => reverse the byte array
  if (uid.substr(0, 2).toLowerCase() !== 'e0') {
    const revUid = this.nfc.bytesToHexString(byteArray.reverse());
    if (revUid.substr(0, 2).toLowerCase() === 'e0') {
      return revUid;
    }
  }
  return uid;
}

thank you @erikm30

0reactions
mameiercommented, Sep 9, 2022

As the lower 6 Byte are simply a serial number, and the standard does’n mention that 0x0E is forbidden as last byte of the serial number, probaly every 256th ID might be misinterpreted.

It’s better to check the os. If its Android, reverse the bytes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type 5 tag which is ISO 15693, In android, it's not working... I ...
Type 5 tag which is ISO 15693, In android, it's not working... I'm able to send command and read mailbox in ios, But...
Read more >
ISO15693 - Tag connection lost on any read command - iOS 13
Im trying to send a readMultipleBlocks command to my ISO15693 tag, which works perfectly on android. Yet on iOS I always get a...
Read more >
UID Changeable ISO15693 iCode SLI NTAG - MTools Tec
The UID can be modified ONLY with an external device (Proxmark3 X and iCopy-X devices). The UID cannot be changed with NFC hardware...
Read more >
Core NFC | Apple Developer Forums
Hello,I am currently writing a little prototype using CoreNFC and NFCTagReaderSession with ISO15693 tags.I have a custom command that takes some data as...
Read more >
Android Question Reading NfcV tag ISO15693 - B4X
but the result is different each time the same tag is read! TagTech.Initialize("TagTech", "android.nfc.tech.NfcV" , si) 'Get the UID
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found