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