HW layer for the Nucleo board, it only work with old BLE_API

Dependents:   Hello_BLE F446RE-BLE

Fork of X_NUCLEO_IDB0XA1 by ST

Committer:
Silvio Lucio Oliva
Date:
Mon Jun 08 17:08:01 2015 +0200
Revision:
70:d20d30f59b1c
Child:
72:730717ed87de
Initial commit for mbed support

Signed-off-by: Silvio Lucio Oliva <silvio.oliva@st.com>

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Silvio Lucio Oliva 70:d20d30f59b1c 1 /******************************************************************************
Silvio Lucio Oliva 70:d20d30f59b1c 2 *
Silvio Lucio Oliva 70:d20d30f59b1c 3 * File Description
Silvio Lucio Oliva 70:d20d30f59b1c 4 * ---------------------
Silvio Lucio Oliva 70:d20d30f59b1c 5 * This file defines constants and functions for HCI layer.
Silvio Lucio Oliva 70:d20d30f59b1c 6 * See Bluetooth Core v 4.0, Vol. 2, Part E.
Silvio Lucio Oliva 70:d20d30f59b1c 7 *
Silvio Lucio Oliva 70:d20d30f59b1c 8 *******************************************************************************/
Silvio Lucio Oliva 70:d20d30f59b1c 9
Silvio Lucio Oliva 70:d20d30f59b1c 10 #ifndef __HCI_INTERNAL_H_
Silvio Lucio Oliva 70:d20d30f59b1c 11 #define __HCI_INTERNAL_H_
Silvio Lucio Oliva 70:d20d30f59b1c 12
Silvio Lucio Oliva 70:d20d30f59b1c 13 #include "compiler.h"
Silvio Lucio Oliva 70:d20d30f59b1c 14 #include "hal_types.h"
Silvio Lucio Oliva 70:d20d30f59b1c 15 #include "clock.h"
Silvio Lucio Oliva 70:d20d30f59b1c 16 #include "link_layer.h"
Silvio Lucio Oliva 70:d20d30f59b1c 17
Silvio Lucio Oliva 70:d20d30f59b1c 18 #include "hci.h"
Silvio Lucio Oliva 70:d20d30f59b1c 19
Silvio Lucio Oliva 70:d20d30f59b1c 20 #define DEFAULT_TIMEOUT (CLOCK_SECOND/10)
Silvio Lucio Oliva 70:d20d30f59b1c 21
Silvio Lucio Oliva 70:d20d30f59b1c 22 /**
Silvio Lucio Oliva 70:d20d30f59b1c 23 * Maximum payload of HCI commands that can be sent. Change this value if needed.
Silvio Lucio Oliva 70:d20d30f59b1c 24 * This value can be up to 255.
Silvio Lucio Oliva 70:d20d30f59b1c 25 */
Silvio Lucio Oliva 70:d20d30f59b1c 26 #define HCI_MAX_PAYLOAD_SIZE 128
Silvio Lucio Oliva 70:d20d30f59b1c 27
Silvio Lucio Oliva 70:d20d30f59b1c 28 /* HCI Packet types */
Silvio Lucio Oliva 70:d20d30f59b1c 29 #define HCI_COMMAND_PKT 0x01
Silvio Lucio Oliva 70:d20d30f59b1c 30 #define HCI_ACLDATA_PKT 0x02
Silvio Lucio Oliva 70:d20d30f59b1c 31 #define HCI_SCODATA_PKT 0x03
Silvio Lucio Oliva 70:d20d30f59b1c 32 #define HCI_EVENT_PKT 0x04
Silvio Lucio Oliva 70:d20d30f59b1c 33 #define HCI_VENDOR_PKT 0xff
Silvio Lucio Oliva 70:d20d30f59b1c 34
Silvio Lucio Oliva 70:d20d30f59b1c 35 typedef __packed struct _hci_uart_pckt{
Silvio Lucio Oliva 70:d20d30f59b1c 36 uint8_t type;
Silvio Lucio Oliva 70:d20d30f59b1c 37 uint8_t data[0];
Silvio Lucio Oliva 70:d20d30f59b1c 38 } PACKED hci_uart_pckt;
Silvio Lucio Oliva 70:d20d30f59b1c 39 #define HCI_HDR_SIZE 1
Silvio Lucio Oliva 70:d20d30f59b1c 40
Silvio Lucio Oliva 70:d20d30f59b1c 41 typedef __packed struct _hci_command_hdr{
Silvio Lucio Oliva 70:d20d30f59b1c 42 uint16_t opcode; /* OCF & OGF */
Silvio Lucio Oliva 70:d20d30f59b1c 43 uint8_t plen;
Silvio Lucio Oliva 70:d20d30f59b1c 44 } PACKED hci_command_hdr;
Silvio Lucio Oliva 70:d20d30f59b1c 45 #define HCI_COMMAND_HDR_SIZE 3
Silvio Lucio Oliva 70:d20d30f59b1c 46
Silvio Lucio Oliva 70:d20d30f59b1c 47 typedef __packed struct _hci_event_pckt{
Silvio Lucio Oliva 70:d20d30f59b1c 48 uint8_t evt;
Silvio Lucio Oliva 70:d20d30f59b1c 49 uint8_t plen;
Silvio Lucio Oliva 70:d20d30f59b1c 50 uint8_t data[0];
Silvio Lucio Oliva 70:d20d30f59b1c 51 } PACKED hci_event_pckt;
Silvio Lucio Oliva 70:d20d30f59b1c 52 #define HCI_EVENT_HDR_SIZE 2
Silvio Lucio Oliva 70:d20d30f59b1c 53
Silvio Lucio Oliva 70:d20d30f59b1c 54 typedef __packed struct _hci_acl_hdr{
Silvio Lucio Oliva 70:d20d30f59b1c 55 uint16_t handle; /* Handle & Flags(PB, BC) */
Silvio Lucio Oliva 70:d20d30f59b1c 56 uint16_t dlen;
Silvio Lucio Oliva 70:d20d30f59b1c 57 } PACKED hci_acl_hdr;
Silvio Lucio Oliva 70:d20d30f59b1c 58 #define HCI_ACL_HDR_SIZE 4
Silvio Lucio Oliva 70:d20d30f59b1c 59
Silvio Lucio Oliva 70:d20d30f59b1c 60 /* Link Control */
Silvio Lucio Oliva 70:d20d30f59b1c 61 #define OGF_LINK_CTL 0x01
Silvio Lucio Oliva 70:d20d30f59b1c 62
Silvio Lucio Oliva 70:d20d30f59b1c 63 #define OCF_DISCONNECT 0x0006
Silvio Lucio Oliva 70:d20d30f59b1c 64 typedef __packed struct _disconnect_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 65 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 66 uint8_t reason;
Silvio Lucio Oliva 70:d20d30f59b1c 67 } PACKED disconnect_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 68 #define DISCONNECT_CP_SIZE 3
Silvio Lucio Oliva 70:d20d30f59b1c 69
Silvio Lucio Oliva 70:d20d30f59b1c 70 /* Host Controller and Baseband */
Silvio Lucio Oliva 70:d20d30f59b1c 71 #define OGF_HOST_CTL 0x03
Silvio Lucio Oliva 70:d20d30f59b1c 72
Silvio Lucio Oliva 70:d20d30f59b1c 73 #define OCF_SET_EVENT_MASK 0x0001
Silvio Lucio Oliva 70:d20d30f59b1c 74 #define OCF_RESET 0x0003
Silvio Lucio Oliva 70:d20d30f59b1c 75
Silvio Lucio Oliva 70:d20d30f59b1c 76 #define OCF_READ_TRANSMIT_POWER_LEVEL 0x002D
Silvio Lucio Oliva 70:d20d30f59b1c 77 typedef __packed struct _read_transmit_power_level_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 78 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 79 uint8_t type;
Silvio Lucio Oliva 70:d20d30f59b1c 80 } PACKED read_transmit_power_level_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 81 #define READ_TRANSMIT_POWER_LEVEL_CP_SIZE 3
Silvio Lucio Oliva 70:d20d30f59b1c 82 typedef __packed struct _read_transmit_power_level_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 83 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 84 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 85 int8_t level;
Silvio Lucio Oliva 70:d20d30f59b1c 86 } PACKED read_transmit_power_level_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 87 #define READ_TRANSMIT_POWER_LEVEL_RP_SIZE 4
Silvio Lucio Oliva 70:d20d30f59b1c 88
Silvio Lucio Oliva 70:d20d30f59b1c 89 #define OCF_SET_CONTROLLER_TO_HOST_FC 0x0031
Silvio Lucio Oliva 70:d20d30f59b1c 90 #define OCF_HOST_BUFFER_SIZE 0x0033
Silvio Lucio Oliva 70:d20d30f59b1c 91 #define OCF_HOST_NUM_COMP_PKTS 0x0035
Silvio Lucio Oliva 70:d20d30f59b1c 92
Silvio Lucio Oliva 70:d20d30f59b1c 93 /* Informational Parameters */
Silvio Lucio Oliva 70:d20d30f59b1c 94 #define OGF_INFO_PARAM 0x04
Silvio Lucio Oliva 70:d20d30f59b1c 95
Silvio Lucio Oliva 70:d20d30f59b1c 96 #define OCF_READ_LOCAL_VERSION 0x0001
Silvio Lucio Oliva 70:d20d30f59b1c 97 typedef __packed struct _read_local_version_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 98 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 99 uint8_t hci_version;
Silvio Lucio Oliva 70:d20d30f59b1c 100 uint16_t hci_revision;
Silvio Lucio Oliva 70:d20d30f59b1c 101 uint8_t lmp_pal_version;
Silvio Lucio Oliva 70:d20d30f59b1c 102 uint16_t manufacturer_name;
Silvio Lucio Oliva 70:d20d30f59b1c 103 uint16_t lmp_pal_subversion;
Silvio Lucio Oliva 70:d20d30f59b1c 104 } PACKED read_local_version_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 105 #define READ_LOCAL_VERSION_RP_SIZE 9
Silvio Lucio Oliva 70:d20d30f59b1c 106
Silvio Lucio Oliva 70:d20d30f59b1c 107 #define OCF_READ_LOCAL_COMMANDS 0x0002
Silvio Lucio Oliva 70:d20d30f59b1c 108 #define OCF_READ_LOCAL_FEATURES 0x0003
Silvio Lucio Oliva 70:d20d30f59b1c 109
Silvio Lucio Oliva 70:d20d30f59b1c 110 #define OCF_READ_BD_ADDR 0x0009
Silvio Lucio Oliva 70:d20d30f59b1c 111 typedef __packed struct _read_bd_addr_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 112 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 113 tBDAddr bdaddr;
Silvio Lucio Oliva 70:d20d30f59b1c 114 } PACKED read_bd_addr_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 115 #define READ_BD_ADDR_RP_SIZE 7
Silvio Lucio Oliva 70:d20d30f59b1c 116
Silvio Lucio Oliva 70:d20d30f59b1c 117 /* Status params */
Silvio Lucio Oliva 70:d20d30f59b1c 118 #define OGF_STATUS_PARAM 0x05
Silvio Lucio Oliva 70:d20d30f59b1c 119
Silvio Lucio Oliva 70:d20d30f59b1c 120 #define OCF_READ_RSSI 0x0005
Silvio Lucio Oliva 70:d20d30f59b1c 121 typedef __packed struct _read_rssi_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 122 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 123 } PACKED read_rssi_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 124 #define READ_RSSI_CP_SIZE 2
Silvio Lucio Oliva 70:d20d30f59b1c 125 typedef __packed struct _read_rssi_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 126 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 127 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 128 int8_t rssi;
Silvio Lucio Oliva 70:d20d30f59b1c 129 } PACKED read_rssi_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 130 #define READ_RSSI_RP_SIZE 4
Silvio Lucio Oliva 70:d20d30f59b1c 131
Silvio Lucio Oliva 70:d20d30f59b1c 132
Silvio Lucio Oliva 70:d20d30f59b1c 133 /* LE commands */
Silvio Lucio Oliva 70:d20d30f59b1c 134 #define OGF_LE_CTL 0x08
Silvio Lucio Oliva 70:d20d30f59b1c 135
Silvio Lucio Oliva 70:d20d30f59b1c 136 #define OCF_LE_SET_EVENT_MASK 0x0001
Silvio Lucio Oliva 70:d20d30f59b1c 137 typedef __packed struct _le_set_event_mask_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 138 uint8_t mask[8];
Silvio Lucio Oliva 70:d20d30f59b1c 139 } PACKED le_set_event_mask_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 140 #define LE_SET_EVENT_MASK_CP_SIZE 8
Silvio Lucio Oliva 70:d20d30f59b1c 141
Silvio Lucio Oliva 70:d20d30f59b1c 142 #define OCF_LE_READ_BUFFER_SIZE 0x0002
Silvio Lucio Oliva 70:d20d30f59b1c 143 typedef __packed struct _le_read_buffer_size_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 144 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 145 uint16_t pkt_len;
Silvio Lucio Oliva 70:d20d30f59b1c 146 uint8_t max_pkt;
Silvio Lucio Oliva 70:d20d30f59b1c 147 } PACKED le_read_buffer_size_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 148 #define LE_READ_BUFFER_SIZE_RP_SIZE 4
Silvio Lucio Oliva 70:d20d30f59b1c 149
Silvio Lucio Oliva 70:d20d30f59b1c 150 #define OCF_LE_READ_LOCAL_SUPPORTED_FEATURES 0x0003
Silvio Lucio Oliva 70:d20d30f59b1c 151 typedef __packed struct _le_read_local_supported_features_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 152 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 153 uint8_t features[8];
Silvio Lucio Oliva 70:d20d30f59b1c 154 } PACKED le_read_local_supported_features_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 155 #define LE_READ_LOCAL_SUPPORTED_FEATURES_RP_SIZE 9
Silvio Lucio Oliva 70:d20d30f59b1c 156
Silvio Lucio Oliva 70:d20d30f59b1c 157 #define OCF_LE_SET_RANDOM_ADDRESS 0x0005
Silvio Lucio Oliva 70:d20d30f59b1c 158 typedef __packed struct _le_set_random_address_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 159 tBDAddr bdaddr;
Silvio Lucio Oliva 70:d20d30f59b1c 160 } PACKED le_set_random_address_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 161 #define LE_SET_RANDOM_ADDRESS_CP_SIZE 6
Silvio Lucio Oliva 70:d20d30f59b1c 162
Silvio Lucio Oliva 70:d20d30f59b1c 163 #define OCF_LE_SET_ADV_PARAMETERS 0x0006
Silvio Lucio Oliva 70:d20d30f59b1c 164 typedef __packed struct _le_set_adv_parameters_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 165 uint16_t min_interval;
Silvio Lucio Oliva 70:d20d30f59b1c 166 uint16_t max_interval;
Silvio Lucio Oliva 70:d20d30f59b1c 167 uint8_t advtype;
Silvio Lucio Oliva 70:d20d30f59b1c 168 uint8_t own_bdaddr_type;
Silvio Lucio Oliva 70:d20d30f59b1c 169 uint8_t direct_bdaddr_type;
Silvio Lucio Oliva 70:d20d30f59b1c 170 tBDAddr direct_bdaddr;
Silvio Lucio Oliva 70:d20d30f59b1c 171 uint8_t chan_map;
Silvio Lucio Oliva 70:d20d30f59b1c 172 uint8_t filter;
Silvio Lucio Oliva 70:d20d30f59b1c 173 } PACKED le_set_adv_parameters_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 174 #define LE_SET_ADV_PARAMETERS_CP_SIZE 15
Silvio Lucio Oliva 70:d20d30f59b1c 175
Silvio Lucio Oliva 70:d20d30f59b1c 176 #define OCF_LE_READ_ADV_CHANNEL_TX_POWER 0x0007
Silvio Lucio Oliva 70:d20d30f59b1c 177 typedef __packed struct _le_read_adv_channel_tx_power_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 178 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 179 int8_t level;
Silvio Lucio Oliva 70:d20d30f59b1c 180 } PACKED le_read_adv_channel_tx_power_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 181 #define LE_READ_ADV_CHANNEL_TX_POWER_RP_SIZE 2
Silvio Lucio Oliva 70:d20d30f59b1c 182
Silvio Lucio Oliva 70:d20d30f59b1c 183 #define OCF_LE_SET_ADV_DATA 0x0008
Silvio Lucio Oliva 70:d20d30f59b1c 184 typedef __packed struct _le_set_adv_data_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 185 uint8_t length;
Silvio Lucio Oliva 70:d20d30f59b1c 186 uint8_t data[31];
Silvio Lucio Oliva 70:d20d30f59b1c 187 } PACKED le_set_adv_data_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 188 #define LE_SET_ADV_DATA_CP_SIZE 32
Silvio Lucio Oliva 70:d20d30f59b1c 189
Silvio Lucio Oliva 70:d20d30f59b1c 190 #define OCF_LE_SET_SCAN_RESPONSE_DATA 0x0009
Silvio Lucio Oliva 70:d20d30f59b1c 191 typedef __packed struct _le_set_scan_response_data_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 192 uint8_t length;
Silvio Lucio Oliva 70:d20d30f59b1c 193 uint8_t data[31];
Silvio Lucio Oliva 70:d20d30f59b1c 194 } PACKED le_set_scan_response_data_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 195 #define LE_SET_SCAN_RESPONSE_DATA_CP_SIZE 32
Silvio Lucio Oliva 70:d20d30f59b1c 196
Silvio Lucio Oliva 70:d20d30f59b1c 197 #define OCF_LE_SET_ADVERTISE_ENABLE 0x000A
Silvio Lucio Oliva 70:d20d30f59b1c 198 typedef __packed struct _le_set_advertise_enable_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 199 uint8_t enable;
Silvio Lucio Oliva 70:d20d30f59b1c 200 } PACKED le_set_advertise_enable_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 201 #define LE_SET_ADVERTISE_ENABLE_CP_SIZE 1
Silvio Lucio Oliva 70:d20d30f59b1c 202
Silvio Lucio Oliva 70:d20d30f59b1c 203 #define OCF_LE_SET_SCAN_PARAMETERS 0x000B
Silvio Lucio Oliva 70:d20d30f59b1c 204 typedef __packed struct _le_set_scan_parameters_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 205 uint8_t type;
Silvio Lucio Oliva 70:d20d30f59b1c 206 uint16_t interval;
Silvio Lucio Oliva 70:d20d30f59b1c 207 uint16_t window;
Silvio Lucio Oliva 70:d20d30f59b1c 208 uint8_t own_bdaddr_type;
Silvio Lucio Oliva 70:d20d30f59b1c 209 uint8_t filter;
Silvio Lucio Oliva 70:d20d30f59b1c 210 } PACKED le_set_scan_parameters_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 211 #define LE_SET_SCAN_PARAMETERS_CP_SIZE 7
Silvio Lucio Oliva 70:d20d30f59b1c 212
Silvio Lucio Oliva 70:d20d30f59b1c 213 #define OCF_LE_SET_SCAN_ENABLE 0x000C
Silvio Lucio Oliva 70:d20d30f59b1c 214 typedef __packed struct _le_set_scan_enable_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 215 uint8_t enable;
Silvio Lucio Oliva 70:d20d30f59b1c 216 uint8_t filter_dup;
Silvio Lucio Oliva 70:d20d30f59b1c 217 } PACKED le_set_scan_enable_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 218 #define LE_SET_SCAN_ENABLE_CP_SIZE 2
Silvio Lucio Oliva 70:d20d30f59b1c 219
Silvio Lucio Oliva 70:d20d30f59b1c 220 #define OCF_LE_CREATE_CONN 0x000D
Silvio Lucio Oliva 70:d20d30f59b1c 221 typedef __packed struct _le_create_connection_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 222 uint16_t interval;
Silvio Lucio Oliva 70:d20d30f59b1c 223 uint16_t window;
Silvio Lucio Oliva 70:d20d30f59b1c 224 uint8_t initiator_filter;
Silvio Lucio Oliva 70:d20d30f59b1c 225 uint8_t peer_bdaddr_type;
Silvio Lucio Oliva 70:d20d30f59b1c 226 tBDAddr peer_bdaddr;
Silvio Lucio Oliva 70:d20d30f59b1c 227 uint8_t own_bdaddr_type;
Silvio Lucio Oliva 70:d20d30f59b1c 228 uint16_t min_interval;
Silvio Lucio Oliva 70:d20d30f59b1c 229 uint16_t max_interval;
Silvio Lucio Oliva 70:d20d30f59b1c 230 uint16_t latency;
Silvio Lucio Oliva 70:d20d30f59b1c 231 uint16_t supervision_timeout;
Silvio Lucio Oliva 70:d20d30f59b1c 232 uint16_t min_ce_length;
Silvio Lucio Oliva 70:d20d30f59b1c 233 uint16_t max_ce_length;
Silvio Lucio Oliva 70:d20d30f59b1c 234 } PACKED le_create_connection_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 235 #define LE_CREATE_CONN_CP_SIZE 25
Silvio Lucio Oliva 70:d20d30f59b1c 236
Silvio Lucio Oliva 70:d20d30f59b1c 237 #define OCF_LE_CREATE_CONN_CANCEL 0x000E
Silvio Lucio Oliva 70:d20d30f59b1c 238
Silvio Lucio Oliva 70:d20d30f59b1c 239 #define OCF_LE_READ_WHITE_LIST_SIZE 0x000F
Silvio Lucio Oliva 70:d20d30f59b1c 240 typedef __packed struct _le_read_white_list_size_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 241 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 242 uint8_t size;
Silvio Lucio Oliva 70:d20d30f59b1c 243 } PACKED le_read_white_list_size_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 244 #define LE_READ_WHITE_LIST_SIZE_RP_SIZE 2
Silvio Lucio Oliva 70:d20d30f59b1c 245
Silvio Lucio Oliva 70:d20d30f59b1c 246 #define OCF_LE_CLEAR_WHITE_LIST 0x0010
Silvio Lucio Oliva 70:d20d30f59b1c 247
Silvio Lucio Oliva 70:d20d30f59b1c 248 #define OCF_LE_ADD_DEVICE_TO_WHITE_LIST 0x0011
Silvio Lucio Oliva 70:d20d30f59b1c 249 typedef __packed struct _le_add_device_to_white_list_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 250 uint8_t bdaddr_type;
Silvio Lucio Oliva 70:d20d30f59b1c 251 tBDAddr bdaddr;
Silvio Lucio Oliva 70:d20d30f59b1c 252 } PACKED le_add_device_to_white_list_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 253 #define LE_ADD_DEVICE_TO_WHITE_LIST_CP_SIZE 7
Silvio Lucio Oliva 70:d20d30f59b1c 254
Silvio Lucio Oliva 70:d20d30f59b1c 255 #define OCF_LE_REMOVE_DEVICE_FROM_WHITE_LIST 0x0012
Silvio Lucio Oliva 70:d20d30f59b1c 256 typedef __packed struct _le_remove_device_from_white_list_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 257 uint8_t bdaddr_type;
Silvio Lucio Oliva 70:d20d30f59b1c 258 tBDAddr bdaddr;
Silvio Lucio Oliva 70:d20d30f59b1c 259 } PACKED le_remove_device_from_white_list_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 260 #define LE_REMOVE_DEVICE_FROM_WHITE_LIST_CP_SIZE 7
Silvio Lucio Oliva 70:d20d30f59b1c 261
Silvio Lucio Oliva 70:d20d30f59b1c 262 #define OCF_LE_CONN_UPDATE 0x0013
Silvio Lucio Oliva 70:d20d30f59b1c 263 typedef __packed struct _le_connection_update_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 264 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 265 uint16_t min_interval;
Silvio Lucio Oliva 70:d20d30f59b1c 266 uint16_t max_interval;
Silvio Lucio Oliva 70:d20d30f59b1c 267 uint16_t latency;
Silvio Lucio Oliva 70:d20d30f59b1c 268 uint16_t supervision_timeout;
Silvio Lucio Oliva 70:d20d30f59b1c 269 uint16_t min_ce_length;
Silvio Lucio Oliva 70:d20d30f59b1c 270 uint16_t max_ce_length;
Silvio Lucio Oliva 70:d20d30f59b1c 271 } PACKED le_connection_update_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 272 #define LE_CONN_UPDATE_CP_SIZE 14
Silvio Lucio Oliva 70:d20d30f59b1c 273
Silvio Lucio Oliva 70:d20d30f59b1c 274 #define OCF_LE_SET_HOST_CHANNEL_CLASSIFICATION 0x0014
Silvio Lucio Oliva 70:d20d30f59b1c 275 typedef __packed struct _le_set_host_channel_classification_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 276 uint8_t map[5];
Silvio Lucio Oliva 70:d20d30f59b1c 277 } PACKED le_set_host_channel_classification_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 278 #define LE_SET_HOST_CHANNEL_CLASSIFICATION_CP_SIZE 5
Silvio Lucio Oliva 70:d20d30f59b1c 279
Silvio Lucio Oliva 70:d20d30f59b1c 280 #define OCF_LE_READ_CHANNEL_MAP 0x0015
Silvio Lucio Oliva 70:d20d30f59b1c 281 typedef __packed struct _le_read_channel_map_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 282 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 283 } PACKED le_read_channel_map_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 284 #define LE_READ_CHANNEL_MAP_CP_SIZE 2
Silvio Lucio Oliva 70:d20d30f59b1c 285
Silvio Lucio Oliva 70:d20d30f59b1c 286 typedef __packed struct _le_read_channel_map_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 287 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 288 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 289 uint8_t map[5];
Silvio Lucio Oliva 70:d20d30f59b1c 290 } le_read_channel_map_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 291 #define LE_READ_CHANNEL_MAP_RP_SIZE 8
Silvio Lucio Oliva 70:d20d30f59b1c 292
Silvio Lucio Oliva 70:d20d30f59b1c 293 #define OCF_LE_READ_REMOTE_USED_FEATURES 0x0016
Silvio Lucio Oliva 70:d20d30f59b1c 294 typedef __packed struct _le_read_remote_used_features_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 295 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 296 } PACKED le_read_remote_used_features_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 297 #define LE_READ_REMOTE_USED_FEATURES_CP_SIZE 2
Silvio Lucio Oliva 70:d20d30f59b1c 298
Silvio Lucio Oliva 70:d20d30f59b1c 299 #define OCF_LE_ENCRYPT 0x0017
Silvio Lucio Oliva 70:d20d30f59b1c 300 typedef __packed struct _le_encrypt_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 301 uint8_t key[16];
Silvio Lucio Oliva 70:d20d30f59b1c 302 uint8_t plaintext[16];
Silvio Lucio Oliva 70:d20d30f59b1c 303 } PACKED le_encrypt_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 304 #define LE_ENCRYPT_CP_SIZE 32
Silvio Lucio Oliva 70:d20d30f59b1c 305
Silvio Lucio Oliva 70:d20d30f59b1c 306 typedef __packed struct _le_encrypt_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 307 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 308 uint8_t encdata[16];
Silvio Lucio Oliva 70:d20d30f59b1c 309 } PACKED le_encrypt_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 310 #define LE_ENCRYPT_RP_SIZE 17
Silvio Lucio Oliva 70:d20d30f59b1c 311
Silvio Lucio Oliva 70:d20d30f59b1c 312 #define OCF_LE_RAND 0x0018
Silvio Lucio Oliva 70:d20d30f59b1c 313 typedef __packed struct _le_rand_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 314 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 315 uint8_t random[8];
Silvio Lucio Oliva 70:d20d30f59b1c 316 } PACKED le_rand_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 317 #define LE_RAND_RP_SIZE 9
Silvio Lucio Oliva 70:d20d30f59b1c 318
Silvio Lucio Oliva 70:d20d30f59b1c 319 #define OCF_LE_START_ENCRYPTION 0x0019
Silvio Lucio Oliva 70:d20d30f59b1c 320 typedef __packed struct _le_start_encryption_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 321 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 322 uint8_t random[8];
Silvio Lucio Oliva 70:d20d30f59b1c 323 uint16_t diversifier;
Silvio Lucio Oliva 70:d20d30f59b1c 324 uint8_t key[16];
Silvio Lucio Oliva 70:d20d30f59b1c 325 } PACKED le_start_encryption_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 326 #define LE_START_ENCRYPTION_CP_SIZE 28
Silvio Lucio Oliva 70:d20d30f59b1c 327
Silvio Lucio Oliva 70:d20d30f59b1c 328 #define OCF_LE_LTK_REPLY 0x001A
Silvio Lucio Oliva 70:d20d30f59b1c 329 typedef __packed struct _le_ltk_reply_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 330 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 331 uint8_t key[16];
Silvio Lucio Oliva 70:d20d30f59b1c 332 } PACKED le_ltk_reply_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 333 #define LE_LTK_REPLY_CP_SIZE 18
Silvio Lucio Oliva 70:d20d30f59b1c 334
Silvio Lucio Oliva 70:d20d30f59b1c 335 typedef __packed struct _le_ltk_reply_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 336 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 337 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 338 } PACKED le_ltk_reply_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 339 #define LE_LTK_REPLY_RP_SIZE 3
Silvio Lucio Oliva 70:d20d30f59b1c 340
Silvio Lucio Oliva 70:d20d30f59b1c 341 #define OCF_LE_LTK_NEG_REPLY 0x001B
Silvio Lucio Oliva 70:d20d30f59b1c 342 typedef __packed struct _le_ltk_neg_reply_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 343 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 344 } PACKED le_ltk_neg_reply_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 345 #define LE_LTK_NEG_REPLY_CP_SIZE 2
Silvio Lucio Oliva 70:d20d30f59b1c 346
Silvio Lucio Oliva 70:d20d30f59b1c 347 typedef __packed struct _le_ltk_neg_reply_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 348 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 349 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 350 } PACKED le_ltk_neg_reply_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 351 #define LE_LTK_NEG_REPLY_RP_SIZE 3
Silvio Lucio Oliva 70:d20d30f59b1c 352
Silvio Lucio Oliva 70:d20d30f59b1c 353 #define OCF_LE_READ_SUPPORTED_STATES 0x001C
Silvio Lucio Oliva 70:d20d30f59b1c 354 typedef __packed struct _le_read_supported_states_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 355 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 356 uint8_t states[8];
Silvio Lucio Oliva 70:d20d30f59b1c 357 } PACKED le_read_supported_states_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 358 #define LE_READ_SUPPORTED_STATES_RP_SIZE 9
Silvio Lucio Oliva 70:d20d30f59b1c 359
Silvio Lucio Oliva 70:d20d30f59b1c 360 #define OCF_LE_RECEIVER_TEST 0x001D
Silvio Lucio Oliva 70:d20d30f59b1c 361 typedef __packed struct _le_receiver_test_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 362 uint8_t frequency;
Silvio Lucio Oliva 70:d20d30f59b1c 363 } PACKED le_receiver_test_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 364 #define LE_RECEIVER_TEST_CP_SIZE 1
Silvio Lucio Oliva 70:d20d30f59b1c 365
Silvio Lucio Oliva 70:d20d30f59b1c 366 #define OCF_LE_TRANSMITTER_TEST 0x001E
Silvio Lucio Oliva 70:d20d30f59b1c 367 typedef __packed struct _le_transmitter_test_cp{
Silvio Lucio Oliva 70:d20d30f59b1c 368 uint8_t frequency;
Silvio Lucio Oliva 70:d20d30f59b1c 369 uint8_t length;
Silvio Lucio Oliva 70:d20d30f59b1c 370 uint8_t payload;
Silvio Lucio Oliva 70:d20d30f59b1c 371 } PACKED le_transmitter_test_cp;
Silvio Lucio Oliva 70:d20d30f59b1c 372 #define LE_TRANSMITTER_TEST_CP_SIZE 3
Silvio Lucio Oliva 70:d20d30f59b1c 373
Silvio Lucio Oliva 70:d20d30f59b1c 374 #define OCF_LE_TEST_END 0x001F
Silvio Lucio Oliva 70:d20d30f59b1c 375 typedef __packed struct _le_test_end_rp{
Silvio Lucio Oliva 70:d20d30f59b1c 376 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 377 uint16_t num_pkts;
Silvio Lucio Oliva 70:d20d30f59b1c 378 } PACKED le_test_end_rp;
Silvio Lucio Oliva 70:d20d30f59b1c 379 #define LE_TEST_END_RP_SIZE 3
Silvio Lucio Oliva 70:d20d30f59b1c 380
Silvio Lucio Oliva 70:d20d30f59b1c 381 /* Vendor specific commands */
Silvio Lucio Oliva 70:d20d30f59b1c 382 #define OGF_VENDOR_CMD 0x3f
Silvio Lucio Oliva 70:d20d30f59b1c 383
Silvio Lucio Oliva 70:d20d30f59b1c 384
Silvio Lucio Oliva 70:d20d30f59b1c 385 /*------------- Events -------------*/
Silvio Lucio Oliva 70:d20d30f59b1c 386 #define EVT_CONN_COMPLETE 0x03
Silvio Lucio Oliva 70:d20d30f59b1c 387 typedef __packed struct _evt_conn_complete{
Silvio Lucio Oliva 70:d20d30f59b1c 388 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 389 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 390 tBDAddr bdaddr;
Silvio Lucio Oliva 70:d20d30f59b1c 391 uint8_t link_type;
Silvio Lucio Oliva 70:d20d30f59b1c 392 uint8_t encr_mode;
Silvio Lucio Oliva 70:d20d30f59b1c 393 } PACKED evt_conn_complete;
Silvio Lucio Oliva 70:d20d30f59b1c 394 #define EVT_CONN_COMPLETE_SIZE 13
Silvio Lucio Oliva 70:d20d30f59b1c 395
Silvio Lucio Oliva 70:d20d30f59b1c 396 #define EVT_DISCONN_COMPLETE 0x05
Silvio Lucio Oliva 70:d20d30f59b1c 397 typedef __packed struct _evt_disconn_complete{
Silvio Lucio Oliva 70:d20d30f59b1c 398 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 399 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 400 uint8_t reason;
Silvio Lucio Oliva 70:d20d30f59b1c 401 } PACKED evt_disconn_complete;
Silvio Lucio Oliva 70:d20d30f59b1c 402 #define EVT_DISCONN_COMPLETE_SIZE 4
Silvio Lucio Oliva 70:d20d30f59b1c 403
Silvio Lucio Oliva 70:d20d30f59b1c 404 #define EVT_ENCRYPT_CHANGE 0x08
Silvio Lucio Oliva 70:d20d30f59b1c 405 typedef __packed struct _evt_encrypt_change{
Silvio Lucio Oliva 70:d20d30f59b1c 406 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 407 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 408 uint8_t encrypt;
Silvio Lucio Oliva 70:d20d30f59b1c 409 } PACKED evt_encrypt_change;
Silvio Lucio Oliva 70:d20d30f59b1c 410 #define EVT_ENCRYPT_CHANGE_SIZE 5
Silvio Lucio Oliva 70:d20d30f59b1c 411
Silvio Lucio Oliva 70:d20d30f59b1c 412 #define EVT_READ_REMOTE_VERSION_COMPLETE 0x0C
Silvio Lucio Oliva 70:d20d30f59b1c 413
Silvio Lucio Oliva 70:d20d30f59b1c 414 #define EVT_CMD_COMPLETE 0x0E
Silvio Lucio Oliva 70:d20d30f59b1c 415 typedef __packed struct _evt_cmd_complete{
Silvio Lucio Oliva 70:d20d30f59b1c 416 uint8_t ncmd;
Silvio Lucio Oliva 70:d20d30f59b1c 417 uint16_t opcode;
Silvio Lucio Oliva 70:d20d30f59b1c 418 } PACKED evt_cmd_complete;
Silvio Lucio Oliva 70:d20d30f59b1c 419 #define EVT_CMD_COMPLETE_SIZE 3
Silvio Lucio Oliva 70:d20d30f59b1c 420
Silvio Lucio Oliva 70:d20d30f59b1c 421 #define EVT_CMD_STATUS 0x0F
Silvio Lucio Oliva 70:d20d30f59b1c 422 typedef __packed struct _evt_cmd_status{
Silvio Lucio Oliva 70:d20d30f59b1c 423 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 424 uint8_t ncmd;
Silvio Lucio Oliva 70:d20d30f59b1c 425 uint16_t opcode;
Silvio Lucio Oliva 70:d20d30f59b1c 426 } PACKED evt_cmd_status;
Silvio Lucio Oliva 70:d20d30f59b1c 427 #define EVT_CMD_STATUS_SIZE 4
Silvio Lucio Oliva 70:d20d30f59b1c 428
Silvio Lucio Oliva 70:d20d30f59b1c 429 #define EVT_HARDWARE_ERROR 0x10
Silvio Lucio Oliva 70:d20d30f59b1c 430 typedef __packed struct _evt_hardware_error{
Silvio Lucio Oliva 70:d20d30f59b1c 431 uint8_t code;
Silvio Lucio Oliva 70:d20d30f59b1c 432 } PACKED evt_hardware_error;
Silvio Lucio Oliva 70:d20d30f59b1c 433 #define EVT_HARDWARE_ERROR_SIZE 1
Silvio Lucio Oliva 70:d20d30f59b1c 434
Silvio Lucio Oliva 70:d20d30f59b1c 435 #define EVT_NUM_COMP_PKTS 0x13
Silvio Lucio Oliva 70:d20d30f59b1c 436 typedef __packed struct _evt_num_comp_pkts{
Silvio Lucio Oliva 70:d20d30f59b1c 437 uint8_t num_hndl;
Silvio Lucio Oliva 70:d20d30f59b1c 438 /* variable length part */
Silvio Lucio Oliva 70:d20d30f59b1c 439 } PACKED evt_num_comp_pkts;
Silvio Lucio Oliva 70:d20d30f59b1c 440 #define EVT_NUM_COMP_PKTS_SIZE 1
Silvio Lucio Oliva 70:d20d30f59b1c 441
Silvio Lucio Oliva 70:d20d30f59b1c 442 /* variable length part of evt_num_comp_pkts. */
Silvio Lucio Oliva 70:d20d30f59b1c 443 typedef __packed struct _evt_num_comp_pkts_param{
Silvio Lucio Oliva 70:d20d30f59b1c 444 uint16_t hndl;
Silvio Lucio Oliva 70:d20d30f59b1c 445 uint16_t num_comp_pkts;
Silvio Lucio Oliva 70:d20d30f59b1c 446 } PACKED evt_num_comp_pkts_param;
Silvio Lucio Oliva 70:d20d30f59b1c 447 #define EVT_NUM_COMP_PKTS_PARAM_SIZE 1
Silvio Lucio Oliva 70:d20d30f59b1c 448
Silvio Lucio Oliva 70:d20d30f59b1c 449 #define EVT_DATA_BUFFER_OVERFLOW 0x1A
Silvio Lucio Oliva 70:d20d30f59b1c 450 typedef __packed struct _evt_data_buffer_overflow{
Silvio Lucio Oliva 70:d20d30f59b1c 451 uint8_t link_type;
Silvio Lucio Oliva 70:d20d30f59b1c 452 } PACKED evt_data_buffer_overflow;
Silvio Lucio Oliva 70:d20d30f59b1c 453 #define EVT_DATA_BUFFER_OVERFLOW_SIZE 1
Silvio Lucio Oliva 70:d20d30f59b1c 454
Silvio Lucio Oliva 70:d20d30f59b1c 455 #define EVT_ENCRYPTION_KEY_REFRESH_COMPLETE 0x30
Silvio Lucio Oliva 70:d20d30f59b1c 456 typedef __packed struct _evt_encryption_key_refresh_complete{
Silvio Lucio Oliva 70:d20d30f59b1c 457 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 458 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 459 } PACKED evt_encryption_key_refresh_complete;
Silvio Lucio Oliva 70:d20d30f59b1c 460 #define EVT_ENCRYPTION_KEY_REFRESH_COMPLETE_SIZE 3
Silvio Lucio Oliva 70:d20d30f59b1c 461
Silvio Lucio Oliva 70:d20d30f59b1c 462 #define EVT_LE_META_EVENT 0x3E
Silvio Lucio Oliva 70:d20d30f59b1c 463 typedef __packed struct _evt_le_meta_event{
Silvio Lucio Oliva 70:d20d30f59b1c 464 uint8_t subevent;
Silvio Lucio Oliva 70:d20d30f59b1c 465 uint8_t data[0];
Silvio Lucio Oliva 70:d20d30f59b1c 466 } PACKED evt_le_meta_event;
Silvio Lucio Oliva 70:d20d30f59b1c 467 #define EVT_LE_META_EVENT_SIZE 1
Silvio Lucio Oliva 70:d20d30f59b1c 468
Silvio Lucio Oliva 70:d20d30f59b1c 469 #define EVT_LE_CONN_COMPLETE 0x01
Silvio Lucio Oliva 70:d20d30f59b1c 470 typedef __packed struct _evt_le_connection_complete{
Silvio Lucio Oliva 70:d20d30f59b1c 471 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 472 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 473 uint8_t role;
Silvio Lucio Oliva 70:d20d30f59b1c 474 uint8_t peer_bdaddr_type;
Silvio Lucio Oliva 70:d20d30f59b1c 475 tBDAddr peer_bdaddr;
Silvio Lucio Oliva 70:d20d30f59b1c 476 uint16_t interval;
Silvio Lucio Oliva 70:d20d30f59b1c 477 uint16_t latency;
Silvio Lucio Oliva 70:d20d30f59b1c 478 uint16_t supervision_timeout;
Silvio Lucio Oliva 70:d20d30f59b1c 479 uint8_t master_clock_accuracy;
Silvio Lucio Oliva 70:d20d30f59b1c 480 } PACKED evt_le_connection_complete;
Silvio Lucio Oliva 70:d20d30f59b1c 481 #define EVT_LE_CONN_COMPLETE_SIZE 18
Silvio Lucio Oliva 70:d20d30f59b1c 482
Silvio Lucio Oliva 70:d20d30f59b1c 483 #define EVT_LE_ADVERTISING_REPORT 0x02
Silvio Lucio Oliva 70:d20d30f59b1c 484 typedef __packed struct _le_advertising_info{
Silvio Lucio Oliva 70:d20d30f59b1c 485 uint8_t evt_type;
Silvio Lucio Oliva 70:d20d30f59b1c 486 uint8_t bdaddr_type;
Silvio Lucio Oliva 70:d20d30f59b1c 487 tBDAddr bdaddr;
Silvio Lucio Oliva 70:d20d30f59b1c 488 uint8_t data_length;
Silvio Lucio Oliva 70:d20d30f59b1c 489 uint8_t data_RSSI[0]; // RSSI is last octect (signed integer).
Silvio Lucio Oliva 70:d20d30f59b1c 490 } PACKED le_advertising_info;
Silvio Lucio Oliva 70:d20d30f59b1c 491 #define LE_ADVERTISING_INFO_SIZE 9
Silvio Lucio Oliva 70:d20d30f59b1c 492
Silvio Lucio Oliva 70:d20d30f59b1c 493 #define EVT_LE_CONN_UPDATE_COMPLETE 0x03
Silvio Lucio Oliva 70:d20d30f59b1c 494 typedef __packed struct _evt_le_connection_update_complete{
Silvio Lucio Oliva 70:d20d30f59b1c 495 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 496 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 497 uint16_t interval;
Silvio Lucio Oliva 70:d20d30f59b1c 498 uint16_t latency;
Silvio Lucio Oliva 70:d20d30f59b1c 499 uint16_t supervision_timeout;
Silvio Lucio Oliva 70:d20d30f59b1c 500 } PACKED evt_le_connection_update_complete;
Silvio Lucio Oliva 70:d20d30f59b1c 501 #define EVT_LE_CONN_UPDATE_COMPLETE_SIZE 9
Silvio Lucio Oliva 70:d20d30f59b1c 502
Silvio Lucio Oliva 70:d20d30f59b1c 503 #define EVT_LE_READ_REMOTE_USED_FEATURES_COMPLETE 0x04
Silvio Lucio Oliva 70:d20d30f59b1c 504 typedef __packed struct _evt_le_read_remote_used_features_complete{
Silvio Lucio Oliva 70:d20d30f59b1c 505 uint8_t status;
Silvio Lucio Oliva 70:d20d30f59b1c 506 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 507 uint8_t features[8];
Silvio Lucio Oliva 70:d20d30f59b1c 508 } PACKED evt_le_read_remote_used_features_complete;
Silvio Lucio Oliva 70:d20d30f59b1c 509 #define EVT_LE_READ_REMOTE_USED_FEATURES_COMPLETE_SIZE 11
Silvio Lucio Oliva 70:d20d30f59b1c 510
Silvio Lucio Oliva 70:d20d30f59b1c 511 #define EVT_LE_LTK_REQUEST 0x05
Silvio Lucio Oliva 70:d20d30f59b1c 512 typedef __packed struct _evt_le_long_term_key_request{
Silvio Lucio Oliva 70:d20d30f59b1c 513 uint16_t handle;
Silvio Lucio Oliva 70:d20d30f59b1c 514 uint8_t random[8];
Silvio Lucio Oliva 70:d20d30f59b1c 515 uint16_t ediv;
Silvio Lucio Oliva 70:d20d30f59b1c 516 } PACKED evt_le_long_term_key_request;
Silvio Lucio Oliva 70:d20d30f59b1c 517 #define EVT_LE_LTK_REQUEST_SIZE 12
Silvio Lucio Oliva 70:d20d30f59b1c 518
Silvio Lucio Oliva 70:d20d30f59b1c 519 /**
Silvio Lucio Oliva 70:d20d30f59b1c 520 * The event code in the @ref hci_event_pckt structure. If event code is EVT_VENDOR,
Silvio Lucio Oliva 70:d20d30f59b1c 521 * application can use @ref evt_blue_aci structure to parse the packet.
Silvio Lucio Oliva 70:d20d30f59b1c 522 */
Silvio Lucio Oliva 70:d20d30f59b1c 523 #define EVT_VENDOR 0xFF
Silvio Lucio Oliva 70:d20d30f59b1c 524
Silvio Lucio Oliva 70:d20d30f59b1c 525
Silvio Lucio Oliva 70:d20d30f59b1c 526 /* Command opcode pack/unpack */
Silvio Lucio Oliva 70:d20d30f59b1c 527 #define cmd_opcode_pack(ogf, ocf) (uint16_t)((ocf & 0x03ff)|(ogf << 10))
Silvio Lucio Oliva 70:d20d30f59b1c 528 #define cmd_opcode_ogf(op) (op >> 10)
Silvio Lucio Oliva 70:d20d30f59b1c 529 #define cmd_opcode_ocf(op) (op & 0x03ff)
Silvio Lucio Oliva 70:d20d30f59b1c 530
Silvio Lucio Oliva 70:d20d30f59b1c 531
Silvio Lucio Oliva 70:d20d30f59b1c 532 struct hci_request {
Silvio Lucio Oliva 70:d20d30f59b1c 533 uint16_t ogf;
Silvio Lucio Oliva 70:d20d30f59b1c 534 uint16_t ocf;
Silvio Lucio Oliva 70:d20d30f59b1c 535 int event;
Silvio Lucio Oliva 70:d20d30f59b1c 536 void *cparam;
Silvio Lucio Oliva 70:d20d30f59b1c 537 int clen;
Silvio Lucio Oliva 70:d20d30f59b1c 538 void *rparam;
Silvio Lucio Oliva 70:d20d30f59b1c 539 int rlen;
Silvio Lucio Oliva 70:d20d30f59b1c 540 };
Silvio Lucio Oliva 70:d20d30f59b1c 541
Silvio Lucio Oliva 70:d20d30f59b1c 542 void hci_send_cmd(uint16_t ogf, uint16_t ocf, uint8_t plen, void *param);
Silvio Lucio Oliva 70:d20d30f59b1c 543
Silvio Lucio Oliva 70:d20d30f59b1c 544 typedef enum {
Silvio Lucio Oliva 70:d20d30f59b1c 545 WAITING_TYPE,
Silvio Lucio Oliva 70:d20d30f59b1c 546 WAITING_OPCODE1,
Silvio Lucio Oliva 70:d20d30f59b1c 547 WAITING_OPCODE2,
Silvio Lucio Oliva 70:d20d30f59b1c 548 WAITING_EVENT_CODE,
Silvio Lucio Oliva 70:d20d30f59b1c 549 WAITING_HANDLE,
Silvio Lucio Oliva 70:d20d30f59b1c 550 WAITING_HANDLE_FLAG,
Silvio Lucio Oliva 70:d20d30f59b1c 551 WAITING_PARAM_LEN,
Silvio Lucio Oliva 70:d20d30f59b1c 552 WAITING_DATA_LEN1,
Silvio Lucio Oliva 70:d20d30f59b1c 553 WAITING_DATA_LEN2,
Silvio Lucio Oliva 70:d20d30f59b1c 554 WAITING_PAYLOAD
Silvio Lucio Oliva 70:d20d30f59b1c 555 }hci_state;
Silvio Lucio Oliva 70:d20d30f59b1c 556
Silvio Lucio Oliva 70:d20d30f59b1c 557 typedef void (*hci_packet_complete_callback)(void *pckt, uint16_t len);
Silvio Lucio Oliva 70:d20d30f59b1c 558
Silvio Lucio Oliva 70:d20d30f59b1c 559 /* HCI library functions. */
Silvio Lucio Oliva 70:d20d30f59b1c 560 void hci_init(void);
Silvio Lucio Oliva 70:d20d30f59b1c 561
Silvio Lucio Oliva 70:d20d30f59b1c 562 int hci_send_req(struct hci_request *r, BOOL async);
Silvio Lucio Oliva 70:d20d30f59b1c 563
Silvio Lucio Oliva 70:d20d30f59b1c 564 #endif /* __HCI_INTERNAL_H_ */