2015-04-20 15:11:02 +03:00
|
|
|
/* hci_core.h - Bluetooth HCI core access */
|
|
|
|
|
|
|
|
/*
|
2016-06-10 12:10:18 +03:00
|
|
|
* Copyright (c) 2015-2016 Intel Corporation
|
2015-04-20 15:11:02 +03:00
|
|
|
*
|
2017-01-18 17:01:01 -08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-04-20 15:11:02 +03: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 09:21:11 +03:00
|
|
|
#if defined(CONFIG_BT_BREDR)
|
2016-08-26 14:39:51 +02:00
|
|
|
#define LMP_FEAT_PAGES_COUNT 3
|
2016-08-28 08:29:39 +03: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 14:29:11 +05:30
|
|
|
/* SCO settings */
|
|
|
|
#define BT_VOICE_CVSD_16BIT 0x0060
|
|
|
|
|
2017-02-02 14:39:28 +02:00
|
|
|
/* k_poll event tags */
|
|
|
|
enum {
|
|
|
|
BT_EVENT_CMD_TX,
|
2017-03-17 08:02:57 +02:00
|
|
|
BT_EVENT_CONN_TX_QUEUE,
|
2017-02-02 14:39:28 +02: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 10:33:34 +02:00
|
|
|
BT_DEV_READY,
|
2018-07-16 14:39:06 +03:00
|
|
|
BT_DEV_PRESET_ID,
|
2016-06-30 20:05:36 +03:00
|
|
|
BT_DEV_HAS_PUB_KEY,
|
|
|
|
BT_DEV_PUB_KEY_BUSY,
|
2015-12-04 10:33:34 +02:00
|
|
|
|
2015-07-23 11:35:59 +02:00
|
|
|
BT_DEV_ADVERTISING,
|
2018-07-10 10:14:23 +03:00
|
|
|
BT_DEV_ADVERTISING_NAME,
|
2018-10-25 15:20:09 +02:00
|
|
|
BT_DEV_ADVERTISING_CONNECTABLE,
|
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 19:41:42 +02:00
|
|
|
BT_DEV_EXPLICIT_SCAN,
|
2016-07-14 15:30:38 +02:00
|
|
|
BT_DEV_ACTIVE_SCAN,
|
2017-10-05 18:20:25 +03:00
|
|
|
BT_DEV_SCAN_FILTER_DUP,
|
2019-07-22 13:13:38 +02:00
|
|
|
BT_DEV_SCAN_WL,
|
|
|
|
BT_DEV_AUTO_CONN,
|
2015-12-03 19:35:02 +02:00
|
|
|
|
2016-09-13 13:49:53 +03:00
|
|
|
BT_DEV_RPA_VALID,
|
|
|
|
|
2017-10-05 22:01:55 +03:00
|
|
|
BT_DEV_ID_PENDING,
|
2019-12-05 13:50:55 +01:00
|
|
|
BT_DEV_STORE_ID,
|
2017-10-05 22:01:55 +03:00
|
|
|
|
2017-08-09 09:21:11 +03: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 09:21:11 +03:00
|
|
|
#endif /* CONFIG_BT_BREDR */
|
2016-07-26 20:28:06 +03: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
|
|
|
};
|
|
|
|
|
2018-05-10 17:25:25 +03:00
|
|
|
/* Flags which should not be cleared upon HCI_Reset */
|
|
|
|
#define BT_DEV_PERSISTENT_FLAGS (BIT(BT_DEV_ENABLE) | \
|
2019-12-05 13:50:55 +01:00
|
|
|
BIT(BT_DEV_PRESET_ID))
|
2018-05-10 17:25:25 +03: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 09:01:26 +03:00
|
|
|
u64_t states;
|
2015-11-03 11:19:19 +01:00
|
|
|
|
2017-08-09 09:21:11 +03:00
|
|
|
#if defined(CONFIG_BT_CONN)
|
2015-11-03 11:19:19 +01:00
|
|
|
/* Controller buffer information */
|
2017-04-21 09:01:26 +03:00
|
|
|
u16_t mtu;
|
2016-10-27 11:32:30 +02:00
|
|
|
struct k_sem pkts;
|
2017-08-09 09:21:11 +03:00
|
|
|
#endif /* CONFIG_BT_CONN */
|
2017-10-05 09:43:56 +03: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 09:21:11 +03: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 13:47:08 +03: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 12:06:12 +03: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 15:11:02 +03:00
|
|
|
/* State tracking for the local Bluetooth controller */
|
|
|
|
struct bt_dev {
|
2018-07-04 12:58:10 +03:00
|
|
|
/* Local Identity Address(es) */
|
|
|
|
bt_addr_le_t id_addr[CONFIG_BT_ID_MAX];
|
|
|
|
u8_t id_count;
|
|
|
|
|
|
|
|
/* ID Address used for advertising */
|
|
|
|
u8_t adv_id;
|
2016-04-02 09:42:08 +03:00
|
|
|
|
|
|
|
/* Current local Random Address */
|
|
|
|
bt_addr_le_t random_addr;
|
|
|
|
|
2015-04-20 15:11:02 +03:00
|
|
|
/* Controller version & manufacturer information */
|
2017-04-20 12:00:29 -05:00
|
|
|
u8_t hci_version;
|
|
|
|
u8_t lmp_version;
|
2017-04-21 09:01:26 +03:00
|
|
|
u16_t hci_revision;
|
|
|
|
u16_t lmp_subversion;
|
|
|
|
u16_t manufacturer;
|
2015-04-20 15:11:02 +03:00
|
|
|
|
2016-08-26 14:39:51 +02:00
|
|
|
/* LMP features (pages 0, 1, 2) */
|
2017-04-20 12:00:29 -05:00
|
|
|
u8_t features[LMP_FEAT_PAGES_COUNT][8];
|
2015-04-20 15:11:02 +03:00
|
|
|
|
2015-10-21 16:09:37 +02:00
|
|
|
/* Supported commands */
|
2017-04-20 12:00:29 -05:00
|
|
|
u8_t supported_commands[64];
|
2015-10-21 16:09:37 +02:00
|
|
|
|
2017-10-17 12:06:12 +03: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 21:09:27 +02:00
|
|
|
struct k_work init;
|
|
|
|
|
2016-07-26 20:28:06 +03: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 15:11:02 +03:00
|
|
|
|
2017-08-09 09:21:11 +03: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 15:11:02 +03:00
|
|
|
/* Number of commands controller can accept */
|
2016-10-27 11:32:30 +02:00
|
|
|
struct k_sem ncmd_sem;
|
2015-04-20 15:11:02 +03:00
|
|
|
|
|
|
|
/* Last sent HCI command */
|
2015-10-28 10:34:15 +02:00
|
|
|
struct net_buf *sent_cmd;
|
2015-04-20 15:11:02 +03:00
|
|
|
|
2017-08-09 09:21:11 +03:00
|
|
|
#if !defined(CONFIG_BT_RECV_IS_RX_THREAD)
|
2015-04-20 15:11:02 +03:00
|
|
|
/* Queue for incoming HCI events & ACL data */
|
2016-11-10 10:45:10 +01:00
|
|
|
struct k_fifo rx_queue;
|
2016-12-21 21:09:27 +02:00
|
|
|
#endif
|
2015-04-20 15:11:02 +03:00
|
|
|
|
|
|
|
/* Queue for outgoing HCI commands */
|
2016-11-10 10:45:10 +01:00
|
|
|
struct k_fifo cmd_tx_queue;
|
2015-04-20 15:11:02 +03:00
|
|
|
|
|
|
|
/* Registered HCI driver */
|
2017-03-14 15:00:15 +02:00
|
|
|
const struct bt_hci_driver *drv;
|
2016-04-04 12:55:11 +03:00
|
|
|
|
2017-08-09 09:21:11 +03:00
|
|
|
#if defined(CONFIG_BT_PRIVACY)
|
2016-04-04 12:55:11 +03:00
|
|
|
/* Local Identity Resolving Key */
|
2018-07-04 12:58:10 +03:00
|
|
|
u8_t irk[CONFIG_BT_ID_MAX][16];
|
2016-07-19 11:55:21 +02:00
|
|
|
|
|
|
|
/* Work used for RPA rotation */
|
2016-11-10 14:20:02 +02:00
|
|
|
struct k_delayed_work rpa_update;
|
2016-04-04 12:55:11 +03:00
|
|
|
#endif
|
2018-07-09 15:12:04 +03:00
|
|
|
|
|
|
|
/* Local Name */
|
2018-07-31 19:57:08 +02:00
|
|
|
#if defined(CONFIG_BT_DEVICE_NAME_DYNAMIC)
|
2019-04-01 13:06:24 +03:00
|
|
|
char name[CONFIG_BT_DEVICE_NAME_MAX + 1];
|
2018-07-31 19:57:08 +02:00
|
|
|
#endif
|
2015-04-20 15:11:02 +03:00
|
|
|
};
|
2015-04-28 14:27:19 +03:00
|
|
|
|
2015-07-15 13:53:17 +03:00
|
|
|
extern struct bt_dev bt_dev;
|
2017-08-09 09:21:11 +03:00
|
|
|
#if defined(CONFIG_BT_SMP) || defined(CONFIG_BT_BREDR)
|
2016-01-14 22:12:28 +02:00
|
|
|
extern const struct bt_conn_auth_cb *bt_auth;
|
2017-08-09 09:21:11 +03:00
|
|
|
#endif /* CONFIG_BT_SMP || CONFIG_BT_BREDR */
|
2015-07-15 13:53:17 +03:00
|
|
|
|
2020-01-15 14:30:27 +01:00
|
|
|
int bt_hci_disconnect(u16_t handle, u8_t reason);
|
|
|
|
|
2017-01-13 13:20:22 +02:00
|
|
|
bool bt_le_conn_params_valid(const struct bt_le_conn_param *param);
|
2015-07-29 13:45:33 +03:00
|
|
|
|
2015-12-03 22:51:16 +02:00
|
|
|
int bt_le_scan_update(bool fast_scan);
|
2016-04-04 13:38:16 +03:00
|
|
|
|
2020-01-06 14:32:07 +01:00
|
|
|
int bt_le_direct_conn(const struct bt_conn *conn);
|
2019-07-22 13:13:38 +02:00
|
|
|
int bt_le_auto_conn(const struct bt_le_conn_param *conn_param);
|
2019-11-21 17:49:55 +01:00
|
|
|
int bt_le_auto_conn_cancel(void);
|
2019-07-22 13:13:38 +02:00
|
|
|
|
2018-07-04 12:58:10 +03:00
|
|
|
bool bt_addr_le_is_bonded(u8_t id, const bt_addr_le_t *addr);
|
2019-08-02 16:04:01 +02:00
|
|
|
const bt_addr_le_t *bt_lookup_id_addr(u8_t id, const bt_addr_le_t *addr);
|
2016-04-20 14:46:48 +03:00
|
|
|
|
|
|
|
int bt_send(struct net_buf *buf);
|
2016-05-24 17:15:03 +02:00
|
|
|
|
2017-10-05 22:01:55 +03:00
|
|
|
/* Don't require everyone to include keys.h */
|
|
|
|
struct bt_keys;
|
2018-08-08 10:28:31 +03:00
|
|
|
void bt_id_add(struct bt_keys *keys);
|
|
|
|
void bt_id_del(struct bt_keys *keys);
|
2018-04-26 22:05:26 +03:00
|
|
|
|
2019-12-05 13:50:55 +01:00
|
|
|
int bt_setup_random_id_addr(void);
|
|
|
|
void bt_setup_public_id_addr(void);
|
|
|
|
|
2019-03-22 12:45:09 +02:00
|
|
|
void bt_finalize_init(void);
|
2018-08-20 14:44:42 +02:00
|
|
|
|
|
|
|
int bt_le_adv_start_internal(const struct bt_le_adv_param *param,
|
|
|
|
const struct bt_data *ad, size_t ad_len,
|
|
|
|
const struct bt_data *sd, size_t sd_len,
|
|
|
|
const bt_addr_le_t *peer);
|
2020-01-07 14:16:49 +01:00
|
|
|
void bt_le_adv_resume(void);
|