BLE Host - Return BLE_HS_ETIMEOUT_HCI on ack tmo.
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/b8b32326 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b8b32326 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b8b32326 Branch: refs/heads/master Commit: b8b32326ccfcc1dfdef1b1d36051a4345e249c20 Parents: af6cb23 Author: Christopher Collins <ccoll...@apache.org> Authored: Mon Jun 20 20:06:03 2016 -0700 Committer: Christopher Collins <ccoll...@apache.org> Committed: Mon Jun 20 20:31:29 2016 -0700 ---------------------------------------------------------------------- net/nimble/host/include/host/ble_hs.h | 1 + net/nimble/host/src/ble_hci_cmd.c | 12 +++++++++++- net/nimble/host/src/test/ble_hs_conn_test.c | 2 +- net/nimble/host/src/test/ble_hs_test_util.c | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b8b32326/net/nimble/host/include/host/ble_hs.h ---------------------------------------------------------------------- diff --git a/net/nimble/host/include/host/ble_hs.h b/net/nimble/host/include/host/ble_hs.h index 1f46f6d..18eb588 100644 --- a/net/nimble/host/include/host/ble_hs.h +++ b/net/nimble/host/include/host/ble_hs.h @@ -53,6 +53,7 @@ struct os_event; #define BLE_HS_EREJECT 17 #define BLE_HS_EUNKNOWN 18 #define BLE_HS_EROLE 19 +#define BLE_HS_ETIMEOUT_HCI 20 #define BLE_HS_ERR_ATT_BASE 0x100 /* 256 */ #define BLE_HS_ATT_ERR(x) ((x) ? BLE_HS_ERR_ATT_BASE + (x) : 0) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b8b32326/net/nimble/host/src/ble_hci_cmd.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_hci_cmd.c b/net/nimble/host/src/ble_hci_cmd.c index 8580673..c41f038 100644 --- a/net/nimble/host/src/ble_hci_cmd.c +++ b/net/nimble/host/src/ble_hci_cmd.c @@ -199,7 +199,7 @@ ble_hci_cmd_wait_for_ack(void) #if PHONY_HCI_ACKS if (ble_hci_cmd_phony_ack_cb == NULL) { - rc = BLE_HS_ETIMEOUT; + rc = BLE_HS_ETIMEOUT_HCI; } else { BLE_HS_DBG_ASSERT(ble_hci_cmd_ack_ev == NULL); ble_hci_cmd_ack_ev = os_memblock_get(&g_hci_cmd_pool); @@ -211,6 +211,16 @@ ble_hci_cmd_wait_for_ack(void) } #else rc = os_sem_pend(&ble_hci_cmd_sem, BLE_HCI_CMD_TIMEOUT); + switch (rc) { + case 0: + break; + case OS_TIMEOUT: + rc = BLE_HS_ETIMEOUT_HCI; + break; + default: + rc = BLE_HS_EOS; + break; + } #endif return rc; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b8b32326/net/nimble/host/src/test/ble_hs_conn_test.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/test/ble_hs_conn_test.c b/net/nimble/host/src/test/ble_hs_conn_test.c index c56efe0..5f86ad1 100644 --- a/net/nimble/host/src/test/ble_hs_conn_test.c +++ b/net/nimble/host/src/test/ble_hs_conn_test.c @@ -98,7 +98,7 @@ TEST_CASE(ble_hs_conn_test_direct_connect_hci_errors) /* Initiate connection; receive no HCI ack. */ rc = ble_gap_conn_initiate(0, addr, NULL, NULL, NULL); - TEST_ASSERT(rc == BLE_HS_ETIMEOUT); + TEST_ASSERT(rc == BLE_HS_ETIMEOUT_HCI); TEST_ASSERT(!ble_gap_master_in_progress()); TEST_ASSERT(!ble_hs_conn_test_util_any()); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b8b32326/net/nimble/host/src/test/ble_hs_test_util.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/test/ble_hs_test_util.c b/net/nimble/host/src/test/ble_hs_test_util.c index 782d359..e2f28c7 100644 --- a/net/nimble/host/src/test/ble_hs_test_util.c +++ b/net/nimble/host/src/test/ble_hs_test_util.c @@ -245,7 +245,7 @@ ble_hs_test_util_phony_ack_cb(uint8_t *ack, int ack_buf_len) struct ble_hs_test_util_phony_ack *entry; if (ble_hs_test_util_num_phony_acks == 0) { - return BLE_HS_ETIMEOUT; + return BLE_HS_ETIMEOUT_HCI; } entry = ble_hs_test_util_phony_acks;