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

payloadAsString doesn't work as expected? #67

Open
white-rabbit07 opened this issue Mar 16, 2021 · 2 comments
Open

payloadAsString doesn't work as expected? #67

white-rabbit07 opened this issue Mar 16, 2021 · 2 comments

Comments

@white-rabbit07
Copy link

Hi. I used this example
https://github.com/don/NDEF/blob/master/examples/ReadTagExtended/ReadTagExtended.ino
to read a RFID-Tag and compare the written text with a given string. It doesn't work as expected and as far as I can tell it's because of a 0x00 that is saved with the string.

I tried this:
if (payloadAsString == Hammer) {Serial.println(" The object is a Hammer"); }
... but it fails.

This snippet seems to be the problem:
String payloadAsString = ""; for (int c = 0; c < payloadLength; c++) { payloadAsString += (char)payload[c]; }

Any hints what to change?

@white-rabbit07
Copy link
Author

a possible workaround:
String payloadAsString = ""; for (int c = 1; c < payloadLength; c++) { payloadAsString += (char)payload[c]; }
by using c=1 the initial 0x00 won't be read!

@white-rabbit07
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant