Microchip® Advanced Software Framework

hci.h File Reference
#include "btstack_config.h"
#include "btstack_chipset.h"
#include "btstack_control.h"
#include "btstack_linked_list.h"
#include "btstack_util.h"
#include "classic/btstack_link_key_db.h"
#include "hci_cmd.h"
#include "gap.h"
#include "hci_transport.h"
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>

Data Structures

struct  hci_connection_t
 
struct  hci_stack_t
 main data structure More...
 
struct  whitelist_entry_t
 

Macros

#define HCI_ACL_BUFFER_SIZE   (HCI_ACL_HEADER_SIZE + HCI_ACL_PAYLOAD_SIZE)
 
#define HCI_CMD_BUFFER_SIZE   (HCI_CMD_HEADER_SIZE + HCI_CMD_PAYLOAD_SIZE_LE)
 
#define HCI_CMD_PAYLOAD_SIZE_LE   32
 
#define HCI_EVENT_BUFFER_SIZE   (HCI_EVENT_HEADER_SIZE + HCI_EVENT_PAYLOAD_SIZE + 1)
 
#define HCI_EVENT_IS_COMMAND_COMPLETE(event, cmd)   ( event[0] == HCI_EVENT_COMMAND_COMPLETE && little_endian_read_16(event,3) == cmd.opcode)
 
#define HCI_EVENT_IS_COMMAND_STATUS(event, cmd)   ( event[0] == HCI_EVENT_COMMAND_STATUS && little_endian_read_16(event,4) == cmd.opcode)
 
#define HCI_INCOMING_PRE_BUFFER_SIZE   0
 
#define HCI_OUTGOING_PRE_BUFFER_SIZE   1
 
#define HCI_PACKET_BUFFER_SIZE   HCI_CMD_BUFFER_SIZE
 
#define IS_COMMAND(packet, command)   (little_endian_read_16(packet,0) == command.opcode)
 
#define OFFSET_OF_DATA_IN_COMMAND_COMPLETE   5
 
#define READ_ACL_CONNECTION_HANDLE(buffer)   ( little_endian_read_16(buffer,0) & 0x0fff)
 
#define READ_ACL_FLAGS(buffer)   ( buffer[1] >> 4 )
 
#define READ_ACL_LENGTH(buffer)   (little_endian_read_16(buffer, 2))
 
#define READ_L2CAP_CHANNEL_ID(buffer)   ( little_endian_read_16(buffer, 6))
 
#define READ_L2CAP_LENGTH(buffer)   ( little_endian_read_16(buffer, 4))
 
#define READ_SCO_CONNECTION_HANDLE(buffer)   ( little_endian_read_16(buffer,0) & 0x0fff)
 

Typedefs

typedef enum hci_init_state hci_substate_t
 HCI Inititizlization State Machine. More...
 

Enumerations

enum  {
  BONDING_REQUEST_REMOTE_FEATURES = 0x01,
  BONDING_RECEIVED_REMOTE_FEATURES = 0x02,
  BONDING_REMOTE_SUPPORTS_SSP = 0x04,
  BONDING_DISCONNECT_SECURITY_BLOCK = 0x08,
  BONDING_DISCONNECT_DEDICATED_DONE = 0x10,
  BONDING_SEND_AUTHENTICATE_REQUEST = 0x20,
  BONDING_SEND_ENCRYPTION_REQUEST = 0x40,
  BONDING_DEDICATED = 0x80,
  BONDING_EMIT_COMPLETE_ON_DISCONNECT = 0x100
}
 
enum  {
  LE_ADVERTISEMENT_TASKS_DISABLE = 1 << 0,
  LE_ADVERTISEMENT_TASKS_SET_ADV_DATA = 1 << 1,
  LE_ADVERTISEMENT_TASKS_SET_SCAN_DATA = 1 << 2,
  LE_ADVERTISEMENT_TASKS_SET_PARAMS = 1 << 3,
  LE_ADVERTISEMENT_TASKS_ENABLE = 1 << 4
}
 
enum  {
  LE_WHITELIST_ON_CONTROLLER = 1 << 0,
  LE_WHITELIST_ADD_TO_CONTROLLER = 1 << 1,
  LE_WHITELIST_REMOVE_FROM_CONTROLLER = 1 << 2
}
 
enum  BLUETOOTH_STATE {
  BLUETOOTH_OFF = 1,
  BLUETOOTH_ON,
  BLUETOOTH_ACTIVE
}
 
