Skip to content

Commit ec53508

Browse files
carlescufiAnas Nashif
authored andcommitted
Bluetooth: controller: Implement Read Build Info cmd
Implement the Read Build Information VS command. This returns a UTF-8 encoded string, which is extendable by the user via a new Kconfig option. Signed-off-by: Carles Cufi <[email protected]>
1 parent 7f65aa8 commit ec53508

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

subsys/bluetooth/controller/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ config BT_CTLR_HCI_VS_EXT
3737
Enable support for the Zephyr HCI Vendor-Specific Extensions in the
3838
Controller.
3939

40+
config BT_CTLR_HCI_VS_BUILD_INFO
41+
string "Zephyr HCI VS Build Info string"
42+
default ""
43+
depends on BT_CTLR_HCI_VS_EXT
44+
help
45+
User-defined string that will be returned by the Zephyr VS Read Build
46+
Information command after the Zephyr version and build time. When
47+
setting this to a value different from an empty string, a space
48+
character is required at the beginning to separate it from the
49+
already included information.
50+
4051
config BT_CTLR_DUP_FILTER_LEN
4152
prompt "Number of addresses in the scan duplicate filter"
4253
int

subsys/bluetooth/controller/hci/hci.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,8 +1674,8 @@ static void vs_read_supported_commands(struct net_buf *buf,
16741674
/* Set Version Information, Supported Commands, Supported Features. */
16751675
rp->commands[0] |= BIT(0) | BIT(1) | BIT(2);
16761676
#if defined(CONFIG_BT_CTLR_HCI_VS_EXT)
1677-
/* Write BD_ADDR */
1678-
rp->commands[0] |= BIT(5);
1677+
/* Write BD_ADDR, Read Build Info */
1678+
rp->commands[0] |= BIT(5) | BIT(7);
16791679
/* Read Static Addresses, Read Key Hierarchy Roots */
16801680
rp->commands[1] |= BIT(0) | BIT(1);
16811681
#endif /* CONFIG_BT_CTLR_HCI_VS_EXT */
@@ -1704,6 +1704,29 @@ static void vs_write_bd_addr(struct net_buf *buf, struct net_buf **evt)
17041704
ccst->status = 0x00;
17051705
}
17061706

1707+
static void vs_read_build_info(struct net_buf *buf, struct net_buf **evt)
1708+
{
1709+
struct bt_hci_rp_vs_read_build_info *rp;
1710+
1711+
#define BUILD_TIMESTAMP " " __DATE__ " " __TIME__
1712+
1713+
#define HCI_VS_BUILD_INFO "Zephyr OS v" \
1714+
KERNEL_VERSION_STRING BUILD_TIMESTAMP CONFIG_BT_CTLR_HCI_VS_BUILD_INFO
1715+
1716+
const char build_info[] = HCI_VS_BUILD_INFO;
1717+
1718+
#define BUILD_INFO_EVT_LEN (sizeof(struct bt_hci_evt_hdr) + \
1719+
sizeof(struct bt_hci_evt_cmd_complete) + \
1720+
sizeof(struct bt_hci_rp_vs_read_build_info) + \
1721+
sizeof(build_info))
1722+
1723+
BUILD_ASSERT(CONFIG_BT_RX_BUF_LEN >= BUILD_INFO_EVT_LEN);
1724+
1725+
rp = cmd_complete(evt, sizeof(*rp) + sizeof(build_info));
1726+
rp->status = 0x00;
1727+
memcpy(rp->info, build_info, sizeof(build_info));
1728+
}
1729+
17071730
static void vs_read_static_addrs(struct net_buf *buf, struct net_buf **evt)
17081731
{
17091732
struct bt_hci_rp_vs_read_static_addrs *rp;
@@ -1809,6 +1832,10 @@ static int vendor_cmd_handle(u16_t ocf, struct net_buf *cmd,
18091832
break;
18101833

18111834
#if defined(CONFIG_BT_CTLR_HCI_VS_EXT)
1835+
case BT_OCF(BT_HCI_OP_VS_READ_BUILD_INFO):
1836+
vs_read_build_info(cmd, evt);
1837+
break;
1838+
18121839
case BT_OCF(BT_HCI_OP_VS_WRITE_BD_ADDR):
18131840
vs_write_bd_addr(cmd, evt);
18141841
break;

0 commit comments

Comments
 (0)