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

Read record from RFID card string UUID via nfc scan reader #653

Open
ankitraut05 opened this issue Feb 19, 2023 · 11 comments
Open

Read record from RFID card string UUID via nfc scan reader #653

ankitraut05 opened this issue Feb 19, 2023 · 11 comments

Comments

@ankitraut05
Copy link

#WebNFC I am using Web NFC in my project. i coming difficulties to read values from RFID card through scan card on nfc reader in Web application. can you help me for how to read hexadecimal, decimal (UUID) from RFID card.

@beaufortfrancois
Copy link
Collaborator

Can you share the model of the NFC device and some of your code so that we can help you?
Do you get at least one NDEF record when you try https://googlechrome.github.io/samples/web-nfc/?

@ankitraut05
Copy link
Author

ankitraut05 commented Feb 20, 2023 via email

@beaufortfrancois
Copy link
Collaborator

Can you share a screenshot of what kind of results you get?

@ankitraut05
Copy link
Author

ankitraut05 commented Feb 20, 2023 via email

@beaufortfrancois
Copy link
Collaborator

You may want to use GitHub website interface to upload the screenshot.

image

@ankitraut05
Copy link
Author

WebAppwithNFC

Open this link and see

@beaufortfrancois
Copy link
Collaborator

beaufortfrancois commented Feb 20, 2023

Thank you! Now, where's the value you're trying to read? It looks like you only have one NDEF record for now.
If you wanted to write an hexadecimal value for instance, you could do something like below:

const ndef = new NDEFReader();
await ndef.write(0x1234);

And for reading it, you could do:

const textDecoder = new TextDecoder(record.encoding);
const text = textDecoder.decode(record.data);
console.log(text.toString(16));  // 1234
}

FYI https://developer.chrome.com/articles/nfc/#read-and-write-a-text-record contains plenty of code examples.

@ankitraut05
Copy link
Author

ankitraut05 commented Feb 20, 2023 via email

@beaufortfrancois
Copy link
Collaborator

Then it means you can't write to this device right? Can you copy/paste the result of NDEF records you successfully read?

@ankitraut05
Copy link
Author

ankitraut05 commented Mar 12, 2023 via email

@eklem
Copy link

eklem commented Mar 12, 2023

It's only available in secure context, @ankitraut05
I'm guessing every production environment should be https, but it makes it a bit more difficult when developing.

I'm using VSCode and using Ngrok and Live Server to make it work when developing. Just a little work the first time, and then it works smoothly. Here's a little bit more about the setup I use.

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

3 participants