enum  CONNECTION_STATE {
  SEND_CREATE_CONNECTION = 0,
  SENT_CREATE_CONNECTION,
  SEND_CANCEL_CONNECTION,
  SENT_CANCEL_CONNECTION,
  RECEIVED_CONNECTION_REQUEST,
  ACCEPTED_CONNECTION_REQUEST,
  REJECTED_CONNECTION_REQUEST,
  OPEN,
  SEND_DISCONNECT,
  SENT_DISCONNECT,
  RECEIVED_DISCONNECTION_COMPLETE
}
 Connection State. More...
 
enum  hci_authentication_flags_t {
  AUTH_FLAGS_NONE = 0x0000,
  RECV_LINK_KEY_REQUEST = 0x0001,
  HANDLE_LINK_KEY_REQUEST = 0x0002,
  SENT_LINK_KEY_REPLY = 0x0004,
  SENT_LINK_KEY_NEGATIVE_REQUEST = 0x0008,
  RECV_LINK_KEY_NOTIFICATION = 0x0010,
  DENY_PIN_CODE_REQUEST = 0x0040,
  RECV_IO_CAPABILITIES_REQUEST = 0x0080,
  SEND_IO_CAPABILITIES_REPLY = 0x0100,
  SEND_USER_CONFIRM_REPLY = 0x0200,
  SEND_USER_PASSKEY_REPLY = 0x0400,
  LEGACY_PAIRING_ACTIVE = 0x2000,
  SSP_PAIRING_ACTIVE = 0x4000,
  CONNECTION_ENCRYPTED = 0x8000
}
 
enum  hci_init_state {
  HCI_INIT_SEND_RESET = 0,
  HCI_INIT_W4_SEND_RESET,
  HCI_INIT_SEND_READ_LOCAL_VERSION_INFORMATION,
  HCI_INIT_W4_SEND_READ_LOCAL_VERSION_INFORMATION,
  HCI_INIT_SEND_READ_LOCAL_NAME,
  HCI_INIT_W4_SEND_READ_LOCAL_NAME,
  HCI_INIT_SEND_BAUD_CHANGE,
  HCI_INIT_W4_SEND_BAUD_CHANGE,
  HCI_INIT_CUSTOM_INIT,
  HCI_INIT_W4_CUSTOM_INIT,
  HCI_INIT_SEND_RESET_CSR_WARM_BOOT,
  HCI_INIT_W4_CUSTOM_INIT_CSR_WARM_BOOT,
  HCI_INIT_W4_CUSTOM_INIT_CSR_WARM_BOOT_LINK_RESET,
  HCI_INIT_W4_CUSTOM_INIT_BCM_DELAY,
  HCI_INIT_READ_LOCAL_SUPPORTED_COMMANDS,
  HCI_INIT_W4_READ_LOCAL_SUPPORTED_COMMANDS,
  HCI_INIT_SEND_BAUD_CHANGE_BCM,
  HCI_INIT_W4_SEND_BAUD_CHANGE_BCM,
  HCI_INIT_SET_BD_ADDR,
  HCI_INIT_W4_SET_BD_ADDR,
  HCI_INIT_SEND_RESET_ST_WARM_BOOT,
  HCI_INIT_W4_SEND_RESET_ST_WARM_BOOT,
  HCI_INIT_READ_BD_ADDR,
  HCI_INIT_W4_READ_BD_ADDR,
  HCI_INIT_READ_BUFFER_SIZE,
  HCI_INIT_W4_READ_BUFFER_SIZE,
  HCI_INIT_READ_LOCAL_SUPPORTED_FEATURES,
  HCI_INIT_W4_READ_LOCAL_SUPPORTED_FEATURES,
  HCI_INIT_SET_EVENT_MASK,
  HCI_INIT_W4_SET_EVENT_MASK,
  HCI_INIT_WRITE_SIMPLE_PAIRING_MODE,
  HCI_INIT_W4_WRITE_SIMPLE_PAIRING_MODE,
  HCI_INIT_WRITE_PAGE_TIMEOUT,
  HCI_INIT_W4_WRITE_PAGE_TIMEOUT,
  HCI_INIT_WRITE_CLASS_OF_DEVICE,
  HCI_INIT_W4_WRITE_CLASS_OF_DEVICE,
  HCI_INIT_WRITE_LOCAL_NAME,
  HCI_INIT_W4_WRITE_LOCAL_NAME,
  HCI_INIT_WRITE_EIR_DATA,
  HCI_INIT_W4_WRITE_EIR_DATA,
  HCI_INIT_WRITE_INQUIRY_MODE,
  HCI_INIT_W4_WRITE_INQUIRY_MODE,
  HCI_INIT_WRITE_SCAN_ENABLE,
  HCI_INIT_W4_WRITE_SCAN_ENABLE,
  HCI_INIT_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE,
  HCI_INIT_W4_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE,
  HCI_INIT_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING,
  HCI_INIT_W4_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING,
  HCI_INIT_BCM_WRITE_SCO_PCM_INT,
  HCI_INIT_W4_BCM_WRITE_SCO_PCM_INT,
  HCI_INIT_DONE,
  HCI_FALLING_ASLEEP_DISCONNECT,
  HCI_FALLING_ASLEEP_W4_WRITE_SCAN_ENABLE,
  HCI_FALLING_ASLEEP_COMPLETE,
  HCI_INIT_AFTER_SLEEP
}
 HCI Inititizlization State Machine. More...
 
