UltralightCard fixes - byte order of ATQA, number of blocks in EV1 #2022
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The ATQA returned by NFC anticollision is converted by a ushort by the Mfrc522, Pn532, and Pn5180 transceivers. In the case of the Mfrc522, the byte order was reversed - which was corrected by #2005. However, perhaps because the ATQA ushorts were inconsistently calculated by the different transceivers, it is also inconsistently used. Iot.Device.Card.Mifare.SetCapacity expects the ATQA of a Mifare classic 1K card to be 0x0004 and the ATQA of a Mifare classic 4K card to be 0x0002 (which are the values defined by NXP for those parts). However, Iot.Device.Card.Ultralight.UltralightCard.IsUltralightCard expects the ATQA of an Ultralight card to be 0x4400, when it should be 0x0044 according to the NXP spec.
In addition, the property UltralightCard.NumberBlocks returns the number of blocks based upon the type of the card. The values returned for UltralightEV1 cards are incorrect. This causes the sample code to attempt to read past the end of the card prevents the card configuration from being decoded.
This change aligns the expected ATQA and the actual number of blocks with the spec.
Tested with an Mfrc522 and a Pn532 using Mifare Classic and Ultralight cards. The cards are now correctly identified.
Microsoft Reviewers: Open in CodeFlow