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

Scan for other devices using nrf51422 PCA10028

Hello, I would appreciate if you could help me solve what i am trying to do. I have nrf51DK board with nrf51422 on it, PCA10028, S130 and i want to use to scan for another devices, but i don't need to scan for all devices, what i want is to make it scanning only for one devices with known address. Does nrf51422 support this possibility? Scan only for a device with known address? After i found this device, i want to change the role and start advertising some data for a certain time(thats why i loaded chip with S130, because if i understand correct, it is possible to use same device for scanning and advertising).If so, could you provide some notes or example hot to do this? Right now i am playing with experimental_ble_app_multiactivity_beacon_hrs_ scanner example and i haven't totally figured out how example works, but i can see that i can monitor found device address in adv_packet structure ( adv_packet->addr.addr). However, don't know where to move from this point. Thank you very much in advance, Regards.

Parents
  • You can tell the SoftDevice to connect to a specific address or IRK.

    The radio will still receive all advertising packets, but if there is IRK or address match the packets will be ignored.

    You can use the following function for this.

    sd_ble_gap_connect(ble_gap_addr_t const *p_peer_addr, ble_gap_scan_params_t const *p_scan_params, ble_gap_conn_params_t const *p_conn_params));
    

    So you can either set the address (not IRK) to p_peer_addr and don't use whitelisting. Or you can set p_peer_addr to NULL and add the address (or IRK) to the whitelist. If you have more than one address/IRK in the whitelist it will connect to the first valid advertising packet it receives.

    Edit 15.10.2015

    experimental_ble_app_multiactivity_beacon is a peripheral example. Peripherals don't usually scan, but here we added scan functionality by using the timeslot API.

    Have a look at the examples in ble_central folder instead of ble_peripheral.

    You start a scan by using sd_ble_gap_scan_start().

    Then you will get the BLE_GAP_EVT_ADV_REPORT event every time the SoftDevice receives an advertising packet.

    It will come together with ble_gap_evt_adv_report_t struct which contains the peer address. You can compare this with the known address and trigger an action if there is a match.

    Or you can provide a whitelist to sd_ble_gap_scan_start(). In the whitelist you add the known address or IRK of the peripheral.

    Then you will only receive the BLE_GAP_EVT_ADV_REPORT event when the SoftDevice receives and advertising packet from those devices.

  • Woops, my mistake. Actually the code is working. But could you check if it is okay if i stop advertisements like this? I mean is it allowed, won't i cause hard fault or something if i'll try to stop advertise while it is going? because i don't know if device is advertising at the time i am calling sd_ble_gap_adv_stop(); function. Still keep an eye of this post if still possible :) Thanks.

Reply
  • Woops, my mistake. Actually the code is working. But could you check if it is okay if i stop advertisements like this? I mean is it allowed, won't i cause hard fault or something if i'll try to stop advertise while it is going? because i don't know if device is advertising at the time i am calling sd_ble_gap_adv_stop(); function. Still keep an eye of this post if still possible :) Thanks.

Children
No Data
Related