enum  le_con_parameter_update_state_t {
  CON_PARAMETER_UPDATE_NONE,
  CON_PARAMETER_UPDATE_SEND_REQUEST,
  CON_PARAMETER_UPDATE_SEND_RESPONSE,
  CON_PARAMETER_UPDATE_CHANGE_HCI_CON_PARAMETERS,
  CON_PARAMETER_UPDATE_DENY
}
 LE connection parameter update state. More...
 
enum  le_connecting_state_t {
  LE_CONNECTING_IDLE,
  LE_CONNECTING_DIRECT,
  LE_CONNECTING_WHITELIST
}
 
enum  le_scanning_state_t {
  LE_SCAN_IDLE,
  LE_START_SCAN,
  LE_SCANNING,
  LE_STOP_SCAN
}
 

Functions

int gap_ssp_supported_on_both_sides (hci_con_handle_t handle)
 Check if SSP is supported on both sides. More...
 
void hci_add_event_handler (btstack_packet_callback_registration_t *callback_handler)
 Add event packet handler. More...
 
int hci_authentication_active_for_handle (hci_con_handle_t handle)
 Check if authentication is active. More...
 
int hci_can_send_acl_classic_packet_now (void)
 Check hci packet buffer is free and a classic acl packet can be sent to controller. More...
 
int hci_can_send_acl_le_packet_now (void)
 Check hci packet buffer is free and an LE acl packet can be sent to controller. More...
 
int hci_can_send_acl_packet_now (hci_con_handle_t con_handle)
 Check hci packet buffer is free and an acl packet for the given handle can be sent to controller. More...
 
int hci_can_send_command_packet_now (void)
 Check if CMD packet can be sent to controller. More...
 
int hci_can_send_prepared_acl_packet_now (hci_con_handle_t con_handle)
 Check if acl packet for the given handle can be sent to controller. More...
 
int hci_can_send_prepared_sco_packet_now (void)
 Check if SCO packet can be sent to controller. More...
 
int hci_can_send_sco_packet_now (void)
 Check HCI packet buffer and if SCO packet can be sent to controller. More...
 
void hci_close (void)
 Shutdown HCI. More...
 
hci_connection_thci_connection_for_bd_addr_and_type (bd_addr_t addr, bd_addr_type_t addr_type)
 Get internal hci_connection_t for given Bluetooth addres. More...
 
hci_connection_thci_connection_for_handle (hci_con_handle_t con_handle)
 Get internal hci_connection_t for given handle. More...
 
void hci_connections_get_iterator (btstack_linked_list_iterator_t *it)
 Get connection iterator. More...
 
void hci_disable_l2cap_timeout_check (void)
 Disable automatic L2CAP disconnect if no L2CAP connection is established. More...
 
void hci_disconnect_all (void)
 Disconnect all HCI connections. More...
 
void hci_disconnect_security_block (hci_con_handle_t con_handle)
 Disconn because of security block. More...
 
void hci_emit_state (void)
 Emit current HCI state. More...
 
int hci_extended_sco_link_supported (void)
 Check if extended SCO Link is supported. More...
 
uint16_t hci_get_manufacturer (void)
 Get Manufactured. More...
 
uint8_t * hci_get_outgoing_packet_buffer (void)
 Get pointer for outgoing packet buffer. More...
 
int hci_get_sco_packet_length (void)
 Get SCO packet length for current SCO Voice setting. More...
 
uint16_t hci_get_sco_voice_setting (void)
 Get SCO Voice Setting. More...
 
HCI_STATE hci_get_state (void)
 Get state. More...
 
void hci_init (const hci_transport_t *transport, const void *config)
 Set up HCI. More...
 
int hci_is_packet_buffer_reserved (void)
 Check if outgoing packet buffer is reserved. More...
 
void hci_le_advertisements_set_params (uint16_t adv_int_min, uint16_t adv_int_max, uint8_t adv_type, uint8_t direct_address_typ, bd_addr_t direct_address, uint8_t channel_map, uint8_t filter_policy)
 Set Advertisement Parameters. More...
 
void hci_le_set_own_address_type (uint8_t own_address_type)
 
uint16_t hci_max_acl_data_packet_length (void)
 Get maximal ACL Classic data packet length based on used buffer size. More...
 
