cancel
Showing results for 
Search instead for 
Did you mean: 

How Emulate NDEF text with ST25R3916 (card emulation) ?

Mickaël Bucher
Associate II

I Use STM32CubeExpansion_NFC6_V1.1.0 for emulate card with NUCLEO-L053R8 and X-NUCLEO-NFC06A1.

I Try NDEF URI card emulation with sucess.

I don't find a example code for NDEF Text emulation card.

Does anyone have a example code for NDEF Text Emulation card ?

Best Regards.

Mickaël

1 ACCEPTED SOLUTION

Accepted Solutions
Brian TIDAL
ST Employee

Hello Mickaël,

The card Emulation demo emulates a T4T tag with a CC file and an NDEF file. In  STM32CubeExpansion_NFC6_V1.1.0, the NDEF file has an hardcoded NDEF URI in ndef_uri bytes array in demo_ce.c file. it can be easily modified to have a TEXT record instead of a URI record, for example:

static const uint8_t ndef_uri[] = {
0x00, 0x1E,               /* NDEF length                */
0xD1,                     /* NDEF Header                */
0x01,                     /* NDEF type length           */
0x1A,                     /* NDEF payload length        */
0x54,                     /* NDEF Type                  */
0x02,                     /* TEXT Lang Len              */
0x65, 0x6E,               /* TEXT Lang value            */
0x57, 0x65, 0x6C, 0x63,   /*  TEXT                      */
0x6F, 0x6D, 0x65, 0x20,   /*  TEXT                      */
0x74, 0x6F, 0x20, 0x53,   /*  TEXT                      */
0x54, 0x20, 0x4E, 0x44,   /*  TEXT                      */
0x45, 0x46, 0x20, 0x64,   /*  TEXT                      */
0x65, 0x6D, 0x6F          /*  TEXT                      */
};

You can also encode NDEF messages thanks to NDEF library and then copy this message into the NDEF file buffer. The STSW-ST25R-LIB has a Card Emulation demo called bluetooth_pairing that encodes a NDEF message and copy it into the NDEF buffer. You can also modify this demo to encode an NDEF with a TEXT record.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

12 REPLIES 12
Brian TIDAL
ST Employee

Hello Mickaël,

The card Emulation demo emulates a T4T tag with a CC file and an NDEF file. In  STM32CubeExpansion_NFC6_V1.1.0, the NDEF file has an hardcoded NDEF URI in ndef_uri bytes array in demo_ce.c file. it can be easily modified to have a TEXT record instead of a URI record, for example:

static const uint8_t ndef_uri[] = {
0x00, 0x1E,               /* NDEF length                */
0xD1,                     /* NDEF Header                */
0x01,                     /* NDEF type length           */
0x1A,                     /* NDEF payload length        */
0x54,                     /* NDEF Type                  */
0x02,                     /* TEXT Lang Len              */
0x65, 0x6E,               /* TEXT Lang value            */
0x57, 0x65, 0x6C, 0x63,   /*  TEXT                      */
0x6F, 0x6D, 0x65, 0x20,   /*  TEXT                      */
0x74, 0x6F, 0x20, 0x53,   /*  TEXT                      */
0x54, 0x20, 0x4E, 0x44,   /*  TEXT                      */
0x45, 0x46, 0x20, 0x64,   /*  TEXT                      */
0x65, 0x6D, 0x6F          /*  TEXT                      */
};

You can also encode NDEF messages thanks to NDEF library and then copy this message into the NDEF file buffer. The STSW-ST25R-LIB has a Card Emulation demo called bluetooth_pairing that encodes a NDEF message and copy it into the NDEF buffer. You can also modify this demo to encode an NDEF with a TEXT record.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Mickaël Bucher
Associate II

Hello Brian,

Sorry but I debug the application and I realize I am using demoP2P( nfcDevice ) instead of demoCe( nfcDevice );

I add DEMO_CARD_EMULATION_ONLY in Symbols of the project (see picture) but it don't work

Can you explain me how use demoCE( nfcDevice ); ?

can you confirm me that an emulated card is recognized by ios 13 and more ?

Rgds

MB

Brian TIDAL
ST Employee

Hello Mickaël,

I believe iOS does not support P2P, so can you share more details on the reader device being used during tour test in front of the ST25R3916 while having P2P?

Can you elaborate on what is not working when using DEMO_CARD_EMULATION_ONLY? I would suggest to set RFAL_FEATURE_NFC_DEP to false to disable Active P2P.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi Mickaël,

I think you are running into an issue which I recently discovered: You need to set the define ST25R3916 to have card emulation operational. You will see the relevant code in demo.c is not activated unless that define is set.

Yes, iOS will recognize NDEF content. AFAIK it only has limited support of NDEF types (for sure URI). I don't think that text is among the supported content.

BR, Ulysses

Mickaël Bucher
Associate II

Hello Brian,

I set RFAL_FEATURE_NFC_DEP to false to disable Active P2P in the file "platform.h" but in debug mode, RFAL_FEATURE_NFC_DEP stay to true, why ?

I apply a smartphone and I go to demoAdpu and with an other smartphone, I go to demoP2P.

How can I go to demoCE for Emulated Card ?

is this mode recognise by android and ios ?

Rgds

MB

0693W000008yjUcQAI.jpg 

Hi Mickaël,

if you visit the following thread you will find some more details on how to set X-CUBE-NFC6 to card emulation only and also some topics about interop:

community.st.com/s/question/0D53W00000e2dtJSAQ/xnucleonfc06a1-doesnt-read-and-write-any-tag-ndef-not-detected-error

P2P is not supported to date by iOS. Also its support in Android is disappearing. Modern Samsung phones and Google Nexus have dropped it.

Regards, Ulysses

Hi Ulysses,

I am a beginner with X-CUBE-NFC6.

I set RFAL_FEATURE_NFC_DEP to false in the file "platform.h" and ST25R3916 in properties of project, is it the good way to run DemoCE ?

The application always go to demoAdpu and demoP2P.

Regards,

Mickael

0693W000008yjsAQAQ.jpg0693W000008yjs5QAA.jpg

Hi Mickael,

just go through the mentioned thread, it contains all needed steps. My minimal changes were: Set ST25R3916 and force discParam.techs2Find = RFAL_NFC_LISTEN_TECH_A; or discParam.techs2Find = RFAL_NFC_LISTEN_TECH_F inside demoIni(). As often there may be multiple ways and playing more with the defines you can optimize out more code.....

Best Regards, Ulysses

Hi Ulysses,

I resolved my problem. I forced discParam.techs2Find = RFAL_NFC_LISTEN_TECH_A and I modified the uint8_t ndef_uri[] by the example given at the beginning of the conversation.

0693W000008ylgzQAA.jpgCan you confim the max lenght of NDEF text is 64 bytes related to using ST25R3916 ?

Do you known why P2P mode is disappearing in android ?

Best Regards,

Mickaël