dotnet / iot

This repo includes .NET Core implementations for various IoT boards, chips, displays and PCBs.
MIT License
2.12k stars 574 forks source link

UltralightCardType detect bug #2285

Closed huangmagyc closed 3 months ago

huangmagyc commented 4 months ago

I have nfc sticker, this chip is NTAG216,i trying PN532 and initialize UltralightCard then UltralightCardType enum shows unknown. I view UltralightCard constructor , about NTAG216 card type check by GetVersion bytes may be not right.

this version 3.1 code

//...
else if ((Data[2] == 0x04) && (Data[3] == 0x01) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x13))
{
    NdefCapacity = 888;
    UltralightCardType = UltralightCardType.UltralightNtag216;
}
//...

the NTAG216 GetVersion bytes[3] is right to 0x02

//...
else if ((Data[2] == 0x04) && (Data[3] == 0x02) && (Data[4] == 0x01) && (Data[5] == 0x00) && (Data[6] == 0x13))
{
    NdefCapacity = 888;
    UltralightCardType = UltralightCardType.UltralightNtag216;
}
//...
Ellerbach commented 4 months ago

Correct, just checked here: https://www.nxp.com/docs/en/data-sheet/NTAG213_215_216.pdf Table 28: image

PR welcome if you want to fix it! I4ll be happy to approve and review it. While you'll be there, please check that the 2 others are correct :-)