int hci_non_flushable_packet_boundary_flag_supported (void)
 Check if ACL packets marked as non flushable can be sent. More...
 
int hci_number_free_acl_slots_for_handle (hci_con_handle_t con_handle)
 Get number of free acl slots for packets of given handle. More...
 
int hci_power_control (HCI_POWER_MODE mode)
 Requests the change of BTstack power mode. More...
 
void hci_register_acl_packet_handler (btstack_packet_handler_t handler)
 Registers a packet handler for ACL data. More...
 
void hci_register_sco_packet_handler (btstack_packet_handler_t handler)
 Registers a packet handler for SCO data. More...
 
void hci_release_packet_buffer (void)
 Release outgoing packet buffer More...
 
int hci_remote_esco_supported (hci_con_handle_t con_handle)
 Query if remote side supports eSCO. More...
 
void hci_request_sco_can_send_now_event (void)
 Request emission of HCI_EVENT_SCO_CAN_SEND_NOW as soon as possible. More...
 
int hci_reserve_packet_buffer (void)
 Reserves outgoing packet buffer. More...
 
int hci_send_acl_packet_buffer (int size)
 Send acl packet prepared in hci packet buffer. More...
 
int hci_send_cmd (const hci_cmd_t *cmd,...)
 Creates and sends HCI command packets based on a template and a list of parameters. More...
 
int hci_send_cmd_packet (uint8_t *packet, int size)
 Send complete CMD packet. More...
 
int hci_send_cmd_va_arg (const hci_cmd_t *cmd, va_list argtr)
 va_list version of hci_send_cmd More...
 
int hci_send_sco_packet_buffer (int size)
 Send SCO packet prepared in HCI packet buffer. More...
 
void hci_set_bd_addr (bd_addr_t addr)
 Set Public BD ADDR - passed on to Bluetooth chipset during init if supported in bt_control_h. More...
 
void hci_set_chipset (const btstack_chipset_t *chipset_driver)
 Configure Bluetooth chipset driver. More...
 
void hci_set_control (const btstack_control_t *hardware_control)
 Configure Bluetooth hardware control. More...
 
void hci_set_hardware_error_callback (void(*fn)(uint8_t error))
 Set callback for Bluetooth Hardware Error. More...
 
void hci_set_inquiry_mode (inquiry_mode_t mode)
 Set inquiry mode: standard, with RSSI, with RSSI + Extended Inquiry Results. More...
 
void hci_set_link_key_db (btstack_link_key_db_t const *link_key_db)
 Configure Bluetooth hardware control. More...
 
void hci_set_sco_voice_setting (uint16_t voice_setting)
 Configure Voice Setting for use with SCO data in HSP/HFP. More...
 
uint16_t hci_usable_acl_packet_types (void)
 Get supported packet types. More...
 

#define HCI_ACL_BUFFER_SIZE   (HCI_ACL_HEADER_SIZE + HCI_ACL_PAYLOAD_SIZE)

Referenced by acl_handler().

#define HCI_CMD_BUFFER_SIZE   (HCI_CMD_HEADER_SIZE + HCI_CMD_PAYLOAD_SIZE_LE)
#define HCI_CMD_PAYLOAD_SIZE_LE   32
#define HCI_EVENT_BUFFER_SIZE   (HCI_EVENT_HEADER_SIZE + HCI_EVENT_PAYLOAD_SIZE + 1)
#define HCI_EVENT_IS_COMMAND_COMPLETE (   event,
  cmd 
)    ( event[0] == HCI_EVENT_COMMAND_COMPLETE && little_endian_read_16(event,3) == cmd.opcode)
#define HCI_EVENT_IS_COMMAND_STATUS (   event,
  cmd 
)    ( event[0] == HCI_EVENT_COMMAND_STATUS && little_endian_read_16(event,4) == cmd.opcode)
#define HCI_INCOMING_PRE_BUFFER_SIZE   0
#define HCI_OUTGOING_PRE_BUFFER_SIZE   1

Referenced by hci_init().

#define IS_COMMAND (   packet,
  command 
)    (little_endian_read_16(packet,0) == command.opcode)

Referenced by hci_send_cmd_packet().

#define OFFSET_OF_DATA_IN_COMMAND_COMPLETE   5
#define READ_ACL_CONNECTION_HANDLE (   buffer)    ( little_endian_read_16(buffer,0) & 0x0fff)
#define READ_ACL_FLAGS (   buffer)    ( buffer[1] >> 4 )

Referenced by acl_handler().

#define READ_ACL_LENGTH (   buffer)    (little_endian_read_16(buffer, 2))

Referenced by acl_handler().

