Skip to content

Commit 3e9d880

Browse files
use invalid connection handle for locally stopped adv sets
1 parent 9283e3e commit 3e9d880

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_adv_ae.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,7 @@ void dmExtAdvActHciEnableCmpl(hciEvt_t *pEvent)
12271227
/* prepare the message for callback */
12281228
dmMsg.advSetStop.numComplEvts = 0; /* this value is invalid, we zero it to avoid confusing the user */
12291229
dmMsg.advSetStop.handle = DM_CONN_ID_NONE;
1230+
dmMsg.advSetStop.handle = DM_ADV_HCI_HANDLE_NONE;
12301231
dmMsg.advSetStop.status = dmMsg.hdr.status;
12311232
dmMsg.advSetStop.advHandle = i;
12321233

connectivity/FEATURE_BLE/source/cordio/source/PalGapImpl.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -870,14 +870,17 @@ void PalGap::gap_handler(const wsfMsgHdr_t *msg)
870870
}
871871

872872
hci_error_code_t status = hci_error_code_t(evt->status);
873-
if (status == hci_error_code_t::SUCCESS && evt->handle == DM_CONN_ID_NONE) {
874-
/* we stopped advertising without a connection, reflect that in the status */
875-
status = hci_error_code_t::OPERATION_CANCELLED_BY_HOST;
873+
connection_handle_t connection_handle = DM_CONN_ID_NONE;
874+
/* the way we distinguish between local close and connection is the invalid HCI conn handle */
875+
if (evt->handle != DM_CONN_HCI_HANDLE_NONE) {
876+
/* use the translated conn handle */
877+
connection_handle = evt->hdr.param;
876878
}
879+
877880
handler->on_advertising_set_terminated(
878881
status,
879882
evt->advHandle,
880-
evt->handle,
883+
connection_handle,
881884
evt->numComplEvts
882885
);
883886
} break;

connectivity/FEATURE_BLE/source/generic/GapImpl.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3479,16 +3479,14 @@ void Gap::on_advertising_set_terminated(
34793479
connection_handle,
34803480
to_string(status),
34813481
number_of_completed_extended_advertising_events);
3482-
3482+
34833483
ble_error_t error_code = BLE_ERROR_UNSPECIFIED;
34843484
bool connected = false;
34853485

3486-
if (status == hci_error_code_t::SUCCESS) {
3487-
/* hci code success means connection terminated it */
3486+
if (status == hci_error_code_t::SUCCESS && connection_handle != DM_CONN_ID_NONE) {
34883487
connected = true;
34893488
error_code = BLE_ERROR_NONE;
3490-
} else if (status == hci_error_code_t::OPERATION_CANCELLED_BY_HOST) {
3491-
/* if we stopped the set ourselves this is not an error */
3489+
} else if (status == hci_error_code_t::ADVERTISING_TIMEOUT) {
34923490
error_code = BLE_ERROR_NONE;
34933491
}
34943492

0 commit comments

Comments
 (0)