Added support for obtaining BLE device name by parsing advertising data.
Fork of BLE_BlueNRG by
hci/inc/hci.h@7:e293b0f43dc7, 2014-07-31 (annotated)
- Committer:
- hemddabral
- Date:
- Thu Jul 31 11:09:28 2014 +0000
- Revision:
- 7:e293b0f43dc7
- Parent:
- 0:309c845d289d
Added support for parsing BLE device name from advertising data
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mridup | 0:309c845d289d | 1 | /******************** (C) COPYRIGHT 2012 STMicroelectronics ******************** |
mridup | 0:309c845d289d | 2 | * File Name : hci.h |
mridup | 0:309c845d289d | 3 | * Author : AMS - HEA&RF BU |
mridup | 0:309c845d289d | 4 | * Version : V1.0.0 |
mridup | 0:309c845d289d | 5 | * Date : 19-July-2012 |
mridup | 0:309c845d289d | 6 | * Description : Constants and functions for HCI layer. See Bluetooth Core |
mridup | 0:309c845d289d | 7 | * v 4.0, Vol. 2, Part E. |
mridup | 0:309c845d289d | 8 | ******************************************************************************** |
mridup | 0:309c845d289d | 9 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
mridup | 0:309c845d289d | 10 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. |
mridup | 0:309c845d289d | 11 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, |
mridup | 0:309c845d289d | 12 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE |
mridup | 0:309c845d289d | 13 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING |
mridup | 0:309c845d289d | 14 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
mridup | 0:309c845d289d | 15 | *******************************************************************************/ |
mridup | 0:309c845d289d | 16 | |
mridup | 0:309c845d289d | 17 | #ifndef __HCI_H_ |
mridup | 0:309c845d289d | 18 | #define __HCI_H_ |
mridup | 0:309c845d289d | 19 | |
mridup | 0:309c845d289d | 20 | #include "hal_types.h" |
mridup | 0:309c845d289d | 21 | #include "link_layer.h" |
mridup | 0:309c845d289d | 22 | #include <list.h> |
mridup | 0:309c845d289d | 23 | |
mridup | 0:309c845d289d | 24 | |
mridup | 0:309c845d289d | 25 | #define HCI_PACKET_SIZE 255 |
mridup | 0:309c845d289d | 26 | |
mridup | 0:309c845d289d | 27 | |
mridup | 0:309c845d289d | 28 | /*** Data types ***/ |
mridup | 0:309c845d289d | 29 | |
mridup | 0:309c845d289d | 30 | /* structure used to read received data */ |
mridup | 0:309c845d289d | 31 | typedef struct _tHciDataPacket |
mridup | 0:309c845d289d | 32 | { |
mridup | 0:309c845d289d | 33 | tListNode currentNode; |
mridup | 0:309c845d289d | 34 | uint8_t dataBuff[HCI_PACKET_SIZE]; |
mridup | 0:309c845d289d | 35 | }tHciDataPacket; |
mridup | 0:309c845d289d | 36 | |
mridup | 0:309c845d289d | 37 | |
mridup | 0:309c845d289d | 38 | /* HCI Error codes */ |
mridup | 0:309c845d289d | 39 | #define HCI_UNKNOWN_COMMAND 0x01 |
mridup | 0:309c845d289d | 40 | #define HCI_NO_CONNECTION 0x02 |
mridup | 0:309c845d289d | 41 | #define HCI_HARDWARE_FAILURE 0x03 |
mridup | 0:309c845d289d | 42 | #define HCI_PAGE_TIMEOUT 0x04 |
mridup | 0:309c845d289d | 43 | #define HCI_AUTHENTICATION_FAILURE 0x05 |
mridup | 0:309c845d289d | 44 | #define HCI_PIN_OR_KEY_MISSING 0x06 |
mridup | 0:309c845d289d | 45 | #define HCI_MEMORY_FULL 0x07 |
mridup | 0:309c845d289d | 46 | #define HCI_CONNECTION_TIMEOUT 0x08 |
mridup | 0:309c845d289d | 47 | #define HCI_MAX_NUMBER_OF_CONNECTIONS 0x09 |
mridup | 0:309c845d289d | 48 | #define HCI_MAX_NUMBER_OF_SCO_CONNECTIONS 0x0a |
mridup | 0:309c845d289d | 49 | #define HCI_ACL_CONNECTION_EXISTS 0x0b |
mridup | 0:309c845d289d | 50 | #define HCI_COMMAND_DISALLOWED 0x0c |
mridup | 0:309c845d289d | 51 | #define HCI_REJECTED_LIMITED_RESOURCES 0x0d |
mridup | 0:309c845d289d | 52 | #define HCI_REJECTED_SECURITY 0x0e |
mridup | 0:309c845d289d | 53 | #define HCI_REJECTED_PERSONAL 0x0f |
mridup | 0:309c845d289d | 54 | #define HCI_HOST_TIMEOUT 0x10 |
mridup | 0:309c845d289d | 55 | #define HCI_UNSUPPORTED_FEATURE 0x11 |
mridup | 0:309c845d289d | 56 | #define HCI_INVALID_PARAMETERS 0x12 |
mridup | 0:309c845d289d | 57 | #define HCI_OE_USER_ENDED_CONNECTION 0x13 |
mridup | 0:309c845d289d | 58 | #define HCI_OE_LOW_RESOURCES 0x14 |
mridup | 0:309c845d289d | 59 | #define HCI_OE_POWER_OFF 0x15 |
mridup | 0:309c845d289d | 60 | #define HCI_CONNECTION_TERMINATED 0x16 |
mridup | 0:309c845d289d | 61 | #define HCI_REPEATED_ATTEMPTS 0x17 |
mridup | 0:309c845d289d | 62 | #define HCI_PAIRING_NOT_ALLOWED 0x18 |
mridup | 0:309c845d289d | 63 | #define HCI_UNKNOWN_LMP_PDU 0x19 |
mridup | 0:309c845d289d | 64 | #define HCI_UNSUPPORTED_REMOTE_FEATURE 0x1a |
mridup | 0:309c845d289d | 65 | #define HCI_SCO_OFFSET_REJECTED 0x1b |
mridup | 0:309c845d289d | 66 | #define HCI_SCO_INTERVAL_REJECTED 0x1c |
mridup | 0:309c845d289d | 67 | #define HCI_AIR_MODE_REJECTED 0x1d |
mridup | 0:309c845d289d | 68 | #define HCI_INVALID_LMP_PARAMETERS 0x1e |
mridup | 0:309c845d289d | 69 | #define HCI_UNSPECIFIED_ERROR 0x1f |
mridup | 0:309c845d289d | 70 | #define HCI_UNSUPPORTED_LMP_PARAMETER_VALUE 0x20 |
mridup | 0:309c845d289d | 71 | #define HCI_ROLE_CHANGE_NOT_ALLOWED 0x21 |
mridup | 0:309c845d289d | 72 | #define HCI_LMP_RESPONSE_TIMEOUT 0x22 |
mridup | 0:309c845d289d | 73 | #define HCI_LMP_ERROR_TRANSACTION_COLLISION 0x23 |
mridup | 0:309c845d289d | 74 | #define HCI_LMP_PDU_NOT_ALLOWED 0x24 |
mridup | 0:309c845d289d | 75 | #define HCI_ENCRYPTION_MODE_NOT_ACCEPTED 0x25 |
mridup | 0:309c845d289d | 76 | #define HCI_UNIT_LINK_KEY_USED 0x26 |
mridup | 0:309c845d289d | 77 | #define HCI_QOS_NOT_SUPPORTED 0x27 |
mridup | 0:309c845d289d | 78 | #define HCI_INSTANT_PASSED 0x28 |
mridup | 0:309c845d289d | 79 | #define HCI_PAIRING_NOT_SUPPORTED 0x29 |
mridup | 0:309c845d289d | 80 | #define HCI_TRANSACTION_COLLISION 0x2a |
mridup | 0:309c845d289d | 81 | #define HCI_QOS_UNACCEPTABLE_PARAMETER 0x2c |
mridup | 0:309c845d289d | 82 | #define HCI_QOS_REJECTED 0x2d |
mridup | 0:309c845d289d | 83 | #define HCI_CLASSIFICATION_NOT_SUPPORTED 0x2e |
mridup | 0:309c845d289d | 84 | #define HCI_INSUFFICIENT_SECURITY 0x2f |
mridup | 0:309c845d289d | 85 | #define HCI_PARAMETER_OUT_OF_RANGE 0x30 |
mridup | 0:309c845d289d | 86 | #define HCI_ROLE_SWITCH_PENDING 0x32 |
mridup | 0:309c845d289d | 87 | #define HCI_SLOT_VIOLATION 0x34 |
mridup | 0:309c845d289d | 88 | #define HCI_ROLE_SWITCH_FAILED 0x35 |
mridup | 0:309c845d289d | 89 | #define HCI_EIR_TOO_LARGE 0x36 |
mridup | 0:309c845d289d | 90 | #define HCI_SIMPLE_PAIRING_NOT_SUPPORTED 0x37 |
mridup | 0:309c845d289d | 91 | #define HCI_HOST_BUSY_PAIRING 0x38 |
mridup | 0:309c845d289d | 92 | #define HCI_CONN_REJ_NO_CH_FOUND 0x39 |
mridup | 0:309c845d289d | 93 | #define HCI_CONTROLLER_BUSY 0x3A |
mridup | 0:309c845d289d | 94 | #define HCI_UNACCEPTABLE_CONN_INTERV 0x3B |
mridup | 0:309c845d289d | 95 | #define HCI_DIRECTED_ADV_TIMEOUT 0x3C |
mridup | 0:309c845d289d | 96 | #define HCI_CONN_TERM_MIC_FAIL 0x3D |
mridup | 0:309c845d289d | 97 | #define HCI_CONN_FAIL_TO_BE_ESTABL 0x3E |
mridup | 0:309c845d289d | 98 | #define HCI_MAC_CONN_FAILED 0x3F |
mridup | 0:309c845d289d | 99 | |
mridup | 0:309c845d289d | 100 | |
mridup | 0:309c845d289d | 101 | /* |
mridup | 0:309c845d289d | 102 | * HCI library functions. |
mridup | 0:309c845d289d | 103 | * Each function returns 0 in case of success, -1 otherwise. |
mridup | 0:309c845d289d | 104 | */ |
mridup | 0:309c845d289d | 105 | |
mridup | 0:309c845d289d | 106 | int hci_reset(void); |
mridup | 0:309c845d289d | 107 | |
mridup | 0:309c845d289d | 108 | int hci_disconnect(uint16_t handle, uint8_t reason); |
mridup | 0:309c845d289d | 109 | |
mridup | 0:309c845d289d | 110 | int hci_le_set_advertise_enable(tHalUint8 enable); |
mridup | 0:309c845d289d | 111 | |
mridup | 0:309c845d289d | 112 | int hci_le_set_advertising_parameters(uint16_t min_interval, uint16_t max_interval, uint8_t advtype, |
mridup | 0:309c845d289d | 113 | uint8_t own_bdaddr_type, uint8_t direct_bdaddr_type, tBDAddr direct_bdaddr, uint8_t chan_map, |
mridup | 0:309c845d289d | 114 | uint8_t filter); |
mridup | 0:309c845d289d | 115 | |
mridup | 0:309c845d289d | 116 | int hci_le_set_advertising_data(uint8_t length, const uint8_t data[]); |
mridup | 0:309c845d289d | 117 | |
mridup | 0:309c845d289d | 118 | int hci_le_set_scan_resp_data(uint8_t length, const uint8_t data[]); |
mridup | 0:309c845d289d | 119 | |
mridup | 0:309c845d289d | 120 | int hci_le_rand(uint8_t random_number[8]); |
mridup | 0:309c845d289d | 121 | |
mridup | 0:309c845d289d | 122 | int hci_le_read_advertising_channel_tx_power(int8_t *tx_power_level); |
mridup | 0:309c845d289d | 123 | |
mridup | 0:309c845d289d | 124 | int hci_acl_data(const uint8_t * data, uint16_t len); |
mridup | 0:309c845d289d | 125 | |
mridup | 0:309c845d289d | 126 | int hci_le_set_random_address(tBDAddr bdaddr); |
mridup | 0:309c845d289d | 127 | |
mridup | 0:309c845d289d | 128 | int hci_read_bd_addr(tBDAddr bdaddr); |
mridup | 0:309c845d289d | 129 | |
mridup | 0:309c845d289d | 130 | int hci_le_read_white_list_size(uint8_t *size); |
mridup | 0:309c845d289d | 131 | |
mridup | 0:309c845d289d | 132 | int hci_le_clear_white_list(); |
mridup | 0:309c845d289d | 133 | |
mridup | 0:309c845d289d | 134 | int hci_le_add_device_to_white_list(uint8_t bdaddr_type, tBDAddr bdaddr); |
mridup | 0:309c845d289d | 135 | |
mridup | 0:309c845d289d | 136 | int hci_le_remove_device_from_white_list(uint8_t bdaddr_type, tBDAddr bdaddr); |
mridup | 0:309c845d289d | 137 | |
mridup | 0:309c845d289d | 138 | int hci_le_encrypt(uint8_t key[16], uint8_t plaintextData[16], uint8_t encryptedData[16]); |
mridup | 0:309c845d289d | 139 | |
mridup | 0:309c845d289d | 140 | int hci_le_ltk_request_reply(uint8_t key[16]); |
mridup | 0:309c845d289d | 141 | |
mridup | 0:309c845d289d | 142 | int hci_le_ltk_request_neg_reply(); |
mridup | 0:309c845d289d | 143 | |
mridup | 0:309c845d289d | 144 | int hci_le_read_buffer_size(uint16_t *pkt_len, uint8_t *max_pkt); |
mridup | 0:309c845d289d | 145 | |
mridup | 0:309c845d289d | 146 | int hci_le_create_connection(uint16_t interval, uint16_t window, uint8_t initiator_filter, uint8_t peer_bdaddr_type, |
mridup | 0:309c845d289d | 147 | const tBDAddr peer_bdaddr, uint8_t own_bdaddr_type, uint16_t min_interval, uint16_t max_interval, |
mridup | 0:309c845d289d | 148 | uint16_t latency, uint16_t supervision_timeout, uint16_t min_ce_length, uint16_t max_ce_length); |
mridup | 0:309c845d289d | 149 | |
mridup | 0:309c845d289d | 150 | int hci_read_transmit_power_level(uint16_t *conn_handle, uint8_t type, int8_t * tx_level); |
mridup | 0:309c845d289d | 151 | |
mridup | 0:309c845d289d | 152 | int hci_read_rssi(uint16_t *conn_handle, int8_t * rssi); |
mridup | 0:309c845d289d | 153 | |
mridup | 0:309c845d289d | 154 | int hci_le_read_local_supported_features(uint8_t *features); |
mridup | 0:309c845d289d | 155 | |
mridup | 0:309c845d289d | 156 | int hci_le_read_channel_map(uint16_t conn_handle, uint8_t ch_map[5]); |
mridup | 0:309c845d289d | 157 | |
mridup | 0:309c845d289d | 158 | int hci_le_read_supported_states(uint8_t states[8]); |
mridup | 0:309c845d289d | 159 | |
mridup | 0:309c845d289d | 160 | int hci_le_receiver_test(uint8_t frequency); |
mridup | 0:309c845d289d | 161 | |
mridup | 0:309c845d289d | 162 | int hci_le_transmitter_test(uint8_t frequency, uint8_t length, uint8_t payload); |
mridup | 0:309c845d289d | 163 | |
mridup | 0:309c845d289d | 164 | int hci_le_test_end(uint16_t *num_pkts); |
mridup | 0:309c845d289d | 165 | |
mridup | 0:309c845d289d | 166 | /** |
mridup | 0:309c845d289d | 167 | * This function must be used to pass the packet received from the HCI |
mridup | 0:309c845d289d | 168 | * interface to the BLE Stack HCI state machine. |
mridup | 0:309c845d289d | 169 | * |
mridup | 0:309c845d289d | 170 | * @param[in] hciReadPacket The packet that is received from HCI interface. |
mridup | 0:309c845d289d | 171 | * |
mridup | 0:309c845d289d | 172 | */ |
mridup | 0:309c845d289d | 173 | void HCI_Input(tHciDataPacket * hciReadPacket); |
mridup | 0:309c845d289d | 174 | |
mridup | 0:309c845d289d | 175 | /** |
mridup | 0:309c845d289d | 176 | * Initialization function. Must be done before any data can be received from |
mridup | 0:309c845d289d | 177 | * BLE controller. |
mridup | 0:309c845d289d | 178 | */ |
mridup | 0:309c845d289d | 179 | void HCI_Init(void); |
mridup | 0:309c845d289d | 180 | |
mridup | 0:309c845d289d | 181 | /** |
mridup | 0:309c845d289d | 182 | * Callback used to pass events to application. |
mridup | 0:309c845d289d | 183 | * |
mridup | 0:309c845d289d | 184 | * @param[in] pckt The event. |
mridup | 0:309c845d289d | 185 | * |
mridup | 0:309c845d289d | 186 | */ |
mridup | 0:309c845d289d | 187 | extern void HCI_Event_CB(void *pckt); |
mridup | 0:309c845d289d | 188 | |
mridup | 0:309c845d289d | 189 | /** |
mridup | 0:309c845d289d | 190 | * Processing function that must be called after an event is received from |
mridup | 0:309c845d289d | 191 | * HCI interface. Must be called outside ISR. It will call HCI_Event_CB if |
mridup | 0:309c845d289d | 192 | * necessary. |
mridup | 0:309c845d289d | 193 | */ |
mridup | 0:309c845d289d | 194 | void HCI_Process(void); |
mridup | 0:309c845d289d | 195 | |
mridup | 0:309c845d289d | 196 | |
mridup | 0:309c845d289d | 197 | extern tListNode hciReadPktPool; |
mridup | 0:309c845d289d | 198 | extern tListNode hciReadPktRxQueue; |
mridup | 0:309c845d289d | 199 | |
mridup | 0:309c845d289d | 200 | #endif /* __HCI_H_ */ |