This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Issue in implementing whitelist

Hi, 

I am working on nrf52832 , SDK15 and softdevice S132. I am modifying the ble_app_hrs example code in SDK

I was trying to implement a whitelist with the address of my ANdroid phone so that peripheral will connect only to this phone .

I have hard coded the MAC address , but it is not connecting.  And If i disable whitelist it is connecting.

My doubt is , which address(of the phone) should we put?(I am attaching an image)

Image showing the addresses in my phone

Or is there any restriction to the adddress type of the address in the phone?(due to which the disconnect happens)

And in which order should the array to be filled?

I have done as follows(the address is shown in the image)

peer_addr.addr[0] = 0xbc;
peer_addr.addr[1] = 0x41;
peer_addr.addr[2] = 0x01;
peer_addr.addr[3] = 0x31;
peer_addr.addr[4] = 0x8f;
peer_addr.addr[5] = 0x48;

Is this the correct way to fill the array?

Thanking you.

Here  are my code snippets

1) In advertising_init() added the following

init.advdata.flags= BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;

init.config.ble_adv_whitelist_enabled = true;

2) Added the following in on_adv_evt()

ble_gap_addr_t peer_addr; //peer device address
ble_gap_addr_t const * p_peer_addr;
ble_gap_addr_t const * const * pp_peer_addr;

..............................

.............................

case BLE_ADV_EVT_WHITELIST_REQUEST:
memset(&peer_addr, 0x00, sizeof(peer_addr));


peer_addr.addr[0] = 0xbc;
peer_addr.addr[1] = 0x41;
peer_addr.addr[2] = 0x01;
peer_addr.addr[3] = 0x31;
peer_addr.addr[4] = 0x8f;
peer_addr.addr[5] = 0x48

//peer_addr pointers. Double pointers for the win! :S
p_peer_addr = &peer_addr;
pp_peer_addr = &p_peer_addr;

// Set white list
err_code = sd_ble_gap_whitelist_set(pp_peer_addr, 0x01);
if (err_code == NRF_SUCCESS)
NRF_LOG_INFO("Successfully set whitelist!\n");

// White list reply
err_code = ble_advertising_whitelist_reply(&m_advertising,p_peer_addr, 1, NULL, (uint32_t) NULL);
if (err_code == NRF_SUCCESS)
NRF_LOG_INFO( "Whitelist replied\n");

APP_ERROR_CHECK(err_code);

break;

Please let me know are the above changes sufficient to make the whitelist work?

Am I missing something?

Anything to do with filter policies?

with regards,

Geetha

  • Hi

    Thank you.

    But today also my phone shows the same address 

    But still I could not connect to the phone.

    But I could connect successfully with nRFConnect on desktop.

    Is there anything I need to take care while connecting to phone?

    with regards,

    Geetha

  • Hi.

    If you don't have the right address in your code you cant connect. You should be able to connect with the address  bc:41:01:33:15:dc added to your whitelist.

    - Andreas

  • Hi Andreas,

    Thank you for your reply.

    I apologize for bothering( after a long time)  you thus.

    I have tried the following.

    I am having two RIGADO DK. I have installed nRFConnect Desktop App in my PC. So one device I connected to the PC to run the desktop App and another DK I used to flash the 'modified ble_app_hrs' code. I have hardcoded the address of the DK (used to run the Desktop App) in the HRM code . And this code is flashed to other DK.

    Now if I press scan button in nRF Connect desktop App, the 'Nordic HRM ' name will get displayed in the list and when I press 'connect '  button it will establish connection successfully.

    If I give a different address( hardcode with a different address) then the device is not getting displayed  in the liast of nRFConnect Desktop App. So this means the whhitelistin is working fine in this set up. Am I correct?

    But if I use nRFConnect App from mobile phone (instead of using nRFConnect Desktop App) the connection is not happening? Is it because the address type in the phone and in the DK are different?

    Thanking you in advance.

    with regards,

    Geetha

Related