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