#define READ_L2CAP_CHANNEL_ID (   buffer)    ( little_endian_read_16(buffer, 6))
#define READ_L2CAP_LENGTH (   buffer)    ( little_endian_read_16(buffer, 4))

Referenced by acl_handler().

#define READ_SCO_CONNECTION_HANDLE (   buffer)    ( little_endian_read_16(buffer,0) & 0x0fff)

HCI Inititizlization State Machine.

anonymous enum
Enumerator
BONDING_REQUEST_REMOTE_FEATURES 
BONDING_RECEIVED_REMOTE_FEATURES 
BONDING_REMOTE_SUPPORTS_SSP 
BONDING_DISCONNECT_SECURITY_BLOCK 
BONDING_DISCONNECT_DEDICATED_DONE 
BONDING_SEND_AUTHENTICATE_REQUEST 
BONDING_SEND_ENCRYPTION_REQUEST 
BONDING_DEDICATED 
BONDING_EMIT_COMPLETE_ON_DISCONNECT 
anonymous enum
Enumerator
LE_ADVERTISEMENT_TASKS_DISABLE 
LE_ADVERTISEMENT_TASKS_SET_ADV_DATA 
LE_ADVERTISEMENT_TASKS_SET_SCAN_DATA 
LE_ADVERTISEMENT_TASKS_SET_PARAMS 
LE_ADVERTISEMENT_TASKS_ENABLE 
anonymous enum
Enumerator
LE_WHITELIST_ON_CONTROLLER 
LE_WHITELIST_ADD_TO_CONTROLLER 
LE_WHITELIST_REMOVE_FROM_CONTROLLER 
Enumerator
BLUETOOTH_OFF 
BLUETOOTH_ON 
BLUETOOTH_ACTIVE 

Connection State.

Enumerator
SEND_CREATE_CONNECTION 
SENT_CREATE_CONNECTION 
SEND_CANCEL_CONNECTION 
SENT_CANCEL_CONNECTION 
RECEIVED_CONNECTION_REQUEST 
ACCEPTED_CONNECTION_REQUEST 
REJECTED_CONNECTION_REQUEST 
OPEN 
SEND_DISCONNECT 
SENT_DISCONNECT 
RECEIVED_DISCONNECTION_COMPLETE 
Enumerator
AUTH_FLAGS_NONE 
RECV_LINK_KEY_REQUEST 
HANDLE_LINK_KEY_REQUEST 
SENT_LINK_KEY_REPLY 
SENT_LINK_KEY_NEGATIVE_REQUEST 
RECV_LINK_KEY_NOTIFICATION 
DENY_PIN_CODE_REQUEST 
RECV_IO_CAPABILITIES_REQUEST 
SEND_IO_CAPABILITIES_REPLY 
SEND_USER_CONFIRM_REPLY 
SEND_USER_PASSKEY_REPLY 
LEGACY_PAIRING_ACTIVE 
SSP_PAIRING_ACTIVE 
CONNECTION_ENCRYPTED 

HCI Inititizlization State Machine.

