How to send a scan request/parse a scan response?

93 views
Skip to first unread message

J Ch

unread,
Sep 29, 2023, 7:20:44 AM9/29/23
to btstack-dev
Are there any examples that show an active BLE scanner, sending a scan request to an advertiser, and then parsing the scan response data?

Matthias Ringwald

unread,
Oct 4, 2023, 3:01:36 AM10/4/23
to btsta...@googlegroups.com
Hi Jacob

When the Bluetooth Controller is configured for active scanning, it will automatically send a scan request when it receives an advertising.
The gap_le_advertisements example configures active scanning. You'll get an GAP_EVENT_ADVERTISING_REPORT or GAP_EVENT_EXTENDED_ADVERTISING_REPORT for Adv as well as Scan Responses. The scan response has a different 'event_type'

Cheers
Matthias



> On 29 Sep 2023, at 13:20, J Ch <jacob.ch...@gmail.com> wrote:
>
> Are there any examples that show an active BLE scanner, sending a scan request to an advertiser, and then parsing the scan response data?
>
> --
> You received this message because you are subscribed to the Google Groups "btstack-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/d42c3a2c-e830-4b6f-abcd-dc32df59c97bn%40googlegroups.com.

J Ch

unread,
Oct 4, 2023, 1:51:30 PM10/4/23
to btstack-dev
Thank you Matthias.

On the flip side, do you have an example that shows how to set up a scan response, to be sent by a peripheral?

J Ch

unread,
Oct 4, 2023, 1:55:38 PM10/4/23
to btstack-dev
Sorry, didn't do my research:

**
 * @brief Set Scan Response Data
 * @param advertising_data_length
 * @param advertising_data (max 31 octets)
 * @note data is not copied, pointer has to stay valid
 */
void gap_scan_response_set_data(uint8_t scan_response_data_length, uint8_t * scan_response_data){
    hci_stack->le_scan_response_data_len = scan_response_data_length;
    hci_stack->le_scan_response_data = scan_response_data;
    hci_stack->le_advertisements_todo |= LE_ADVERTISEMENT_TASKS_SET_SCAN_DATA;
    hci_run();
Reply all
Reply to author
Forward
0 new messages