Web NFC (and writing to NFC tags) #4234
Replies: 1 comment
-
Posted at 2020-12-31 by François NDEFWriter has been merged into NDEFReader recently. See espruino/EspruinoDocs#589 Posted at 2021-01-05 by @gfwilliams Thanks! Updated code is here: http://www.espruino.com/Web+NFC Posted at 2023-08-11 by user156200 Hi. Looking at this code it would seem that programming is done with an Android device. Is there an option to do so by program ? The idea would be to dynamically change the Tag content. The NRF.nfcURL is stated to advertise an URL. Would that be as a tag and can this url be updated with subsequent calls to this function ? Posted at 2023-08-11 by user156200
Posted at 2023-08-14 by @gfwilliams
Yes - absolutely! So once called, if the Puck.js/etc is scanned with a device then that device will grab the URL. You can change the URL as often as you like so can transfer information that way if you wish. Posted at 2023-08-23 by user156200 Yes this works however it seem to be some kind of unwarranted size limitation. The TAG has a max message size of 246 bytes (256-10 I guess) while the capabilities NDEF Capability container has 992 bytes. I assume this is set during initialization before the actual URL is set. Adding a longer URL just truncate it... Any clue on how to fix this ? Posted at 2023-08-23 by @fanoush
you mean you need url over 246 characters?
I think this line is the issue, it saves length as single byte Fortunately there is also the Posted at 2023-08-23 by user156200 Yes I need a longer URL. To give some context I am including a signature in the URL over the payload and that stretches well beyond the current limit but may be viable if the 900+ available space. Posted at 2023-08-23 by @fanoush Oh, actually when checking nfcRaw method it has same limitation :-( Posted at 2023-08-23 by user156200 Bummer so major surgery is needed. But thanks I now where to look to correct this. I have to check if we want to go this route and take it from there. Posted at 2023-08-24 by @fanoush I have reported it here espruino/Espruino#2406 Looks like bug as all the allocations and adding termination part uses full length. Until that is fixed you could also use the code above in post #1 which emulates whole NFC tag including everything. Posted at 2023-08-25 by @fanoush Made a PR with a fix, both NRF.nfcUrl and NRF.nfcRaw should work with NDEF block length over 254 bytes. It works for me. Posted at 2023-08-29 by @gfwilliams Thanks for your work on this @fanoush! I'm just back from holidays today but I'll give this a check over and merge ASAP Posted at 2023-08-29 by @fanoush It was good timing. Never tried NFC before but now I am testing those 52832 based keychain NFC tags https://forum.espruino.com/conversations/388395/ They are simple - no sensors, just button, two leds, piezo and NFC, but they are small and cheap and even have 32kHz crystal and DC/DC enabled. Espruino on the keychain is cool and NFC and piezo speaker is a nice bonus, typical smart watch is missing both. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-09-25 by @gfwilliams
Hi, I'll try and turn this into a tutorial at some point, but it turns out you can now use 'Web NFC' on Android to read and write NFC tags including Puck.js/Pixl.js.
HTML looks like this:
Puck.js/Pixl.js code is a bit more complex as right now it's emulating an NFC tag in JS:
But basically this lets you send strings of data over NFC (no bluetooth connection needed). You just hold the phone near, tap 'red/green/blue' and then when you move the phone away Puck.js reads the text in the tag and decides what colour to make itself...
Beta Was this translation helpful? Give feedback.
All reactions