Yes, I did push those changes to develop. Please given them a whirl. Nimble Side Notes: 1) I attempted to create a controller only application. As we expected, there are two functions that are missing (the ones that the controller uses to send the host data and events). A bit unexpected was the hci command pool and associated os events. A simple (possibly) temporary fix was to move those declarations into the common hci definition (duh!). I did that and now there are only those two functions to deal with. More on that later...
2) I looked over the LE controller requirements (Vol 2 Part E 3.19). The only unsupported mandatory command is Test End. We will add that shortly as well as the other test commands (rx and tx). > On Mar 23, 2016, at 7:05 AM, Sterling Hughes > <[email protected]> wrote: > > Hi Will, > > I think some folks were looking for these features, should they try develop > branch to test them out? > > Cheers, > Sterling > > > Begin forwarded message: > >> From: [email protected] >> Date: March 22, 2016 at 11:13:29 PM PDT >> To: [email protected] >> Subject: [1/3] incubator-mynewt-core git commit: Add read supported commands >> and read local supported features commands >> Reply-To: [email protected] >> >> Repository: incubator-mynewt-core >> Updated Branches: >> refs/heads/develop e233384b4 -> 8a7eb7d48 >> >> >> Add read supported commands and read local supported features commands >> >> >> 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/8a7eb7d4 >> Tree: >> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/8a7eb7d4 >> Diff: >> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/8a7eb7d4 >> >> Branch: refs/heads/develop >> Commit: 8a7eb7d4817d935feb8cf8492685d9251a7651fd >> Parents: 3dc5a47 >> Author: wes3 <[email protected]> >> Authored: Tue Mar 22 23:12:38 2016 -0700 >> Committer: wes3 <[email protected]> >> Committed: Tue Mar 22 23:12:43 2016 -0700 >> >> ---------------------------------------------------------------------- >> apps/bletest/src/main.c | 10 + >> .../controller/include/controller/ble_ll_hci.h | 4 + >> net/nimble/controller/src/ble_ll_hci.c | 49 +++++ >> net/nimble/controller/src/ble_ll_supp_cmd.c | 197 +++++++++++++++++++ >> net/nimble/host/include/host/host_hci.h | 2 + >> net/nimble/host/src/host_dbg.c | 83 +++++--- >> net/nimble/host/src/host_hci_cmd.c | 20 ++ >> net/nimble/include/nimble/hci_common.h | 101 +++++----- >> 8 files changed, 388 insertions(+), 78 deletions(-) >> ---------------------------------------------------------------------- >> >> >> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8a7eb7d4/apps/bletest/src/main.c >> ---------------------------------------------------------------------- >> diff --git a/apps/bletest/src/main.c b/apps/bletest/src/main.c >> index 8b62c77..0863bf4 100755 >> --- a/apps/bletest/src/main.c >> +++ b/apps/bletest/src/main.c >> @@ -792,6 +792,16 @@ bletest_task_handler(void *arg) >> assert(rc == 0); >> host_hci_outstanding_opcode = 0; >> >> + /* Read local features */ >> + rc = host_hci_cmd_rd_local_feat(); >> + assert(rc == 0); >> + host_hci_outstanding_opcode = 0; >> + >> + /* Read local commands */ >> + rc = host_hci_cmd_rd_local_cmd(); >> + assert(rc == 0); >> + host_hci_outstanding_opcode = 0; >> + >> /* Read version */ >> rc = host_hci_cmd_rd_local_version(); >> assert(rc == 0); >> >> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8a7eb7d4/net/nimble/controller/include/controller/ble_ll_hci.h >> ---------------------------------------------------------------------- >> diff --git a/net/nimble/controller/include/controller/ble_ll_hci.h >> b/net/nimble/controller/include/controller/ble_ll_hci.h >> index 3e1558f..0f80b54 100644 >> --- a/net/nimble/controller/include/controller/ble_ll_hci.h >> +++ b/net/nimble/controller/include/controller/ble_ll_hci.h >> @@ -20,6 +20,10 @@ >> #ifndef H_BLE_LL_HCI_ >> #define H_BLE_LL_HCI_ >> >> +/* For supported commands */ >> +#define BLE_LL_SUPP_CMD_LEN (36) >> +extern const uint8_t g_ble_ll_supp_cmds[BLE_LL_SUPP_CMD_LEN]; >> + >> /* >> * This determines the number of outstanding commands allowed from the >> * host to the controller. >> >> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8a7eb7d4/net/nimble/controller/src/ble_ll_hci.c >> ---------------------------------------------------------------------- >> diff --git a/net/nimble/controller/src/ble_ll_hci.c >> b/net/nimble/controller/src/ble_ll_hci.c >> index 7ac07db..e726fd3 100644 >> --- a/net/nimble/controller/src/ble_ll_hci.c >> +++ b/net/nimble/controller/src/ble_ll_hci.c >> @@ -123,6 +123,45 @@ ble_ll_hci_rd_local_version(uint8_t *rspbuf, uint8_t >> *rsplen) >> } >> >> /** >> + * Reade local supported features >> + * >> + * @param rspbuf >> + * @param rsplen >> + * >> + * @return int >> + */ >> +static int >> +ble_ll_hci_rd_local_supp_feat(uint8_t *rspbuf, uint8_t *rsplen) >> +{ >> + /* >> + * The only two bits we set here currently are: >> + * BR/EDR not supported (bit 5) >> + * LE supported (controller) (bit 6) >> + */ >> + memset(rspbuf, 0, BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN); >> + rspbuf[4] = 0x60; >> + *rsplen = BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN; >> + return BLE_ERR_SUCCESS; >> +} >> + >> +/** >> + * Read local supported commands >> + * >> + * @param rspbuf >> + * @param rsplen >> + * >> + * @return int >> + */ >> +static int >> +ble_ll_hci_rd_local_supp_cmd(uint8_t *rspbuf, uint8_t *rsplen) >> +{ >> + memset(rspbuf, 0, BLE_HCI_RD_LOC_SUPP_CMD_RSPLEN); >> + memcpy(rspbuf, g_ble_ll_supp_cmds, sizeof(g_ble_ll_supp_cmds)); >> + *rsplen = BLE_HCI_RD_LOC_SUPP_CMD_RSPLEN; >> + return BLE_ERR_SUCCESS; >> +} >> + >> +/** >> * Called to read the public device address of the device >> * >> * >> @@ -582,6 +621,16 @@ ble_ll_hci_info_params_cmd_proc(uint8_t *cmdbuf, >> uint16_t ocf, uint8_t *rsplen) >> rc = ble_ll_hci_rd_local_version(rspbuf, rsplen); >> } >> break; >> + case BLE_HCI_OCF_IP_RD_LOC_SUPP_CMD: >> + if (len == 0) { >> + rc = ble_ll_hci_rd_local_supp_cmd(rspbuf, rsplen); >> + } >> + break; >> + case BLE_HCI_OCF_IP_RD_LOC_SUPP_FEAT: >> + if (len == 0) { >> + rc = ble_ll_hci_rd_local_supp_feat(rspbuf, rsplen); >> + } >> + break; >> case BLE_HCI_OCF_IP_RD_BD_ADDR: >> if (len == 0) { >> rc = ble_ll_hci_rd_bd_addr(rspbuf, rsplen); >> >> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8a7eb7d4/net/nimble/controller/src/ble_ll_supp_cmd.c >> ---------------------------------------------------------------------- >> diff --git a/net/nimble/controller/src/ble_ll_supp_cmd.c >> b/net/nimble/controller/src/ble_ll_supp_cmd.c >> new file mode 100644 >> index 0000000..1ef5780 >> --- /dev/null >> +++ b/net/nimble/controller/src/ble_ll_supp_cmd.c >> @@ -0,0 +1,197 @@ >> +/** >> + * 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 "nimble/ble.h" >> +#include "nimble/nimble_opt.h" >> +#include "nimble/hci_common.h" >> +#include "controller/ble_ll.h" >> +#include "controller/ble_ll_hci.h" >> + >> +/* Octet 0 */ >> +#define BLE_SUPP_CMD_DISCONNECT (1 << 5) >> +#define BLE_LL_SUPP_CMD_OCTET_0 (BLE_SUPP_CMD_DISCONNECT) >> + >> +/* Octet 5 */ >> +#define BLE_SUPP_CMD_SET_EVENT_MASK (1 << 6) >> +#define BLE_LL_SUPP_CMD_OCTET_5 (BLE_SUPP_CMD_SET_EVENT_MASK) >> + >> +/* Octet 10 */ >> +#define BLE_SUPP_CMD_RD_TX_PWR (0 << 2) >> +#define BLE_LL_SUPP_CMD_OCTET_10 (BLE_SUPP_CMD_RD_TX_PWR) >> + >> +/* Octet 14 */ >> +#define BLE_SUPP_CMD_RD_LOC_VER (1 << 3) >> +#define BLE_SUPP_CMD_RD_LOC_SUPP_FEAT (1 << 5) >> +#define BLE_LL_SUPP_CMD_OCTET_14 \ >> +( \ >> + BLE_SUPP_CMD_RD_LOC_VER | \ >> + BLE_SUPP_CMD_RD_LOC_SUPP_FEAT \ >> +) >> + >> +/* Octet 15 */ >> +#define BLE_SUPP_CMD_RD_BD_ADDR (1 << 1) >> +#define BLE_SUPP_CMD_RD_RSSI (1 << 5) >> + >> +#define BLE_LL_SUPP_CMD_OCTET_15 \ >> +( \ >> + BLE_SUPP_CMD_RD_BD_ADDR | \ >> + BLE_SUPP_CMD_RD_RSSI \ >> +) >> + >> +/* Octet 25 */ >> +#define BLE_SUPP_CMD_LE_SET_EV_MASK (1 << 0) >> +#define BLE_SUPP_CMD_LE_RD_BUF_SIZE (1 << 1) >> +#define BLE_SUPP_CMD_LE_RD_LOC_FEAT (1 << 2) >> +#define BLE_SUPP_CMD_LE_SET_RAND_ADDR (1 << 4) >> +#define BLE_SUPP_CMD_LE_SET_ADV_PARAMS (1 << 5) >> +#define BLE_SUPP_CMD_LE_SET_ADV_TX_PWR (1 << 6) >> +#define BLE_SUPP_CMD_LE_SET_ADV_DATA (1 << 7) >> + >> +#define BLE_LL_SUPP_CMD_OCTET_25 \ >> +( \ >> + BLE_SUPP_CMD_LE_SET_EV_MASK | \ >> + BLE_SUPP_CMD_LE_RD_BUF_SIZE | \ >> + BLE_SUPP_CMD_LE_RD_LOC_FEAT | \ >> + BLE_SUPP_CMD_LE_SET_RAND_ADDR | \ >> + BLE_SUPP_CMD_LE_SET_ADV_PARAMS | \ >> + BLE_SUPP_CMD_LE_SET_ADV_TX_PWR | \ >> + BLE_SUPP_CMD_LE_SET_ADV_DATA \ >> +) >> + >> +/* Octet 26 */ >> +#define BLE_SUPP_CMD_LE_SET_SCAN_RSP_DATA (1 << 0) >> +#define BLE_SUPP_CMD_LE_SET_ADV_ENABLE (1 << 1) >> +#define BLE_SUPP_CMD_LE_SET_SCAN_PARAMS (1 << 2) >> +#define BLE_SUPP_CMD_LE_SET_SCAN_ENABLE (1 << 3) >> +#define BLE_SUPP_CMD_LE_CREATE_CONN (1 << 4) >> +#define BLE_SUPP_CMD_LE_CREATE_CONN_CANCEL (1 << 5) >> +#define BLE_SUPP_CMD_LE_RD_WHITELIST_SIZE (1 << 6) >> +#define BLE_SUPP_CMD_LE_CLR_WHITELIST (1 << 7) >> + >> +#define BLE_LL_SUPP_CMD_OCTET_26 \ >> +( \ >> + BLE_SUPP_CMD_LE_SET_SCAN_RSP_DATA | \ >> + BLE_SUPP_CMD_LE_SET_ADV_ENABLE | \ >> + BLE_SUPP_CMD_LE_SET_SCAN_PARAMS | \ >> + BLE_SUPP_CMD_LE_SET_SCAN_ENABLE | \ >> + BLE_SUPP_CMD_LE_CREATE_CONN | \ >> + BLE_SUPP_CMD_LE_CREATE_CONN_CANCEL | \ >> + BLE_SUPP_CMD_LE_RD_WHITELIST_SIZE | \ >> + BLE_SUPP_CMD_LE_CLR_WHITELIST \ >> +) >> + >> +/* Octet 27 */ >> +#define BLE_SUPP_CMD_LE_ADD_DEV_WHITELIST (1 << 0) >> +#define BLE_SUPP_CMD_LE_RMV_DEV_WHITELIST (1 << 1) >> +#define BLE_SUPP_CMD_LE_CONN_UPDATE (1 << 2) >> +#define BLE_SUPP_CMD_LE_SET_HOST_CHAN_CLASS (1 << 3) >> +#define BLE_SUPP_CMD_LE_RD_CHAN_MAP (1 << 4) >> +#define BLE_SUPP_CMD_LE_RD_REM_USED_FEAT (1 << 5) >> +#define BLE_SUPP_CMD_LE_ENCRYPT (0 << 6) >> +#define BLE_SUPP_CMD_LE_RAND (0 << 7) >> + >> +#define BLE_LL_SUPP_CMD_OCTET_27 \ >> +( \ >> + BLE_SUPP_CMD_LE_ADD_DEV_WHITELIST | \ >> + BLE_SUPP_CMD_LE_RMV_DEV_WHITELIST | \ >> + BLE_SUPP_CMD_LE_CONN_UPDATE | \ >> + BLE_SUPP_CMD_LE_SET_HOST_CHAN_CLASS | \ >> + BLE_SUPP_CMD_LE_RD_CHAN_MAP | \ >> + BLE_SUPP_CMD_LE_RD_REM_USED_FEAT | \ >> + BLE_SUPP_CMD_LE_ENCRYPT | \ >> + BLE_SUPP_CMD_LE_RAND \ >> +) >> + >> +/* Octet 28 */ >> +#define BLE_SUPP_CMD_LE_START_ENCRYPT (0 << 0) >> +#define BLE_SUPP_CMD_LE_LTK_REQ_REPLY (0 << 1) >> +#define BLE_SUPP_CMD_LE_LTK_REQ_NEG_REPLY (0 << 2) >> +#define BLE_SUPP_CMD_LE_READ_SUPP_STATES (1 << 3) >> +#define BLE_SUPP_CMD_LE_RX_TEST (0 << 4) >> +#define BLE_SUPP_CMD_LE_TX_TEST (0 << 5) >> +#define BLE_SUPP_CMD_LE_TEST_END (0 << 6) >> + >> +#define BLE_LL_SUPP_CMD_OCTET_28 \ >> +( \ >> + BLE_SUPP_CMD_LE_START_ENCRYPT | \ >> + BLE_SUPP_CMD_LE_LTK_REQ_REPLY | \ >> + BLE_SUPP_CMD_LE_LTK_REQ_NEG_REPLY | \ >> + BLE_SUPP_CMD_LE_READ_SUPP_STATES | \ >> + BLE_SUPP_CMD_LE_RX_TEST | \ >> + BLE_SUPP_CMD_LE_TX_TEST | \ >> + BLE_SUPP_CMD_LE_TEST_END \ >> +) >> + >> +/* Octet 33 */ >> +#define BLE_SUPP_CMD_LE_REM_CONN_PRR (1 << 4) >> +#define BLE_SUPP_CMD_LE_REM_CONN_PRNR (1 << 5) >> +#define BLE_SUPP_CMD_LE_SET_DATALEN (0 << 6) >> +#define BLE_SUPP_CMD_LE_RD_SUGG_DATALEN (0 << 7) >> + >> +#define BLE_LL_SUPP_CMD_OCTET_33 \ >> +( \ >> + BLE_SUPP_CMD_LE_REM_CONN_PRR | \ >> + BLE_SUPP_CMD_LE_REM_CONN_PRNR | \ >> + BLE_SUPP_CMD_LE_SET_DATALEN | \ >> + BLE_SUPP_CMD_LE_RD_SUGG_DATALEN \ >> +) >> + >> +/* Defines the array of supported commands */ >> +const uint8_t g_ble_ll_supp_cmds[BLE_LL_SUPP_CMD_LEN] = >> +{ >> + BLE_LL_SUPP_CMD_OCTET_0, /* Octet 0 */ >> + 0, >> + 0, >> + 0, >> + 0, >> + BLE_LL_SUPP_CMD_OCTET_5, >> + 0, >> + 0, >> + 0, /* Octet 8 */ >> + 0, >> + BLE_LL_SUPP_CMD_OCTET_10, >> + 0, >> + 0, >> + 0, >> + BLE_LL_SUPP_CMD_OCTET_14, >> + BLE_LL_SUPP_CMD_OCTET_15, >> + 0, /* Octet 16 */ >> + 0, >> + 0, >> + 0, >> + 0, >> + 0, >> + 0, >> + 0, >> + 0, /* Octet 24 */ >> + BLE_LL_SUPP_CMD_OCTET_25, >> + BLE_LL_SUPP_CMD_OCTET_26, >> + BLE_LL_SUPP_CMD_OCTET_27, >> + BLE_LL_SUPP_CMD_OCTET_28, >> + 0, >> + 0, >> + 0, >> + 0, /* Octet 32 */ >> + BLE_LL_SUPP_CMD_OCTET_33, >> + 34, >> + 35, >> +}; >> >> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8a7eb7d4/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 >> index f6c0d1e..d920d18 100644 >> --- a/net/nimble/host/include/host/host_hci.h >> +++ b/net/nimble/host/include/host/host_hci.h >> @@ -31,6 +31,8 @@ int host_hci_cmd_set_event_mask(uint64_t event_mask); >> int host_hci_cmd_disconnect(uint16_t handle, uint8_t reason); >> int host_hci_cmd_rd_rem_version(uint16_t handle); >> int host_hci_cmd_rd_local_version(void); >> +int host_hci_cmd_rd_local_feat(void); >> +int host_hci_cmd_rd_local_cmd(void); >> int host_hci_cmd_rd_bd_addr(void); >> int host_hci_cmd_read_rssi(uint16_t handle); >> int host_hci_cmd_le_set_host_chan_class(uint8_t *new_chan_map); >> >> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8a7eb7d4/net/nimble/host/src/host_dbg.c >> ---------------------------------------------------------------------- >> diff --git a/net/nimble/host/src/host_dbg.c b/net/nimble/host/src/host_dbg.c >> index ae9dff0..e17ae4b 100644 >> --- a/net/nimble/host/src/host_dbg.c >> +++ b/net/nimble/host/src/host_dbg.c >> @@ -26,7 +26,7 @@ >> #include "nimble/hci_transport.h" >> #include "ble_hs_priv.h" >> >> -void >> +static void >> host_hci_dbg_le_event_disp(uint8_t subev, uint8_t len, uint8_t *evdata) >> { >> int8_t rssi; >> @@ -138,7 +138,7 @@ host_hci_dbg_le_event_disp(uint8_t subev, uint8_t len, >> uint8_t *evdata) >> * @param evdata >> * @param len >> */ >> -void >> +static void >> host_hci_dbg_disconn_comp_disp(uint8_t *evdata, uint8_t len) >> { >> uint8_t status; >> @@ -178,7 +178,7 @@ host_hci_dbg_rd_rem_ver_disp(uint8_t *evdata, uint8_t >> len) >> * @param evdata >> * @param len >> */ >> -void >> +static void >> host_hci_dbg_num_comp_pkts_disp(uint8_t *evdata, uint8_t len) >> { >> uint8_t handles; >> @@ -211,42 +211,70 @@ host_hci_dbg_num_comp_pkts_disp(uint8_t *evdata, >> uint8_t len) >> } >> } >> >> -void >> +static void >> +host_hci_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 >> host_hci_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; >> >> + cmd_pkts = evdata[0]; >> opcode = le16toh(evdata + 1); >> ogf = BLE_HCI_OGF(opcode); >> ocf = BLE_HCI_OCF(opcode); >> + status = evdata[3]; >> >> BLE_HS_LOG(DEBUG, "Command Complete: cmd_pkts=%u ogf=0x%x ocf=0x%x " >> - "status=%u ", evdata[0], ogf, ocf, evdata[3]); >> + "status=%u ", cmd_pkts, ogf, ocf, status); >> >> /* Display parameters based on command. */ >> switch (ogf) { >> case BLE_HCI_OGF_INFO_PARAMS: >> - switch (ocf) { >> - case BLE_HCI_OCF_IP_RD_LOCAL_VER: >> - if (evdata[3] == BLE_ERR_SUCCESS) { >> - BLE_HS_LOG(DEBUG, "hci_ver=%u hci_rev=%u lmp_ver=%u mfrg=%u >> " >> - "lmp_subver=%u", >> - evdata[4], le16toh(evdata + 5), evdata[7], >> - le16toh(evdata + 8), le16toh(evdata + 10)); >> - } >> - break; >> - case BLE_HCI_OCF_IP_RD_BD_ADDR: >> - if (evdata[3] == BLE_ERR_SUCCESS) { >> - BLE_HS_LOG(DEBUG, "bd_addr=%x:%x:%x:%x:%x:%x", >> - evdata[9], evdata[8], evdata[7], >> - evdata[6], evdata[5], evdata[4]); >> - } >> - break; >> - default: >> - break; >> - } >> + evdata += 4; >> + host_hci_dbg_cmd_comp_info_params(status, ocf, evdata); >> break; >> case BLE_HCI_OGF_STATUS_PARAMS: >> switch (ocf) { >> @@ -271,7 +299,7 @@ host_hci_dbg_cmd_complete_disp(uint8_t *evdata, uint8_t >> len) >> le16toh(evdata + 8), le16toh(evdata + 10)); >> break; >> case BLE_HCI_OCF_LE_RD_SUPP_STATES: >> - BLE_HS_LOG(DEBUG, "states=0x%lx%lx", le32toh(evdata + 8), >> + BLE_HS_LOG(DEBUG, "states=0x%lx%08lx", le32toh(evdata + 8), >> le32toh(evdata + 4)); >> break; >> default: >> @@ -284,7 +312,7 @@ host_hci_dbg_cmd_complete_disp(uint8_t *evdata, uint8_t >> len) >> BLE_HS_LOG(DEBUG, "\n"); >> } >> >> -void >> +static void >> host_hci_dbg_cmd_status_disp(uint8_t *evdata, uint8_t len) >> { >> uint8_t ogf; >> @@ -306,9 +334,10 @@ host_hci_dbg_event_disp(uint8_t *evbuf) >> 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 + 2; >> + evdata = evbuf + BLE_HCI_EVENT_HDR_LEN; >> >> switch (evcode) { >> case BLE_HCI_EVCODE_DISCONN_CMP: >> >> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8a7eb7d4/net/nimble/host/src/host_hci_cmd.c >> ---------------------------------------------------------------------- >> diff --git a/net/nimble/host/src/host_hci_cmd.c >> b/net/nimble/host/src/host_hci_cmd.c >> index 8839c12..39f7784 100644 >> --- a/net/nimble/host/src/host_hci_cmd.c >> +++ b/net/nimble/host/src/host_hci_cmd.c >> @@ -238,6 +238,26 @@ host_hci_cmd_rd_local_version(void) >> } >> >> int >> +host_hci_cmd_rd_local_feat(void) >> +{ >> + int rc; >> + >> + rc = host_hci_cmd_send(BLE_HCI_OGF_INFO_PARAMS, >> + BLE_HCI_OCF_IP_RD_LOC_SUPP_FEAT, 0, NULL); >> + return rc; >> +} >> + >> +int >> +host_hci_cmd_rd_local_cmd(void) >> +{ >> + int rc; >> + >> + rc = host_hci_cmd_send(BLE_HCI_OGF_INFO_PARAMS, >> + BLE_HCI_OCF_IP_RD_LOC_SUPP_CMD, 0, NULL); >> + return rc; >> +} >> + >> +int >> host_hci_cmd_rd_bd_addr(void) >> { >> int rc; >> >> http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8a7eb7d4/net/nimble/include/nimble/hci_common.h >> ---------------------------------------------------------------------- >> diff --git a/net/nimble/include/nimble/hci_common.h >> b/net/nimble/include/nimble/hci_common.h >> index 3895ac3..331a2ed 100644 >> --- a/net/nimble/include/nimble/hci_common.h >> +++ b/net/nimble/include/nimble/hci_common.h >> @@ -39,14 +39,13 @@ >> #define BLE_HCI_OGF(opcode) (((opcode) >> 10) & 0x003F) >> #define BLE_HCI_OCF(opcode) ((opcode) & 0x03FF) >> >> -/* Opcode Group */ >> +/* Opcode Group definitions (note: 0x07 not defined in spec) */ >> #define BLE_HCI_OGF_LINK_CTRL (0x01) >> #define BLE_HCI_OGF_LINK_POLICY (0x02) >> #define BLE_HCI_OGF_CTLR_BASEBAND (0x03) >> #define BLE_HCI_OGF_INFO_PARAMS (0x04) >> #define BLE_HCI_OGF_STATUS_PARAMS (0x05) >> #define BLE_HCI_OGF_TESTING (0x06) >> -/* NOTE: 0x07 not defined in specification */ >> #define BLE_HCI_OGF_LE (0x08) >> >> /* >> @@ -59,51 +58,19 @@ >> #define BLE_HCI_OCF_DISCONNECT_CMD (0x0006) >> #define BLE_HCI_OCF_RD_REM_VER_INFO (0x001D) >> >> -/* Command specific definitions */ >> -/* Disconnect command */ >> -#define BLE_HCI_DISCONNECT_CMD_LEN (3) >> - >> /* List of OCF for Controller and Baseband commands (OGF=0x03) */ >> #define BLE_HCI_OCF_CB_SET_EVENT_MASK (0x0001) >> #define BLE_HCI_OCF_CB_RESET (0x0003) >> #define BLE_HCI_OCF_CB_SET_EV_FILT (0x0005) >> #define BLE_HCI_OCF_CB_READ_TX_PWR (0x002D) >> >> -/* Command specific definitions */ >> -/* Set event mask */ >> -#define BLE_HCI_SET_EVENT_MASK_LEN (8) >> - >> /* List of OCF for Info Param commands (OGF=0x04) */ >> #define BLE_HCI_OCF_IP_RD_LOCAL_VER (0x0001) >> #define BLE_HCI_OCF_IP_RD_LOC_SUPP_CMD (0x0002) >> +#define BLE_HCI_OCF_IP_RD_LOC_SUPP_FEAT (0x0003) >> #define BLE_HCI_OCF_IP_RD_BD_ADDR (0x0009) >> >> -/* Command specific definitions */ >> -/* NOTE: does not include status field in command complete event! */ >> -#define BLE_HCI_RD_LOC_VER_INFO_RSPLEN (8) >> - >> -/* Bluetooth Assigned numbers for version information.*/ >> -#define BLE_HCI_VER_BCS_1_0b (0) >> -#define BLE_HCI_VER_BCS_1_1 (1) >> -#define BLE_HCI_VER_BCS_1_2 (2) >> -#define BLE_HCI_VER_BCS_2_0_EDR (3) >> -#define BLE_HCI_VER_BCS_2_1_EDR (4) >> -#define BLE_HCI_VER_BCS_3_0_HCS (5) >> -#define BLE_HCI_VER_BCS_4_0 (6) >> -#define BLE_HCI_VER_BCS_4_1 (7) >> -#define BLE_HCI_VER_BCS_4_2 (8) >> - >> -#define BLE_LMP_VER_BCS_1_0b (0) >> -#define BLE_LMP_VER_BCS_1_1 (1) >> -#define BLE_LMP_VER_BCS_1_2 (2) >> -#define BLE_LMP_VER_BCS_2_0_EDR (3) >> -#define BLE_LMP_VER_BCS_2_1_EDR (4) >> -#define BLE_LMP_VER_BCS_3_0_HCS (5) >> -#define BLE_LMP_VER_BCS_4_0 (6) >> -#define BLE_LMP_VER_BCS_4_1 (7) >> -#define BLE_LMP_VER_BCS_4_2 (8) >> - >> -/* List of OCD for Status parameters commands (OGF = 0x05) */ >> +/* List of OCF for Status parameters commands (OGF = 0x05) */ >> #define BLE_HCI_OCF_RD_RSSI (0x0005) >> >> /* List of OCF for LE commands (OGF = 0x08) */ >> @@ -156,21 +123,32 @@ >> #define BLE_HCI_OCF_LE_RD_MAX_DATA_LEN (0x002F) >> >> /* Command Specific Definitions */ >> +/* --- Disconnect command (OGF 0x01, OCF 0x0006) --- */ >> +#define BLE_HCI_DISCONNECT_CMD_LEN (3) >> + >> +/* --- Set event mask (OGF 0x03, OCF 0x0001 --- */ >> +#define BLE_HCI_SET_EVENT_MASK_LEN (8) >> + >> +/* --- Read local version information (OGF 0x04, OCF 0x0001) --- */ >> +/* NOTE: does not include status field in command complete event! */ >> +#define BLE_HCI_RD_LOC_VER_INFO_RSPLEN (8) >> +#define BLE_HCI_RD_LOC_SUPP_CMD_RSPLEN (64) >> + >> /* --- Read RSSI (OGF 0x05, OCF 0x0005) --- */ >> -#define BLE_HCI_READ_RSSI_ACK_PARAM_LEN (4) /* Includes status byte. */ >> +#define BLE_HCI_READ_RSSI_ACK_PARAM_LEN (4) /* Includes status byte. */ >> >> /* --- LE set event mask (OCF 0x0001) --- */ >> -#define BLE_HCI_SET_LE_EVENT_MASK_LEN (8) >> +#define BLE_HCI_SET_LE_EVENT_MASK_LEN (8) >> >> /* --- LE read buffer size (OCF 0x0002) --- */ >> -#define BLE_HCI_RD_BUF_SIZE_LEN (0) >> -#define BLE_HCI_RD_BUF_SIZE_RSPLEN (3) >> +#define BLE_HCI_RD_BUF_SIZE_LEN (0) >> +#define BLE_HCI_RD_BUF_SIZE_RSPLEN (3) >> >> /* --- LE read local supported features (OCF 0x0003) --- */ >> -#define BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN (8) >> +#define BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN (8) >> >> /* --- LE set advertising parameters (OCF 0x0006) */ >> -#define BLE_HCI_SET_ADV_PARAM_LEN (15) >> +#define BLE_HCI_SET_ADV_PARAM_LEN (15) >> >> /* Advertising types */ >> #define BLE_HCI_ADV_TYPE_ADV_IND (0) >> @@ -181,11 +159,11 @@ >> #define BLE_HCI_ADV_TYPE_MAX (4) >> >> /* Own address types */ >> -#define BLE_HCI_ADV_OWN_ADDR_PUBLIC (0) >> -#define BLE_HCI_ADV_OWN_ADDR_RANDOM (1) >> -#define BLE_HCI_ADV_OWN_ADDR_PRIV_PUB (2) >> -#define BLE_HCI_ADV_OWN_ADDR_PRIV_RAND (3) >> -#define BLE_HCI_ADV_OWN_ADDR_MAX (3) >> +#define BLE_HCI_ADV_OWN_ADDR_PUBLIC (0) >> +#define BLE_HCI_ADV_OWN_ADDR_RANDOM (1) >> +#define BLE_HCI_ADV_OWN_ADDR_PRIV_PUB (2) >> +#define BLE_HCI_ADV_OWN_ADDR_PRIV_RAND (3) >> +#define BLE_HCI_ADV_OWN_ADDR_MAX (3) >> >> /* Advertisement peer address Type */ >> #define BLE_HCI_ADV_PEER_ADDR_PUBLIC (0) >> @@ -198,16 +176,16 @@ >> #define BLE_HCI_ADV_CHAN_TXPWR_MAX (10) >> >> /* --- LE set advertising data (OCF 0x0008) */ >> -#define BLE_HCI_MAX_ADV_DATA_LEN (31) >> +#define BLE_HCI_MAX_ADV_DATA_LEN (31) >> >> /* --- LE set scan response data (OCF 0x0009) */ >> -#define BLE_HCI_MAX_SCAN_RSP_DATA_LEN (31) >> +#define BLE_HCI_MAX_SCAN_RSP_DATA_LEN (31) >> >> /* --- LE set advertising enable (OCF 0x000a) */ >> -#define BLE_HCI_SET_ADV_ENABLE_LEN (1) >> +#define BLE_HCI_SET_ADV_ENABLE_LEN (1) >> >> /* --- LE set scan enable (OCF 0x000c) */ >> -#define BLE_HCI_SET_SCAN_ENABLE_LEN (2) >> +#define BLE_HCI_SET_SCAN_ENABLE_LEN (2) >> >> /* Connect peer address type */ >> #define BLE_HCI_CONN_PEER_ADDR_PUBLIC (0) >> @@ -474,6 +452,27 @@ >> /* LE data length change event (sub event 0x07) */ >> #define BLE_HCI_LE_DATA_LEN_CHG_LEN (11) >> >> +/* Bluetooth Assigned numbers for version information.*/ >> +#define BLE_HCI_VER_BCS_1_0b (0) >> +#define BLE_HCI_VER_BCS_1_1 (1) >> +#define BLE_HCI_VER_BCS_1_2 (2) >> +#define BLE_HCI_VER_BCS_2_0_EDR (3) >> +#define BLE_HCI_VER_BCS_2_1_EDR (4) >> +#define BLE_HCI_VER_BCS_3_0_HCS (5) >> +#define BLE_HCI_VER_BCS_4_0 (6) >> +#define BLE_HCI_VER_BCS_4_1 (7) >> +#define BLE_HCI_VER_BCS_4_2 (8) >> + >> +#define BLE_LMP_VER_BCS_1_0b (0) >> +#define BLE_LMP_VER_BCS_1_1 (1) >> +#define BLE_LMP_VER_BCS_1_2 (2) >> +#define BLE_LMP_VER_BCS_2_0_EDR (3) >> +#define BLE_LMP_VER_BCS_2_1_EDR (4) >> +#define BLE_LMP_VER_BCS_3_0_HCS (5) >> +#define BLE_LMP_VER_BCS_4_0 (6) >> +#define BLE_LMP_VER_BCS_4_1 (7) >> +#define BLE_LMP_VER_BCS_4_2 (8) >> + >> /*--- Shared data structures ---*/ >> /* Read local version information (OGF=0x0004, OCF=0x0001) */ >> struct hci_loc_ver_info >>
