Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ultralight NDEF fixes #2060

Merged
merged 1 commit into from
Mar 30, 2023
Merged

Ultralight NDEF fixes #2060

merged 1 commit into from
Mar 30, 2023

Conversation

jdbruner
Copy link
Contributor

@jdbruner jdbruner commented Mar 25, 2023

This fixes NDEF issues in UltralightCard:

FormatNdef reads block 3 (the OTP block) to determine if it contains the correct values; if not, it writes to it. Then it writes an empty NDEF tag in block 4. However, it relies upon the Command and Data properties being set by the write to block 3. If the write to block 3 didn't happen, then instead of writing to block 4 it was reading block 4.

WriteNdefMessage intends to compare the required size for the NDEF tag against the available memory on the card, but there is an error in the comparison. Also, it will now throw ArgumentOutOfRangeException when the size is too large (instead of returning false), so that it is more consistent with behavior of MifareCard.WriteNdefMessage. The code was treating a non-positive return from RunUltralightCommand as an error, but in the case of a successful write it returns 0.

Microsoft Reviewers: Open in CodeFlow

@ghost ghost added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label Mar 25, 2023
Copy link
Member

@Ellerbach Ellerbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I've started to play again with all this and found out some other issues. I'll need to check if those has been fixed with the PR and the latest one as well.

@krwq krwq merged commit 91aa85a into dotnet:main Mar 30, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants