MYNEWT-629: Unexpected advertising state machine stop. This commit should fix the bug where an advertising state machine that was not expected to be stopped could be stopped when a different state machine was stopped through the hci advertising enable command.
This change does affect both MULTI_ADV_SUPPORT and normal builds. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/1449ffcd Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1449ffcd Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1449ffcd Branch: refs/heads/sensors_branch Commit: 1449ffcdbac75131f98f933036696427bbc3b57a Parents: 4ef28aa Author: William San Filippo <[email protected]> Authored: Wed Feb 22 09:36:20 2017 -0800 Committer: William San Filippo <[email protected]> Committed: Wed Feb 22 09:38:25 2017 -0800 ---------------------------------------------------------------------- net/nimble/controller/src/ble_ll_adv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1449ffcd/net/nimble/controller/src/ble_ll_adv.c ---------------------------------------------------------------------- diff --git a/net/nimble/controller/src/ble_ll_adv.c b/net/nimble/controller/src/ble_ll_adv.c index 077ca5a..1130638 100644 --- a/net/nimble/controller/src/ble_ll_adv.c +++ b/net/nimble/controller/src/ble_ll_adv.c @@ -739,11 +739,21 @@ ble_ll_adv_sm_stop(struct ble_ll_adv_sm *advsm) /* Set to standby if we are no longer advertising */ OS_ENTER_CRITICAL(sr); +#if MYNEWT_VAL(BLE_MULTI_ADV_SUPPORT) + if (g_ble_ll_cur_adv_sm == advsm) { + ble_phy_disable(); + ble_ll_wfr_disable(); + ble_ll_state_set(BLE_LL_STATE_STANDBY); + g_ble_ll_cur_adv_sm = NULL; + } +#else if (ble_ll_state_get() == BLE_LL_STATE_ADV) { ble_phy_disable(); ble_ll_wfr_disable(); ble_ll_state_set(BLE_LL_STATE_STANDBY); + g_ble_ll_cur_adv_sm = NULL; } +#endif OS_EXIT_CRITICAL(sr); os_eventq_remove(&g_ble_ll_data.ll_evq, &advsm->adv_txdone_ev);
