nimble/controller: Add helper to check if controller is busy In couple of places we were checking if controller is scanning, advertising or connection is in progress. Lets make a helper for this
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/0536012a Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/0536012a Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/0536012a Branch: refs/heads/bluetooth5 Commit: 0536012adbda8df58e2e1f7d548abb626012a2d1 Parents: ac7b489 Author: Åukasz Rymanowski <[email protected]> Authored: Thu Apr 6 09:40:04 2017 +0200 Committer: Åukasz Rymanowski <[email protected]> Committed: Thu Apr 6 09:46:45 2017 +0200 ---------------------------------------------------------------------- net/nimble/controller/src/ble_ll_resolv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0536012a/net/nimble/controller/src/ble_ll_resolv.c ---------------------------------------------------------------------- diff --git a/net/nimble/controller/src/ble_ll_resolv.c b/net/nimble/controller/src/ble_ll_resolv.c index c38a5bc..8d17f87 100644 --- a/net/nimble/controller/src/ble_ll_resolv.c +++ b/net/nimble/controller/src/ble_ll_resolv.c @@ -44,6 +44,12 @@ struct ble_ll_resolv_data g_ble_ll_resolv_data; struct ble_ll_resolv_entry g_ble_ll_resolv_list[MYNEWT_VAL(BLE_LL_RESOLV_LIST_SIZE)]; +static int +ble_ll_is_controller_busy(void) +{ + return ble_ll_adv_enabled() || ble_ll_scan_enabled() || + g_ble_ll_conn_create_sm; +} /** * Called to determine if a change is allowed to the resolving list at this * time. We are not allowed to modify the resolving list if address translation @@ -58,8 +64,7 @@ ble_ll_resolv_list_chg_allowed(void) int rc; if (g_ble_ll_resolv_data.addr_res_enabled && - (ble_ll_adv_enabled() || ble_ll_scan_enabled() || - g_ble_ll_conn_create_sm)) { + ble_ll_is_controller_busy()) { rc = 0; } else { rc = 1; @@ -310,8 +315,7 @@ ble_ll_resolv_enable_cmd(uint8_t *cmdbuf) int32_t tmo; uint8_t enabled; - if (ble_ll_adv_enabled() || ble_ll_scan_enabled() || - g_ble_ll_conn_create_sm) { + if (ble_ll_is_controller_busy()) { rc = BLE_ERR_CMD_DISALLOWED; } else { enabled = cmdbuf[0]; @@ -378,8 +382,7 @@ ble_ll_resolve_set_priv_mode(uint8_t *cmdbuf) { struct ble_ll_resolv_entry *rl; - if (ble_ll_adv_enabled() || ble_ll_scan_enabled() || - g_ble_ll_conn_create_sm) { + if (ble_ll_is_controller_busy()) { return BLE_ERR_CMD_DISALLOWED; }