Enumerator
HCI_INIT_SEND_RESET 
HCI_INIT_W4_SEND_RESET 
HCI_INIT_SEND_READ_LOCAL_VERSION_INFORMATION 
HCI_INIT_W4_SEND_READ_LOCAL_VERSION_INFORMATION 
HCI_INIT_SEND_READ_LOCAL_NAME 
HCI_INIT_W4_SEND_READ_LOCAL_NAME 
HCI_INIT_SEND_BAUD_CHANGE 
HCI_INIT_W4_SEND_BAUD_CHANGE 
HCI_INIT_CUSTOM_INIT 
HCI_INIT_W4_CUSTOM_INIT 
HCI_INIT_SEND_RESET_CSR_WARM_BOOT 
HCI_INIT_W4_CUSTOM_INIT_CSR_WARM_BOOT 
HCI_INIT_W4_CUSTOM_INIT_CSR_WARM_BOOT_LINK_RESET 
HCI_INIT_W4_CUSTOM_INIT_BCM_DELAY 
HCI_INIT_READ_LOCAL_SUPPORTED_COMMANDS 
HCI_INIT_W4_READ_LOCAL_SUPPORTED_COMMANDS 
HCI_INIT_SEND_BAUD_CHANGE_BCM 
HCI_INIT_W4_SEND_BAUD_CHANGE_BCM 
HCI_INIT_SET_BD_ADDR 
HCI_INIT_W4_SET_BD_ADDR 
HCI_INIT_SEND_RESET_ST_WARM_BOOT 
HCI_INIT_W4_SEND_RESET_ST_WARM_BOOT 
HCI_INIT_READ_BD_ADDR 
HCI_INIT_W4_READ_BD_ADDR 
HCI_INIT_READ_BUFFER_SIZE 
HCI_INIT_W4_READ_BUFFER_SIZE 
HCI_INIT_READ_LOCAL_SUPPORTED_FEATURES 
HCI_INIT_W4_READ_LOCAL_SUPPORTED_FEATURES 
HCI_INIT_SET_EVENT_MASK 
HCI_INIT_W4_SET_EVENT_MASK 
HCI_INIT_WRITE_SIMPLE_PAIRING_MODE 
HCI_INIT_W4_WRITE_SIMPLE_PAIRING_MODE 
HCI_INIT_WRITE_PAGE_TIMEOUT 
HCI_INIT_W4_WRITE_PAGE_TIMEOUT 
HCI_INIT_WRITE_CLASS_OF_DEVICE 
HCI_INIT_W4_WRITE_CLASS_OF_DEVICE 
HCI_INIT_WRITE_LOCAL_NAME 
HCI_INIT_W4_WRITE_LOCAL_NAME 
HCI_INIT_WRITE_EIR_DATA 
HCI_INIT_W4_WRITE_EIR_DATA 
HCI_INIT_WRITE_INQUIRY_MODE 
HCI_INIT_W4_WRITE_INQUIRY_MODE 
HCI_INIT_WRITE_SCAN_ENABLE 
HCI_INIT_W4_WRITE_SCAN_ENABLE 
HCI_INIT_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE 
HCI_INIT_W4_WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE 
HCI_INIT_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING 
HCI_INIT_W4_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING 
HCI_INIT_BCM_WRITE_SCO_PCM_INT 
HCI_INIT_W4_BCM_WRITE_SCO_PCM_INT 
HCI_INIT_DONE 
HCI_FALLING_ASLEEP_DISCONNECT 
HCI_FALLING_ASLEEP_W4_WRITE_SCAN_ENABLE 
HCI_FALLING_ASLEEP_COMPLETE 
HCI_INIT_AFTER_SLEEP 

LE connection parameter update state.

Enumerator
CON_PARAMETER_UPDATE_NONE 
CON_PARAMETER_UPDATE_SEND_REQUEST 
CON_PARAMETER_UPDATE_SEND_RESPONSE 
CON_PARAMETER_UPDATE_CHANGE_HCI_CON_PARAMETERS 
CON_PARAMETER_UPDATE_DENY 
Enumerator
LE_CONNECTING_IDLE 
LE_CONNECTING_DIRECT 
LE_CONNECTING_WHITELIST 
Enumerator
LE_SCAN_IDLE 
LE_START_SCAN 
LE_SCANNING 
LE_STOP_SCAN 

int gap_ssp_supported_on_both_sides ( hci_con_handle_t  handle)

Check if SSP is supported on both sides.

Called by L2CAP

int hci_authentication_active_for_handle ( hci_con_handle_t  handle)

Check if authentication is active.

It delays automatic disconnect while no L2CAP connection Called by l2cap.

Referenced by l2cap_hci_event_handler().

int hci_can_send_acl_classic_packet_now ( void  )

Check hci packet buffer is free and a classic acl packet can be sent to controller.

Referenced by l2cap_notify_channel_can_send().

int hci_can_send_acl_le_packet_now ( void  )

Check hci packet buffer is free and an LE acl packet can be sent to controller.

References BD_ADDR_TYPE_LE_PUBLIC, hci_can_send_prepared_acl_packet_for_address_type(), and hci_stack_t::hci_packet_buffer_reserved.

Referenced by att_packet_handler(), and l2cap_notify_channel_can_send().

int hci_can_send_acl_packet_now ( hci_con_handle_t  con_handle)

Check hci packet buffer is free and an acl packet for the given handle can be sent to controller.

References hci_can_send_prepared_acl_packet_now(), and hci_stack_t::hci_packet_buffer_reserved.

Referenced by l2cap_can_send_fixed_channel_packet_now(), l2cap_notify_channel_can_send(), l2cap_run(), and l2cap_send_connectionless().

int hci_can_send_command_packet_now ( void  )
int hci_can_send_prepared_acl_packet_now ( hci_con_handle_t  con_handle)
int hci_can_send_prepared_sco_packet_now ( void  )

Check if SCO packet can be sent to controller.

int hci_can_send_sco_packet_now ( void  )

Check HCI packet buffer and if SCO packet can be sent to controller.

hci_connection_t* hci_connection_for_bd_addr_and_type ( bd_addr_t  addr,
bd_addr_type_t  addr_type 
)

Get internal hci_connection_t for given Bluetooth addres.

Called by L2CAP

Get internal hci_connection_t for given Bluetooth addres.

Returns
connection OR NULL, if not found

