Hi, I'm working with nRF52832 and S132 v6.1.1 on SDK15.3.0.
I'm using two nRF52832: one is scanning (active scanning) and one is advertising, and I want to exchange data between them using the scan request/scan response mechanism.
Using your nRF Sniffer with WireShark, I'm able to see that the scanning device is correctly sending scan requests (SCAN_REQ), and the advertising device is sending scan responses (SCAN_RSP) with my custom payload as expected:
My problem is that I've not been able to retrieve such scan response data on the scanning device.
I'm parsing the received advertising packets using on_adv_report(ble_gap_evt_adv_report_t const * p_adv_report), called by BLE_GAP_EVT_ADV_REPORT within ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context).
My understanding is that I should find the scan response data within the p_adv_report->data.p_data buffer, which is just the same where regular advertising packets data is temporarily stored. Is it correct? Because I can't seem to find the scan response data I'm looking for.
Also, how should I recognize scan response packets from regular advertising packets? I've come up with this but I'm not quite sure that's the correct way:
if ((p_adv_report->type.scan_response >> 3) & 1) { // That's a scan response packet } else { // That's a regular advertising packet }
Finally, on the advertising device side, I'd like to ask if what I'm currently doing everytime I'm starting the advertising activity:
if (i_want_regular_adv_packet) { // Filling m_advertising.enc_advdata here... m_advertising.adv_data.adv_data.len = whatever; m_advertising.adv_data.adv_data.p_data = m_advertising.enc_advdata; // Explicity avoid scan response m_advertising.adv_data.scan_rsp_data.len = 0; m_advertising.adv_data.scan_rsp_data.p_data = NULL; } else if (i_want_scan_response_packet) { // Filling m_advertising.enc_scan_rsp_data here... m_advertising.adv_data.scan_rsp_data.len = whatever; m_advertising.adv_data.scan_rsp_data.p_data = m_advertising.enc_scan_rsp_data; // Explicity avoid regular adv packet m_advertising.adv_data.adv_data.len = 0; m_advertising.adv_data.adv_data.p_data = NULL; } ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
Is it necessary to always "zero" one of the two packets, or does the softdevice take care of which packet to send in which condition (basically if upon a scan request or not).
Thank you in advance for your precious help.
Best regards,
Lorenzo