BLE: return stack busy instead of invalid state when applicable

enabling/disabling scanning and advertising operations can be prevented if the previous operations hasn't completed.
Return that the stack is busy and cannot fulfill the request at the moment rather than the state is invalid.
pull/13759/head
Vincent Coubard 2020-09-10 14:57:56 +01:00
parent 3c22f8ae1d
commit 48f4cfbe04
1 changed files with 5 additions and 5 deletions

View File

@ -462,7 +462,7 @@ ble_error_t Gap::stopScan()
ble_error_t err;
if ((!_scan_enabled && !_scan_pending) || _scan_pending) {
return BLE_ERROR_NONE;
return BLE_STACK_BUSY;
}
if (is_extended_advertising_available()) {
@ -1985,10 +1985,10 @@ ble_error_t Gap::startAdvertising(
{
ble_error_t error = BLE_ERROR_NONE;
// invalid state because it is starting, stopping or refreshing internally
// the stack is busy because it is starting, stopping or refreshing internally
// the address.
if (_pending_sets.get(handle) || _address_refresh_sets.get(handle)) {
return BLE_ERROR_INVALID_STATE;
return BLE_STACK_BUSY;
}
#if BLE_FEATURE_EXTENDED_ADVERTISING
@ -2085,7 +2085,7 @@ ble_error_t Gap::stopAdvertising(advertising_handle_t handle)
#endif // BLE_FEATURE_EXTENDED_ADVERTISING
if (!_active_sets.get(handle) || _pending_sets.get(handle)) {
return BLE_ERROR_INVALID_STATE;
return BLE_STACK_BUSY;
}
#if BLE_FEATURE_EXTENDED_ADVERTISING
@ -2684,7 +2684,7 @@ ble_error_t Gap::startScan(
)
{
if (_scan_pending || _scan_address_refresh) {
return BLE_ERROR_INVALID_STATE;
return BLE_STACK_BUSY;
}
const address_t *address = get_random_address(controller_operation_t::scanning);