References hci_connection_t::address, hci_connection_t::address_type, btstack_linked_list_iterator_has_next(), btstack_linked_list_iterator_init(), btstack_linked_list_iterator_next(), hci_stack_t::connections, and NULL.

Referenced by event_handler(), and hci_send_cmd_packet().

void hci_connections_get_iterator ( btstack_linked_list_iterator_t it)

Get connection iterator.

Only used by l2cap.c and sm.c

Get connection iterator.

Returns
hci connections iterator

References btstack_linked_list_iterator_init(), and hci_stack_t::connections.

Referenced by att_server_handle_can_send_now(), l2cap_run(), and sm_run().

void hci_disable_l2cap_timeout_check ( void  )

Disable automatic L2CAP disconnect if no L2CAP connection is established.

void hci_disconnect_security_block ( hci_con_handle_t  con_handle)

Disconn because of security block.

Called by L2CAP

References BONDING_DISCONNECT_SECURITY_BLOCK, hci_connection_t::bonding_flags, and hci_connection_for_handle().

Referenced by l2cap_hci_event_handler(), and l2cap_run().

void hci_emit_state ( void  )

Emit current HCI state.

Called by daemon

References BTSTACK_EVENT_STATE, hci_emit_event(), and hci_stack_t::state.

Referenced by hci_init_done(), hci_power_control(), and hci_run().

int hci_extended_sco_link_supported ( void  )

Check if extended SCO Link is supported.

Referenced by event_handler().

uint16_t hci_get_manufacturer ( void  )

Get Manufactured.

Returns
manufacturer id

References hci_stack_t::manufacturer.

uint8_t* hci_get_outgoing_packet_buffer ( void  )
int hci_get_sco_packet_length ( void  )

Get SCO packet length for current SCO Voice setting.

Note
Using SCO packets of the exact length is required for USB transfer
Returns
Length of SCO packets in bytes (not audio frames) incl. 3 byte header
uint16_t hci_get_sco_voice_setting ( void  )

Get SCO Voice Setting.

Returns
current voice setting
HCI_STATE hci_get_state ( void  )

Get state.

References hci_stack_t::state.

Referenced by sm_run().

int hci_is_packet_buffer_reserved ( void  )

Check if outgoing packet buffer is reserved.

Used for internal checks in l2cap.c

References hci_stack_t::hci_packet_buffer_reserved.

Referenced by l2cap_send_prepared_connectionless().

void hci_le_advertisements_set_params ( uint16_t  adv_int_min,
uint16_t  adv_int_max,
uint8_t  adv_type,
uint8_t  direct_address_typ,
bd_addr_t  direct_address,
uint8_t  channel_map,
uint8_t  filter_policy 
)

Set Advertisement Parameters.

Parameters
adv_int_min
adv_int_max
adv_type
direct_address_type
direct_address
channel_map
filter_policy
Note
internal use. use gap_advertisements_set_params from gap.h instead.
void hci_le_set_own_address_type ( uint8_t  own_address_type)
Note
internal use. use gap_random_address_set_mode from gap.h instead.

Referenced by gap_random_address_set_mode().

uint16_t hci_max_acl_data_packet_length ( void  )

Get maximal ACL Classic data packet length based on used buffer size.

Called by L2CAP

References hci_stack_t::acl_data_packet_length.

Referenced by l2cap_run().

int hci_non_flushable_packet_boundary_flag_supported ( void  )

Check if ACL packets marked as non flushable can be sent.

Called by L2CAP

References hci_stack_t::local_supported_features.

Referenced by l2cap_create_signaling_internal().

int hci_number_free_acl_slots_for_handle ( hci_con_handle_t  con_handle)

Get number of free acl slots for packets of given handle.

Called by daemon

References hci_connection_t::address_type, hci_connection_for_handle(), hci_number_free_acl_slots_for_connection_type(), and log_error.

Referenced by hci_can_send_prepared_acl_packet_now().

void hci_register_acl_packet_handler ( btstack_packet_handler_t  handler)

Registers a packet handler for ACL data.

Used by L2CAP

Registers a packet handler for ACL data.

References hci_stack_t::acl_packet_handler.

Referenced by l2cap_init().

void hci_register_sco_packet_handler ( btstack_packet_handler_t  handler)

Registers a packet handler for SCO data.

Used for HSP and HFP profiles.

void hci_release_packet_buffer ( void  )

Release outgoing packet buffer

Note
only called instead of hci_send_preparared

References hci_stack_t::hci_packet_buffer_reserved.

Referenced by event_handler(), hci_send_acl_packet_buffer(), hci_send_acl_packet_fragments(), and l2cap_release_packet_buffer().

int hci_remote_esco_supported ( hci_con_handle_t  con_handle)

Query if remote side supports eSCO.

void hci_request_sco_can_send_now_event ( void  )

