Target is nrf52832+SoftDeviceS132
When run ActiveScan,
Is SCAN_RSP advertise_report notified only after ADV_SCAN_IND advertise_report?
If I receive only the SCAN_RSP of the SCAN_REQ performed by another device, will it be notified?
Target is nrf52832+SoftDeviceS132
When run ActiveScan,
Is SCAN_RSP advertise_report notified only after ADV_SCAN_IND advertise_report?
If I receive only the SCAN_RSP of the SCAN_REQ performed by another device, will it be notified?
SCAN_RSP will only be sent everytime by the advertiser when it receives SCN_REQ from the scanner.
In the previous figure, we want to allocate adv_report_buffer1 by malloc.
Shouldn't I free adv_report_buffer1 until I receive the SCAN_RSP?
Please look at the documentation for the API before using it. In the documentation for sd_ble_gap_scan_start, it is clearly mentioned for p_adv_report_buffer, the buffer used to store incoming advertising data should be kept alive until the scanning is stopped. So if you allocated memory using malloc, you cannot free the memory while scanner is running.
written for sd_ble_gap_scan_start()
The scanner will automatically stop in the following cases:
sd_ble_gap_scan_stop is called.
sd_ble_gap_connect is called.
A BLE_GAP_EVT_TIMEOUT with source set to BLE_GAP_TIMEOUT_SRC_SCAN is received.
When a BLE_GAP_EVT_ADV_REPORT event is received and ble_gap_adv_report_type_t::status is not set to BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. In this case scanning is only paused to let the application access received data. The application must call this function to continue scanning, or call sd_ble_gap_scan_stop to stop scanning.
-----------------------
p_adv_report_buffer The memory pointed to should be kept alive until the scanning is stopped.
Isn't it okay to free the buffer when BLE_GAP_EVT_ADV_REPORT (ADV_SCAN_IND) is returned?
And shouldn't we set up a new buffer to get the SCAN_RSP?
loquat said:Isn't it okay to free the buffer when BLE_GAP_EVT_ADV_REPORT (ADV_SCAN_IND) is returned?
If you want to pause/stop the scanner after this event, then it is ok to free the buffer, but if you intend to make the scanner resume then it is wise to keep this buffer alive.
loquat said:And shouldn't we set up a new buffer to get the SCAN_RSP?
Scan response data is a complete different buffer (p_gap->params.scan_req_report) and complete different event. You need to manage it differently. I am not sure why you need to have a dynamic memory here but if you think you do, then have two different buffers for adv report and scan response data