diff --git a/nimble/controller/src/ble_ll_hci.c b/nimble/controller/src/ble_ll_hci.c index a3da98d9b..7cd3621c6 100644 --- a/nimble/controller/src/ble_ll_hci.c +++ b/nimble/controller/src/ble_ll_hci.c @@ -1525,6 +1525,47 @@ ble_ll_hci_status_params_cmd_proc(const uint8_t *cmdbuf, uint8_t len, return rc; } +#if MYNEWT_VAL(BLE_HCI_VS) +static int +ble_ll_hci_vs_rd_static_addr(uint8_t *rspbuf, uint8_t *rsplen) +{ + struct ble_hci_vs_rd_static_addr_rp *rsp = (void *) rspbuf; + ble_addr_t addr; + + if (ble_hw_get_static_addr(&addr) < 0) { + return BLE_ERR_UNSPECIFIED; + } + + memcpy(rsp->addr, addr.val, sizeof(rsp->addr)); + + *rsplen = sizeof(*rsp); + return BLE_ERR_SUCCESS; +} + +static int +ble_ll_hci_vs_cmd_proc(const uint8_t *cmdbuf, uint8_t len, uint16_t ocf, + uint8_t *rspbuf, uint8_t *rsplen) +{ + int rc; + + /* Assume error; if all pass rc gets set to 0 */ + rc = BLE_ERR_INV_HCI_CMD_PARMS; + + switch (ocf) { + case BLE_HCI_OCF_VS_RD_STATIC_ADDR: + if (len == 0) { + rc = ble_ll_hci_vs_rd_static_addr(rspbuf, rsplen); + } + break; + default: + rc = BLE_ERR_UNKNOWN_HCI_CMD; + break; + } + + return rc; +} +#endif + /** * Called to process an HCI command from the host. * @@ -1584,6 +1625,11 @@ ble_ll_hci_cmd_proc(struct ble_npl_event *ev) case BLE_HCI_OGF_LE: rc = ble_ll_hci_le_cmd_proc(cmd->data, cmd->length, ocf, rspbuf, &rsplen, &post_cb); break; +#if MYNEWT_VAL(BLE_HCI_VS) + case BLE_HCI_OGF_VENDOR: + rc = ble_ll_hci_vs_cmd_proc(cmd->data, cmd->length, ocf, rspbuf, &rsplen); + break; +#endif default: /* XXX: Need to support other OGF. For now, return unsupported */ rc = BLE_ERR_UNKNOWN_HCI_CMD; diff --git a/nimble/include/nimble/hci_common.h b/nimble/include/nimble/hci_common.h index 3df8dd662..92031c3c1 100644 --- a/nimble/include/nimble/hci_common.h +++ b/nimble/include/nimble/hci_common.h @@ -1061,6 +1061,12 @@ struct ble_hci_le_set_host_feat_cp { uint8_t val; } __attribute__((packed)); +/* --- Vendor specific commands (OGF 0x00FF) */ +#define BLE_HCI_OCF_VS_RD_STATIC_ADDR (0x0001) +struct ble_hci_vs_rd_static_addr_rp { + uint8_t addr[6]; +} __attribute__((packed)); + /* Command Specific Definitions */ /* --- Set controller to host flow control (OGF 0x03, OCF 0x0031) --- */ #define BLE_HCI_CTLR_TO_HOST_FC_OFF (0) diff --git a/nimble/syscfg.yml b/nimble/syscfg.yml index dcbdfd1d6..b5cfc585d 100644 --- a/nimble/syscfg.yml +++ b/nimble/syscfg.yml @@ -95,6 +95,15 @@ syscfg.defs: restrictions: - 'BLE_ISO if 1' + BLE_HCI_VS: + description: > + Enables support for NimBLE specific vendor HCI commands + value: 0 + # Allow periodic sync transfer only if 5.1 or higher syscfg.restrictions: - "'BLE_PERIODIC_ADV_SYNC_TRANSFER == 0' || 'BLE_VERSION >= 51'" + +# Enable VS HCI by default for combined or standalone controller build +syscfg.vals.BLE_CONTROLLER: + BLE_HCI_VS: 1