[BLE] restarting a discovery

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

cross mob
user_2112781
Level 4
Level 4
10 likes received 10 likes given 5 likes given

I always get the 8033 (WICED_BT_BUSY) error code when I want to start again a discovery.

At the end of the scan, in the p_scan_result_cback, I try the following:

void scanCallback(wiced_bt_ble_scan_results_t *p_scan_result, uint8_t *p_adv_data)

{

  if (p_scan_result == NULL)

  {

  printf("wiced_bt_ble_get_current_scan_state = %u\n", wiced_bt_ble_get_current_scan_state());

  printf("wiced_bt_ble_scan(START) = %d\n", wiced_bt_ble_scan(BTM_BLE_SCAN_TYPE_HIGH_DUTY, WICED_TRUE, scanCallback));

  }

}

And as expected I get:

wiced_bt_ble_get_current_scan_state = 0

wiced_bt_ble_scan(START) = 8033

So, why can't the device discovery restart if the state is 0 ?

0 Likes
1 Solution
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

When you attempt to restart a scan, the stack checks for the existence of a non-NULL callback. If one exists it will throw you a WICED_BT_BUSY error. This is what is happening in your code.

You're correct that the scan is stopped by that point in the code, and, as you've seen, the indicator variable is appropriately set. However, until you allow the callback to return, the control block still has a non-NULL value for the callback. You must allow the callback to return--only then is the control block passed a NULL value for the callback, and only then can you restart a new scan.  

Jacob

View solution in original post

8 Replies