Skip to content

Commit b4be302

Browse files
translate error codes in adv set terminated event
1 parent 88dc483 commit b4be302

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

connectivity/FEATURE_BLE/include/ble/gap/Events.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,9 +629,13 @@ struct AdvertisingEndEvent {
629629
* @param advHandle Advertising set handle.
630630
* @param connection Connection handle - only valid if connected is True.
631631
* @param completed_events Number of events created during before advertising end - only valid
632-
* if advertising end has been caused by a connection or timeout, not the local user.
632+
* if advertising end has been caused by BLE_ERROR_LIMIT_REACHED, not the local user.
633+
* Check getStatus().
633634
* @param connected True if connection has been established.
634-
* @param status Error code if stop command failed.
635+
* @param status Error code showing the reason for event. BLE_ERROR_LIMIT_REACHED if set number
636+
* of events have been reached. BLE_ERROR_TIMEOUT if set time has elapsed.
637+
* BLE_ERROR_SUCCESS if connection occurred or user ended the set. Check isConnected()
638+
* to determine which.
635639
*/
636640
AdvertisingEndEvent(
637641
advertising_handle_t advHandle,

connectivity/FEATURE_BLE/source/generic/GapImpl.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3484,11 +3484,17 @@ void Gap::on_advertising_set_terminated(
34843484
ble_error_t error_code = BLE_ERROR_UNSPECIFIED;
34853485
bool connected = false;
34863486

3487-
if (status == hci_error_code_t::SUCCESS && connection_handle != DM_CONN_ID_NONE) {
3488-
connected = true;
3487+
/* translate HCI error into BLE API error code */
3488+
if (status == hci_error_code_t::SUCCESS) {
34893489
error_code = BLE_ERROR_NONE;
3490+
/* self cancelled set will have the handle set to invalid value */
3491+
if (connection_handle != DM_CONN_ID_NONE) {
3492+
connected = true;
3493+
}
34903494
} else if (status == hci_error_code_t::ADVERTISING_TIMEOUT) {
3491-
error_code = BLE_ERROR_NONE;
3495+
error_code = BLE_ERROR_TIMEOUT;
3496+
} else if (status == hci_error_code_t::LIMIT_REACHED) {
3497+
error_code = BLE_ERROR_LIMIT_REACHED;
34923498
}
34933499

34943500
if (error_code == BLE_ERROR_NONE) {

0 commit comments

Comments
 (0)