Skip to main content
Explorer
January 16, 2025
Solved

ST25R3920B for OOB Bluetooth Pairing

  • January 16, 2025
  • 16 replies
  • 6206 views

Hello everyone,

I am using the X-NUCLEO-NFC08A1 NFC Shield that has the ST25R3920B chip. I want to know if it is possible to use this to make OOB Bluetooth with my android smartphone, and if so how can I achieve it. I read some documentation regarding the demos in X-Cube-NFC6 with card emulation, but I don´t if that is suitable for what I am trying to achieve.

 

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

    Hi,

    the NFC Forum "Bluetooth® Secure Simple Pairing Using Version 1.3" application document only defines the following mimes types:

    • application/vnd.bluetooth.ep.oob (BR/EDR)
    • application/vnd.bluetooth.le.oob (BLE)

    In this document, "application/vnd.bluetooth.le.oob" is being used even with Secure Connections Random Value EIR and Secure Connections Confirmation Value EIR.

    Can you try to encode your record using application/vnd.bluetooth.le.oob (NDEF_TYPE_ID_BLUETOOTH_LE) and with your:

    • LE Role EIR
    • LE Bluetooth Device Address EIR
    • Secure Connections Random Value EIR
    • Secure Connections Confirmation Value EIR

    Rgds

    BT

    16 replies

    Technical Moderator
    January 17, 2025

    Hi JPortilha,

    yes, you can find exactly such an example in stsw-st25r-lib. Just look for the pairing example.

    BR, Ulysses

    JPortilhaAuthor
    Explorer
    January 17, 2025

    Hello, I have already downloaded that lib (for the 20 series), however I am still having some troubles.

     

    First of all, I am not finding the pairing example. I have searched through the files but I am not seeing where the Bluetooth pairing information is being written into the NFC shield, and how the shield is being emulated like a tag for the purpose.

    Secondly, yesterday I have included the files "demo_polling" and "demo_ce" into my project, however the NFC state is always changing between 'RFAL_NFC_STATE_POLL_TECHDETECT' and 'RFAL_NFC_STATE_POLL_COLAVOIDANCE'. The shield is not detecting my smartphone when I get it close to the shield.

     

    BR.

    Technical Moderator
    January 17, 2025

    Hi JPortilha,

     

    I think your are using the wrong package. There is no "20" series. The STSW-ST25R200 is for ST25R100 / ST25R200 but not for ST25R3920B.

    BR, Ulysses

    JPortilhaAuthor
    Explorer
    January 17, 2025

    Hello,

    I have noticed that. I tested the the package for ST25R3916 but it is not working, I don´t know if it is compatible. Can you provide an example fot the ST25R3920B?

    BR.

    JPortilhaAuthor
    Explorer
    January 22, 2025

    Hello,

    I have managed to run the example and my smartphone can detect the shield as a tag. However, the bluetooth pairing is not happening, do I need to change the record information? If so, what kind of data should be set so the pairing can occur? Also, should the board be advertising to complete the pairing? In the code, there is no reference to bluetooth peripheral initialization.

    BR.

     

     

    Technical Moderator
    January 22, 2025

    Hi,

    this demo just shows how to start an out-of-band bluetooth pairing. The board does not have any bluetooth radio, whatsoever.

    For a real application you will need to change demoEncodeBluetoothRecord() to insert the device names, addresses, etcs as for the Bluetooth device which you want to pair.

     

    BR, Ulysses

    JPortilhaAuthor
    Explorer
    January 22, 2025

    Hello, this is my starting code:

     

    int BLEHandler::SetOOBPairData(uint8_t *buffer, uint32_t length)
    {
     ndefTypeBluetooth bluetooth;
     ndefRecord record;
     ndefType ndefBt;
     ndefStatus rc;
    
     if( buffer == NULL )
     return ERR_PARAM;
     
     /* Reset bluetooth record */
     rc = ndefBluetoothReset(&bluetooth);
     if( rc != ERR_NONE )
     return rc;
     
     /* Get bluetooth informations - Address, Address Type, Random and Confirm value */
     rc = bt_le_oob_get_local(0, &oob_data);
    
     /* Mandatory field: bufDeviceAddress - Device Address (only for BR/EDR) */
     ndefConstBuffer bufDeviceAddress = { (uint8_t*)oob_data.addr.a.val, sizeof(oob_data.addr.a.val) };
     bluetooth.bufDeviceAddress = bufDeviceAddress;
    
     /* Optional fields: Extended Inquiry Responses. Up to 8 data structures 
     * According to BLE spec, the data format should be: Length, EIR Data Type, EIR Data 
     */
     /* EIR Field 1: LE Device Address - 6 LSB bytes: Device address, 7th byte: Address type (Public/Random) */
     memcpy(&eirLeAddress[2], oob_data.addr.a.val, 6);
     eirLeAddress[8] = oob_data.addr.type;
     
     rc = ndefBluetoothSetEir(&bluetooth, (uint8_t*)&eirLeAddress);
     if (rc != ERR_NONE)
     {
     return rc;
     } 
     
     rc = ndefBluetoothLeInit(&ndefBt, &bluetooth);
     if( rc != ERR_NONE )
     {
     return rc;
     }
     
     rc = ndefTypeToRecord(&ndefBt, &record);
     if( rc != ERR_NONE )
     return rc;
     
     /* Encode the record starting after the first two bytes that are saved to store the NDEF file length */
     ndefBuffer bufRecord = { &buffer[2], length - 2 };
     rc = ndefRecordEncode(&record, &bufRecord);
     if( rc != ERR_NONE )
     {
     return rc;
     }
     
     /* Store the NDEF file length on the two first bytes */
     buffer[0] = bufRecord.length >> 8;
     buffer[1] = bufRecord.length & 0xFF;
    
     return rc;
    }

     

     

    The function does not return any error code, however when I read the tag with my smartphone it always says that is an empty tag. Any idea why that is happening?

    BR

    Technical Moderator
    January 23, 2025

    Hi,

    well, start debugging: What is the resulting buffer on your MCU, compare it against the working buffer from our demo. And compare all that against what the smartphone reads. There are some tools showing you also the raw data. I think ST25 app can do that.

    BR, Ulysses

    JPortilhaAuthor
    Explorer
    January 23, 2025

    Hello,

    The data is ok, I think the problem is that this function in the end only encodes the NDEF message into a raw buffer, but where do you exactly write this data in the tag? I think its just missing something in the code.

    BR

    Technical Moderator
    January 23, 2025

    Well our demo code encodes this buffer into the emulated NDEF file for the T4T emulation:

    static uint8_t ndefFile[80]; /* Buffer to encode NDEF file */
    const uint8_t *demoNdefFile = ndefFile; /* Overwrite weak demoNdefFile pointer */
    ...
    if( demoEncodeBluetoothRecord(ndefFile, sizeof(ndefFile)) != ERR_NONE )

    the demoNdefFile is used by demo_ce.c to populate the emulated memory.

    BR, Ulysses

    JPortilhaAuthor
    Explorer
    January 23, 2025

    Ok, I understand that. I am using NFC tools application to read the tag with the smartphone and even without using the Bluetooth Encode function, the application always says the tag is empty. It is not being able to read the URI string "st.com/st25-demo" from the example.

    BR.

    JPortilhaAuthor
    Explorer
    January 23, 2025

    If I use the NFC tools to read/write from/to the tag there is no problem at all, I can even read the memory sectors and confirm that every byte is being well written. However, with the demo the memory is not correctly populated. I can leave prints if you want to inspect it.

    BR.

    Technical Moderator
    January 24, 2025

    Hi,

    with the ST25NFCTap application on your Android phone, can you go the MEMORY tab and read the memory? Then use the Dump memory to file and provide the binary file.

    Go to the CC FILE tab and provide us the content of the cc file (screen copy).

    Go to the TAG INFO tab and provide us the content of this tab (screen copy).

    Rgds

    BT

    JPortilhaAuthor
    Explorer
    January 24, 2025

    Hello, for some reason I cannot read the tag using the ST25NFC application. I have tried with 2 smartphones from 2 different brands and in both cases I got the messages "Unknown tag" or "Error reading tag" in the application. However, I can read the tag using the NFCTools app and I will leave you the prints with the tag information and memory dump.

    From these informations I can conclude the following:

    - My smartphone is recognizing the tag as Type 3 (Felica, JIS 6319-4). I have read in some forums that bluetooth pairing requires a Type 4 Tag, but I am not 100% sure of this. Can you clarify this to me?

    - When I run the default example (without calling the OOBBluetoothRecordEncode function), the smartphone can detect the ST link and acess the webpage. The memory dump also confirms this. However, when is a Bluetooth record, I cannot read the tag memory ("This tag is not supported" message), and the application shows me less information about the tag itself (I will also leave a print).

    I hope this information helps, tell me if you need more information.

    BR.Screenshot_2025-01-24-14-39-38-305_com.wakdev.wdnfc.jpgScreenshot_2025-01-24-14-28-10-338_com.wakdev.wdnfc.jpgScreenshot_2025-01-24-14-27-09-829_com.wakdev.wdnfc.jpg

    Technical Moderator
    January 24, 2025

    Hi,

    as far as I remember, ST25NFCTap does not provide the support for Felica tag. As an alternative, TagInfo app can be used rather than NFC Tools.

    By default, the paring demo emulates both a T4T tag and a Felica tag. You can disable the Felica emulation by commenting the following line  in demo_polling.c:

    Line 317: discParam.techs2Find |= RFAL_NFC_LISTEN_TECH_F;

    "bluetooth pairing requires a Type 4 Tag" is probably a wrong information: I have no issue to retrieve pairing information with a Felica Card Emulation.

    I've ran the pairing demo on my side and can properly decode the content of the NDEF (whatever Felica or T4T card Emulation is used). I've attached the result of the scan from TagInfo as a reference.

    In order to debug your issue, the content of the CardEmulation memory is needed. It should be available with ST25NFCTap if you disable Felica or with TagInfo if you want to emulate both Felica and T4T.

    Rgds

    BT