2015-04-20 14:11:02 +02:00
|
|
|
/* hci_core.h - Bluetooth HCI core access */
|
|
|
|
|
|
|
|
/*
|
2016-06-10 11:10:18 +02:00
|
|
|
* Copyright (c) 2015-2016 Intel Corporation
|
2015-04-20 14:11:02 +02:00
|
|
|
*
|
2017-01-19 02:01:01 +01:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-20 14:11:02 +02:00
|
|
|
*/
|
|
|
|
|
2015-08-10 21:53:45 +02:00
|
|
|
/* LL connection parameters */
|
|
|
|
#define LE_CONN_LATENCY 0x0000
|
|
|
|
#define LE_CONN_TIMEOUT 0x002a
|
|
|
|
|
2017-08-09 08:21:11 +02:00
|
|
|
#if defined(CONFIG_BT_BREDR)
|
2016-08-26 14:39:51 +02:00
|
|
|
#define LMP_FEAT_PAGES_COUNT 3
|
2016-08-28 07:29:39 +02:00
|
|
|
#else
|
|
|
|
#define LMP_FEAT_PAGES_COUNT 1
|
|
|
|
#endif
|
2016-08-26 14:39:51 +02:00
|
|
|
|
Bluetooth: HFP HF: SCO: Accept eSCO conn request
1. Accept the incoming Synchronous connection request and establish
a new sco connection object.
2. Enable sco conn complete in event_mask
> HCI Event: Connect Request (0x04) plen 10 [hci0] 126.198264
Address: 48:9D:24:1F:4D:1D (BlackBerry RTS)
Class: 0x7a020c
Major class: Phone (cellular, cordless, payphone, modem)
Minor class: Smart phone
Networking (LAN, Ad hoc)
Capturing (Scanner, Microphone)
Object Transfer (v-Inbox, v-Folder)
Audio (Speaker, Microphone, Headset)
Telephony (Cordless telephony, Modem, Headset)
Link type: eSCO (0x02)
< HCI Command: Accept Synchronous Co.. (0x01|0x0029) plen 21
Address: 48:9D:24:1F:4D:1D (BlackBerry RTS)
Transmit bandwidth: 8000
Receive bandwidth: 8000
Max latency: 7
Setting: 0x0060
Input Coding: Linear
Input Data Format: 2's complement
Input Sample Size: 16-bit
# of bits padding at MSB: 0
Air Coding Format: CVSD
Retransmission effort: Optimize for power consumption (0x01)
Packet type: 0x0006
HV2 may be used
HV3 may be used
> HCI Event: Command Status (0x0f) plen 4 [hci0] 126.205171
Accept Synchronous Connection Request (0x01|0x0029) ncmd 1
Status: Success (0x00)
Change-Id: I71597aef94e945a9c07be1960994ad20c1b44bb3
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
2017-02-15 09:59:11 +01:00
|
|
|
/* SCO settings */
|
|
|
|
#define BT_VOICE_CVSD_16BIT 0x0060
|
|
|
|
|
2017-02-02 13:39:28 +01:00
|
|
|
/* k_poll event tags */
|
|
|
|
enum {
|
|
|
|
BT_EVENT_CMD_TX,
|
2017-03-17 07:02:57 +01:00
|
|
|
BT_EVENT_CONN_TX_NOTIFY,
|
|
|
|
BT_EVENT_CONN_TX_QUEUE,
|
2017-02-02 13:39:28 +01:00
|
|
|
};
|
|
|
|
|
2015-07-23 11:35:59 +02:00
|
|
|
/* bt_dev flags: the flags defined here represent BT controller state */
|
|
|
|
enum {
|
2016-05-30 14:20:42 +02:00
|
|
|
BT_DEV_ENABLE,
|
2015-12-04 09:33:34 +01:00
|
|
|
BT_DEV_READY,
|
2016-05-09 11:41:14 +02:00
|
|
|
BT_DEV_ID_STATIC_RANDOM,
|
2016-06-30 19:05:36 +02:00
|
|
|
BT_DEV_HAS_PUB_KEY,
|
|
|
|
BT_DEV_PUB_KEY_BUSY,
|
2015-12-04 09:33:34 +01:00
|
|
|
|
2015-07-23 11:35:59 +02:00
|
|
|
BT_DEV_ADVERTISING,
|
2016-02-17 09:43:04 +01:00
|
|
|
BT_DEV_KEEP_ADVERTISING,
|
2015-07-23 11:35:59 +02:00
|
|
|
BT_DEV_SCANNING,
|
2015-12-03 18:41:42 +01:00
|
|
|
BT_DEV_EXPLICIT_SCAN,
|
2016-07-14 15:30:38 +02:00
|
|
|
BT_DEV_ACTIVE_SCAN,
|
2017-10-05 17:20:25 +02:00
|
|
|
BT_DEV_SCAN_FILTER_DUP,
|
2015-12-03 18:35:02 +01:00
|
|
|
|
2016-09-13 12:49:53 +02:00
|
|
|
BT_DEV_RPA_VALID,
|
|
|
|
|
2017-10-05 21:01:55 +02:00
|
|
|
BT_DEV_ID_PENDING,
|
|
|
|
|
2017-08-09 08:21:11 +02:00
|
|
|
#if defined(CONFIG_BT_BREDR)
|
2015-11-26 14:47:11 +01:00
|
|
|
BT_DEV_ISCAN,
|
|
|
|
BT_DEV_PSCAN,
|
2016-03-10 11:58:56 +01:00
|
|
|
BT_DEV_INQUIRY,
|
2017-08-09 08:21:11 +02:00
|
|
|
#endif /* CONFIG_BT_BREDR */
|
2016-07-26 19:28:06 +02:00
|
|
|
|
|
|
|
/* Total number of flags - must be at the end of the enum */
|
|
|
|
BT_DEV_NUM_FLAGS,
|
2015-07-23 11:35:59 +02:00
|
|
|
};
|
|
|
|
|
2015-11-03 11:19:19 +01:00
|
|
|
struct bt_dev_le {
|
|
|
|
/* LE features */
|
2017-05-06 07:08:56 +02:00
|
|
|
u8_t features[8];
|
2016-08-30 06:08:27 +02:00
|
|
|
/* LE states */
|
2017-04-21 08:01:26 +02:00
|
|
|
u64_t states;
|
2015-11-03 11:19:19 +01:00
|
|
|
|
2017-08-09 08:21:11 +02:00
|
|
|
#if defined(CONFIG_BT_CONN)
|
2015-11-03 11:19:19 +01:00
|
|
|
/* Controller buffer information */
|
2017-04-21 08:01:26 +02:00
|
|
|
u16_t mtu;
|
2016-10-27 11:32:30 +02:00
|
|
|
struct k_sem pkts;
|
2017-08-09 08:21:11 +02:00
|
|
|
#endif /* CONFIG_BT_CONN */
|
2017-10-05 08:43:56 +02:00
|
|
|
|
|
|
|
#if defined(CONFIG_BT_SMP)
|
|
|
|
/* Size of the the controller resolving list */
|
|
|
|
u8_t rl_size;
|
|
|
|
/* Number of entries in the resolving list. rl_entries > rl_size
|
|
|
|
* means that host-side resolving is used.
|
|
|
|
*/
|
|
|
|
u8_t rl_entries;
|
|
|
|
#endif /* CONFIG_BT_SMP */
|
2015-11-03 11:19:19 +01:00
|
|
|
};
|
|
|
|
|
2017-08-09 08:21:11 +02:00
|
|
|
#if defined(CONFIG_BT_BREDR)
|
2015-11-16 14:29:30 +01:00
|
|
|
struct bt_dev_br {
|
|
|
|
/* Max controller's acceptable ACL packet length */
|
2017-04-21 12:47:08 +02:00
|
|
|
u16_t mtu;
|
|
|
|
struct k_sem pkts;
|
|
|
|
u16_t esco_pkt_type;
|
2015-11-16 14:29:30 +01:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2017-10-17 11:06:12 +02:00
|
|
|
/* The theoretical max for these is 8 and 64, but there's no point
|
|
|
|
* in allocating the full memory if we only support a small subset.
|
|
|
|
* These values must be updated whenever the host implementation is
|
|
|
|
* extended beyond the current values.
|
|
|
|
*/
|
|
|
|
#define BT_DEV_VS_FEAT_MAX 1
|
|
|
|
#define BT_DEV_VS_CMDS_MAX 2
|
|
|
|
|
2015-04-20 14:11:02 +02:00
|
|
|
/* State tracking for the local Bluetooth controller */
|
|
|
|
struct bt_dev {
|
2016-04-02 08:42:08 +02:00
|
|
|
/* Local Identity Address */
|
|
|
|
bt_addr_le_t id_addr;
|
|
|
|
|
|
|
|
/* Current local Random Address */
|
|
|
|
bt_addr_le_t random_addr;
|
|
|
|
|
2015-04-20 14:11:02 +02:00
|
|
|
/* Controller version & manufacturer information */
|
2017-04-20 19:00:29 +02:00
|
|
|
u8_t hci_version;
|
|
|
|
u8_t lmp_version;
|
2017-04-21 08:01:26 +02:00
|
|
|
u16_t hci_revision;
|
|
|
|
u16_t lmp_subversion;
|
|
|
|
u16_t manufacturer;
|
2015-04-20 14:11:02 +02:00
|
|
|
|
2016-08-26 14:39:51 +02:00
|
|
|
/* LMP features (pages 0, 1, 2) */
|
2017-04-20 19:00:29 +02:00
|
|
|
u8_t features[LMP_FEAT_PAGES_COUNT][8];
|
2015-04-20 14:11:02 +02:00
|
|
|
|
2015-10-21 16:09:37 +02:00
|
|
|
/* Supported commands */
|
2017-04-20 19:00:29 +02:00
|
|
|
u8_t supported_commands[64];
|
2015-10-21 16:09:37 +02:00
|
|
|
|
2017-10-17 11:06:12 +02:00
|
|
|
#if defined(CONFIG_BT_HCI_VS_EXT)
|
|
|
|
/* Vendor HCI support */
|
|
|
|
u8_t vs_features[BT_DEV_VS_FEAT_MAX];
|
|
|
|
u8_t vs_commands[BT_DEV_VS_CMDS_MAX];
|
|
|
|
#endif
|
|
|
|
|
2016-12-21 20:09:27 +01:00
|
|
|
struct k_work init;
|
|
|
|
|
2016-07-26 19:28:06 +02:00
|
|
|
ATOMIC_DEFINE(flags, BT_DEV_NUM_FLAGS);
|
2015-05-08 10:33:34 +02:00
|
|
|
|
2015-11-03 11:19:19 +01:00
|
|
|
/* LE controller specific features */
|
|
|
|
struct bt_dev_le le;
|
2015-04-20 14:11:02 +02:00
|
|
|
|
2017-08-09 08:21:11 +02:00
|
|
|
#if defined(CONFIG_BT_BREDR)
|
2015-11-16 14:29:30 +01:00
|
|
|
/* BR/EDR controller specific features */
|
|
|
|
struct bt_dev_br br;
|
|
|
|
#endif
|
|
|
|
|
2015-04-20 14:11:02 +02:00
|
|
|
/* Number of commands controller can accept */
|
2016-10-27 11:32:30 +02:00
|
|
|
struct k_sem ncmd_sem;
|
2015-04-20 14:11:02 +02:00
|
|
|
|
|
|
|
/* Last sent HCI command */
|
2015-10-28 09:34:15 +01:00
|
|
|
struct net_buf *sent_cmd;
|
2015-04-20 14:11:02 +02:00
|
|
|
|
2017-08-09 08:21:11 +02:00
|
|
|
#if !defined(CONFIG_BT_RECV_IS_RX_THREAD)
|
2015-04-20 14:11:02 +02:00
|
|
|
/* Queue for incoming HCI events & ACL data */
|
2016-11-10 10:45:10 +01:00
|
|
|
struct k_fifo rx_queue;
|
2016-12-21 20:09:27 +01:00
|
|
|
#endif
|
2015-04-20 14:11:02 +02:00
|
|
|
|
2015-06-03 18:47:06 +02:00
|
|
|
/* Queue for high priority HCI events which may unlock waiters
|
2016-11-11 09:06:05 +01:00
|
|
|
* in other threads. Such events include Number of Completed
|
2015-06-03 18:47:06 +02:00
|
|
|
* Packets, as well as the Command Complete/Status events.
|
|
|
|
*/
|
2016-11-10 10:45:10 +01:00
|
|
|
struct k_fifo rx_prio_queue;
|
2015-05-23 18:58:06 +02:00
|
|
|
|
2015-04-20 14:11:02 +02:00
|
|
|
/* Queue for outgoing HCI commands */
|
2016-11-10 10:45:10 +01:00
|
|
|
struct k_fifo cmd_tx_queue;
|
2015-04-20 14:11:02 +02:00
|
|
|
|
|
|
|
/* Registered HCI driver */
|
2017-03-14 14:00:15 +01:00
|
|
|
const struct bt_hci_driver *drv;
|
2016-04-04 11:55:11 +02:00
|
|
|
|
2017-08-09 08:21:11 +02:00
|
|
|
#if defined(CONFIG_BT_PRIVACY)
|
2016-04-04 11:55:11 +02:00
|
|
|
/* Local Identity Resolving Key */
|
2017-04-20 19:00:29 +02:00
|
|
|
u8_t irk[16];
|
2016-07-19 11:55:21 +02:00
|
|
|
|
|
|
|
/* Work used for RPA rotation */
|
2016-11-10 13:20:02 +01:00
|
|
|
struct k_delayed_work rpa_update;
|
2016-04-04 11:55:11 +02:00
|
|
|
#endif
|
2015-04-20 14:11:02 +02:00
|
|
|
};
|
2015-04-28 13:27:19 +02:00
|
|
|
|
2015-07-15 12:53:17 +02:00
|
|
|
extern struct bt_dev bt_dev;
|
2016-04-05 09:14:32 +02:00
|
|
|
extern const struct bt_storage *bt_storage;
|
2017-08-09 08:21:11 +02:00
|
|
|
#if defined(CONFIG_BT_SMP) || defined(CONFIG_BT_BREDR)
|
2016-01-14 21:12:28 +01:00
|
|
|
extern const struct bt_conn_auth_cb *bt_auth;
|
2017-08-09 08:21:11 +02:00
|
|
|
#endif /* CONFIG_BT_SMP || CONFIG_BT_BREDR */
|
2015-07-15 12:53:17 +02:00
|
|
|
|
2017-01-13 12:20:22 +01:00
|
|
|
bool bt_le_conn_params_valid(const struct bt_le_conn_param *param);
|
2015-07-29 12:45:33 +02:00
|
|
|
|
2017-04-20 19:00:29 +02:00
|
|
|
struct net_buf *bt_hci_cmd_create(u16_t opcode, u8_t param_len);
|
|
|
|
int bt_hci_cmd_send(u16_t opcode, struct net_buf *buf);
|
|
|
|
int bt_hci_cmd_send_sync(u16_t opcode, struct net_buf *buf,
|
2015-10-28 09:34:15 +01:00
|
|
|
struct net_buf **rsp);
|
2015-05-08 20:53:39 +02:00
|
|
|
|
2015-12-03 21:51:16 +01:00
|
|
|
int bt_le_scan_update(bool fast_scan);
|
2016-04-04 12:38:16 +02:00
|
|
|
|
|
|
|
bool bt_addr_le_is_bonded(const bt_addr_le_t *addr);
|
2016-04-20 13:46:48 +02:00
|
|
|
|
|
|
|
int bt_send(struct net_buf *buf);
|
2016-05-24 17:15:03 +02:00
|
|
|
|
2017-04-20 19:00:29 +02:00
|
|
|
u16_t bt_hci_get_cmd_opcode(struct net_buf *buf);
|
2017-10-05 08:43:56 +02:00
|
|
|
|
2017-10-05 21:01:55 +02:00
|
|
|
/* Don't require everyone to include keys.h */
|
|
|
|
struct bt_keys;
|
|
|
|
int bt_id_add(struct bt_keys *keys);
|
|
|
|
int bt_id_del(struct bt_keys *keys);
|