cancel
Showing results for 
Search instead for 
Did you mean: 

ST25R3920B for OOB Bluetooth Pairing

JPortilha
Associate II

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.

 

28 REPLIES 28
Ulysses HERNIOSUS
ST Employee

Hi JPortilha,

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

BR, Ulysses

JPortilha
Associate II

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.

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

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.

Hi,

you will find the proper project here inside the package: Projects\STM32L476RG-Nucleo\Applications\X-NUCLEO-NFC08A1\pairing

The software for ST25R3920B and ST25R3916B are compatible.

BR, Ulysses

JPortilha
Associate II

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.

 

 

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

JPortilha
Associate II

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

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