Scan BLE forever

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
agmi_3321141
Level 4
Level 4
5 likes given First like received First like given

Hello All!

I have a really basic question on how I can continuously scan for BLE packets. There seems to be two APIs - observe and scan, and I have been able to use them as console commands to scan for packets. I tried spinning a new thread and enclosed the scan/observe call in a while 1 loop but that doesn't actually seem right. what is the right way to continually scan for BLE packets?

For example, this didn't work for me:

while ( 1 )

    {

            wiced_result_t scan_result;

            do {

                scan_result = wiced_bt_ble_scan(BTM_BLE_SCAN_TYPE_HIGH_DUTY, WICED_TRUE, (wiced_bt_ble_scan_result_cback_t *) hello_sensor_scan_ble_callback);

            } while (scan_result != WICED_BT_BUSY);

        // wiced_bt_ble_scan(BTM_BLE_SCAN_TYPE_HIGH_DUTY, WICED_TRUE, (wiced_bt_ble_scan_result_cback_t *) hello_sensor_scan_ble_callback);

    }

Thanks!

0 Likes
1 Solution
RaktimR_11
Moderator
Moderator
Moderator
500 replies posted 250 replies posted 100 replies posted

You can use wiced_bt_ble_observe API with the duration set to zero.

View solution in original post

4 Replies
RaktimR_11
Moderator
Moderator
Moderator
500 replies posted 250 replies posted 100 replies posted

You can use wiced_bt_ble_observe API with the duration set to zero.

I guess a follow-up question would be how to stop it once the infinite scan has started?

0 Likes

vmore_3321141 wrote:

I guess a follow-up question would be how to stop it once the infinite scan has started?

Have you tested stop it by wiced_bt_ble_observe(WICED_FALSE,...)?

Yes, I tried that. It worked