cancel
Showing results for 
Search instead for 
Did you mean: 

Bonding problem

Francesco Sarasini
Associate II
Posted on January 03, 2018 at 17:23

Hi,

I'm using BlueNRG as bt peripheral. I can successfully pair my android smartphone, but the

BlueNRG doesn'tadd the smartphone to the bonding list.

aci_gap_init(GAP_PERIPHERAL_ROLE, 0x00, 0x08, &BluetoothIOService_ServiceHandle, &dev_name_char_handle, &appearance_char_handle);
aci_gap_set_authentication_requirement(BONDING, MITM_PROTECTION_NOT_REQUIRED, SC_IS_NOT_SUPPORTED, KEYPRESS_IS_NOT_SUPPORTED,
7, 16, USE_FIXED_PIN_FOR_PAIRING, 123456, 0x01);�?�?�?�?

On pairing complete event the bonded devices list is always empty. I suppose it should contains the smartphone address.

numBonds is always 0

void aci_gap_pairing_complete_event(uint16_t Connection_Handle, uint8_t Status, uint8_t Reason) {
if (Status == 0x00) {
uint8_t ret = aci_gap_configure_whitelist();
uint8_t numBonds;
Bonded_Device_Entry_t bonds[12];
ret = aci_gap_get_bonded_devices(&numBonds, bonds);
if (numBonds > 0) {
Whitelist_Identity_Entry_t wle;
wle.Peer_Identity_Address_Type = bonds[0].Address_Type;
memcpy(wle.Peer_Identity_Address, bonds[0].Address, 6);
ret = aci_gap_add_devices_to_resolving_list(1, &wle, 0);
uint8_t i;
for (i = 0; i < numBonds; i++) {
printf('bonded %0X:%0X:%0X:%0X:%0X:%0X', bonds[i].Address[0], bonds[i].Address[1],
bonds[i].Address[2], bonds[i].Address[3], bonds[i].Address[4], bonds[i].Address[5]);
}
}
}
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

What I'm doing wrong?

Thanks

#bluenrg-1 #bluenrg
5 REPLIES 5
Andrea Palmieri
ST Employee
Posted on January 08, 2018 at 15:57

Hi Francesco,

according to section 3.5 of

http://www.st.com/content/ccc/resource/technical/document/programming_manual/group0/03/12/05/a4/84/de/47/35/DM00294449/files/DM00294449.pdf/jcr:content/translations/en.DM00294449.pdf

 you should add one more step in the pairing process, i.e., you should set the I/O caps (aci_gap_set_io_capability() API) before calling aci_gap_set_authentication_requirement() API.

Hope that could help.

Kind regards

Andrea

Francesco Sarasini
Associate II
Posted on January 08, 2018 at 16:11

Hi Andrea,

I already have it in my code. Here the complete source:

ret = BlueNRG_Stack_Initialization(&BlueNRG_Stack_Init_params);
if (ret != BLE_STATUS_SUCCESS) {
 return false;
}
/* Configure Public address */
ret = aci_hal_write_config_data(CONFIG_DATA_PUBADDR_OFFSET, CONFIG_DATA_PUBADDR_LEN, bdaddr);
if (ret != BLE_STATUS_SUCCESS) {
 return false;
}
/* Set the TX power to -2 dBm */
ret = aci_hal_set_tx_power_level(1, 4);
if (ret != BLE_STATUS_SUCCESS) {
 return false;
}
/* Init the GATT */
ret = aci_gatt_init();
if (ret != BLE_STATUS_SUCCESS) {
 return false;
}
ret = aci_gap_init(GAP_PERIPHERAL_ROLE, 0x00, 0x08, &BluetoothIOService_ServiceHandle, &dev_name_char_handle, &appearance_char_handle);
if (ret != BLE_STATUS_SUCCESS) {
 Log_error('BLE', 'cannot init peripheral role 0x%02x', ret);
 return false;
}
ret = aci_gap_set_io_capability(IO_CAP_NO_INPUT_NO_OUTPUT);
if (ret != BLE_STATUS_SUCCESS) {
 Log_error('BLE', 'cannot set io capability 0x%02x', ret);
 return false;
}
// 0x01: Random (static) Identity Address
ret = aci_gap_set_authentication_requirement(BONDING, MITM_PROTECTION_NOT_REQUIRED, SC_IS_NOT_SUPPORTED, KEYPRESS_IS_NOT_SUPPORTED,
 7, 16, USE_FIXED_PIN_FOR_PAIRING, 123456, 0x01);
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Andrea Palmieri
ST Employee
Posted on January 08, 2018 at 18:03

Hi Francesco,

let me add one more thing. It could happen that your smartphone is using a Non Resolvable Private Address (this could be checked sniffing packets coming from the master). In this case, the smartphone cannot be added to the bonded devices list unless a more secure I/O capability is set by the slave.

Kind regards

Andrea

Francesco Sarasini
Associate II
Posted on January 11, 2018 at 15:02

Hi Andrea,

thanks. The smartphone is not using a 

Non Resolvable Private Address. I also verified that with another device (not bluenrg) it can bonds correctly.

I really don't know what to do

Thanks

Francesco Sarasini
Associate II
Posted on January 12, 2018 at 10:43

Hi,

I also tried setting 

I/O capability to IO_CAP_DISPLAY_ONLY but the bonding list is always empty after the pairing process.