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 <carles.cufi@nordicsemi.no>
This commit is contained in:
Carles Cufi 2017-09-25 14:19:18 +02:00 committed by Carles Cufí
parent 573c1c9071
commit 3b2120f500
2 changed files with 40 additions and 2 deletions

View file

@ -37,6 +37,17 @@ config BT_CTLR_HCI_VS_EXT
Enable support for the Zephyr HCI Vendor-Specific Extensions in the
Controller.
config BT_CTLR_HCI_VS_BUILD_INFO
string "Zephyr HCI VS Build Info string"
default ""
depends on BT_CTLR_HCI_VS_EXT
help
User-defined string that will be returned by the Zephyr VS Read Build
Information command after the Zephyr version and build time. When
setting this to a value different from an empty string, a space
character is required at the beginning to separate it from the
already included information.
config BT_CTLR_DUP_FILTER_LEN
prompt "Number of addresses in the scan duplicate filter"
int

View file

@ -1674,8 +1674,8 @@ static void vs_read_supported_commands(struct net_buf *buf,
/* Set Version Information, Supported Commands, Supported Features. */
rp->commands[0] |= BIT(0) | BIT(1) | BIT(2);
#if defined(CONFIG_BT_CTLR_HCI_VS_EXT)
/* Write BD_ADDR */
rp->commands[0] |= BIT(5);
/* Write BD_ADDR, Read Build Info */
rp->commands[0] |= BIT(5) | BIT(7);
/* Read Static Addresses, Read Key Hierarchy Roots */
rp->commands[1] |= BIT(0) | BIT(1);
#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)
ccst->status = 0x00;
}
static void vs_read_build_info(struct net_buf *buf, struct net_buf **evt)
{
struct bt_hci_rp_vs_read_build_info *rp;
#define BUILD_TIMESTAMP " " __DATE__ " " __TIME__
#define HCI_VS_BUILD_INFO "Zephyr OS v" \
KERNEL_VERSION_STRING BUILD_TIMESTAMP CONFIG_BT_CTLR_HCI_VS_BUILD_INFO
const char build_info[] = HCI_VS_BUILD_INFO;
#define BUILD_INFO_EVT_LEN (sizeof(struct bt_hci_evt_hdr) + \
sizeof(struct bt_hci_evt_cmd_complete) + \
sizeof(struct bt_hci_rp_vs_read_build_info) + \
sizeof(build_info))
BUILD_ASSERT(CONFIG_BT_RX_BUF_LEN >= BUILD_INFO_EVT_LEN);
rp = cmd_complete(evt, sizeof(*rp) + sizeof(build_info));
rp->status = 0x00;
memcpy(rp->info, build_info, sizeof(build_info));
}
static void vs_read_static_addrs(struct net_buf *buf, struct net_buf **evt)
{
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,
break;
#if defined(CONFIG_BT_CTLR_HCI_VS_EXT)
case BT_OCF(BT_HCI_OP_VS_READ_BUILD_INFO):
vs_read_build_info(cmd, evt);
break;
case BT_OCF(BT_HCI_OP_VS_WRITE_BD_ADDR):
vs_write_bd_addr(cmd, evt);
break;