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

How to fire BLE_GAP_EVT_ADV_REPORT fire for nus on SDK 15.2

Earlier for nrf52 we could filter out connections on the peripheral based on rssi, need similar operation for nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral\ble_app_uart.
Basically the intent is to prevent connection to peer with rssi below certain threshold.

This old code for earlier sdk does not work any more.

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context) {
    ret_code_t            err_code;
    ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt; 

    switch (p_ble_evt->header.evt_id)    {

        case BLE_GAP_EVT_ADV_REPORT:  { /*does not fire any more*/
            ble_gap_evt_adv_report_t const * p_adv_report = &p_gap_evt->params.adv_report; 
            // Look for advertising nRF peripheral devices only when in range of the RSSI threshold 
            if (p_gap_evt->params.adv_report.rssi >= MIN_RSSI_THRESHOLD)   {
            ...

Parents
  • Not sure which earlier SDK you are referring to, but the behavior of the SD was changed so that when you receive an adv_report scanning is stopped to give the mcu some time to handle the report. You now have to restart scanning after receiving the adv report. This can be done in the ble_evt_handler in main by calling sd_ble_gap_scan_start in BLE_GAP_EVT_ADV_REPORT

Reply
  • Not sure which earlier SDK you are referring to, but the behavior of the SD was changed so that when you receive an adv_report scanning is stopped to give the mcu some time to handle the report. You now have to restart scanning after receiving the adv report. This can be done in the ble_evt_handler in main by calling sd_ble_gap_scan_start in BLE_GAP_EVT_ADV_REPORT

Children
No Data
Related