don / NDEF

NDEF Library for Arduino. Read and Write NDEF Messages to NFC tags with Arduino.
Other
286 stars 142 forks source link

How to choose which sector to write to ? And store nice data to a variable ? #55

Open wanegain3 opened 4 years ago

wanegain3 commented 4 years ago

Hi there !

Congrats for this nice library. I have 2 questions. Sorry for that but I couldn't find an online reference/doc somewhere beyound github.

QUESTION 1 : about writing

I am triying to write stuff to a MIFARE CLASSIC card.

I tried to use either : ndefMessage.addTextRecord("hello, world"); or ndefMessage.addUriRecord("http://arduino.cc");

However I need to write new stuff to prewritten tags. I would like to do it on sector 3 for example, because sector 1 already contains data. Is there any (easy) way to do this ? So far it seems to be written on sector 1 ?

QUESTION 2 : about storing data

Also when I get the records, the data begins by either a . or a .en (or a square !) I saw the example on github to print the data to serial and it looks fine, however I need to store it into a variable. I kinda manage to do it but it looks pretty ugly. Is there a nicer way to do it ?

for(int i=0;i<message.getRecordCount();i++) { NdefRecord record = message.getRecord(i); int payloadLength = record.getPayloadLength(); byte payload[payloadLength]; record.getPayload(payload); String data = (char *)payload; data = data.substring(3,data.length()-2); show(data); //my own method to print to serial. Could be serial here. }

Thanks a lot !