BLE: rework GenericGap::stopAdvertising(AdvHandle)

pull/8738/head
Vincent Coubard 2018-11-10 20:02:44 +00:00
parent 74356aa7f0
commit d6d1ea5c2a
1 changed files with 11 additions and 6 deletions

View File

@ -1840,7 +1840,6 @@ ble_error_t GenericGap::startAdvertising(
maxDuration maxDuration
); );
} }
} else { } else {
/* round up */ /* round up */
uint16_t duration_10ms = maxDuration ? (maxDuration - 1) / 10 + 1 : 0 ; uint16_t duration_10ms = maxDuration ? (maxDuration - 1) / 10 + 1 : 0 ;
@ -1868,15 +1867,21 @@ ble_error_t GenericGap::stopAdvertising(AdvHandle_t handle) {
} }
if (!is_extended_advertising_available()) { if (!is_extended_advertising_available()) {
if (handle == Gap::LEGACY_ADVERTISING_HANDLE) { if (handle != Gap::LEGACY_ADVERTISING_HANDLE) {
return stopAdvertising(); return BLE_ERROR_INVALID_PARAM;
} }
return BLE_ERROR_NOT_IMPLEMENTED;
ble_error_t err = _pal_gap.advertising_enable(false);
if (err) {
return err;
}
_advertising_timeout.detach();
// FIXME: Handle random address rotation of this advertising set
} }
return _pal_gap.extended_advertising_enable( return _pal_gap.extended_advertising_enable(
true, /*enable ? */ false,
1, /* number of advertising sets */ 1,
&handle, &handle,
NULL, NULL,
NULL NULL