Skip to main content
Cake Huang
Associate II
December 23, 2016
Question

BlueNRG-MS in central role can not get paired with another BlueNRG-MS in peripheral role

  • December 23, 2016
  • 2 replies
  • 1669 views
Posted on December 23, 2016 at 10:31

Can anyone provide sample project ofBlueNRG-MS in central role where security linking is required?

In sample project 'STM32CubeExpansion_BLE1_V2.7.0\Projects\Multi\Applications\SampleAppThT', it includes

central role but it does not require bonding/pairing.

I also checked 'OSXSmartConnPS\OSXSmartConnPS_V1.5.0\Projects\Multi\Applications\Profiles_Central\MDK-ARM\STM32L476RG-Nucleo',which does has central profile framework but no source code of this framework is provided.

I use

x-Nucleo-IDB05A1 kit to send pairing request toWesu kit.

x-Nucleo-IDB05A1 kit is set to central role whileWesu reference kit is coming with peripheral role naturally. Both sides are set to use fixed PIN code 1234

After connection is made,

x-Nucleo-IDB05A1 kit sends pairing request to

Wesu kit

by calling:

ret = aci_gap_send_pairing_request(connection_handle,0);

Immediately,

x-Nucleo-IDB05A1 gets an event of pairing completion with 0x02 which says pairing has just failed

0x02: Pairing failed

The pairing failed with the remote device

I tried using an android phone to pair with wesu kit and this was OK after I input 6 digit numbers of 123456 on my phone.

So something must be wrong with my

x-Nucleo-IDB05A1 central board but I could not figure it out.

I followed the documentDM00141271_ProgrammingManual.pdf to add pairing-related code on x-Nucleo-IDB05A1 kit.

Below are some parts of my code:

uint8_t DIV[2]={0x4A, 0x5D};

 

uint8_t ER[16]={0x4A, 0x5D, 0x9D, 0x5B, 0xA4, 0xCE, 0x2D, 0xE1, 0x72, 0x8E, 0x3B, 0xF4, 0x80, 0x35, 0x0F, 0x25};uint8_t IR[16]={0xE0, 0x7E, 0x21, 0xC9, 0x47, 0xD1, 0x9E, 0x33, 0x76, 0xF0, 0x9B, 0x3C, 0x1E, 0x16, 0x17, 0x42};

ret = aci_hal_write_config_data(CONFIG_DATA_PUBADDR_OFFSET,

CONFIG_DATA_PUBADDR_LEN,

bdaddr);

ret = aci_hal_write_config_data(CONFIG_DATA_DIV_OFFSET,

CONFIG_DATA_DIV_LEN,(uint8_t *) DIV);

ret = aci_hal_write_config_data(CONFIG_DATA_ER_OFFSET,

CONFIG_DATA_ER_LEN,(uint8_t *) ER);

/

ret = aci_hal_write_config_data(CONFIG_DATA_IR_OFFSET,

CONFIG_DATA_IR_LEN,(uint8_t *) IR);

ret = aci_gatt_init();

if(ret){

PRINTF('GATT_Init failed.\n');

}

if(BLE_Role == SERVER) {

if (bnrg_expansion_board == IDB05A1) {

ret = aci_gap_init_IDB05A1(GAP_PERIPHERAL_ROLE_IDB05A1, 0, 0x07, &service_handle, &dev_name_char_handle, &appearance_char_handle);

}

else {

ret = aci_gap_init_IDB04A1(GAP_PERIPHERAL_ROLE_IDB04A1, &service_handle, &dev_name_char_handle, &appearance_char_handle);

}

}

else {

if (bnrg_expansion_board == IDB05A1) {

ret = aci_gap_init_IDB05A1(GAP_CENTRAL_ROLE_IDB05A1, 0, 0x07, &service_handle, &dev_name_char_handle, &appearance_char_handle);

}

else {

ret = aci_gap_init_IDB04A1(GAP_CENTRAL_ROLE_IDB04A1, &service_handle, &dev_name_char_handle, &appearance_char_handle);

}

}

if(ret != BLE_STATUS_SUCCESS){

PRINTF('GAP_Init failed.\n');

}

//0x03: No Input, no output

ret = aci_gap_set_io_capability(IO_CAP_NO_INPUT_NO_OUTPUT);

if (ret != BLE_STATUS_SUCCESS) {

PRINTF('Failure.\n');

}

//aci_gap_clear_security_database();

ret = aci_gap_set_auth_requirement(MITM_PROTECTION_REQUIRED,

OOB_AUTH_DATA_ABSENT,

NULL,

7,

16,

USE_FIXED_PIN_FOR_PAIRING,

123456,

BONDING);

Note: this post was migrated and contained many threaded conversations, some content may be missing.
    This topic has been closed for replies.

    2 replies

    Andrea Palmieri
    ST Employee
    December 23, 2016
    Posted on December 23, 2016 at 12:44

    Hi Cake,

    what is the FW version of the X-NUCLEO-IDB05A1 you are using? The document

    DM00141271_ProgrammingManual.pdf  states that

    Starting from BlueNRG-MS BLE FW stack 7.1b the IR and ER root keys are randomly

    generated and permanently stored in internal BlueNRG-MS device Flash at the first

    initialization of the device (ACI_GATT_INIT).

    Kind regards,

    Andrea

    Cake Huang
    Associate II
    December 24, 2016
    Posted on December 24, 2016 at 09:27

    Hi Palmieri,

    The FW version of the X-NUCLEO-IDB05A1 I am using is 0x0713. According to  DM00141271.pdf, my

    X-NUCLEO-IDB05A1

     needs DIV/ER/IR configuration.

    I also tried deleting below lines:

    ret = aci_hal_write_config_data(CONFIG_DATA_DIV_OFFSET,

    CONFIG_DATA_DIV_LEN,(uint8_t *) DIV);

    ret = aci_hal_write_config_data(CONFIG_DATA_ER_OFFSET,

    CONFIG_DATA_ER_LEN,(uint8_t *) ER);

    /

    ret = aci_hal_write_config_data(CONFIG_DATA_IR_OFFSET,

    CONFIG_DATA_IR_LEN,(uint8_t *) IR);

    But the pairing problem is still there.

    Anyway,  Is there any reference projecct of central role which could demostrate successful pairing procedure between 2 BlueNRG/BlueNRG-MS? 

    Thanks!

    Andrea Palmieri
    ST Employee
    January 10, 2017
    Posted on January 10, 2017 at 12:30

    Did you consider the possibility to upgrade the FW to version 7.2c?

    Cake Huang
    Associate II
    February 21, 2017
    Posted on February 21, 2017 at 09:32

    Thank palmieri&vilei,

    After spending some efforts I have recovered my 

    X-NUCLEO-IDB05A1 and its firmware is now updated to 7.2c

    Both STSW-BNRGUI and mbed's BlueNRG-MS-Stack-Updater can be used to update  

    X-NUCLEO-IDB05A1.

    And 7.2c setted to central role can successfully get paired with another ble peripheral role,here in my case the peripheral is a standard BLE mouse.

    Thank you again!