NUCLEO-F401RE + BlueNRG shield client test (TI Sensortag reading)

Dependencies:   mbed-src

Committer:
ostapsky
Date:
Sat Aug 16 11:00:04 2014 +0000
Revision:
0:aa1e012ec210
CLIENT mode first revision

Who changed what in which revision?

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