Bluetooth: controller: Add skeleton for vendor HCI commands
Signed-off-by: Marcel Holtmann <marcel.holtmann@intel.com>
This commit is contained in:
parent
a8173b9033
commit
aefcf547ad
2 changed files with 109 additions and 1 deletions
44
include/bluetooth/hci_vs.h
Normal file
44
include/bluetooth/hci_vs.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* hci_vs.h - Bluetooth Host Control Interface Vendor Specific definitions */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015-2016 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef __BT_HCI_VS_H
|
||||
#define __BT_HCI_VS_H
|
||||
|
||||
#include <bluetooth/hci.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BT_HCI_OP_VS_READ_VERSION_INFO BT_OP(BT_OGF_VS, 0x0001)
|
||||
struct bt_hci_rp_vs_read_version_info {
|
||||
u8_t status;
|
||||
u16_t hw_platform;
|
||||
u16_t hw_variant;
|
||||
u8_t fw_variant;
|
||||
u8_t fw_version;
|
||||
u16_t fw_revision;
|
||||
u32_t fw_build;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_OP_VS_READ_SUPPORTED_COMMANDS BT_OP(BT_OGF_VS, 0x0002)
|
||||
struct bt_hci_rp_vs_read_supported_commands {
|
||||
u8_t status;
|
||||
u8_t commands[64];
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_OP_VS_READ_SUPPORTED_FEATURES BT_OP(BT_OGF_VS, 0x0003)
|
||||
struct bt_hci_rp_vs_read_supported_features {
|
||||
u8_t status;
|
||||
u8_t features[8];
|
||||
} __packed;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BT_HCI_VS_H */
|
|
@ -14,6 +14,7 @@
|
|||
#include <errno.h>
|
||||
#include <atomic.h>
|
||||
#include <bluetooth/hci.h>
|
||||
#include <bluetooth/hci_vs.h>
|
||||
#include <bluetooth/buf.h>
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <misc/byteorder.h>
|
||||
|
@ -1393,6 +1394,69 @@ static int controller_cmd_handle(u16_t ocf, struct net_buf *cmd,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void vs_read_version_info(struct net_buf *buf, struct net_buf **evt)
|
||||
{
|
||||
struct bt_hci_rp_vs_read_version_info *rp;
|
||||
|
||||
rp = cmd_complete(evt, sizeof(*rp));
|
||||
|
||||
rp->status = 0x00;
|
||||
rp->hw_platform = sys_cpu_to_le16(0);
|
||||
rp->hw_variant = sys_cpu_to_le16(0);
|
||||
rp->fw_variant = 0;
|
||||
rp->fw_version = 0;
|
||||
rp->fw_revision = sys_cpu_to_le16(0);
|
||||
rp->fw_build = sys_cpu_to_le32(0);
|
||||
}
|
||||
|
||||
static void vs_read_supported_commands(struct net_buf *buf,
|
||||
struct net_buf **evt)
|
||||
{
|
||||
struct bt_hci_rp_vs_read_supported_commands *rp;
|
||||
|
||||
rp = cmd_complete(evt, sizeof(*rp));
|
||||
|
||||
rp->status = 0x00;
|
||||
memset(&rp->commands[0], 0, sizeof(rp->commands));
|
||||
|
||||
/* Set Version Information, Supported Commands, Supported Features. */
|
||||
rp->commands[0] |= BIT(0) | BIT(1) | BIT(2);
|
||||
}
|
||||
|
||||
static void vs_read_supported_features(struct net_buf *buf,
|
||||
struct net_buf **evt)
|
||||
{
|
||||
struct bt_hci_rp_vs_read_supported_features *rp;
|
||||
|
||||
rp = cmd_complete(evt, sizeof(*rp));
|
||||
|
||||
rp->status = 0x00;
|
||||
memset(&rp->features[0], 0x00, sizeof(rp->features));
|
||||
}
|
||||
|
||||
static int vendor_cmd_handle(u16_t ocf, struct net_buf *cmd,
|
||||
struct net_buf **evt)
|
||||
{
|
||||
switch (ocf) {
|
||||
case BT_OCF(BT_HCI_OP_VS_READ_VERSION_INFO):
|
||||
vs_read_version_info(cmd, evt);
|
||||
break;
|
||||
|
||||
case BT_OCF(BT_HCI_OP_VS_READ_SUPPORTED_COMMANDS):
|
||||
vs_read_supported_commands(cmd, evt);
|
||||
break;
|
||||
|
||||
case BT_OCF(BT_HCI_OP_VS_READ_SUPPORTED_FEATURES):
|
||||
vs_read_supported_features(cmd, evt);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct net_buf *hci_cmd_handle(struct net_buf *cmd)
|
||||
{
|
||||
struct bt_hci_evt_cc_status *ccst;
|
||||
|
@ -1433,7 +1497,7 @@ struct net_buf *hci_cmd_handle(struct net_buf *cmd)
|
|||
err = controller_cmd_handle(ocf, cmd, &evt);
|
||||
break;
|
||||
case BT_OGF_VS:
|
||||
err = -EINVAL;
|
||||
err = vendor_cmd_handle(ocf, cmd, &evt);
|
||||
break;
|
||||
default:
|
||||
err = -EINVAL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue