stm32duino / X-NUCLEO-NFC04A1

Arduino library to support X-NUCLEO-NFC04A1 based on the dynamic NFC/RFID Tag IC ST25DV04K
BSD 3-Clause "New" or "Revised" License
5 stars 14 forks source link

Issue reading from NFC after writing #13

Closed Mowglli closed 2 years ago

Mowglli commented 2 years ago

Hello, what is the command to read from the NFC ? I would like to use SerialPort.println(). To see it in the Serial monitor? Regards!

cparata commented 2 years ago

Hi @Mowglli , did you give a look at the X_NUCLEO_NFC04A1_HelloWorld example contained into the library? There, if you call a "writeURI" to write the NFC tag, then you can call a "readURI" to get the content that was written into the tag. Best Regards, Carlo

Mowglli commented 2 years ago

Yes, that's the one iv'e been using. It works for the most part with NFC Tools and the app I developed as well. But I don't seem to be able to print the read to the serial monitor in Arduino IO. I have initializers serial begin

cparata commented 2 years ago

Please, after the "readURI", try something like: Serial.println(uri_read.c_str()); Let me know if with this command, you are able to see the content on the serial. Best Regards, Carlo

Mowglli commented 2 years ago

Dosen't seem to print. I'll find an other solution to debug :) Thanks again!

cparata commented 2 years ago

I don't know which board you are using. Anyway, you should initialize the serial port at the beginning of the setup function with: Serial.begin(115200); and then you should be able to see the output on an hyperterminal like TeraTerm or Arduino Monitor using the configuration 115200 8N1. Please check that the configuration of your hyperterminal fits the serial settings in the firmware. Best Regards, Carlo

Mowglli commented 2 years ago

Hello agin, Yes I have initialized the serial, as well as using the Serial.print(). Where im able to send Serial.print("Hello from serial"). Ive tried parcing the command you provided as well without succes. Ive also tried println(); Ive made an android app, that solves the needed for me for now though :)

Mowglli commented 2 years ago

Just to clarify, its the payload I would like to print out

cparata commented 2 years ago

What is your hardware setup? We need more information to try to help you.

Mowglli commented 2 years ago

Im using an arduino Uno R3 board on a macbook. Worning in Arduino IDE

Sendt fra min iPhone

Den 3. feb. 2022 kl. 14.19 skrev Carlo Parata @.***>:

 What is your hardware setup? We need more information to try to help you.

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you modified the open/close state.

Mowglli commented 2 years ago

Im Using an arduino UNO R3. Working in arduino IDE on a macbook

cparata commented 2 years ago

Ok, I do not exclude also a stack issue, because Arduino UNO R3 has really small resources in terms of RAM. Unfortunately, I do not have an Arduino UNO now with me to give a try. Next week I will try to get one and give a try.

Mowglli commented 2 years ago

Thanks, i'm looking forward to your test :)

cparata commented 2 years ago

Hi @Mowglli , I did the test and I confirm your issue. My suspect is that Arduino UNO does not have enough memory to run the example also using the serial port. In fact during the compilation I also got the message "Low memory available, stability problems may occur". So, I suggest to use a more powerful motherboard like a Nucleo-F401RE where you should not have memory issues. Best Regards, Carlo

Mowglli commented 2 years ago

Thanks Carlo, I’ll try on a board with more memory. I appreciate your time. Have a Nice Day

Den 11. feb. 2022 kl. 08.46 skrev Carlo Parata @.***>:

 Hi @Mowglli , I did the test and I confirm your issue. My suspect is that Arduino UNO does not have enough memory to run the example also using the serial port. In fact during the compilation I also got the message "Low memory available, stability problems may occur". So, I suggest to use a more powerful motherboard like a Nucleo-F401RE where you should not have memory issues. Best Regards, Carlo

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.

Mowglli commented 2 years ago

It worked with another board.

cparata commented 2 years ago

Great! Thanks for the feedback

Mowglli commented 2 years ago

Im trying to make a function that reads a text on the tag. Ive been trying to use some of the functions in lib_NDEF and SV25DV libary. Have you tried making a function like that You Can provide me with ?

Sendt fra min iPhone

Den 17. feb. 2022 kl. 13.21 skrev Carlo Parata @.***>:

 Great! Thanks for the feedback

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.

cparata commented 2 years ago

Unfortunately, only writeURI and readURI APIs are exported at the class level. Anyway, giving a look at the implementation of the readURI, you should be able also to read a text using something like:

int readText(NDEF_Text_info_t *text_info)
{
  uint16_t ret;
  sRecordInfo_t recordInfo;
  // increase buffer size for bigger messages
  ret = NDEF_ReadNDEF(NDEF_Buffer);
  if (ret) {
    return ret;
  }

  ret = NDEF_IdentifyBuffer(&recordInfo, NDEF_Buffer);
  if (ret) {
    return ret;
  }

  ret = NDEF_ReadText(&recordInfo, text_info);
  if (ret) {
    return ret;
  }

  return 0;
}

And then in the application code you can print the values in this way:

if(text_info.encoding == NDEF_TEXT_UTF8) {
  Serial.println("UTF-8 Encoding");
} else if (text_info.encoding == NDEF_TEXT_UTF16){
  Serial.println("UTF-16 Encoding");
} else {
  Serial.println("Unknown Encoding");
}

Serial.print("Metadata: ");
Serial.println(text_info.language_code);
Serial.print("Plain text: ");
Serial.println(text_info.text);

Let me know if it works on your side. Best Regards, Carlo

Mowglli commented 2 years ago

It works perfectly! thank you so much!

If I would to make a write text to tag, would that be something like:

`int writeText(String text){

NDEF_Text_info_t text_info;

strcpy(text_info.text, text.c_str());

int len = text.length() + 1; char Buf[len]; char txt; txt = text.toCharArray(Buf, len); return NDEF_WriteText(&txt); }`

I seem to get a void error though? :)

cparata commented 2 years ago

Great! To write text, you can try directly something like:

char myText[] = "Hello World!";

NDEF_WriteText(myText);

Let me know if it works. Best Regards, Carlo

Mowglli commented 2 years ago

Wow! Thanks, it works I appreciate your time helping me! Have a great weekend!

Mowglli commented 2 years ago

If the tag is written with two records. Is it correct that it is the NDEF_Buffer offset has to be used to read out both records ?

cparata commented 2 years ago

Unfortunately, I don't think that the class APIs support multi-records. But, of course, you can try to implement it by yourself using the record APIs. Sorry, but I don't know so deeply this library to help you on this task. If you can contribute to improve the library, your contribution is welcome. ;-)

Mowglli commented 2 years ago

Okay Thanks for the answer! I’ll Update you👍

Sendt fra min iPhone

Den 21. feb. 2022 kl. 14.07 skrev Carlo Parata @.***>:

 Unfortunately, I don't think that the class APIs support multi-records. But, of course, you can try to implement it by yourself using the record APIs. Sorry, but I don't know so deeply this library to help you on this task. If you can contribute to improve the library, your contribution is welcome. ;-)

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.