-
-
Notifications
You must be signed in to change notification settings - Fork 736
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
NRF.nfcRaw (and nfcUrl) limited to payload/message length 255 #2406
Comments
The Pucket.js with the Nordic Semiconductor chip set supports up to 992 bytes. Limiting the usable size to 246 bytes should be avoided. |
When checking the source and nfc tag 2 type an NDEF structures the header here https://github.com/espruino/Espruino/blob/master/libs/bluetooth/bluetooth.h#L319 At position 0x10 there is 0x03 0x00 with comments TT - tag type (03), ML message len (0) And then there is TF = TNF and Flags = 0xC1. In this the SR bit in not set so the payload length then takes 4 bytes. So the first part of the header does not allow size over 254 and then the NDEF payload is in long format to allow more, but only one byte is written in code anyway. However If I understand it correctly the TT+ML is in fact something called TLV block described here So my guess is to fix that
|
also found this https://stackoverflow.com/a/42108779 where it confirms my guess
So it should work, however I am not sure what happens when for simplicity we will encode length <255 in longer format i.e. 254 as 0x03 0xff 0x00 0xFE - should be valid but maybe it may confuse some implementations? |
If it works with IOS/Android which can be tested my assumption is that it should be fine... |
found NFCForum-TS-Type-2-Tag_1.1.pdf specification here https://github.com/somq/nfccard-tool/blob/master/docs/NFCForum-TS-Type-2-Tag_1.1.pdf and it says |
Tried to work around that by right padding with space so the long format could allways be used but that hits browser specfic behaviour. Works with chrome but not with Safari/Firefox that sends this along and them som sites will crash. So this workaround is not viable... |
@RonnyNewco if you want you can try PUCKJS build from https://github.com/espruino/Espruino/pull/2407/checks - download PUCKJS artifact here This code works for me in build for AMIIBOLINK NFC tag mentioned in the forum. I tried urls with ndef record length of 254,255 and up like this
my phone shows it just fine in NXP TagInfo app |
Yes, sorry, as mentioned it is zip inside zip, unpack the first one and use the one inside for DFU. Do not unpack the second one. |
Perfect. Works as intended. Thank you very much for your effort. Much appropriated. |
see also conversation https://forum.espruino.com/conversations/354213/#17099032
https://github.com/espruino/Espruino/blob/master/libs/bluetooth/jswrap_bluetooth.c#L2638
flatStrPtr
isuint8_t *
so the dataLen is truncated even if data buffer is allocated with full length herehttps://github.com/espruino/Espruino/blob/master/libs/bluetooth/jswrap_bluetooth.c#L2626
and also terminated with full length here
https://github.com/espruino/Espruino/blob/master/libs/bluetooth/jswrap_bluetooth.c#L2641
same bug/feature is there for nfcUrl - two lines here truncate length to
uint8_t
https://github.com/espruino/Espruino/blob/master/libs/bluetooth/jswrap_bluetooth.c#L2456-L2457
If this should not be supported then at least the length should be checked and rejected to not to allocate big buffers and terminate NDEF at wrong place.
The text was updated successfully, but these errors were encountered: