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

Whitelisting the Dongle/MCP

I have an advertising device (NRF52DK+SD132_V3.1.0+SDK_12.2.0) where I whitelisted an address corresponding to my NRF51 Dongle (0xDA509C569622).

While the dongle is initiating (with help of MCP v3.10.0.14) a connection to my device the MCP shows:

[22:29:21.6] Loading...
[22:29:22.1] Device address: 0xDA509C569622
[22:29:22.1] Master emulator firmware version: mefw_nrf51822_0.11.0.18378
[22:29:22.3] Ready
[22:29:22.3] SERVER: Server has started
[22:29:29.7] Device discovery started
[22:29:33.5] Device discovery stopped
[22:29:36.9] ConnectToDevice()
[22:29:37.1] SERVER: Received packet <HciEvent: eventCode=0x05> - <HciEvent: eventCode=0x05>
[22:29:37.1] ----------------------------
[22:29:37.1] Connected to device
[22:29:37.1] Role: 0
[22:29:37.1] PeerAddressType: 1
[22:29:37.1] PeerAddress (MSB): D5E441FB1A38
[22:29:37.1] Connection Interval: 20.0ms
[22:29:37.1] Connection Latency: 0
[22:29:37.1] Supervision Timeout: 3000ms
[22:29:37.1] Clock Accuracy: (1)
[22:29:37.1] ----------------------------
[22:29:37.1] Connected to D5E441FB1A38
[22:29:37.2] Lost connection to device. Reason: BTLE_CONN_FAILED_TO_BE_ESTABLISHED
[22:29:37.2] SERVER: Received packet <HciEvent: eventCode=0x0A> - <HciEvent: eventCode=0x0A>
[22:29:37.2] SERVER: Received Link Loss

So, according to the MCP's log the connection is established and then it is lost but according to my device log (I use LOG_NRF_INFO) - BLE_GAP_EVT_CONNECTED doesn't happen and there is nothing in my on_ble_evt except BLE_GAP_EVT_SCAN_REQ_REPORT.

I then replaced the address in the whitelist with the one corresponding to my second NRF52DK and used that second board with nRF Connect to connect to my device - and was successfully able to do so which proves that whitelist is actually working.

So somehow my setup Dongle/MCP is failing to connect (when I whitelist the Dongle) but NRF52DK/NRF Connect is succeeding. What could be so special in case of the Dongle/MCP and what are the ways to troubleshoot it?

I am not using PM. The whitelist is set in the BLE_ADV_EVT_WHITELIST_REQUEST's handler:

ble_gap_addr_t whitelist_addr = {0, BLE_GAP_ADDR_TYPE_RANDOM_STATIC, {0x22, 0x96, 0x56, 0x9c, 0x50, 0xDA}};
const ble_gap_addr_t      *p_whitelist_addr[1] = {&whitelist_addr};

err_code = sd_ble_gap_whitelist_set(p_whitelist_addr, 1);
APP_ERROR_CHECK(err_code);
err_code = ble_advertising_whitelist_reply(&whitelist_addr, 1, NULL, 0);
APP_ERROR_CHECK(err_code);

So, it probably looks like I whitelisted wrong address but as can be seen from the code above and from the MCP's log - it is correct, meaning the value in the code is matching the value printed out by MCP when it initializes the Dongle. Another thing which makes me think that the problem is unlikely on advertising side is that fact, as I mentioned above, that if I substitute that address with the one belonging to another board and use that board with nRF Connect - then the whitelist is working meaning I can initiate a connection from that board to my peripheral.

  • I'm not sure why it isn't working. The only thing I can think of is that the address type is incorrect, but I don't think MCP changes this. You could double check by running a program on the dongle and call sd_ble_gap_addr_get(). I will try to test with a dongle, but it will not be until Monday.

  • I tried to use the address type BLE_GAP_ADDR_TYPE_PUBLIC but got the same result. I then tried to download a sample program into my 10031 Dongle but was not able to do so because my attempt to program resulted in "Error: Flash Download failed - "Cortext-M0"". I used the app from nRF5_SDK_12.2.0_f012efa\examples\peripheral\template_project\pca10028\blank\arm5_no_packs and programmed my dongle with SD 130 v2.0.1. The target in Keil was selected as 'nrf51422-xxac'. IROM1= 0x0/0x40000. IRAM1=0x20000000/0x8000 Seems like I need to adjust RAM/ROM, right? If so, is there some sort of compatibility matrix I could use to figure out what settings I should use with my combinations of hardware/softdevice/sdk?

  • For the templete project they should be: IROM1 = 0x1B000/0x25000 and IRAM1 = 0x20001FE8/0x6018. You can find the ROM size of the SoftDevice in the SoftDevice specification, then need RAM is returned when you call sd_ble_enable().

  • I did some testing. The address type when running MCP is actually BLE_GAP_ADDR_TYPE_PUBLIC.

    With device address 0xDA509C569622 the following should work:

    ble_gap_addr_t whitelist_addr = {0, BLE_GAP_ADDR_TYPE_PUBLIC, {0xDA, 0x50, 0x9C, 0x56, 0x96, 0x22}};
    
Related