You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/08/04 02:59:36 UTC
[12/14] incubator-mynewt-core git commit: BLE Host - Rename HCI
identifiers and files.
BLE Host - Rename HCI identifiers and files.
The HCI-related host functionality was using some really inconsistent
names. Identifiers and files have been renamed as reorganized as
follows:
* host_dbg --> ble_hs_dbg
* host_hci_cmd --> ble_hs_hci_cmd
* host_hci --> ble_hs_hci_evt / ble_hs_hci
* ble_hci_util --> ble_hs_hci_util
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/d842a43c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d842a43c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d842a43c
Branch: refs/heads/develop
Commit: d842a43c98ee8acc812b49ac6a4da3681af86ed9
Parents: ef6ef4c
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Aug 3 18:41:01 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Aug 3 19:54:16 2016 -0700
----------------------------------------------------------------------
apps/blecent/src/main.c | 1 -
apps/bleprph/src/main.c | 1 -
apps/bletest/src/bletest_hci.c | 128 +-
apps/bletest/src/main.c | 9 +-
apps/bletiny/src/main.c | 4 +-
apps/bleuart/src/main.c | 1 -
net/nimble/host/include/host/ble_hs.h | 1 -
net/nimble/host/include/host/ble_hs_test.h | 2 +-
net/nimble/host/include/host/host_hci.h | 130 --
net/nimble/host/src/ble_eddystone.c | 2 +-
net/nimble/host/src/ble_gap.c | 85 +-
net/nimble/host/src/ble_gap_priv.h | 2 +-
net/nimble/host/src/ble_gattc.c | 4 +-
net/nimble/host/src/ble_hci_cmd.c | 320 -----
net/nimble/host/src/ble_hci_priv.h | 51 -
net/nimble/host/src/ble_hci_util.c | 178 ---
net/nimble/host/src/ble_hs.c | 9 +-
net/nimble/host/src/ble_hs_adv.c | 2 +-
net/nimble/host/src/ble_hs_conn.c | 1 -
net/nimble/host/src/ble_hs_dbg.c | 509 ++++++++
net/nimble/host/src/ble_hs_dbg_priv.h | 26 +
net/nimble/host/src/ble_hs_hci.c | 528 ++++++++
net/nimble/host/src/ble_hs_hci_cmd.c | 1375 ++++++++++++++++++++
net/nimble/host/src/ble_hs_hci_evt.c | 677 ++++++++++
net/nimble/host/src/ble_hs_hci_priv.h | 158 +++
net/nimble/host/src/ble_hs_hci_util.c | 196 +++
net/nimble/host/src/ble_hs_id.c | 4 +-
net/nimble/host/src/ble_hs_priv.h | 7 +-
net/nimble/host/src/ble_hs_pvcy.c | 18 +-
net/nimble/host/src/ble_hs_startup.c | 35 +-
net/nimble/host/src/ble_ibeacon.c | 2 +-
net/nimble/host/src/ble_l2cap.c | 3 +-
net/nimble/host/src/ble_sm.c | 26 +-
net/nimble/host/src/ble_sm_alg.c | 5 +-
net/nimble/host/src/ble_sm_sc.c | 2 +-
net/nimble/host/src/host_dbg.c | 503 -------
net/nimble/host/src/host_dbg_priv.h | 25 -
net/nimble/host/src/host_hci.c | 899 -------------
net/nimble/host/src/host_hci_cmd.c | 1364 -------------------
net/nimble/host/src/test/ble_att_clt_test.c | 9 +-
net/nimble/host/src/test/ble_gap_test.c | 49 +-
net/nimble/host/src/test/ble_gatt_read_test.c | 21 +-
net/nimble/host/src/test/ble_host_hci_test.c | 100 --
net/nimble/host/src/test/ble_hs_adv_test.c | 1 -
net/nimble/host/src/test/ble_hs_conn_test.c | 1 -
net/nimble/host/src/test/ble_hs_hci_test.c | 99 ++
net/nimble/host/src/test/ble_hs_test.c | 2 +-
net/nimble/host/src/test/ble_hs_test_util.c | 83 +-
net/nimble/host/src/test/ble_l2cap_test.c | 4 +-
net/nimble/host/src/test/ble_os_test.c | 3 +-
net/nimble/host/src/test/ble_sm_lgcy_test.c | 1 -
net/nimble/host/src/test/ble_sm_sc_test.c | 1 -
net/nimble/host/src/test/ble_sm_test.c | 1 -
net/nimble/host/src/test/ble_sm_test_util.c | 21 +-
net/nimble/host/store/ram/src/ble_store_ram.c | 3 +-
55 files changed, 3855 insertions(+), 3837 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/apps/blecent/src/main.c
----------------------------------------------------------------------
diff --git a/apps/blecent/src/main.c b/apps/blecent/src/main.c
index 3cc0f24..8f10814 100755
--- a/apps/blecent/src/main.c
+++ b/apps/blecent/src/main.c
@@ -27,7 +27,6 @@
/* BLE */
#include "nimble/ble.h"
#include "controller/ble_ll.h"
-#include "host/host_hci.h"
#include "host/ble_hs.h"
/* RAM persistence layer. */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/apps/bleprph/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/main.c b/apps/bleprph/src/main.c
index 3a3d64a..0e6ec14 100755
--- a/apps/bleprph/src/main.c
+++ b/apps/bleprph/src/main.c
@@ -31,7 +31,6 @@
/* BLE */
#include "nimble/ble.h"
-#include "host/host_hci.h"
#include "host/ble_hs.h"
#include "host/ble_hs_adv.h"
#include "host/ble_uuid.h"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/apps/bletest/src/bletest_hci.c
----------------------------------------------------------------------
diff --git a/apps/bletest/src/bletest_hci.c b/apps/bletest/src/bletest_hci.c
index 9b0eacd..5e6c31e 100755
--- a/apps/bletest/src/bletest_hci.c
+++ b/apps/bletest/src/bletest_hci.c
@@ -26,7 +26,6 @@
#include "nimble/ble.h"
#include "nimble/hci_transport.h"
#include "nimble/hci_common.h"
-#include "host/host_hci.h"
#include "host/ble_hs.h"
#include "controller/ble_ll.h"
#include "controller/ble_ll_hci.h"
@@ -56,7 +55,7 @@ bletest_send_conn_update(uint16_t handle)
hcu.min_ce_len = 4;
hcu.max_ce_len = 4;
- rc = host_hci_cmd_le_conn_update(&hcu);
+ rc = ble_hs_hci_cmd_le_conn_update(&hcu);
assert(rc == 0);
}
@@ -77,12 +76,12 @@ bletest_send_ltk_req_neg_reply(uint16_t handle)
uint8_t rsplen;
dst = buf;
- host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_LT_KEY_REQ_NEG_REPLY,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_LT_KEY_REQ_NEG_REPLY,
sizeof(uint16_t), dst);
dst += BLE_HCI_CMD_HDR_LEN;
htole16(dst, handle);
- rc = ble_hci_cmd_tx(buf, &ack_conn_handle, 2, &rsplen);
+ rc = ble_hs_hci_cmd_tx(buf, &ack_conn_handle, 2, &rsplen);
if (rc == 0) {
if (rsplen != 2) {
rc = -1;
@@ -104,8 +103,8 @@ bletest_send_ltk_req_reply(uint16_t handle)
hkr.conn_handle = handle;
swap_buf(hkr.long_term_key, (uint8_t *)g_bletest_LTK, 16);
- host_hci_cmd_build_le_lt_key_req_reply(&hkr, buf, sizeof buf);
- rc = ble_hci_cmd_tx(buf, &ack_conn_handle, sizeof ack_conn_handle,
+ ble_hs_hci_cmd_build_le_lt_key_req_reply(&hkr, buf, sizeof buf);
+ rc = ble_hs_hci_cmd_tx(buf, &ack_conn_handle, sizeof ack_conn_handle,
&ack_params_len);
if (rc != 0) {
return rc;
@@ -127,8 +126,9 @@ bletest_hci_reset_ctlr(void)
{
uint8_t buf[BLE_HCI_CMD_HDR_LEN];
- host_hci_write_hdr(BLE_HCI_OGF_CTLR_BASEBAND, BLE_HCI_OCF_CB_RESET, 0, buf);
- return ble_hci_cmd_tx(buf, NULL, 0, NULL);
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_CTLR_BASEBAND, BLE_HCI_OCF_CB_RESET,
+ 0, buf);
+ return ble_hs_hci_cmd_tx(buf, NULL, 0, NULL);
}
int
@@ -139,9 +139,9 @@ bletest_hci_rd_bd_addr(void)
uint8_t rspbuf[BLE_DEV_ADDR_LEN];
uint8_t rsplen;
- host_hci_write_hdr(BLE_HCI_OGF_INFO_PARAMS, BLE_HCI_OCF_IP_RD_BD_ADDR, 0,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_INFO_PARAMS, BLE_HCI_OCF_IP_RD_BD_ADDR, 0,
buf);
- rc = ble_hci_cmd_tx(buf, rspbuf, BLE_DEV_ADDR_LEN, &rsplen);
+ rc = ble_hs_hci_cmd_tx(buf, rspbuf, BLE_DEV_ADDR_LEN, &rsplen);
if (rc != 0) {
return rc;
}
@@ -164,13 +164,13 @@ bletest_hci_le_encrypt(uint8_t *key, uint8_t *pt)
uint8_t rsplen;
dst = buf;
- host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_ENCRYPT,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_ENCRYPT,
BLE_HCI_LE_ENCRYPT_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
swap_buf(dst, key, BLE_ENC_BLOCK_SIZE);
swap_buf(dst + BLE_ENC_BLOCK_SIZE, pt, BLE_ENC_BLOCK_SIZE);
- rc = ble_hci_cmd_tx(buf, rspbuf, 16, &rsplen);
+ rc = ble_hs_hci_cmd_tx(buf, rspbuf, 16, &rsplen);
if (rc != 0) {
return rc;
}
@@ -192,14 +192,14 @@ bletest_hci_le_set_datalen(uint16_t handle, uint16_t txoctets, uint16_t txtime)
uint8_t rsplen;
dst = buf;
- host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_DATA_LEN,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_DATA_LEN,
BLE_HCI_SET_DATALEN_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
htole16(dst, handle);
htole16(dst + 2, txoctets);
htole16(dst + 4, txtime);
- rc = ble_hci_cmd_tx(buf, rspbuf, 2, &rsplen);
+ rc = ble_hs_hci_cmd_tx(buf, rspbuf, 2, &rsplen);
if (rc != 0) {
return rc;
}
@@ -218,13 +218,13 @@ bletest_hci_le_write_sugg_datalen(uint16_t txoctets, uint16_t txtime)
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_WR_SUGG_DATALEN_LEN];
dst = buf;
- host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_WR_SUGG_DEF_DATA_LEN,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_WR_SUGG_DEF_DATA_LEN,
BLE_HCI_WR_SUGG_DATALEN_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
htole16(dst, txoctets);
htole16(dst + 2, txtime);
- return ble_hci_cmd_tx(buf, NULL, 0, NULL);
+ return ble_hs_hci_cmd_tx(buf, NULL, 0, NULL);
}
int
@@ -235,10 +235,10 @@ bletest_hci_le_rd_sugg_datalen(void)
uint8_t rspbuf[BLE_HCI_RD_SUGG_DATALEN_RSPLEN];
uint8_t rsplen;
- host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_SUGG_DEF_DATA_LEN, 0,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_SUGG_DEF_DATA_LEN, 0,
buf);
- rc = ble_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_SUGG_DATALEN_RSPLEN, &rsplen);
+ rc = ble_hs_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_SUGG_DATALEN_RSPLEN, &rsplen);
if (rc != 0) {
return rc;
}
@@ -258,9 +258,9 @@ bletest_hci_rd_local_version(void)
uint8_t rspbuf[BLE_HCI_RD_LOC_VER_INFO_RSPLEN];
uint8_t rsplen;
- host_hci_write_hdr(BLE_HCI_OGF_INFO_PARAMS, BLE_HCI_OCF_IP_RD_LOCAL_VER, 0,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_INFO_PARAMS, BLE_HCI_OCF_IP_RD_LOCAL_VER, 0,
buf);
- rc = ble_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_LOC_VER_INFO_RSPLEN, &rsplen);
+ rc = ble_hs_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_LOC_VER_INFO_RSPLEN, &rsplen);
if (rc != 0) {
return rc;
}
@@ -279,9 +279,9 @@ bletest_hci_rd_local_feat(void)
uint8_t rspbuf[BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN];
uint8_t rsplen;
- host_hci_write_hdr(BLE_HCI_OGF_INFO_PARAMS, BLE_HCI_OCF_IP_RD_LOC_SUPP_FEAT,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_INFO_PARAMS, BLE_HCI_OCF_IP_RD_LOC_SUPP_FEAT,
0, buf);
- rc = ble_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN, &rsplen);
+ rc = ble_hs_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN, &rsplen);
if (rc != 0) {
return rc;
}
@@ -300,9 +300,9 @@ bletest_hci_rd_local_supp_cmd(void)
uint8_t rspbuf[BLE_HCI_RD_LOC_SUPP_CMD_RSPLEN];
uint8_t rsplen;
- host_hci_write_hdr(BLE_HCI_OGF_INFO_PARAMS, BLE_HCI_OCF_IP_RD_LOC_SUPP_CMD,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_INFO_PARAMS, BLE_HCI_OCF_IP_RD_LOC_SUPP_CMD,
0, buf);
- rc = ble_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_LOC_SUPP_CMD_RSPLEN, &rsplen);
+ rc = ble_hs_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_LOC_SUPP_CMD_RSPLEN, &rsplen);
if (rc != 0) {
return rc;
}
@@ -329,8 +329,8 @@ bletest_hci_le_read_supp_states(void)
uint8_t rspbuf[BLE_HCI_RD_SUPP_STATES_RSPLEN];
uint8_t rsplen;
- host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_SUPP_STATES, 0, buf);
- rc = ble_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_SUPP_STATES_RSPLEN, &rsplen);
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_SUPP_STATES, 0, buf);
+ rc = ble_hs_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_SUPP_STATES_RSPLEN, &rsplen);
if (rc != 0) {
return rc;
}
@@ -349,8 +349,8 @@ bletest_hci_le_rd_max_datalen(void)
uint8_t rspbuf[BLE_HCI_RD_MAX_DATALEN_RSPLEN];
uint8_t rsplen;
- host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_MAX_DATA_LEN, 0, buf);
- rc = ble_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_MAX_DATALEN_RSPLEN, &rsplen);
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_MAX_DATA_LEN, 0, buf);
+ rc = ble_hs_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_MAX_DATALEN_RSPLEN, &rsplen);
if (rc != 0) {
return rc;
}
@@ -367,9 +367,9 @@ bletest_hci_le_set_adv_data(uint8_t *data, uint8_t len)
int rc;
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADV_DATA_LEN];
- rc = host_hci_cmd_build_le_set_adv_data(data, len, buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_le_set_adv_data(data, len, buf, sizeof buf);
assert(rc == 0);
- return ble_hci_cmd_tx_empty_ack(buf);
+ return ble_hs_hci_cmd_tx_empty_ack(buf);
}
#if (BLE_LL_CFG_FEAT_LE_ENCRYPTION == 1)
@@ -378,8 +378,8 @@ bletest_hci_le_start_encrypt(struct hci_start_encrypt *cmd)
{
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_LE_START_ENCRYPT_LEN];
- host_hci_cmd_build_le_start_encrypt(cmd, buf, sizeof buf);
- return ble_hci_cmd_tx_empty_ack(buf);
+ ble_hs_hci_cmd_build_le_start_encrypt(cmd, buf, sizeof buf);
+ return ble_hs_hci_cmd_tx_empty_ack(buf);
}
#endif
@@ -390,12 +390,12 @@ bletest_hci_le_read_rem_used_feat(uint16_t handle)
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_CONN_RD_REM_FEAT_LEN];
dst = buf;
- host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_REM_FEAT,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_REM_FEAT,
BLE_HCI_CONN_RD_REM_FEAT_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
htole16(dst, handle);
- return ble_hci_cmd_tx(buf, NULL, 0, NULL);
+ return ble_hs_hci_cmd_tx(buf, NULL, 0, NULL);
}
int
@@ -404,9 +404,9 @@ bletest_hci_le_set_adv_params(struct hci_adv_params *adv)
int rc;
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADV_PARAM_LEN];
- rc = host_hci_cmd_build_le_set_adv_params(adv, buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_le_set_adv_params(adv, buf, sizeof buf);
if (!rc) {
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
}
return rc;
}
@@ -418,12 +418,12 @@ bletest_hci_le_set_rand_addr(uint8_t *addr)
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_DATALEN_LEN];
dst = buf;
- host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_RAND_ADDR,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_RAND_ADDR,
BLE_DEV_ADDR_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
memcpy(dst, addr, BLE_DEV_ADDR_LEN);
- return ble_hci_cmd_tx(buf, NULL, 0, NULL);
+ return ble_hs_hci_cmd_tx(buf, NULL, 0, NULL);
}
int
@@ -433,12 +433,12 @@ bletest_hci_rd_rem_version(uint16_t handle)
uint8_t buf[BLE_HCI_CMD_HDR_LEN + sizeof(uint16_t)];
dst = buf;
- host_hci_write_hdr(BLE_HCI_OGF_LINK_CTRL, BLE_HCI_OCF_RD_REM_VER_INFO,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LINK_CTRL, BLE_HCI_OCF_RD_REM_VER_INFO,
sizeof(uint16_t), dst);
dst += BLE_HCI_CMD_HDR_LEN;
htole16(dst, handle);
- return ble_hci_cmd_tx(buf, NULL, 0, NULL);
+ return ble_hs_hci_cmd_tx(buf, NULL, 0, NULL);
}
int
@@ -448,12 +448,12 @@ bletest_hci_le_set_host_chan_class(uint8_t *chanmap)
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_HOST_CHAN_CLASS_LEN];
dst = buf;
- host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_HOST_CHAN_CLASS,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_HOST_CHAN_CLASS,
BLE_HCI_SET_HOST_CHAN_CLASS_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
memcpy(dst, chanmap, BLE_HCI_SET_HOST_CHAN_CLASS_LEN);
- return ble_hci_cmd_tx(buf, NULL, 0, NULL);
+ return ble_hs_hci_cmd_tx(buf, NULL, 0, NULL);
}
int
@@ -466,12 +466,12 @@ bletest_hci_le_rd_chanmap(uint16_t handle)
uint8_t rsplen;
dst = buf;
- host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_CHAN_MAP,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_CHAN_MAP,
BLE_HCI_RD_CHANMAP_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
htole16(dst, handle);
- rc = ble_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_CHANMAP_RSP_LEN, &rsplen);
+ rc = ble_hs_hci_cmd_tx(buf, rspbuf, BLE_HCI_RD_CHANMAP_RSP_LEN, &rsplen);
if (rc != 0) {
return rc;
}
@@ -490,12 +490,12 @@ bletest_hci_le_set_adv_enable(uint8_t enable)
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADV_ENABLE_LEN];
dst = buf;
- host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_ADV_ENABLE,
+ ble_hs_hci_cmd_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_ADV_ENABLE,
BLE_HCI_SET_ADV_ENABLE_LEN, dst);
dst += BLE_HCI_CMD_HDR_LEN;
dst[0] = enable;
- return ble_hci_cmd_tx(buf, NULL, 0, NULL);
+ return ble_hs_hci_cmd_tx(buf, NULL, 0, NULL);
}
int
@@ -503,8 +503,8 @@ bletest_hci_le_set_event_mask(uint64_t event_mask)
{
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_LE_EVENT_MASK_LEN];
- host_hci_cmd_build_le_set_event_mask(event_mask, buf, sizeof buf);
- return ble_hci_cmd_tx_empty_ack(buf);
+ ble_hs_hci_cmd_build_le_set_event_mask(event_mask, buf, sizeof buf);
+ return ble_hs_hci_cmd_tx_empty_ack(buf);
}
int
@@ -512,8 +512,8 @@ bletest_hci_set_event_mask(uint64_t event_mask)
{
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_EVENT_MASK_LEN];
- host_hci_cmd_build_set_event_mask(event_mask, buf, sizeof buf);
- return ble_hci_cmd_tx_empty_ack(buf);
+ ble_hs_hci_cmd_build_set_event_mask(event_mask, buf, sizeof buf);
+ return ble_hs_hci_cmd_tx_empty_ack(buf);
}
int
@@ -522,9 +522,9 @@ bletest_hci_le_set_scan_rsp_data(uint8_t *data, uint8_t len)
int rc;
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_SCAN_RSP_DATA_LEN];
- rc = host_hci_cmd_build_le_set_scan_rsp_data(data, len, buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_le_set_scan_rsp_data(data, len, buf, sizeof buf);
assert(rc == 0);
- return ble_hci_cmd_tx_empty_ack(buf);
+ return ble_hs_hci_cmd_tx_empty_ack(buf);
}
int
@@ -534,11 +534,11 @@ bletest_hci_cmd_le_set_scan_params(uint8_t scan_type, uint16_t scan_itvl,
int rc;
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_SCAN_PARAM_LEN];
- rc = host_hci_cmd_build_le_set_scan_params(scan_type, scan_itvl,
+ rc = ble_hs_hci_cmd_build_le_set_scan_params(scan_type, scan_itvl,
scan_window, own_addr_type,
filter_policy, buf, sizeof buf);
if (!rc) {
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
}
return rc;
}
@@ -549,10 +549,10 @@ bletest_hci_le_add_to_whitelist(uint8_t *addr, uint8_t addr_type)
int rc;
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_SCAN_PARAM_LEN];
- rc = host_hci_cmd_build_le_add_to_whitelist(addr, addr_type, buf,
+ rc = ble_hs_hci_cmd_build_le_add_to_whitelist(addr, addr_type, buf,
sizeof buf);
if (!rc) {
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
}
return rc;
}
@@ -562,8 +562,8 @@ bletest_hci_le_set_scan_enable(uint8_t enable, uint8_t filter_dups)
{
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_SCAN_ENABLE_LEN];
- host_hci_cmd_build_le_set_scan_enable(enable, filter_dups, buf, sizeof buf);
- return ble_hci_cmd_tx_empty_ack(buf);
+ ble_hs_hci_cmd_build_le_set_scan_enable(enable, filter_dups, buf, sizeof buf);
+ return ble_hs_hci_cmd_tx_empty_ack(buf);
}
int
@@ -572,9 +572,9 @@ bletest_hci_le_create_connection(struct hci_create_conn *hcc)
int rc;
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_CREATE_CONN_LEN];
- rc = host_hci_cmd_build_le_create_connection(hcc, buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_le_create_connection(hcc, buf, sizeof buf);
if (!rc) {
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
}
return rc;
}
@@ -591,9 +591,9 @@ bletest_hci_le_add_resolv_list(uint8_t *local_irk, uint8_t *peer_irk,
memcpy(padd.addr, peer_ident_addr, BLE_DEV_ADDR_LEN);
swap_buf(padd.local_irk, local_irk, 16);
swap_buf(padd.peer_irk, peer_irk, 16);
- rc = host_hci_cmd_build_add_to_resolv_list(&padd, buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_add_to_resolv_list(&padd, buf, sizeof buf);
if (!rc) {
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
}
return rc;
}
@@ -605,9 +605,9 @@ bletest_hci_le_enable_resolv_list(uint8_t enable)
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADDR_RESOL_ENA_LEN];
- rc = host_hci_cmd_build_set_addr_res_en(enable, buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_set_addr_res_en(enable, buf, sizeof buf);
if (!rc) {
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
}
return rc;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/apps/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletest/src/main.c b/apps/bletest/src/main.c
index dbfa053..f6bb187 100755
--- a/apps/bletest/src/main.c
+++ b/apps/bletest/src/main.c
@@ -38,7 +38,6 @@
#include "nimble/ble.h"
#include "nimble/hci_transport.h"
#include "nimble/hci_common.h"
-#include "host/host_hci.h"
#include "host/ble_hs.h"
#include "controller/ble_ll.h"
#include "controller/ble_ll_hci.h"
@@ -420,14 +419,14 @@ bletest_init_scanner(void)
uint8_t add_whitelist;
own_addr_type = BLETEST_CFG_SCAN_OWN_ADDR_TYPE;
- rc = host_hci_cmd_build_le_set_scan_params(BLETEST_CFG_SCAN_TYPE,
+ rc = ble_hs_hci_cmd_build_le_set_scan_params(BLETEST_CFG_SCAN_TYPE,
BLETEST_CFG_SCAN_ITVL,
BLETEST_CFG_SCAN_WINDOW,
BLETEST_CFG_SCAN_OWN_ADDR_TYPE,
BLETEST_CFG_SCAN_FILT_POLICY,
buf, sizeof buf);
assert(rc == 0);
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc == 0) {
add_whitelist = BLETEST_CFG_SCAN_FILT_POLICY;
#if (BLE_LL_CFG_FEAT_LL_PRIVACY == 1)
@@ -615,7 +614,7 @@ bletest_execute_initiator(void)
} else {
for (i = 0; i < g_bletest_current_conns; ++i) {
if (ble_ll_conn_find_active_conn(i + 1)) {
- ble_hci_util_read_rssi(i+1, &rssi);
+ ble_hs_hci_util_read_rssi(i+1, &rssi);
}
}
}
@@ -989,7 +988,7 @@ bletest_task_handler(void *arg)
#endif
/* Get a random number */
- rc = ble_hci_util_rand(&rand64, 8);
+ rc = ble_hs_hci_util_rand(&rand64, 8);
assert(rc == 0);
/* Wait some time before starting */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index 733f8d1..2f3c474 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -59,7 +59,7 @@
*/
#include "../src/ble_hs_conn_priv.h"
#include "../src/ble_hs_atomic_priv.h"
-#include "../src/ble_hci_priv.h"
+#include "../src/ble_hs_hci_priv.h"
/* Nimble task priorities */
#define BLE_LL_TASK_PRI (OS_TASK_PRI_HIGHEST)
@@ -1408,7 +1408,7 @@ bletiny_datalen(uint16_t conn_handle, uint16_t tx_octets, uint16_t tx_time)
{
int rc;
- rc = ble_hci_util_set_data_len(conn_handle, tx_octets, tx_time);
+ rc = ble_hs_hci_util_set_data_len(conn_handle, tx_octets, tx_time);
return rc;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/apps/bleuart/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleuart/src/main.c b/apps/bleuart/src/main.c
index 24f1a3b..0a5dd82 100755
--- a/apps/bleuart/src/main.c
+++ b/apps/bleuart/src/main.c
@@ -30,7 +30,6 @@
/* BLE */
#include "nimble/ble.h"
-#include "host/host_hci.h"
#include "host/ble_hs.h"
#include "host/ble_hs_adv.h"
#include "host/ble_uuid.h"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/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 4a707af..954d278 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -34,7 +34,6 @@
#include "host/ble_sm.h"
#include "host/ble_store.h"
#include "host/ble_uuid.h"
-#include "host/host_hci.h"
struct os_eventq;
struct os_event;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/include/host/ble_hs_test.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs_test.h b/net/nimble/host/include/host/ble_hs_test.h
index 5d28291..3247b59 100644
--- a/net/nimble/host/include/host/ble_hs_test.h
+++ b/net/nimble/host/include/host/ble_hs_test.h
@@ -36,7 +36,7 @@ int ble_gatt_write_test_all(void);
int ble_gatts_notify_test_all(void);
int ble_gatts_read_test_suite(void);
int ble_gatts_reg_test_all(void);
-int ble_host_hci_test_all(void);
+int ble_hs_hci_test_all(void);
int ble_hs_adv_test_all(void);
int ble_hs_conn_test_all(void);
int ble_l2cap_test_all(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/include/host/host_hci.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/host_hci.h b/net/nimble/host/include/host/host_hci.h
deleted file mode 100644
index 79a0034..0000000
--- a/net/nimble/host/include/host/host_hci.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef H_HOST_HCI_
-#define H_HOST_HCI_
-
-#include "nimble/hci_common.h"
-struct ble_hs_conn;
-struct os_mbuf;
-
-int host_hci_evt_process(uint8_t *data);
-uint16_t host_hci_opcode_join(uint8_t ogf, uint16_t ocf);
-void host_hci_write_hdr(uint8_t ogf, uint8_t ocf, uint8_t len, void *buf);
-int host_hci_cmd_send(uint8_t ogf, uint8_t ocf, uint8_t len,
- const void *cmddata);
-int host_hci_cmd_send_buf(void *cmddata);
-void host_hci_cmd_build_read_bd_addr(uint8_t *dst, int dst_len);
-void host_hci_cmd_build_set_event_mask(uint64_t event_mask,
- uint8_t *dst, int dst_len);
-void host_hci_cmd_build_set_event_mask2(uint64_t event_mask, uint8_t *dst,
- int dst_len);
-void host_hci_cmd_build_disconnect(uint16_t handle, uint8_t reason,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_disconnect(uint16_t handle, uint8_t reason);
-void host_hci_cmd_build_read_rssi(uint16_t handle, uint8_t *dst, int dst_len);
-int host_hci_cmd_read_rssi(uint16_t handle);
-int host_hci_cmd_build_le_set_scan_rsp_data(const uint8_t *data, uint8_t len,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_le_set_adv_data(const uint8_t *data, uint8_t len,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_le_set_adv_params(const struct hci_adv_params *adv,
- uint8_t *dst, int dst_len);
-void host_hci_cmd_build_le_set_event_mask(uint64_t event_mask,
- uint8_t *dst, int dst_len);
-void host_hci_cmd_build_le_read_buffer_size(uint8_t *dst, int dst_len);
-int host_hci_cmd_le_read_buffer_size(void);
-void host_hci_cmd_build_le_read_loc_supp_feat(uint8_t *dst, uint8_t dst_len);
-void host_hci_cmd_build_le_set_adv_enable(uint8_t enable, uint8_t *dst,
- int dst_len);
-int host_hci_cmd_le_set_adv_enable(uint8_t enable);
-int host_hci_cmd_build_le_set_scan_params(uint8_t scan_type,
- uint16_t scan_itvl,
- uint16_t scan_window,
- uint8_t own_addr_type,
- uint8_t filter_policy,
- uint8_t *dst, int dst_len);
-void host_hci_cmd_build_le_set_scan_enable(uint8_t enable,
- uint8_t filter_dups,
- uint8_t *dst, uint8_t dst_len);
-int host_hci_cmd_le_set_scan_enable(uint8_t enable, uint8_t filter_dups);
-int host_hci_cmd_build_le_create_connection(const struct hci_create_conn *hcc,
- uint8_t *cmd, int cmd_len);
-int host_hci_cmd_le_create_connection(const struct hci_create_conn *hcc);
-void host_hci_cmd_build_le_clear_whitelist(uint8_t *dst, int dst_len);
-int host_hci_cmd_build_le_add_to_whitelist(const uint8_t *addr,
- uint8_t addr_type,
- uint8_t *dst, int dst_len);
-void host_hci_cmd_build_reset(uint8_t *dst, int dst_len);
-int host_hci_cmd_reset(void);
-void host_hci_cmd_build_read_adv_pwr(uint8_t *dst, int dst_len);
-int host_hci_cmd_read_adv_pwr(void);
-void host_hci_cmd_build_le_create_conn_cancel(uint8_t *dst, int dst_len);
-int host_hci_cmd_le_create_conn_cancel(void);
-int host_hci_cmd_build_le_conn_update(const struct hci_conn_update *hcu,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_le_conn_update(const struct hci_conn_update *hcu);
-void host_hci_cmd_build_le_lt_key_req_reply(
- const struct hci_lt_key_req_reply *hkr, uint8_t *dst, int dst_len);
-void host_hci_cmd_build_le_lt_key_req_neg_reply(uint16_t conn_handle,
- uint8_t *dst, int dst_len);
-void host_hci_cmd_build_le_conn_param_reply(
- const struct hci_conn_param_reply *hcr, uint8_t *dst, int dst_len);
-int host_hci_cmd_le_conn_param_reply(const struct hci_conn_param_reply *hcr);
-void host_hci_cmd_build_le_conn_param_neg_reply(
- const struct hci_conn_param_neg_reply *hcn, uint8_t *dst, int dst_len);
-int host_hci_cmd_le_conn_param_neg_reply(
- const struct hci_conn_param_neg_reply *hcn);
-void host_hci_cmd_build_le_rand(uint8_t *dst, int dst_len);
-void host_hci_cmd_build_le_start_encrypt(const struct hci_start_encrypt *cmd,
- uint8_t *dst, int dst_len);
-int host_hci_set_buf_size(uint16_t pktlen, uint8_t max_pkts);
-
-uint16_t host_hci_handle_pb_bc_join(uint16_t handle, uint8_t pb, uint8_t bc);
-
-int host_hci_data_rx(struct os_mbuf *om);
-int host_hci_data_tx(struct ble_hs_conn *connection, struct os_mbuf *txom);
-
-int host_hci_cmd_build_set_data_len(uint16_t connection_handle,
- uint16_t tx_octets, uint16_t tx_time,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_add_to_resolv_list(
- const struct hci_add_dev_to_resolving_list *padd,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_remove_from_resolv_list(
- uint8_t addr_type, const uint8_t *addr, uint8_t *dst, int dst_len);
-int host_hci_cmd_build_read_resolv_list_size(uint8_t *dst, int dst_len);
-int host_hci_cmd_build_clear_resolv_list(uint8_t *dst, int dst_len);
-int host_hci_cmd_build_read_peer_resolv_addr(
- uint8_t peer_identity_addr_type, const uint8_t *peer_identity_addr,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_read_lcl_resolv_addr(
- uint8_t local_identity_addr_type, const uint8_t *local_identity_addr,
- uint8_t *dst, int dst_len);
-int host_hci_cmd_build_set_addr_res_en(
- uint8_t enable, uint8_t *dst, int dst_len);
-int host_hci_cmd_build_set_resolv_priv_addr_timeout(
- uint16_t timeout, uint8_t *dst, int dst_len);
-
-void host_hci_timer_set(void);
-
-int host_hci_cmd_build_set_random_addr(const uint8_t *addr,
- uint8_t *dst, int dst_len);
-
-#endif /* H_HOST_HCI_ */
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/src/ble_eddystone.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_eddystone.c b/net/nimble/host/src/ble_eddystone.c
index 5e7a3f0..2ca496f 100644
--- a/net/nimble/host/src/ble_eddystone.c
+++ b/net/nimble/host/src/ble_eddystone.c
@@ -186,7 +186,7 @@ ble_eddystone_set_adv_data_url(struct ble_hs_adv_fields *adv_fields,
svc_data = ble_eddystone_set_svc_data_base(BLE_EDDYSTONE_FRAME_TYPE_URL);
- rc = ble_hci_util_read_adv_tx_pwr(&tx_pwr);
+ rc = ble_hs_hci_util_read_adv_tx_pwr(&tx_pwr);
if (rc != 0) {
return rc;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/src/ble_gap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c
index 1a41956..6086c50 100644
--- a/net/nimble/host/src/ble_gap.c
+++ b/net/nimble/host/src/ble_gap.c
@@ -23,7 +23,6 @@
#include "bsp/bsp.h"
#include "os/os.h"
#include "nimble/nimble_opt.h"
-#include "host/host_hci.h"
#include "host/ble_hs_adv.h"
#include "ble_hs_priv.h"
@@ -1201,13 +1200,13 @@ ble_gap_wl_tx_add(const struct ble_gap_white_entry *entry)
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_CHG_WHITE_LIST_LEN];
int rc;
- rc = host_hci_cmd_build_le_add_to_whitelist(entry->addr, entry->addr_type,
- buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_le_add_to_whitelist(
+ entry->addr, entry->addr_type, buf, sizeof buf);
if (rc != 0) {
return rc;
}
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -1221,8 +1220,8 @@ ble_gap_wl_tx_clear(void)
uint8_t buf[BLE_HCI_CMD_HDR_LEN];
int rc;
- host_hci_cmd_build_le_clear_whitelist(buf, sizeof buf);
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ ble_hs_hci_cmd_build_le_clear_whitelist(buf, sizeof buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -1309,8 +1308,8 @@ ble_gap_adv_enable_tx(int enable)
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADV_ENABLE_LEN];
int rc;
- host_hci_cmd_build_le_set_adv_enable(!!enable, buf, sizeof buf);
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ ble_hs_hci_cmd_build_le_set_adv_enable(!!enable, buf, sizeof buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -1377,14 +1376,14 @@ ble_gap_adv_rsp_data_tx(void)
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_SCAN_RSP_DATA_LEN];
int rc;
- rc = host_hci_cmd_build_le_set_scan_rsp_data(ble_gap_slave.rsp_data,
- ble_gap_slave.rsp_data_len,
- buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_le_set_scan_rsp_data(ble_gap_slave.rsp_data,
+ ble_gap_slave.rsp_data_len,
+ buf, sizeof buf);
if (rc != 0) {
return rc;
}
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -1443,14 +1442,14 @@ ble_gap_adv_data_tx(void)
ble_gap_slave.adv_auto_flags = 0;
}
- rc = host_hci_cmd_build_le_set_adv_data(ble_gap_slave.adv_data,
- ble_gap_slave.adv_data_len,
- buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_le_set_adv_data(ble_gap_slave.adv_data,
+ ble_gap_slave.adv_data_len,
+ buf, sizeof buf);
if (rc != 0) {
return rc;
}
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -1549,13 +1548,13 @@ ble_gap_adv_params_tx(uint8_t own_addr_type,
hci_adv_params.adv_filter_policy = adv_params->filter_policy;
hci_adv_params.adv_type = ble_gap_adv_type(adv_params);
- rc = host_hci_cmd_build_le_set_adv_params(&hci_adv_params,
- buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_le_set_adv_params(&hci_adv_params,
+ buf, sizeof buf);
if (rc != 0) {
return BLE_HS_EINVAL;
}
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -1881,9 +1880,9 @@ ble_gap_disc_enable_tx(int enable, int filter_duplicates)
uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_SCAN_ENABLE_LEN];
int rc;
- host_hci_cmd_build_le_set_scan_enable(!!enable, !!filter_duplicates,
- buf, sizeof buf);
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ ble_hs_hci_cmd_build_le_set_scan_enable(!!enable, !!filter_duplicates,
+ buf, sizeof buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -1905,17 +1904,17 @@ ble_gap_disc_tx_params(uint8_t own_addr_type,
scan_type = BLE_HCI_SCAN_TYPE_ACTIVE;
}
- rc = host_hci_cmd_build_le_set_scan_params(scan_type,
- disc_params->itvl,
- disc_params->window,
- own_addr_type,
- disc_params->filter_policy,
- buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_le_set_scan_params(scan_type,
+ disc_params->itvl,
+ disc_params->window,
+ own_addr_type,
+ disc_params->filter_policy,
+ buf, sizeof buf);
if (rc != 0) {
return BLE_HS_EINVAL;
}
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -2164,12 +2163,12 @@ ble_gap_conn_create_tx(uint8_t own_addr_type,
hcc.min_ce_len = params->min_ce_len;
hcc.max_ce_len = params->max_ce_len;
- rc = host_hci_cmd_build_le_create_connection(&hcc, buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_le_create_connection(&hcc, buf, sizeof buf);
if (rc != 0) {
return BLE_HS_EUNKNOWN;
}
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -2356,9 +2355,9 @@ ble_gap_terminate(uint16_t conn_handle, uint8_t hci_reason)
"conn_handle=%d hci_reason=%d\n",
conn_handle, hci_reason);
- host_hci_cmd_build_disconnect(conn_handle, hci_reason,
- buf, sizeof buf);
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ ble_hs_hci_cmd_build_disconnect(conn_handle, hci_reason,
+ buf, sizeof buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
goto done;
}
@@ -2384,8 +2383,8 @@ ble_gap_conn_cancel_tx(void)
uint8_t buf[BLE_HCI_CMD_HDR_LEN];
int rc;
- host_hci_cmd_build_le_create_conn_cancel(buf, sizeof buf);
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ ble_hs_hci_cmd_build_le_create_conn_cancel(buf, sizeof buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -2454,8 +2453,8 @@ ble_gap_tx_param_pos_reply(uint16_t conn_handle,
pos_reply.min_ce_len = params->min_ce_len;
pos_reply.max_ce_len = params->max_ce_len;
- host_hci_cmd_build_le_conn_param_reply(&pos_reply, buf, sizeof buf);
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ ble_hs_hci_cmd_build_le_conn_param_reply(&pos_reply, buf, sizeof buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -2473,8 +2472,8 @@ ble_gap_tx_param_neg_reply(uint16_t conn_handle, uint8_t reject_reason)
neg_reply.handle = conn_handle;
neg_reply.reason = reject_reason;
- host_hci_cmd_build_le_conn_param_neg_reply(&neg_reply, buf, sizeof buf);
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ ble_hs_hci_cmd_build_le_conn_param_neg_reply(&neg_reply, buf, sizeof buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -2551,12 +2550,12 @@ ble_gap_update_tx(uint16_t conn_handle,
cmd.min_ce_len = params->min_ce_len;
cmd.max_ce_len = params->max_ce_len;
- rc = host_hci_cmd_build_le_conn_update(&cmd, buf, sizeof buf);
+ rc = ble_hs_hci_cmd_build_le_conn_update(&cmd, buf, sizeof buf);
if (rc != 0) {
return rc;
}
- rc = ble_hci_cmd_tx_empty_ack(buf);
+ rc = ble_hs_hci_cmd_tx_empty_ack(buf);
if (rc != 0) {
return rc;
}
@@ -2811,7 +2810,7 @@ ble_gap_conn_rssi(uint16_t conn_handle, int8_t *out_rssi)
{
int rc;
- rc = ble_hci_util_read_rssi(conn_handle, out_rssi);
+ rc = ble_hs_hci_util_read_rssi(conn_handle, out_rssi);
return rc;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/src/ble_gap_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gap_priv.h b/net/nimble/host/src/ble_gap_priv.h
index 3168d48..c2abbf3 100644
--- a/net/nimble/host/src/ble_gap_priv.h
+++ b/net/nimble/host/src/ble_gap_priv.h
@@ -28,7 +28,7 @@ struct hci_le_conn_param_req;
struct hci_le_conn_complete;
struct hci_disconn_complete;
struct hci_encrypt_change;
-struct ble_hci_ack;
+struct ble_hs_hci_ack;
struct ble_hs_adv;
STATS_SECT_START(ble_gap_stats)
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/src/ble_gattc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_gattc.c b/net/nimble/host/src/ble_gattc.c
index 49c432f..84ecff3 100644
--- a/net/nimble/host/src/ble_gattc.c
+++ b/net/nimble/host/src/ble_gattc.c
@@ -3754,7 +3754,9 @@ ble_gattc_write_reliable_rx_prep(struct ble_gattc_proc *proc,
}
if (proc->write_reliable.cur_attr >= proc->write_reliable.num_attrs) {
- /* Expecting an execute write response, not a prepare write response. */
+ /* Expecting an execute write response, not a prepare write
+ * response.
+ */
rc = BLE_HS_EBADDATA;
goto err;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/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
deleted file mode 100644
index 53fe726..0000000
--- a/net/nimble/host/src/ble_hci_cmd.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-#include <stdint.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-#include "os/os.h"
-#include "nimble/ble_hci_trans.h"
-#include "ble_hs_priv.h"
-#include "host_dbg_priv.h"
-
-#define BLE_HCI_CMD_TIMEOUT (OS_TICKS_PER_SEC)
-
-static struct os_mutex ble_hci_cmd_mutex;
-static struct os_sem ble_hci_cmd_sem;
-
-static uint8_t *ble_hci_cmd_ack;
-
-#if PHONY_HCI_ACKS
-static ble_hci_cmd_phony_ack_fn *ble_hci_cmd_phony_ack_cb;
-#endif
-
-#if PHONY_HCI_ACKS
-void
-ble_hci_set_phony_ack_cb(ble_hci_cmd_phony_ack_fn *cb)
-{
- ble_hci_cmd_phony_ack_cb = cb;
-}
-#endif
-
-static void
-ble_hci_cmd_lock(void)
-{
- int rc;
-
- rc = os_mutex_pend(&ble_hci_cmd_mutex, 0xffffffff);
- BLE_HS_DBG_ASSERT_EVAL(rc == 0 || rc == OS_NOT_STARTED);
-}
-
-static void
-ble_hci_cmd_unlock(void)
-{
- int rc;
-
- rc = os_mutex_release(&ble_hci_cmd_mutex);
- BLE_HS_DBG_ASSERT_EVAL(rc == 0 || rc == OS_NOT_STARTED);
-}
-
-static int
-ble_hci_cmd_rx_cmd_complete(uint8_t event_code, uint8_t *data, int len,
- struct ble_hci_ack *out_ack)
-{
- uint16_t opcode;
- uint8_t *params;
- uint8_t params_len;
- uint8_t num_pkts;
-
- if (len < BLE_HCI_EVENT_CMD_COMPLETE_HDR_LEN) {
- return BLE_HS_ECONTROLLER;
- }
-
- num_pkts = data[2];
- opcode = le16toh(data + 3);
- params = data + 5;
-
- /* XXX: Process num_pkts field. */
- (void)num_pkts;
-
- out_ack->bha_opcode = opcode;
-
- params_len = len - BLE_HCI_EVENT_CMD_COMPLETE_HDR_LEN;
- if (params_len > 0) {
- out_ack->bha_status = BLE_HS_HCI_ERR(params[0]);
- } else if (opcode == BLE_HCI_OPCODE_NOP) {
- out_ack->bha_status = 0;
- } else {
- out_ack->bha_status = BLE_HS_ECONTROLLER;
- }
-
- /* Don't include the status byte in the parameters blob. */
- if (params_len > 1) {
- out_ack->bha_params = params + 1;
- out_ack->bha_params_len = params_len - 1;
- } else {
- out_ack->bha_params = NULL;
- out_ack->bha_params_len = 0;
- }
-
- return 0;
-}
-
-static int
-ble_hci_cmd_rx_cmd_status(uint8_t event_code, uint8_t *data, int len,
- struct ble_hci_ack *out_ack)
-{
- uint16_t opcode;
- uint8_t num_pkts;
- uint8_t status;
-
- if (len < BLE_HCI_EVENT_CMD_STATUS_LEN) {
- return BLE_HS_ECONTROLLER;
- }
-
- status = data[2];
- num_pkts = data[3];
- opcode = le16toh(data + 4);
-
- /* XXX: Process num_pkts field. */
- (void)num_pkts;
-
- out_ack->bha_opcode = opcode;
- out_ack->bha_params = NULL;
- out_ack->bha_params_len = 0;
- out_ack->bha_status = BLE_HS_HCI_ERR(status);
-
- return 0;
-}
-
-static int
-ble_hci_cmd_process_ack(uint16_t expected_opcode,
- uint8_t *params_buf, uint8_t params_buf_len,
- struct ble_hci_ack *out_ack)
-{
- uint8_t event_code;
- uint8_t param_len;
- uint8_t event_len;
- int rc;
-
- BLE_HS_DBG_ASSERT(ble_hci_cmd_ack != NULL);
-
- /* Count events received */
- STATS_INC(ble_hs_stats, hci_event);
-
- /* Display to console */
- host_hci_dbg_event_disp(ble_hci_cmd_ack);
-
- event_code = ble_hci_cmd_ack[0];
- param_len = ble_hci_cmd_ack[1];
- event_len = param_len + 2;
-
- /* Clear ack fields up front to silence spurious gcc warnings. */
- memset(out_ack, 0, sizeof *out_ack);
-
- switch (event_code) {
- case BLE_HCI_EVCODE_COMMAND_COMPLETE:
- rc = ble_hci_cmd_rx_cmd_complete(event_code, ble_hci_cmd_ack,
- event_len, out_ack);
- break;
-
- case BLE_HCI_EVCODE_COMMAND_STATUS:
- rc = ble_hci_cmd_rx_cmd_status(event_code, ble_hci_cmd_ack,
- event_len, out_ack);
- break;
-
- default:
- BLE_HS_DBG_ASSERT(0);
- rc = BLE_HS_EUNKNOWN;
- break;
- }
-
- if (rc == 0) {
- if (params_buf == NULL) {
- out_ack->bha_params_len = 0;
- } else {
- if (out_ack->bha_params_len > params_buf_len) {
- out_ack->bha_params_len = params_buf_len;
- rc = BLE_HS_ECONTROLLER;
- }
- memcpy(params_buf, out_ack->bha_params, out_ack->bha_params_len);
- }
- out_ack->bha_params = params_buf;
-
- if (out_ack->bha_opcode != expected_opcode) {
- rc = BLE_HS_ECONTROLLER;
- }
- }
-
- if (rc != 0) {
- STATS_INC(ble_hs_stats, hci_invalid_ack);
- }
-
- return rc;
-}
-
-static int
-ble_hci_cmd_wait_for_ack(void)
-{
- int rc;
-
-#if PHONY_HCI_ACKS
- if (ble_hci_cmd_phony_ack_cb == NULL) {
- rc = BLE_HS_ETIMEOUT_HCI;
- } else {
- ble_hci_cmd_ack =
- ble_hci_trans_buf_alloc(BLE_HCI_TRANS_BUF_CMD);
- BLE_HS_DBG_ASSERT(ble_hci_cmd_ack != NULL);
- rc = ble_hci_cmd_phony_ack_cb(ble_hci_cmd_ack, 260);
- }
-#else
- rc = os_sem_pend(&ble_hci_cmd_sem, BLE_HCI_CMD_TIMEOUT);
- switch (rc) {
- case 0:
- BLE_HS_DBG_ASSERT(ble_hci_cmd_ack != NULL);
- break;
- case OS_TIMEOUT:
- rc = BLE_HS_ETIMEOUT_HCI;
- STATS_INC(ble_hs_stats, hci_timeout);
- break;
- default:
- rc = BLE_HS_EOS;
- break;
- }
-#endif
-
- return rc;
-}
-
-int
-ble_hci_cmd_tx(void *cmd, void *evt_buf, uint8_t evt_buf_len,
- uint8_t *out_evt_buf_len)
-{
- struct ble_hci_ack ack;
- uint16_t opcode;
- int rc;
-
- opcode = le16toh((uint8_t *)cmd);
-
- BLE_HS_DBG_ASSERT(ble_hci_cmd_ack == NULL);
- ble_hci_cmd_lock();
-
- rc = host_hci_cmd_send_buf(cmd);
- if (rc != 0) {
- goto done;
- }
-
- rc = ble_hci_cmd_wait_for_ack();
- if (rc != 0) {
- ble_hs_sched_reset(rc);
- goto done;
- }
-
- rc = ble_hci_cmd_process_ack(opcode, evt_buf, evt_buf_len, &ack);
- if (rc != 0) {
- ble_hs_sched_reset(rc);
- goto done;
- }
-
- if (out_evt_buf_len != NULL) {
- *out_evt_buf_len = ack.bha_params_len;
- }
-
- rc = ack.bha_status;
-
-done:
- if (ble_hci_cmd_ack != NULL) {
- ble_hci_trans_buf_free(ble_hci_cmd_ack);
- ble_hci_cmd_ack = NULL;
- }
-
- ble_hci_cmd_unlock();
- return rc;
-}
-
-int
-ble_hci_cmd_tx_empty_ack(void *cmd)
-{
- int rc;
-
- rc = ble_hci_cmd_tx(cmd, NULL, 0, NULL);
- if (rc != 0) {
- return rc;
- }
-
- return 0;
-}
-
-void
-ble_hci_cmd_rx_ack(uint8_t *ack_ev)
-{
- if (ble_hci_cmd_sem.sem_tokens != 0) {
- /* This ack is unexpected; ignore it. */
- ble_hci_trans_buf_free(ack_ev);
- return;
- }
- BLE_HS_DBG_ASSERT(ble_hci_cmd_ack == NULL);
-
- /* Unblock the application now that the HCI command buffer is populated
- * with the acknowledgement.
- */
- ble_hci_cmd_ack = ack_ev;
- os_sem_release(&ble_hci_cmd_sem);
-}
-
-void
-ble_hci_cmd_init(void)
-{
- int rc;
-
- rc = os_sem_init(&ble_hci_cmd_sem, 0);
- BLE_HS_DBG_ASSERT_EVAL(rc == 0);
-
- rc = os_mutex_init(&ble_hci_cmd_mutex);
- BLE_HS_DBG_ASSERT_EVAL(rc == 0);
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/src/ble_hci_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hci_priv.h b/net/nimble/host/src/ble_hci_priv.h
deleted file mode 100644
index 7bc019f..0000000
--- a/net/nimble/host/src/ble_hci_priv.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#ifndef H_BLE_HCI_PRIV_
-#define H_BLE_HCI_PRIV_
-
-struct ble_hci_ack {
- int bha_status; /* A BLE_HS_E<...> error; NOT a naked HCI code. */
- uint8_t *bha_params;
- int bha_params_len;
- uint16_t bha_opcode;
- uint8_t bha_hci_handle;
-};
-
-int ble_hci_cmd_tx(void *cmd, void *evt_buf, uint8_t evt_buf_len,
- uint8_t *out_evt_buf_len);
-int ble_hci_cmd_tx_empty_ack(void *cmd);
-void ble_hci_cmd_rx_ack(uint8_t *ack_ev);
-void ble_hci_cmd_init(void);
-
-#if PHONY_HCI_ACKS
-typedef int ble_hci_cmd_phony_ack_fn(uint8_t *ack, int ack_buf_len);
-void ble_hci_set_phony_ack_cb(ble_hci_cmd_phony_ack_fn *cb);
-#endif
-
-int ble_hci_util_read_adv_tx_pwr(int8_t *out_pwr);
-int ble_hci_util_rand(void *dst, int len);
-int ble_hci_util_read_rssi(uint16_t conn_handle, int8_t *out_rssi);
-int ble_hci_util_set_random_addr(const uint8_t *addr);
-int ble_hci_util_set_data_len(uint16_t conn_handle, uint16_t tx_octets,
- uint16_t tx_time);
-int ble_hci_util_data_hdr_strip(struct os_mbuf *om,
- struct hci_data_hdr *out_hdr);
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/src/ble_hci_util.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hci_util.c b/net/nimble/host/src/ble_hci_util.c
deleted file mode 100644
index caf36e2..0000000
--- a/net/nimble/host/src/ble_hci_util.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <string.h>
-#include "nimble/hci_common.h"
-#include "host/host_hci.h"
-#include "ble_hs_priv.h"
-
-int
-ble_hci_util_read_adv_tx_pwr(int8_t *out_tx_pwr)
-{
- uint8_t buf[BLE_HCI_CMD_HDR_LEN];
- uint8_t params_len;
- int rc;
-
- host_hci_cmd_build_read_adv_pwr(buf, sizeof buf);
- rc = ble_hci_cmd_tx(buf, out_tx_pwr, 1, ¶ms_len);
- if (rc != 0) {
- return rc;
- }
-
- if (params_len != 1 ||
- *out_tx_pwr < BLE_HCI_ADV_CHAN_TXPWR_MIN ||
- *out_tx_pwr > BLE_HCI_ADV_CHAN_TXPWR_MAX) {
-
- return BLE_HS_ECONTROLLER;
- }
-
- return 0;
-}
-
-int
-ble_hci_util_rand(void *dst, int len)
-{
- uint8_t rsp_buf[BLE_HCI_LE_RAND_LEN];
- uint8_t req_buf[BLE_HCI_CMD_HDR_LEN];
- uint8_t params_len;
- uint8_t *u8ptr;
- int chunk_sz;
- int rc;
-
- host_hci_cmd_build_le_rand(req_buf, sizeof req_buf);
-
- u8ptr = dst;
- while (len > 0) {
- rc = ble_hci_cmd_tx(req_buf, rsp_buf, sizeof rsp_buf, ¶ms_len);
- if (rc != 0) {
- return rc;
- }
- if (params_len != sizeof rsp_buf) {
- return BLE_HS_ECONTROLLER;
- }
-
- chunk_sz = min(len, sizeof rsp_buf);
- memcpy(u8ptr, rsp_buf, chunk_sz);
-
- len -= chunk_sz;
- u8ptr += chunk_sz;
- }
-
- return 0;
-}
-
-int
-ble_hci_util_read_rssi(uint16_t conn_handle, int8_t *out_rssi)
-{
- uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_READ_RSSI_LEN];
- uint8_t params[BLE_HCI_READ_RSSI_ACK_PARAM_LEN];
- uint16_t params_conn_handle;
- uint8_t params_len;
- int rc;
-
- host_hci_cmd_build_read_rssi(conn_handle, buf, sizeof buf);
- rc = ble_hci_cmd_tx(buf, params, sizeof params, ¶ms_len);
- if (rc != 0) {
- return rc;
- }
-
- if (params_len != BLE_HCI_READ_RSSI_ACK_PARAM_LEN) {
- return BLE_HS_ECONTROLLER;
- }
-
- params_conn_handle = le16toh(params + 0);
- if (params_conn_handle != conn_handle) {
- return BLE_HS_ECONTROLLER;
- }
-
- *out_rssi = params[2];
-
- return 0;
-}
-
-int
-ble_hci_util_set_random_addr(const uint8_t *addr)
-{
- uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_RAND_ADDR_LEN];
- int rc;
-
- /* set the address in the controller */
-
- rc = host_hci_cmd_build_set_random_addr(addr, buf, sizeof(buf));
- if (rc != 0) {
- return rc;
- }
-
- rc = ble_hci_cmd_tx_empty_ack(buf);
- return rc;
-}
-
-int
-ble_hci_util_set_data_len(uint16_t conn_handle, uint16_t tx_octets,
- uint16_t tx_time)
-{
-
- uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_DATALEN_LEN];
- uint8_t params[BLE_HCI_SET_DATALEN_ACK_PARAM_LEN];
- uint16_t params_conn_handle;
- uint8_t params_len;
- int rc;
-
- rc = host_hci_cmd_build_set_data_len(conn_handle, tx_octets, tx_time, buf,
- sizeof buf);
- if (rc != 0) {
- return BLE_HS_HCI_ERR(rc);
- }
-
- rc = ble_hci_cmd_tx(buf, params, BLE_HCI_SET_DATALEN_ACK_PARAM_LEN,
- ¶ms_len);
- if (rc != 0) {
- return rc;
- }
-
- if (params_len != BLE_HCI_SET_DATALEN_ACK_PARAM_LEN) {
- return BLE_HS_ECONTROLLER;
- }
-
- params_conn_handle = le16toh(params + 0);
- if (params_conn_handle != conn_handle) {
- return BLE_HS_ECONTROLLER;
- }
-
- return 0;
-}
-
-int
-ble_hci_util_data_hdr_strip(struct os_mbuf *om, struct hci_data_hdr *out_hdr)
-{
- int rc;
-
- rc = os_mbuf_copydata(om, 0, BLE_HCI_DATA_HDR_SZ, out_hdr);
- if (rc != 0) {
- return BLE_HS_ECONTROLLER;
- }
-
- /* Strip HCI ACL data header from the front of the packet. */
- os_mbuf_adj(om, BLE_HCI_DATA_HDR_SZ);
-
- out_hdr->hdh_handle_pb_bc = le16toh(&out_hdr->hdh_handle_pb_bc);
- out_hdr->hdh_len = le16toh(&out_hdr->hdh_len);
-
- return 0;
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/src/ble_hs.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs.c b/net/nimble/host/src/ble_hs.c
index 95befc0..8035b49 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -24,7 +24,6 @@
#include "util/tpq.h"
#include "os/os.h"
#include "nimble/ble_hci_trans.h"
-#include "host/host_hci.h"
#include "ble_hs_priv.h"
/**
@@ -173,7 +172,7 @@ ble_hs_process_rx_data_queue(void)
struct os_mbuf *om;
while ((om = os_mqueue_get(&ble_hs_rx_q)) != NULL) {
- host_hci_acl_process(om);
+ ble_hs_hci_evt_acl_process(om);
}
}
@@ -370,7 +369,7 @@ ble_hs_event_handle(void *unused)
rc = os_memblock_put(&ble_hs_hci_ev_pool, ev);
BLE_HS_DBG_ASSERT_EVAL(rc == 0);
- host_hci_evt_process(hci_evt);
+ ble_hs_hci_evt_process(hci_evt);
break;
case BLE_HS_EVENT_TX_NOTIFICATIONS:
@@ -579,7 +578,7 @@ ble_hs_init(struct os_eventq *app_evq, struct ble_hs_cfg *cfg)
goto err;
}
- ble_hci_cmd_init();
+ ble_hs_hci_init();
rc = ble_hs_conn_init();
if (rc != 0) {
@@ -642,7 +641,7 @@ ble_hs_init(struct os_eventq *app_evq, struct ble_hs_cfg *cfg)
#endif
/* Configure the HCI transport to communicate with a host. */
- ble_hci_trans_cfg_hs(host_hci_evt_rx, NULL, ble_hs_rx_data, NULL);
+ ble_hci_trans_cfg_hs(ble_hs_hci_rx_evt, NULL, ble_hs_rx_data, NULL);
return 0;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/src/ble_hs_adv.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_adv.c b/net/nimble/host/src/ble_hs_adv.c
index 4fdc529..da0d5c1 100644
--- a/net/nimble/host/src/ble_hs_adv.c
+++ b/net/nimble/host/src/ble_hs_adv.c
@@ -214,7 +214,7 @@ ble_hs_adv_set_fields(const struct ble_hs_adv_fields *adv_fields,
* the explicitly specified value.
*/
if (adv_fields->tx_pwr_lvl == BLE_HS_ADV_TX_PWR_LVL_AUTO) {
- rc = ble_hci_util_read_adv_tx_pwr(&tx_pwr_lvl);
+ rc = ble_hs_hci_util_read_adv_tx_pwr(&tx_pwr_lvl);
if (rc != 0) {
return rc;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/src/ble_hs_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_conn.c b/net/nimble/host/src/ble_hs_conn.c
index 164cc6d..76196ef 100644
--- a/net/nimble/host/src/ble_hs_conn.c
+++ b/net/nimble/host/src/ble_hs_conn.c
@@ -20,7 +20,6 @@
#include <string.h>
#include <errno.h>
#include "os/os.h"
-#include "host/host_hci.h"
#include "host/ble_hs_id.h"
#include "ble_hs_priv.h"
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/src/ble_hs_dbg.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_dbg.c b/net/nimble/host/src/ble_hs_dbg.c
new file mode 100644
index 0000000..bb6ebdf
--- /dev/null
+++ b/net/nimble/host/src/ble_hs_dbg.c
@@ -0,0 +1,509 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+#include <stdint.h>
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+#include "os/os.h"
+#include "console/console.h"
+#include "nimble/hci_common.h"
+#include "nimble/ble_hci_trans.h"
+#include "ble_hs_priv.h"
+
+static void
+ble_hs_dbg_le_event_disp(uint8_t subev, uint8_t len, uint8_t *evdata)
+{
+ int8_t rssi;
+ uint8_t advlen;
+ uint8_t status;
+ int i;
+ int imax;
+ uint8_t *dptr;
+ char *adv_ptr;
+ char adv_data_buf[32];
+
+ switch (subev) {
+ case BLE_HCI_LE_SUBEV_ENH_CONN_COMPLETE:
+ case BLE_HCI_LE_SUBEV_CONN_COMPLETE:
+ status = evdata[0];
+ if (status == BLE_ERR_SUCCESS) {
+ BLE_HS_LOG(DEBUG, "LE connection complete. handle=%u role=%u "
+ "paddrtype=%u addr=%x.%x.%x.%x.%x.%x ",
+ le16toh(evdata + 1), evdata[3], evdata[4],
+ evdata[10], evdata[9], evdata[8], evdata[7],
+ evdata[6], evdata[5]);
+
+ evdata += 11;
+ if (subev == BLE_HCI_LE_SUBEV_ENH_CONN_COMPLETE) {
+ BLE_HS_LOG(DEBUG, "local_rpa=%x.%x.%x.%x.%x.%x "
+ "peer_rpa=%x.%x.%x.%x.%x.%x ",
+ evdata[5], evdata[4], evdata[3], evdata[2],
+ evdata[1], evdata[0],
+ evdata[11], evdata[10], evdata[9], evdata[8],
+ evdata[7], evdata[6]);
+
+ evdata += 12;
+ }
+ BLE_HS_LOG(DEBUG, "itvl=%u latency=%u spvn_tmo=%u mca=%u\n",
+ le16toh(evdata), le16toh(evdata + 2),
+ le16toh(evdata + 4), evdata[6]);
+ } else {
+ BLE_HS_LOG(DEBUG, "LE connection complete. FAIL (status=%u)\n",
+ status);
+ }
+ break;
+ case BLE_HCI_LE_SUBEV_ADV_RPT:
+ advlen = evdata[9];
+ rssi = evdata[10 + advlen];
+ BLE_HS_LOG(DEBUG, "LE advertising report. len=%u num=%u evtype=%u "
+ "addrtype=%u addr=%x.%x.%x.%x.%x.%x advlen=%u "
+ "rssi=%d\n", len, evdata[0], evdata[1], evdata[2],
+ evdata[8], evdata[7], evdata[6], evdata[5],
+ evdata[4], evdata[3], advlen, rssi);
+ if (advlen) {
+ dptr = &evdata[10];
+ while (advlen > 0) {
+ memset(adv_data_buf, 0, 32);
+ imax = advlen;
+ if (imax > 8) {
+ imax = 8;
+ }
+ adv_ptr = &adv_data_buf[0];
+ for (i = 0; i < imax; ++i) {
+ snprintf(adv_ptr, 4, "%02x ", *dptr);
+ adv_ptr += 3;
+ ++dptr;
+ }
+ advlen -= imax;
+ BLE_HS_LOG(DEBUG, "%s\n", adv_data_buf);
+ }
+ }
+ break;
+ case BLE_HCI_LE_SUBEV_CONN_UPD_COMPLETE:
+ status = evdata[0];
+ if (status == BLE_ERR_SUCCESS) {
+ BLE_HS_LOG(DEBUG, "LE Connection Update Complete. handle=%u "
+ "itvl=%u latency=%u timeout=%u\n",
+ le16toh(evdata + 1), le16toh(evdata + 3),
+ le16toh(evdata + 5), le16toh(evdata + 7));
+ } else {
+ BLE_HS_LOG(DEBUG, "LE Connection Update Complete. FAIL "
+ "(status=%u)\n", status);
+ }
+ break;
+
+ case BLE_HCI_LE_SUBEV_DATA_LEN_CHG:
+ BLE_HS_LOG(DEBUG, "LE Data Length Change. handle=%u max_tx_bytes=%u "
+ "max_tx_time=%u max_rx_bytes=%u max_rx_time=%u\n",
+ le16toh(evdata), le16toh(evdata + 2),
+ le16toh(evdata + 4), le16toh(evdata + 6),
+ le16toh(evdata + 8));
+ break;
+ case BLE_HCI_LE_SUBEV_REM_CONN_PARM_REQ:
+ BLE_HS_LOG(DEBUG, "LE Remote Connection Parameter Request. handle=%u "
+ "min_itvl=%u max_itvl=%u latency=%u timeout=%u\n",
+ le16toh(evdata), le16toh(evdata + 2),
+ le16toh(evdata + 4), le16toh(evdata + 6),
+ le16toh(evdata + 8));
+ break;
+
+ case BLE_HCI_LE_SUBEV_RD_REM_USED_FEAT:
+ status = evdata[0];
+ if (status == BLE_ERR_SUCCESS) {
+ BLE_HS_LOG(DEBUG, "LE Remote Used Features. handle=%u feat=",
+ le16toh(evdata + 1));
+ for (i = 0; i < BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN; ++i) {
+ BLE_HS_LOG(DEBUG, "%02x ", evdata[3 + i]);
+ }
+ BLE_HS_LOG(DEBUG, "\n");
+ } else {
+ BLE_HS_LOG(DEBUG, "LE Remote Used Features. FAIL (status=%u)\n",
+ status);
+ }
+ break;
+
+ case BLE_HCI_LE_SUBEV_LT_KEY_REQ:
+ BLE_HS_LOG(DEBUG, "LE LTK Req. handle=%u rand=%lx%lx encdiv=%u\n",
+ le16toh(evdata), le32toh(evdata + 6),
+ le32toh(evdata + 2), le16toh(evdata + 10));
+ break;
+
+ default:
+ BLE_HS_LOG(DEBUG, "\tUnknown LE event\n");
+ break;
+ }
+}
+
+/**
+ * Display a disconnection complete command.
+ *
+ *
+ * @param evdata
+ * @param len
+ */
+static void
+ble_hs_dbg_disconn_comp_disp(uint8_t *evdata, uint8_t len)
+{
+ uint8_t status;
+ uint8_t reason;
+ uint16_t handle;
+
+ status = evdata[0];
+ handle = le16toh(evdata + 1);
+ /* Ignore reason if status is not success */
+ if (status != BLE_ERR_SUCCESS) {
+ reason = 0;
+ } else {
+ reason = evdata[3];
+ }
+ BLE_HS_LOG(DEBUG, "Disconnection Complete: status=%u handle=%u "
+ "reason=%u\n", status, handle, reason);
+}
+
+/**
+ * Display an encryption change event or encryption key refresh event
+ *
+ * @param evdata
+ * @param len
+ */
+static void
+ble_hs_dbg_encrypt_chg_disp(uint8_t *evdata, uint8_t len)
+{
+ uint8_t status;
+ uint8_t enabled;
+ uint16_t handle;
+
+ status = evdata[0];
+ handle = le16toh(evdata + 1);
+
+ /* Ignore reason if status is not success */
+ if (status != BLE_ERR_SUCCESS) {
+ enabled = 0;
+ } else {
+ enabled = evdata[3];
+ }
+ BLE_HS_LOG(DEBUG, "Encrypt change: status=%u handle=%u state=%u\n",
+ status, handle, enabled);
+}
+
+/**
+ * Display an encryption encryption key refresh event
+ *
+ * @param evdata
+ * @param len
+ */
+static void
+ble_hs_dbg_encrypt_refresh_disp(uint8_t *evdata, uint8_t len)
+{
+ uint8_t status;
+ uint16_t handle;
+
+ status = evdata[0];
+ handle = le16toh(evdata + 1);
+
+ BLE_HS_LOG(DEBUG, "Encrypt key refresh: status=%u handle=%u\n",
+ status, handle);
+}
+
+/**
+ * Display a version information event
+ *
+ * @param evdata
+ * @param len
+ */
+static void
+ble_hs_dbg_rd_rem_ver_disp(uint8_t *evdata, uint8_t len)
+{
+ BLE_HS_LOG(DEBUG, "Remote Version Info: status=%u handle=%u vers_nr=%u "
+ "compid=%u subver=%u\n",
+ evdata[0], le16toh(evdata + 1), evdata[3],
+ le16toh(evdata + 4), le16toh(evdata + 6));
+}
+
+/**
+ * Display the number of completed packets event
+ *
+ * @param evdata
+ * @param len
+ */
+static void
+ble_hs_dbg_num_comp_pkts_disp(uint8_t *evdata, uint8_t len)
+{
+ uint8_t handles;
+ uint8_t *handle_ptr;
+ uint8_t *pkt_ptr;
+ uint16_t handle;
+ uint16_t pkts;
+
+ handles = evdata[0];
+ if (len != ((handles * 4) + 1)) {
+ BLE_HS_LOG(DEBUG, "ERR: Number of Completed Packets bad length: "
+ "num_handles=%u len=%u\n", handles, len);
+ return;
+
+ }
+
+ BLE_HS_LOG(DEBUG, "Number of Completed Packets: num_handles=%u\n",
+ handles);
+ if (handles) {
+ handle_ptr = evdata + 1;
+ pkt_ptr = handle_ptr + (2 * handles);
+ while (handles) {
+ handle = le16toh(handle_ptr);
+ handle_ptr += 2;
+ pkts = le16toh(pkt_ptr);
+ pkt_ptr += 2;
+ BLE_HS_LOG(DEBUG, "handle:%u pkts:%u\n", handle, pkts);
+ --handles;
+ }
+ }
+}
+
+/**
+ * Display the authenticated payload timeout event
+ *
+ * @param evdata
+ * @param len
+ */
+static void
+ble_hs_dbg_auth_pyld_tmo_disp(uint8_t *evdata, uint8_t len)
+{
+ uint16_t handle;
+
+ if (len != sizeof(uint16_t)) {
+ BLE_HS_LOG(DEBUG, "ERR: AuthPyldTmoEvent bad length %u\n", len);
+ return;
+
+ }
+
+ handle = le16toh(evdata);
+ BLE_HS_LOG(DEBUG, "AuthPyldTmo: handle=%u\n", handle);
+}
+
+
+static void
+ble_hs_dbg_cmd_comp_info_params(uint8_t status, uint8_t ocf, uint8_t *evdata)
+{
+ int i;
+ uint8_t *dptr;
+
+ if (status != BLE_ERR_SUCCESS) {
+ return;
+ }
+
+ switch (ocf) {
+ case BLE_HCI_OCF_IP_RD_LOCAL_VER:
+ BLE_HS_LOG(DEBUG, "hci_ver=%u hci_rev=%u lmp_ver=%u mfrg=%u "
+ "lmp_subver=%u",
+ evdata[0], le16toh(evdata + 1), evdata[3],
+ le16toh(evdata + 4), le16toh(evdata + 6));
+ break;
+ case BLE_HCI_OCF_IP_RD_LOC_SUPP_CMD:
+ BLE_HS_LOG(DEBUG, "supp_cmds=");
+ dptr = evdata;
+ for (i = 0; i < 8; ++i) {
+ BLE_HS_LOG(DEBUG, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:",
+ dptr[0], dptr[1], dptr[2], dptr[3],
+ dptr[4], dptr[5], dptr[6], dptr[7]);
+ dptr += 8;
+ }
+ break;
+ case BLE_HCI_OCF_IP_RD_LOC_SUPP_FEAT:
+ BLE_HS_LOG(DEBUG, "supp_feat=0x%lx%08lx",
+ le32toh(evdata + 4), le32toh(evdata));
+ break;
+ case BLE_HCI_OCF_IP_RD_BD_ADDR:
+ BLE_HS_LOG(DEBUG, "bd_addr=%x:%x:%x:%x:%x:%x",
+ evdata[5], evdata[4], evdata[3],
+ evdata[2], evdata[1], evdata[0]);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+ble_hs_dbg_cmd_complete_disp(uint8_t *evdata, uint8_t len)
+{
+ uint8_t cmd_pkts;
+ uint8_t ogf;
+ uint8_t ocf;
+ uint8_t status;
+ uint16_t opcode;
+
+ if (len < 3) {
+ BLE_HS_LOG(DEBUG, "Invalid command complete: len=%d "
+ "(expected >= 3)", len);
+ goto done;
+ }
+
+ cmd_pkts = evdata[0];
+ opcode = le16toh(evdata + 1);
+ ogf = BLE_HCI_OGF(opcode);
+ ocf = BLE_HCI_OCF(opcode);
+
+ BLE_HS_LOG(DEBUG, "Command complete: cmd_pkts=%u ogf=0x%x ocf=0x%x",
+ cmd_pkts, ogf, ocf);
+
+ if (len == 3) {
+ goto done;
+ }
+
+ status = evdata[3];
+ BLE_HS_LOG(DEBUG, " status=%u ", status);
+
+ /* Move past header and status */
+ evdata += 4;
+
+ /* Display parameters based on command. */
+ switch (ogf) {
+ case BLE_HCI_OGF_INFO_PARAMS:
+ ble_hs_dbg_cmd_comp_info_params(status, ocf, evdata);
+ break;
+ case BLE_HCI_OGF_STATUS_PARAMS:
+ switch (ocf) {
+ case BLE_HCI_OCF_RD_RSSI:
+ BLE_HS_LOG(DEBUG, "handle=%u rssi=%d", le16toh(evdata),
+ (int8_t)evdata[2]);
+ break;
+ default:
+ break;
+ }
+ break;
+ case BLE_HCI_OGF_LE:
+ switch (ocf) {
+ case BLE_HCI_OCF_LE_RD_CHAN_MAP:
+ BLE_HS_LOG(DEBUG, "handle=%u chanmap=%x.%x.%x.%x.%x",
+ le16toh(evdata), evdata[2], evdata[3], evdata[4],
+ evdata[5], evdata[6]);
+ break;
+ case BLE_HCI_OCF_LE_RD_MAX_DATA_LEN:
+ BLE_HS_LOG(DEBUG, "txoct=%u txtime=%u rxoct=%u rxtime=%u",
+ le16toh(evdata), le16toh(evdata + 2),
+ le16toh(evdata + 4), le16toh(evdata + 6));
+ break;
+ case BLE_HCI_OCF_LE_RD_SUPP_STATES:
+ BLE_HS_LOG(DEBUG, "states=0x%lx%08lx", le32toh(evdata + 4),
+ le32toh(evdata));
+ break;
+ case BLE_HCI_OCF_LE_ENCRYPT:
+ BLE_HS_LOG(DEBUG, "encdata=0x%02x%02x%02x%02x%02x%02x%02x%02x",
+ evdata[15], evdata[14], evdata[13], evdata[12],
+ evdata[11], evdata[10], evdata[9], evdata[8]);
+ BLE_HS_LOG(DEBUG, "%02x%02x%02x%02x%02x%02x%02x%02x",
+ evdata[7], evdata[6], evdata[5], evdata[4],
+ evdata[3], evdata[2], evdata[1], evdata[0]);
+
+ break;
+ case BLE_HCI_OCF_LE_RAND:
+ BLE_HS_LOG(DEBUG, "rand=0x%02x%02x%02x%02x%02x%02x%02x%02x",
+ evdata[0], evdata[1], evdata[2], evdata[3],
+ evdata[4], evdata[5], evdata[6], evdata[7]);
+ break;
+ case BLE_HCI_OCF_LE_RD_SUGG_DEF_DATA_LEN:
+ BLE_HS_LOG(DEBUG, "txoct=%u txtime=%u", le16toh(evdata),
+ le16toh(evdata + 2));
+ break;
+ case BLE_HCI_OCF_LE_LT_KEY_REQ_REPLY:
+ case BLE_HCI_OCF_LE_LT_KEY_REQ_NEG_REPLY:
+ case BLE_HCI_OCF_LE_SET_DATA_LEN:
+ BLE_HS_LOG(DEBUG, "handle=%u", le16toh(evdata));
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+done:
+ BLE_HS_LOG(DEBUG, "\n");
+}
+
+static void
+ble_hs_dbg_cmd_status_disp(uint8_t *evdata, uint8_t len)
+{
+ uint8_t ogf;
+ uint8_t ocf;
+ uint16_t opcode;
+
+ opcode = le16toh(evdata + 2);
+ ogf = BLE_HCI_OGF(opcode);
+ ocf = BLE_HCI_OCF(opcode);
+
+ BLE_HS_LOG(DEBUG, "Command Status: status=%u cmd_pkts=%u ocf=0x%x "
+ "ogf=0x%x\n", evdata[0], evdata[1], ocf, ogf);
+}
+
+void
+ble_hs_dbg_event_disp(uint8_t *evbuf)
+{
+#if LOG_LEVEL > LOG_LEVEL_DEBUG
+ return;
+#endif
+
+ uint8_t *evdata;
+ uint8_t evcode;
+ uint8_t len;
+
+ /* Extract event code and length; move pointer to event parameter data */
+ evcode = evbuf[0];
+ len = evbuf[1];
+ evdata = evbuf + BLE_HCI_EVENT_HDR_LEN;
+
+ switch (evcode) {
+ case BLE_HCI_EVCODE_DISCONN_CMP:
+ ble_hs_dbg_disconn_comp_disp(evdata, len);
+ break;
+ case BLE_HCI_EVCODE_ENC_KEY_REFRESH:
+ ble_hs_dbg_encrypt_refresh_disp(evdata, len);
+ break;
+ case BLE_HCI_EVCODE_ENCRYPT_CHG:
+ ble_hs_dbg_encrypt_chg_disp(evdata, len);
+ break;
+ case BLE_HCI_EVCODE_RD_REM_VER_INFO_CMP:
+ ble_hs_dbg_rd_rem_ver_disp(evdata, len);
+ break;
+ case BLE_HCI_EVCODE_COMMAND_COMPLETE:
+ ble_hs_dbg_cmd_complete_disp(evdata, len);
+ break;
+ case BLE_HCI_EVCODE_COMMAND_STATUS:
+ ble_hs_dbg_cmd_status_disp(evdata, len);
+ break;
+ case BLE_HCI_EVCODE_NUM_COMP_PKTS:
+ ble_hs_dbg_num_comp_pkts_disp(evdata, len);
+ break;
+ case BLE_HCI_EVCODE_LE_META:
+ ble_hs_dbg_le_event_disp(evdata[0], len, evdata + 1);
+ break;
+ case BLE_HCI_EVCODE_AUTH_PYLD_TMO:
+ ble_hs_dbg_auth_pyld_tmo_disp(evdata, len);
+ break;
+ default:
+ BLE_HS_LOG(DEBUG, "Unknown event 0x%x len=%u\n", evcode, len);
+ break;
+ }
+}
+
+void
+ble_hs_dbg_set_sync_state(uint8_t sync_state)
+{
+ ble_hs_sync_state = sync_state;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d842a43c/net/nimble/host/src/ble_hs_dbg_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_dbg_priv.h b/net/nimble/host/src/ble_hs_dbg_priv.h
new file mode 100644
index 0000000..cf8d203
--- /dev/null
+++ b/net/nimble/host/src/ble_hs_dbg_priv.h
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef H_BLE_HS_DBG_PRIV_
+#define H_BLE_HS_DBG_PRIV_
+
+void ble_hs_dbg_event_disp(uint8_t *evbuf);
+void ble_hs_dbg_set_sync_state(uint8_t sync_state);
+
+#endif /* H_HOST_DBG_ */