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

Can not make scan_req_notification working...

Hi!

I am trying to get scan_req_notification to fire notifications when central devices issue scan reqs but without success until now. Here is my code:

Env: SDK15, SES, nrf52DK

In a ble template derived project, in the advertising_start() function I added this code before calling ble_advertising_start():

...

m_advertising.adv_params.scan_req_notification = 1;
m_advertising.adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED;

ret_code_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);

...

Then from the ble_cus_on_ble_evt (observer) handler, I added a new case with:

case BLE_GAP_EVT_SCAN_REQ_REPORT:
            printf("\n SCAN_REQ called ...\n");
            const ble_gap_evt_t   * p_gap_evt = &p_ble_evt->evt.gap_evt;

            break;

I also added a breakpoint to the printf line

However, the BLE_GAP_EVT_SCAN_REQ_REPORT notification is never fired when using nRFConnect app or a Linux Bluez C app used for scan BLE devices. This linux C app was configured in order to do scan request:

...

le_set_scan_parameters_cp scan_params_cp;
memset(&scan_params_cp, 0, sizeof(scan_params_cp));
scan_params_cp.type   = 0x01; //00 Passive 01 Active

...

What am I doing wrong?

Thanks

Alex

Parents
  • Hello,

    I tested enabling the scan request notifications, and it works here. What SDK version do you use? SDK15.3.0?

    I tested on both SDK15.3.0 and SDK15.0.0, and it worked in both. 

    Where did you insert the line:

    m_advertising.adv_params.scan_req_notification = 1;

    The reason I ask is that in ble_advertising.c where the ble_advertising_start() function is defined, it uses p_advertising, and not m_advertising. Can you try to add it inside the ble_advertising_start() function?

    Also, I don't know how your ble_cus_on_ble_evt() is set up, but can you try to add the case BLE_GAP_EVT_SCAN_REQ_REPORT in ble_evt_handler() in main.c as well? Do you get the event there?

    One last thing: printf() is used in among others the ble_app_uart example, but it is not necessarily set up in the other examples. Do you see the other messages that you print using printf()?

    Best regards,

    Edvin

Reply
  • Hello,

    I tested enabling the scan request notifications, and it works here. What SDK version do you use? SDK15.3.0?

    I tested on both SDK15.3.0 and SDK15.0.0, and it worked in both. 

    Where did you insert the line:

    m_advertising.adv_params.scan_req_notification = 1;

    The reason I ask is that in ble_advertising.c where the ble_advertising_start() function is defined, it uses p_advertising, and not m_advertising. Can you try to add it inside the ble_advertising_start() function?

    Also, I don't know how your ble_cus_on_ble_evt() is set up, but can you try to add the case BLE_GAP_EVT_SCAN_REQ_REPORT in ble_evt_handler() in main.c as well? Do you get the event there?

    One last thing: printf() is used in among others the ble_app_uart example, but it is not necessarily set up in the other examples. Do you see the other messages that you print using printf()?

    Best regards,

    Edvin

Children
No Data
Related