Skip to main content
Visitor II
April 1, 2021
Solved

How Emulate NDEF text with ST25R3916 (card emulation) ?

  • April 1, 2021
  • 4 replies
  • 3217 views

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

    This topic has been closed for replies.
    Best answer by Brian TIDAL

    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

    4 replies

    Technical Moderator
    April 1, 2021

    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

    Visitor II
    April 2, 2021

    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

    Technical Moderator
    April 6, 2021

    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

    Technical Moderator
    April 5, 2021

    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

    Visitor II
    April 6, 2021

    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 

    Technical Moderator
    April 6, 2021

    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

    Visitor II
    April 6, 2021

    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