2019-11-29 05:57 AM
Hi I'm trying to write text via NDEF library to be available to read from EEPROM by phone nfc aplication. Also I want to read text send by phone directly to EEPROM. I tried to change NDEF_URI example method to implement NDEF_WriteText and NDEF_ReadText method and write some text into ST25DV EEPROM and read from but honestly I have no idea what's wrong with my conception. Could you show me some code where you are using these methods?
Solved! Go to Solution.
2019-12-03 02:49 AM
Hi @NewOne ,
Here is a simple example to write a simple Text NDEF message and read it after.
/* Init ST25DV driver */
while( NFC04A1_NFCTAG_Init(0) != NFCTAG_OK );
/* Reset Mailbox enable to allow write to EEPROM */
NFC04A1_NFCTAG_ResetMBEN_Dyn(0);
NfcTag_SelectProtocol(NFCTAG_TYPE5);
/* Check NDEF presence, if no init mem in Tag Type 5 */
if( NfcType5_NDEFDetection( ) != NDEF_OK )
{
/* If CCFile is not present add it to memory */
CCFileStruct.MagicNumber = NFCT5_MAGICNUMBER_E1_CCFILE;
CCFileStruct.Version = NFCT5_VERSION_V1_0;
CCFileStruct.MemorySize = ( ST25DV_MAX_SIZE / 8 ) & 0xFF; // ST25DV_MAX_SIZE = 0x200 => 4Kb memory
CCFileStruct.TT5Tag = 0x01;
/* Init of the Type Tag 5 component */
while( NfcType5_TT5Init( ) != NFCTAG_OK );
}
/* write text message to EEPROM */
while( NDEF_WriteText( "NDEF Text message" ) != NDEF_OK );
NDEF_Text_info_t Text;
sRecordInfo_t record;
uint8_t p_ndef_buffer[64];
/* read NDEF file */
NDEF_ReadNDEF(p_ndef_buffer);
/* Extract record info */
NDEF_IdentifyBuffer(&record,p_ndef_buffer);
/* Read Text in record */
NDEF_ReadText( &record, &Text );
Hope this could help you.
Regards.
2019-12-03 02:49 AM
Hi @NewOne ,
Here is a simple example to write a simple Text NDEF message and read it after.
/* Init ST25DV driver */
while( NFC04A1_NFCTAG_Init(0) != NFCTAG_OK );
/* Reset Mailbox enable to allow write to EEPROM */
NFC04A1_NFCTAG_ResetMBEN_Dyn(0);
NfcTag_SelectProtocol(NFCTAG_TYPE5);
/* Check NDEF presence, if no init mem in Tag Type 5 */
if( NfcType5_NDEFDetection( ) != NDEF_OK )
{
/* If CCFile is not present add it to memory */
CCFileStruct.MagicNumber = NFCT5_MAGICNUMBER_E1_CCFILE;
CCFileStruct.Version = NFCT5_VERSION_V1_0;
CCFileStruct.MemorySize = ( ST25DV_MAX_SIZE / 8 ) & 0xFF; // ST25DV_MAX_SIZE = 0x200 => 4Kb memory
CCFileStruct.TT5Tag = 0x01;
/* Init of the Type Tag 5 component */
while( NfcType5_TT5Init( ) != NFCTAG_OK );
}
/* write text message to EEPROM */
while( NDEF_WriteText( "NDEF Text message" ) != NDEF_OK );
NDEF_Text_info_t Text;
sRecordInfo_t record;
uint8_t p_ndef_buffer[64];
/* read NDEF file */
NDEF_ReadNDEF(p_ndef_buffer);
/* Extract record info */
NDEF_IdentifyBuffer(&record,p_ndef_buffer);
/* Read Text in record */
NDEF_ReadText( &record, &Text );
Hope this could help you.
Regards.
2023-03-16 07:11 PM
Hello, I wrote an NDEF message with your reference code, but the phone did not read any messages.
2023-03-17 01:04 AM
Hello,
When you say "the phone did not read any message", you mean without an application (natively)?
In that case NDEF Text message are not recognized by Android (or iOS) stack. Natively Android will work with URL, Bluetooth, Wifi, …. For other NDEF you will need an application, you can try the ST25 NFC Tap available on google play store and Apple store.
Hope this can help you.
Kind Regards.
2023-03-20 01:31 AM
hello.Do I only need to download the app to read text messages? So the above code provided can be read correctly, right?
2023-03-20 01:47 AM
I wish you can help me check if the code can implement this feature, is there a bug?
2023-03-22 06:04 AM
@Rene Lenerve
I wish you can help me check if the code can implement this feature, is there a bug?
I still can't read NDEF messages using app
2023-03-22 07:18 AM
Hi @帅 罗,
I think your issue come from this line (106):
CCFileStruct.MemorySize = 0x00;
with that you are saying that the tag's memory size is 0, which result in the St25 App to display no data in NDEF field. A value of 0x40 represent 4Kbits (512 Bytes). It can be another value of course.
Another point to update may be the type for the Text variable, for me it's compiling with NDEF_Text_info_t as type.
Let me know if that helps you.
Kind Regards.
2023-03-23 12:51 AM
Hi
I have modified the code according to what you said. Could you please help me to see if it is possible to read NDEF information
2023-03-23 01:03 AM
Hi @帅罗.1 (Community Member),
You need to erase the memory of the Tag to rewrite the CC file, because with this code the NDEF detection doesn't enter the NfcTyp5_TT5Init process and CCFile keeps the old values.
You can perform this by erasing the tag memory with the NFC Tap App or in debug mode on the nucleo board by jumping the line "if ( NfcTyp5_NDEFDetection() != NDEF_OK )"
Kind Regards.