nrf8001: added new BLE module with broadcasting example
[contrib/upm.git] / src / nrf8001 / lib_aci.h
1 /* Copyright (c) 2014, Nordic Semiconductor ASA\r
2  *\r
3  * Permission is hereby granted, free of charge, to any person obtaining a copy\r
4  * of this software and associated documentation files (the "Software"), to deal\r
5  * in the Software without restriction, including without limitation the rights\r
6  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
7  * copies of the Software, and to permit persons to whom the Software is\r
8  * furnished to do so, subject to the following conditions:\r
9  *\r
10  * The above copyright notice and this permission notice shall be included in all\r
11  * copies or substantial portions of the Software.\r
12  *\r
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
19  * SOFTWARE.\r
20  */\r
21 \r
22 #ifndef LIB_ACI_H__\r
23 #define LIB_ACI_H__\r
24 \r
25 /** @file\r
26 * @brief ACI library\r
27 */\r
28 \r
29 /** @addtogroup lib_aci\r
30 @{\r
31 @brief Library for the logical part of the Application Controller Interface (ACI)\r
32 */\r
33 \r
34 #ifdef __cplusplus\r
35 extern "C" {\r
36 #endif\r
37 \r
38 #include "hal_platform.h"\r
39 #include "hal_aci_tl.h"\r
40 #include "aci_queue.h"\r
41 #include "aci.h"\r
42 #include "aci_cmds.h"\r
43 #include "aci_evts.h"\r
44 \r
45 #define EVT_CMD_RESPONSE_MIN_LENGTH              3\r
46 \r
47 #define PIPES_ARRAY_SIZE                ((ACI_DEVICE_MAX_PIPES + 7)/8)\r
48 \r
49 /* Same size as a hal_aci_data_t */\r
50 typedef struct {\r
51   uint8_t   debug_byte;\r
52   aci_evt_t evt;\r
53 } _aci_packed_ hal_aci_evt_t;\r
54 \r
55 ACI_ASSERT_SIZE(hal_aci_evt_t, 34);\r
56 \r
57 typedef struct\r
58 {\r
59   uint8_t  location; /**< enum aci_pipe_store_t */\r
60   aci_pipe_type_t   pipe_type;\r
61 } services_pipe_type_mapping_t;\r
62 \r
63 typedef struct aci_setup_info_t\r
64 {\r
65   services_pipe_type_mapping_t *services_pipe_type_mapping;\r
66   uint8_t                       number_of_pipes;\r
67   hal_aci_data_t               *setup_msgs;\r
68   uint8_t                       num_setup_msgs;\r
69 } aci_setup_info_t;\r
70 \r
71 \r
72 \r
73 // aci_struct that will contain\r
74 // total initial credits\r
75 // current credit\r
76 // current state of the aci (setup/standby/active/sleep)\r
77 // open remote pipe pending\r
78 // close remote pipe pending\r
79 // Current pipe available bitmap\r
80 // Current pipe closed bitmap\r
81 // Current connection interval, slave latency and link supervision timeout\r
82 // Current State of the the GATT client (Service Discovery status)\r
83 // Relationship of bond to peer address\r
84 typedef struct aci_state_t\r
85 {\r
86     aci_pins_t                    aci_pins;                               /* Pins on the MCU used to connect to the nRF8001 */\r
87     aci_setup_info_t              aci_setup_info;                         /* Data structures that are created from nRFgo Studio */\r
88     uint8_t                       bonded;                                 /* ( aci_bond_status_code_t ) Is the nRF8001 bonded to a peer device */\r
89     uint8_t                       data_credit_total;                      /* Total data credit available for the specific version of the nRF8001, total equals available when a link is established */\r
90     aci_device_operation_mode_t   device_state;                           /* Operating mode of the nRF8001 */\r
91 \r
92     /* */\r
93 \r
94     /* Start : Variables that are valid only when in a connection */\r
95     uint8_t                       data_credit_available;                  /* Available data credits at a specific point of time, ACI_EVT_DATA_CREDIT updates the available credits */\r
96 \r
97     uint16_t                      connection_interval;                    /* Multiply by 1.25 to get the connection interval in milliseconds*/\r
98     uint16_t                      slave_latency;                          /* Number of consecutive connection intervals that the nRF8001 is not required to transmit. Use this to save power */\r
99     uint16_t                      supervision_timeout;                    /* Multiply by 10 to get the supervision timeout in milliseconds */\r
100 \r
101     uint8_t                       pipes_open_bitmap[PIPES_ARRAY_SIZE];    /* Bitmap -> pipes are open and can be used for sending data over the air */\r
102     uint8_t                       pipes_closed_bitmap[PIPES_ARRAY_SIZE];  /* Bitmap -> pipes are closed and cannot be used for sending data over the air */\r
103     bool                          confirmation_pending;                   /* Attribute protocol Handle Value confirmation is pending for a Handle Value Indication\r
104                                                                         (ACK is pending for a TX_ACK pipe) on local GATT Server*/\r
105     /* End : Variables that are valid only when in a connection */\r
106 \r
107 } aci_state_t;\r
108 \r
109 \r
110 \r
111 #define DISCONNECT_REASON_CX_TIMEOUT                 0x08\r
112 #define DISCONNECT_REASON_CX_CLOSED_BY_PEER_DEVICE   0x13\r
113 #define DISCONNECT_REASON_POWER_LOSS                 0x14\r
114 #define DISCONNECT_REASON_CX_CLOSED_BY_LOCAL_DEVICE  0x16\r
115 #define DISCONNECT_REASON_ADVERTISER_TIMEOUT         0x50\r
116 \r
117 \r
118 /** @name Functions for library management */\r
119 //@{\r
120 \r
121 /** @brief Function to enable printing of all ACI commands sent and ACI events received\r
122  *  @details This function shall be used to enable or disable the debug printing.\r
123               Debug printing is disabled by default.\r
124  */\r
125 void lib_aci_debug_print(bool enable);\r
126 \r
127 /** @brief Function to pin reset the nRF8001\r
128  *  @details Pin resets the nRF8001 also handles differences between development boards\r
129  */\r
130 void lib_aci_pin_reset(void);\r
131 \r
132 /** @brief Initialization function.\r
133  *  @details This function shall be used to initialize/reset ACI Library and also Resets the\r
134  *           nRF8001 by togging the reset pin of the nRF8001. This function will reset\r
135  *           all the variables locally used by ACI library to their respective default values.\r
136  *  @param bool True if the data was successfully queued for sending,\r
137  *  false if there is no more space to store messages to send.\r
138  */\r
139 void lib_aci_init(aci_state_t *aci_stat, bool debug);\r
140 \r
141 \r
142 /** @brief Gets the number of currently available ACI credits.\r
143  *  @return Number of ACI credits.\r
144  */\r
145 uint8_t lib_aci_get_nb_available_credits(aci_state_t *aci_stat);\r
146 \r
147 /** @brief Gets the connection interval in milliseconds.\r
148  *  @return Connection interval in milliseconds.\r
149  */\r
150 uint16_t lib_aci_get_cx_interval_ms(aci_state_t *aci_stat);\r
151 \r
152 /** @brief Gets the connection interval in multiple of 1.25&nbsp;ms.\r
153  *  @return Connection interval in multiple of 1.25&nbsp;ms.\r
154  */\r
155 uint16_t lib_aci_get_cx_interval(aci_state_t *aci_stat);\r
156 \r
157 /** @brief Gets the current slave latency.\r
158  *  @return Current slave latency.\r
159  */\r
160 uint16_t lib_aci_get_slave_latency(aci_state_t *aci_stat);\r
161 \r
162 /** @brief Checks if a given pipe is available.\r
163  *  @param pipe Pipe to check.\r
164  *  @return True if the pipe is available, otherwise false.\r
165  */\r
166 bool lib_aci_is_pipe_available(aci_state_t *aci_stat, uint8_t pipe);\r
167 \r
168 /** @brief Checks if a given pipe is closed.\r
169  *  @param pipe Pipe to check.\r
170  *  @return True if the pipe is closed, otherwise false.\r
171  */\r
172 bool lib_aci_is_pipe_closed(aci_state_t *aci_stat, uint8_t pipe);\r
173 \r
174 /** @brief Checks if the discovery operation is finished.\r
175  *  @return True if the discovery is finished.\r
176  */\r
177 bool lib_aci_is_discovery_finished(aci_state_t *aci_stat);\r
178 \r
179 \r
180 \r
181 //@}\r
182 \r
183 /** @name ACI Commands available in all modes */\r
184 //@{\r
185 \r
186 /** @brief Sets the radio in sleep mode.\r
187  *  @details The function sends a @c sleep command to the radio.\r
188  *  If the radio is advertising or connected, it sends back an error, then use lib_aci_radio_reset\r
189  *  if advertising or disconnect if in a connection.\r
190  *  @return True if the transaction is successfully initiated.\r
191  */\r
192 bool lib_aci_sleep(void);\r
193 \r
194 /** @brief Resets the radio.\r
195  *  @details The function sends a @c BasebandReset command to the radio.\r
196  *  @return True if the transaction is successfully initiated.\r
197  */\r
198 bool lib_aci_radio_reset(void);\r
199 \r
200 /** @brief Radio starts directed advertising to bonded device.\r
201  *  @details The function sends a @c DirectedConnect command to the radio.\r
202  *  @return True if the transaction is successfully initiated.\r
203  */\r
204 bool lib_aci_direct_connect(void);\r
205 \r
206 /** @brief Gets the radio's version.\r
207  *  @details This function sends a @c GetDeviceVersion command.\r
208  *  @return True if the transaction is successfully initiated.\r
209  */\r
210 bool lib_aci_device_version(void);\r
211 \r
212 /** @brief Gets the device address.\r
213  *  @details This function sends a @c GetDeviceAddress command.\r
214  *  @return True if the transaction is successfully initiated.\r
215  */\r
216 bool lib_aci_get_address(void);\r
217 \r
218 /** @brief Gets the temperature.\r
219  *  @details This function sends a @c GetTemperature command. lib_aci\r
220  *  calls the @ref lib_aci_transaction_finished_hook() function when the temperature is received.\r
221  *  @return True if the transaction is successfully initiated.\r
222  */\r
223 bool lib_aci_get_temperature(void);\r
224 \r
225 /** @brief Gets the battery level.\r
226  *  @details This function sends a @c GetBatteryLevel command.\r
227  *  @return True if the transaction is successfully initiated.\r
228  */\r
229 bool lib_aci_get_battery_level(void);\r
230 \r
231 //@}\r
232 \r
233 /** @name ACI commands available in Sleep mode */\r
234 //@{\r
235 \r
236 /** @brief Wakes up the radio.\r
237  *  @details This function sends a @c Wakeup command to wake up the radio from\r
238  *  sleep mode. When woken up the radio sends a @c DeviceStartedEvent and\r
239  *  a @c CommandResponseEvent.\r
240  *  @return True if the transaction is successfully initiated.\r
241  */\r
242 bool lib_aci_wakeup(void);\r
243 \r
244 //@}\r
245 \r
246 /** @name ACI commands available in Active mode */\r
247 //@{\r
248 \r
249 /** @brief Sets the radio in test mode.\r
250  *  @details This function sends a @c Test command to the radio. There are two\r
251  *  Test modes available:\r
252  *  - UART: DTM commands are received over UART.\r
253  *  - ACI: DTM commands are received over ACI.\r
254  *  The same command is used to exit the test mode When receiving\r
255  *  a @c DeviceStartedEvent the radio has entered the new mode.\r
256  *  @param enter_exit_test_mode Enter a Test mode, or exit Test mode.\r
257  *  @return True if the transaction is successfully initiated.\r
258  */\r
259 bool lib_aci_test(aci_test_mode_change_t enter_exit_test_mode);\r
260 \r
261 /** @brief Sets the radio's TX power.\r
262  *  @details This function sends a @c SetTxPower command.\r
263  *  @param tx_power TX power to be used by the radio.\r
264  *  @return True if the transaction is successfully initiated.\r
265  */\r
266 bool lib_aci_set_tx_power(aci_device_output_power_t tx_power);\r
267 \r
268 /** @brief Tries to connect to a peer device.\r
269  *  @details This function sends a @c Connect command to the radio.\r
270  *  @param run_timeout Maximum advertising time in seconds (0 means infinite).\r
271  *  @param adv_interval Advertising interval (in multiple of 0.625&nbsp;ms).\r
272  *  @return True if the transaction is successfully initiated.\r
273  */\r
274 bool lib_aci_connect(uint16_t run_timeout, uint16_t adv_interval);\r
275 \r
276 /** @brief Tries to bond with a peer device.\r
277  *  @details This function sends a @c Bond command to the radio.\r
278  *  @param run_timeout Maximum advertising time in seconds (0 means infinite).\r
279  *  @param adv_interval Advertising interval (in multiple of 0.625&nbsp;ms).\r
280  *  @return True if the transaction is successfully initiated.\r
281  */\r
282 bool lib_aci_bond(uint16_t run_timeout, uint16_t adv_interval);\r
283 \r
284 /** @brief Disconnects from peer device.\r
285  *  @details This function sends a @c Disconnect command to the radio.\r
286  *  @param reason Reason for disconnecting.\r
287  *  @return True if the transaction is successfully initiated.\r
288  */\r
289 bool lib_aci_disconnect(aci_state_t *aci_stat, aci_disconnect_reason_t reason);\r
290 \r
291 /**@brief Sets Local Data.\r
292  *  @details\r
293  *  This command updates the value of the characteristic value or the characteristic descriptor stored locally on the device.\r
294  *  Can be called for all types of pipes as long as the data is stored locally.\r
295  *  @param ACI state structure\r
296  *  @param pipe Pipe number on which the data should be set.\r
297  *  @param value Pointer to the data to set.\r
298  *  @param size Size of the data to set.\r
299  *  @return True if the transaction is successfully initiated.\r
300 */\r
301 bool lib_aci_set_local_data(aci_state_t *aci_stat, uint8_t pipe, uint8_t *value, uint8_t size);\r
302 \r
303 /** @brief Sends Broadcast message to the radio.\r
304  *  @details The Broadcast message starts advertisement procedure\r
305  *  using the given interval with the intention of broadcasting data to a peer device.\r
306  *  @param timeout Time, in seconds, to advertise before exiting to standby mode (0 means infinite).\r
307  *  Valid values: 0 to 16383.\r
308  *  @param adv_interval Advertising interval (in multiple of 0.625&nbsp;ms).\r
309  *  Valid values: 160 to 16384 (which corresponds to an interval from 100 ms to 10.24 s).\r
310  *  @return True if the broadcast message is sent successfully to the radio.\r
311 */\r
312 bool lib_aci_broadcast(const uint16_t timeout, const uint16_t adv_interval);\r
313 \r
314 /** @name Open Advertising Pipes.  */\r
315 \r
316 /** @brief Sends a command to the radio to set the input pipe to be placed in Advertisement Service Data.\r
317  *  @details This function sends a command to the radio that places the pipe in\r
318  *  advertisement service data.  To start advertising service data, call this function before\r
319  *  Connecting, Broadcasting or Bonding to peer. The data that should be sent in the advertisement packets\r
320  *  must be set using the @c lib_aci_set_local_data function. This function can be called during\r
321  *  advertising to enable/disable broadcast pipes.\r
322  *  @param pipe The pipe that has to be placed in advertising service data.\r
323  *  @return True if the Open Adv Pipe message is sent successfully to the radio.\r
324 */\r
325 bool lib_aci_open_adv_pipe(const uint8_t pipe);\r
326 \r
327 \r
328 /** @name Open Advertising Pipes  */\r
329 \r
330 /** @brief Sends a command to the radio to set the pipes to be placed in Advertisement Service Data.\r
331  *  @details This function will send a command to the radio that will set the pipes to be placed in\r
332  *  advertisement Service Data.  To start advertising service data, this function should be called before\r
333  *  Connecting, Broadcasting or Bonding to peer. This function can be called during\r
334  *  advertising to enable/disable broadcast pipes. Use this as an alternative to @ref lib_aci_open_adv_pipe\r
335  *  to avoid multiple function calls for placing multiple pipes in the adv data.\r
336  *  @param adv_service_data_pipes Pipe bitmap, where '1' indicates that the corresponding\r
337  *  Valid Values: 0000000000000000 to FEFFFFFFFFFFFF7F (See the ACI Pipe Status Evt bitmap in the nRF8001 datasheet\r
338  *  TX_BROADCAST pipe data is to be placed in Advertising Service Data fields\r
339  *  @return true if the Open Adv Pipe message was sent successfully to the radio.\r
340 */\r
341 bool lib_aci_open_adv_pipes(const uint8_t * const adv_service_data_pipes);\r
342 \r
343 \r
344 //@}\r
345 \r
346 /** @name ACI commands available in Connected mode */\r
347 //@{\r
348 \r
349 \r
350 /** @brief Sets a given application latency.\r
351  *  @details This function sends a @c setApplicationLatency command.\r
352  *  @return True if the transaction is successfully initiated.\r
353  */\r
354 bool lib_aci_set_app_latency(uint16_t latency, aci_app_latency_mode_t latency_mode);\r
355 \r
356 /** @brief Opens a remote pipe.\r
357  *  @details This function sends an @c OpenRemotePipe command.\r
358  *  @param pipe Number of the pipe to open.\r
359  *  @return True if the transaction is successfully initiated.\r
360  */\r
361 bool lib_aci_open_remote_pipe(aci_state_t *aci_stat, uint8_t pipe);\r
362 \r
363 /** @brief Closes a remote pipe.\r
364  *  @details This function sends an @c CloseRemotePipe command.\r
365  *  @param pipe Pipe number to close.\r
366  *  @return True if the transaction is successfully initiated.\r
367  */\r
368 bool lib_aci_close_remote_pipe(aci_state_t *aci_stat, uint8_t pipe);\r
369 \r
370 /** @brief Sends data on a given pipe.\r
371  *  @details This function sends a @c SendData command with application data to\r
372  *  the radio. This function memorizes credit use, and checks that\r
373  *  enough credits are available.\r
374  *  @param pipe Pipe number on which the data should be sent.\r
375  *  @param value Pointer to the data to send.\r
376  *  @param size Size of the data to send.\r
377  *  @return True if the transaction is successfully initiated.\r
378  */\r
379 bool lib_aci_send_data(uint8_t pipe, uint8_t *value, uint8_t size);\r
380 \r
381 /** @brief Requests data from a given pipe.\r
382  *  @details This function sends a @c RequestData command to the radio. This\r
383  *  function memorizes credit uses, and check that enough credits are available.\r
384  *  After this command, the radio sends back either a @c DataReceivedEvent\r
385  *  or a @c PipeErrorEvent.\r
386  *  @param pipe Pipe number on which the data is requested.\r
387  *  @return True if the transaction is successfully initiated.\r
388  */\r
389 bool lib_aci_request_data(aci_state_t *aci_stat, uint8_t pipe);\r
390 \r
391 /** @brief Sends a L2CAP change connection parameters request.\r
392  *  @details This function sends a @c ChangeTiming command to the radio.  This command triggers a "L2CAP change connection parameters" request\r
393  *  to the master. If the master rejects or accepts but doesn't change the connection parameters within\r
394  *  30 seconds, a timing event with the unchanged connection parameters is sent by the radio.\r
395  *  If the request is accepted and the master changes connection parameters, a timing event with\r
396  *  the new connection parameters is sent by the radio.\r
397  *  If the master doesn't reply to the request within 60 seconds, the radio disconnects.\r
398  *  @param minimun_cx_interval Minimum connection interval requested, in multiple of 1.25&nbsp;ms.\r
399  *  @param maximum_cx_interval Maximum connection interval requested, in multiple of 1.25&nbsp;ms.\r
400  *  @param slave_latency requested slave latency.\r
401  *  @param timeout requested slave timeout, in multiple of 10&nbsp;ms.\r
402  *  @return True if the transaction is successfully initiated.\r
403  */\r
404 bool lib_aci_change_timing(uint16_t minimun_cx_interval, uint16_t maximum_cx_interval, uint16_t slave_latency, uint16_t timeout);\r
405 \r
406 /** @brief Sends a L2CAP change connection parameters request with the connection predefined preffered connection parameters.\r
407  *  @details This function sends a @c ChangeTiming command to the radio. This command triggers a "L2CAP change connection parameters" request\r
408  *  to the master. If the master rejects or accepts but doesn't change the connection parameters within\r
409  *  30 seconds, a timing event with the unchanged connection parameters is sent by the radio.\r
410  *  If the request is accepted and the master changes connection parameters, a timing event with\r
411  *  the new connection parameters is sent by the radio.\r
412  *  If the master doesn't reply to the request within 60 seconds, the radio disconnects.\r
413  *  The timing parameters used are the Timing parameters in the GAP settings in the nRFgo Studio.\r
414  *  The Timing parameters as stored as the GAP Preferred Peripheral Connection Parameters.\r
415  *  @return True if the transaction is successfully initiated.\r
416  */\r
417 bool lib_aci_change_timing_GAP_PPCP(void);\r
418 \r
419 /** @brief Sends acknowledgement message to peer.\r
420  *  @details This function sends @c SendDataAck command to radio. The radio is expected\r
421  *  to send either Handle Value Confirmation or Write response depending\r
422  *  on whether the data is stored remotely or locally.\r
423  *  @param pipe Pipe number for which the acknowledgement is to be sent.\r
424  *  @return True if the ack was sent successfully. False otherwise.\r
425 */\r
426 bool lib_aci_send_ack(aci_state_t *aci_stat, const uint8_t pipe);\r
427 \r
428 /** @brief Sends negative acknowledgement message to peer.\r
429  *  @details This function sends @c SendDataNack command to radio. The radio is expected\r
430  *  to send Error Response to the peer.\r
431  *  @param pipe Pipe number for which the nack is to be sent.\r
432  *  @param error_code Error code to be sent in the NACk.\r
433  *  @return True if the nack was sent successfully. False otherwise.\r
434 */\r
435 bool lib_aci_send_nack(aci_state_t *aci_stat, const uint8_t pipe, const uint8_t error_code);\r
436 \r
437 /** @brief Sends ReadDynamicData command to the host.\r
438  *  @details This function sends @c ReadDynamicData command to host. The host is expected\r
439  *  to send @c CommandResponse back with the dynamic data. The application is expected to\r
440  *  call this function in a loop until all the dynamic data is read out from the host.\r
441  *  As long as there is dynamic data to be read from the host, the command response\r
442  *  for this message has its status field set to ACI_STATUS_TRANSACTION_CONTINUE (0x01).\r
443  *  The application may chose to store this read out data in a non-volatile memory location\r
444  *  and later chose to write it back using the function lib_aci_write_dynamic_data.\r
445  *  @return True if the command was sent successfully through the ACI. False otherwise.\r
446 */\r
447 bool lib_aci_read_dynamic_data(void);\r
448 \r
449 /** @brief Sends WriteDynamicData command to the host.\r
450  *  @details This function sends @c WriteDynamicData command to host. The host is expected\r
451  *  to send @c CommandResponse with the status of this operation. As long as the status field\r
452  *  in the @c CommandResponse is ACI_STATUS_TRANSACTION_CONTINUE (0x01), the hosts expects\r
453  *  more dynamic data to be written. This function should ideally be called in a cycle,\r
454  *  until all the stored dynamic data is sent to the host. This function should be\r
455  *  called with the dynamic data obtained from the response to a @c ReadDynamicData\r
456  *  (see @c lib_aci_read_dynamic_data) command.\r
457  *  @param sequence_number Sequence number of the dynamic data to be sent.\r
458  *  @param dynamic_data Pointer to the dynamic data.\r
459  *  @param length Length of the dynamic data.\r
460  *  @return True if the command was sent successfully through the ACI. False otherwise.\r
461 */\r
462 bool lib_aci_write_dynamic_data(uint8_t sequence_number, uint8_t* dynamic_data, uint8_t length);\r
463 //@}\r
464 \r
465 /** @name ACI commands available while connected in Bond mode */\r
466 //@{\r
467 \r
468 /** @brief Sends a SMP Security Request.\r
469  *  @details This function send a @c BondRequest command to the radio.\r
470  *  This command triggers a SMP Security Request to the master. If the\r
471  *  master rejects with a pairing failed or if the bond timer expires the connection is closed.\r
472  *  @return True if the transaction is successfully initiated.\r
473  */\r
474 bool lib_aci_bond_request(void);\r
475 \r
476 /** @brief Set the key requested by the 8001.\r
477  *  @details This function sends an @c SetKey command to the radio.\r
478  *  @param key_rsp_type Type of key.\r
479  *  @param key Pointer to the key to set.\r
480  *  @param len Length of the key.\r
481  *  @return True if the transaction is successfully initiated.\r
482 */\r
483 bool lib_aci_set_key(aci_key_type_t key_rsp_type, uint8_t *key, uint8_t len);\r
484 \r
485 //@}\r
486 \r
487 \r
488 \r
489 /** @name ACI commands available in Test mode */\r
490 //@{\r
491 \r
492 /** @brief Sends an echo message\r
493  *  @details This function sends an @c Echo command to the radio. lib_aci\r
494  *  places the Echp ACI command in the ACI command queue\r
495  *  @param message_size Length of the data to send.\r
496  *  @param message_data Pointer to the data to send.\r
497  *  @return True if the transaction is successfully initiated.\r
498 */\r
499 bool lib_aci_echo_msg(uint8_t message_size, uint8_t *message_data);\r
500 \r
501 /** @brief Sends an DTM command\r
502  *  @details This function sends an @c DTM command to the radio.\r
503  *  @param dtm_command_msbyte Most significant byte of the DTM command.\r
504  *  @param dtm_command_lsbyte Least significant byte of the DTM command.\r
505  *  @return True if the transaction is successfully initiated.\r
506 */\r
507 bool lib_aci_dtm_command(uint8_t dtm_command_msbyte, uint8_t dtm_command_lsbyte);\r
508 \r
509 /** @brief Gets an ACI event from the ACI Event Queue\r
510  *  @details This function gets an ACI event from the ACI event queue.\r
511  *  The queue is updated by the SPI driver for the ACI running in the interrupt context\r
512  *  @param aci_stat pointer to the state of the ACI.\r
513  *  @param p_aci_data pointer to the ACI Event. The ACI Event received will be copied into this pointer.\r
514  *  @return True if an ACI Event was copied to the pointer.\r
515 */\r
516 bool lib_aci_event_get(aci_state_t *aci_stat, hal_aci_evt_t * aci_evt);\r
517 \r
518 /** @brief Peeks an ACI event from the ACI Event Queue\r
519  * @details This function peeks at the top event in the ACI event queue.\r
520  * In polling mode, this function will query the nRF8001 for pending events, but unlike\r
521  * lib_aci_event_get() it will not dequeue the event from the local queue, but will instead\r
522  * only peek at it.\r
523  * @return True if an ACI Event was copied to the pointer.\r
524 */\r
525 bool lib_aci_event_peek(hal_aci_evt_t *p_aci_evt_data);\r
526 \r
527 /** @brief Flushes the events in the ACI command queues and ACI Event queue\r
528  *\r
529 */\r
530 void lib_aci_flush(void);\r
531 \r
532 /** @brief Return full status of the Event queue\r
533  *  @details\r
534  *\r
535  */\r
536  bool lib_aci_event_queue_full(void);\r
537 \r
538  /** @brief Return empty status of the Event queue\r
539  *  @details\r
540  *\r
541  */\r
542  bool lib_aci_event_queue_empty(void);\r
543 \r
544 /** @brief Return full status of Command queue\r
545  *  @details\r
546  *\r
547  */\r
548  bool lib_aci_command_queue_full(void);\r
549 \r
550  /** @brief Return empty status of Command queue\r
551  *  @details\r
552  *\r
553  */\r
554  bool lib_aci_command_queue_empty(void);\r
555 \r
556 //@}\r
557 \r
558 /** @} */\r
559 \r
560 #ifdef __cplusplus\r
561 }\r
562 #endif\r
563 \r
564 #endif /* LIB_ACI_H__ */\r