Request emission of HCI_EVENT_SCO_CAN_SEND_NOW as soon as possible.

Note
HCI_EVENT_SCO_CAN_SEND_NOW might be emitted during call to this function so packet handler should be ready to handle it
int hci_reserve_packet_buffer ( void  )
int hci_send_cmd ( const hci_cmd_t cmd,
  ... 
)

Creates and sends HCI command packets based on a template and a list of parameters.

Will return error if outgoing data buffer is occupied.

Creates and sends HCI command packets based on a template and a list of parameters.

References hci_send_cmd_va_arg().

Referenced by hci_initialization_timeout_handler(), hci_initializing_run(), hci_run(), l2cap_hci_event_handler(), l2cap_run(), sm_aes128_start(), sm_random_start(), and sm_run().

int hci_send_cmd_packet ( uint8_t *  packet,
int  size 
)

Send complete CMD packet.

Called by daemon

References bd_addr_to_str(), BD_ADDR_TYPE_CLASSIC, BTSTACK_MEMORY_ALLOC_FAILED, hci_connection_t::con_handle, create_connection_for_bd_addr_and_type(), btstack_link_key_db_t::delete_link_key, hci_accept_synchronous_connection, HCI_COMMAND_DATA_PACKET, hci_connection_for_bd_addr_and_type(), hci_create_connection, hci_delete_stored_link_key, hci_dump_packet(), hci_le_create_connection, hci_le_create_connection_cancel, hci_le_set_advertise_enable, hci_le_set_random_address, hci_link_key_request_negative_reply, hci_link_key_request_reply, hci_stack_t::hci_packet_buffer, hci_stack_t::hci_packet_buffer_reserved, hci_pin_code_request_negative_reply, hci_pin_code_request_reply, hci_setup_synchronous_connection, hci_stack_t::hci_transport, hci_transport_synchronous(), hci_user_confirmation_request_negative_reply, hci_user_confirmation_request_reply, hci_user_passkey_request_negative_reply, hci_user_passkey_request_reply, hci_write_loopback_mode, IS_COMMAND, LE_CONNECTING_DIRECT, LE_CONNECTING_IDLE, LE_CONNECTING_WHITELIST, LEGACY_PAIRING_ACTIVE, hci_stack_t::link_key_db, little_endian_read_16(), log_error, log_info, hci_stack_t::loopback_mode, hci_stack_t::num_cmd_packets, OPEN, reverse_bd_addr(), hci_stack_t::sco_voice_setting_active, SEND_CREATE_CONNECTION, hci_transport_t::send_packet, SENT_CREATE_CONNECTION, SENT_LINK_KEY_NEGATIVE_REQUEST, SENT_LINK_KEY_REPLY, SSP_PAIRING_ACTIVE, and hci_connection_t::state.

Referenced by hci_initializing_run(), and hci_send_cmd_va_arg().

int hci_send_sco_packet_buffer ( int  size)

Send SCO packet prepared in HCI packet buffer.

void hci_set_bd_addr ( bd_addr_t  addr)

Set Public BD ADDR - passed on to Bluetooth chipset during init if supported in bt_control_h.

References hci_stack_t::custom_bd_addr, and hci_stack_t::custom_bd_addr_set.

void hci_set_chipset ( const btstack_chipset_t chipset_driver)

Configure Bluetooth chipset driver.

Has to be called before power on, or right after receiving the local version information.

Has to be called before power on, or right after receiving the local version information

References hci_stack_t::chipset, hci_stack_t::config, and btstack_chipset_t::init.

Referenced by bt_app_init().

void hci_set_control ( const btstack_control_t hardware_control)

Configure Bluetooth hardware control.

Has to be called before power on.

Has to be called after hci_init() but before power on.

References hci_stack_t::config, hci_stack_t::control, and btstack_control_t::init.

void hci_set_hardware_error_callback ( void(*)(uint8_t error)  fn)

Set callback for Bluetooth Hardware Error.

References hci_stack_t::hardware_error_callback.

void hci_set_inquiry_mode ( inquiry_mode_t  mode)

Set inquiry mode: standard, with RSSI, with RSSI + Extended Inquiry Results.

Has to be called before power on.

Parameters
inquriy_modesee bluetooth_defines.h
void hci_set_link_key_db ( btstack_link_key_db_t const *  link_key_db)

Configure Bluetooth hardware control.

Has to be called before power on.

Referenced by bt_app_init().

void hci_set_sco_voice_setting ( uint16_t  voice_setting)

Configure Voice Setting for use with SCO data in HSP/HFP.

uint16_t hci_usable_acl_packet_types ( void  )

Get supported packet types.

Called by L2CAP

Referenced by hci_run(), and l2cap_run().