Skip to content

Commit ddd0046

Browse files
committed
nimble/ll: Add support for read static address VS HCI command
This allows to enable support for reading static random address from controller via dedicated VS HCI command.
1 parent eecf6fb commit ddd0046

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

nimble/controller/src/ble_ll_hci.c

+46
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,47 @@ ble_ll_hci_status_params_cmd_proc(const uint8_t *cmdbuf, uint8_t len,
15251525
return rc;
15261526
}
15271527

1528+
#if MYNEWT_VAL(BLE_HCI_VS)
1529+
static int
1530+
ble_ll_hci_vs_rd_static_addr(uint8_t *rspbuf, uint8_t *rsplen)
1531+
{
1532+
struct ble_hci_vs_rd_static_addr_rp *rsp = (void *) rspbuf;
1533+
ble_addr_t addr;
1534+
1535+
if (ble_hw_get_static_addr(&addr) < 0) {
1536+
return BLE_ERR_UNSPECIFIED;
1537+
}
1538+
1539+
memcpy(rsp->addr, addr.val, sizeof(rsp->addr));
1540+
1541+
*rsplen = sizeof(*rsp);
1542+
return BLE_ERR_SUCCESS;
1543+
}
1544+
1545+
static int
1546+
ble_ll_hci_vs_cmd_proc(const uint8_t *cmdbuf, uint8_t len, uint16_t ocf,
1547+
uint8_t *rspbuf, uint8_t *rsplen)
1548+
{
1549+
int rc;
1550+
1551+
/* Assume error; if all pass rc gets set to 0 */
1552+
rc = BLE_ERR_INV_HCI_CMD_PARMS;
1553+
1554+
switch (ocf) {
1555+
case BLE_HCI_OCF_VS_RD_STATIC_ADDR:
1556+
if (len == 0) {
1557+
rc = ble_ll_hci_vs_rd_static_addr(rspbuf, rsplen);
1558+
}
1559+
break;
1560+
default:
1561+
rc = BLE_ERR_UNKNOWN_HCI_CMD;
1562+
break;
1563+
}
1564+
1565+
return rc;
1566+
}
1567+
#endif
1568+
15281569
/**
15291570
* Called to process an HCI command from the host.
15301571
*
@@ -1584,6 +1625,11 @@ ble_ll_hci_cmd_proc(struct ble_npl_event *ev)
15841625
case BLE_HCI_OGF_LE:
15851626
rc = ble_ll_hci_le_cmd_proc(cmd->data, cmd->length, ocf, rspbuf, &rsplen, &post_cb);
15861627
break;
1628+
#if MYNEWT_VAL(BLE_HCI_VS)
1629+
case BLE_HCI_OGF_VENDOR:
1630+
rc = ble_ll_hci_vs_cmd_proc(cmd->data, cmd->length, ocf, rspbuf, &rsplen);
1631+
break;
1632+
#endif
15871633
default:
15881634
/* XXX: Need to support other OGF. For now, return unsupported */
15891635
rc = BLE_ERR_UNKNOWN_HCI_CMD;

nimble/include/nimble/hci_common.h

+6
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,12 @@ struct ble_hci_le_set_host_feat_cp {
10611061
uint8_t val;
10621062
} __attribute__((packed));
10631063

1064+
/* --- Vendor specific commands (OGF 0x00FF) */
1065+
#define BLE_HCI_OCF_VS_RD_STATIC_ADDR (0x0001)
1066+
struct ble_hci_vs_rd_static_addr_rp {
1067+
uint8_t addr[6];
1068+
} __attribute__((packed));
1069+
10641070
/* Command Specific Definitions */
10651071
/* --- Set controller to host flow control (OGF 0x03, OCF 0x0031) --- */
10661072
#define BLE_HCI_CTLR_TO_HOST_FC_OFF (0)

nimble/syscfg.yml

+9
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ syscfg.defs:
9595
restrictions:
9696
- 'BLE_ISO if 1'
9797

98+
BLE_HCI_VS:
99+
description: >
100+
Enables support for NimBLE specific vendor HCI commands
101+
value: 0
102+
98103
# Allow periodic sync transfer only if 5.1 or higher
99104
syscfg.restrictions:
100105
- "'BLE_PERIODIC_ADV_SYNC_TRANSFER == 0' || 'BLE_VERSION >= 51'"
106+
107+
# Enable VS HCI by default for combined or standalone controller build
108+
syscfg.vals.BLE_CONTROLLER:
109+
BLE_HCI_VS: 1

0 commit comments

Comments
 (0)