1 /* Copyright (c) 2014, Nordic Semiconductor ASA
\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
10 * The above copyright notice and this permission notice shall be included in all
\r
11 * copies or substantial portions of the Software.
\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
25 * @ingroup group_acilib
\r
27 * @brief Prototypes for the acilib interfaces.
\r
30 #ifndef _acilib_IF_H_
\r
31 #define _acilib_IF_H_
\r
33 /** @brief Encode the ACI message for set test mode command
\r
35 * @param[in,out] buffer Pointer to ACI message buffer
\r
36 * @param[in] test_mode Pointer to the test mode in ::aci_cmd_params_test_t
\r
40 void acil_encode_cmd_set_test_mode(uint8_t *buffer, aci_cmd_params_test_t *p_aci_cmd_params_test);
\r
42 /** @brief Encode the ACI message for sleep command
\r
44 * @param[in,out] buffer Pointer to ACI message buffer
\r
48 void acil_encode_cmd_sleep(uint8_t *buffer);
\r
50 /** @brief Encode the ACI message for get device version
\r
52 * @param[in,out] buffer Pointer to ACI message buffer
\r
56 void acil_encode_cmd_get_device_version(uint8_t *buffer);
\r
58 /** @brief Encode the ACI message for set local data
\r
60 * @param[in,out] buffer Pointer to ACI message buffer
\r
61 * @param[in] p_aci_cmd_params_set_local_data Pointer to the local data parameters in ::aci_cmd_params_set_local_data_t
\r
62 * @param[in] data_size Size of data message
\r
66 void acil_encode_cmd_set_local_data(uint8_t *buffer, aci_cmd_params_set_local_data_t *p_aci_cmd_params_set_local_data, uint8_t data_size);
\r
68 /** @brief Encode the ACI message to connect
\r
70 * @param[in,out] buffer Pointer to ACI message buffer
\r
71 * @param[in] p_aci_cmd_params_connect Pointer to the run parameters in ::aci_cmd_params_connect_t
\r
75 void acil_encode_cmd_connect(uint8_t *buffer, aci_cmd_params_connect_t *p_aci_cmd_params_connect);
\r
77 /** @brief Encode the ACI message to bond
\r
79 * @param[in,out] buffer Pointer to ACI message buffer
\r
80 * @param[in] p_aci_cmd_params_bond Pointer to the run parameters in ::aci_cmd_params_bond_t
\r
84 void acil_encode_cmd_bond(uint8_t *buffer, aci_cmd_params_bond_t *p_aci_cmd_params_bond);
\r
86 /** @brief Encode the ACI message to disconnect
\r
88 * @param[in,out] buffer Pointer to ACI message buffer
\r
89 * @param[in] p_aci_cmd_params_disconnect Pointer to the run parameters in ::aci_cmd_params_disconnect_t
\r
93 void acil_encode_cmd_disconnect(uint8_t *buffer, aci_cmd_params_disconnect_t *p_aci_cmd_params_disconnect);
\r
95 /** @brief Encode the ACI message to baseband reset
\r
97 * @param[in,out] buffer Pointer to ACI message buffer
\r
101 void acil_encode_baseband_reset(uint8_t *buffer);
\r
103 /** @brief Encode the ACI message for Directed Advertising
\r
105 * @param[in,out] buffer Pointer to ACI message buffer
\r
109 void acil_encode_direct_connect(uint8_t *buffer);
\r
111 /** @brief Encode the ACI message to wakeup
\r
113 * @param[in,out] buffer Pointer to ACI message buffer
\r
117 void acil_encode_cmd_wakeup(uint8_t *buffer);
\r
119 /** @brief Encode the ACI message for set radio Tx power
\r
121 * @param[in,out] buffer Pointer to ACI message buffer
\r
122 * @param[in] p_aci_cmd_params_set_tx_power Pointer to the set Tx power parameters in ::aci_cmd_params_set_tx_power_t
\r
126 void acil_encode_cmd_set_radio_tx_power(uint8_t *buffer, aci_cmd_params_set_tx_power_t *p_aci_cmd_params_set_tx_power);
\r
128 /** @brief Encode the ACI message for get device address
\r
130 * @param[in,out] buffer Pointer to ACI message buffer
\r
134 void acil_encode_cmd_get_address(uint8_t *buffer);
\r
136 /** @brief Encode the ACI message for send data
\r
138 * @param[in,out] buffer Pointer to ACI message buffer
\r
139 * @param[in] p_aci_cmd_params_send_data_t Pointer to the data parameters in ::aci_cmd_params_send_data_t
\r
140 * @param[in] data_size Size of data message
\r
144 void acil_encode_cmd_send_data(uint8_t *buffer, aci_cmd_params_send_data_t *p_aci_cmd_params_send_data_t, uint8_t data_size);
\r
146 /** @brief Encode the ACI message for request data
\r
148 * @param[in,out] buffer Pointer to ACI message buffer
\r
149 * @param[in] p_aci_cmd_params_request_data Pointer to the request data parameters in ::aci_cmd_params_request_data_t
\r
153 void acil_encode_cmd_request_data(uint8_t *buffer, aci_cmd_params_request_data_t *p_aci_cmd_params_request_data);
\r
155 /** @brief Encode the ACI message for open remote pipe
\r
157 * @param[in,out] buffer Pointer to ACI message buffer
\r
158 * @param[in] p_aci_cmd_params_open_remote_pipe Pointer to the dynamic data parameters in ::aci_cmd_params_open_remote_pipe_t
\r
162 void acil_encode_cmd_open_remote_pipe(uint8_t *buffer, aci_cmd_params_open_remote_pipe_t *p_aci_cmd_params_open_remote_pipe);
\r
164 /** @brief Encode the ACI message for close remote pipe
\r
166 * @param[in,out] buffer Pointer to ACI message buffer
\r
167 * @param[in] p_aci_cmd_params_close_remote_pipe Pointer to the dynamic data parameters in ::aci_cmd_params_close_remote_pipe_t
\r
171 void acil_encode_cmd_close_remote_pipe(uint8_t *buffer, aci_cmd_params_close_remote_pipe_t *p_aci_cmd_params_close_remote_pipe);
\r
173 /** @brief Encode the ACI message for echo message
\r
175 * @param[in,out] buffer Pointer to ACI message buffer
\r
176 * @param[in] p_cmd_params_echo Pointer to the dynamic data parameters in ::aci_cmd_params_echo_t
\r
177 * @param[in] msg_size Size of the message
\r
181 void acil_encode_cmd_echo_msg(uint8_t *buffer, aci_cmd_params_echo_t *p_cmd_params_echo, uint8_t msg_size);
\r
183 /** @brief Encode the ACI message to battery level
\r
185 * @param[in,out] buffer Pointer to ACI message buffer
\r
189 void acil_encode_cmd_battery_level(uint8_t *buffer);
\r
191 /** @brief Encode the ACI message to temparature
\r
193 * @param[in,out] buffer Pointer to ACI message buffer
\r
197 void acil_encode_cmd_temparature(uint8_t *buffer);
\r
199 /** @brief Encode the ACI message to read dynamic data
\r
201 * @param[in,out] buffer Pointer to ACI message buffer
\r
205 void acil_encode_cmd_read_dynamic_data(uint8_t *buffer);
\r
207 /** @brief Encode the ACI message to change timing request
\r
209 * @param[in,out] buffer Pointer to ACI message buffer
\r
210 * @param[in] p_aci_cmd_params_change_timing Pointer to the change timing parameters in ::aci_cmd_params_change_timing_t
\r
214 void acil_encode_cmd_change_timing_req(uint8_t *buffer, aci_cmd_params_change_timing_t *p_aci_cmd_params_change_timing);
\r
216 /** @brief Encode the ACI message to change timing request using the timing parameters from GAP PPCP
\r
218 * @param[in,out] buffer Pointer to ACI message buffer
\r
219 * @param[in] p_aci_cmd_params_change_timing Pointer to the change timing parameters in ::aci_cmd_params_change_timing_t
\r
223 void acil_encode_cmd_change_timing_req_GAP_PPCP(uint8_t *buffer);
\r
226 /** @brief Encode the ACI message for write dynamic data
\r
228 * @param[in,out] buffer Pointer to ACI message buffer
\r
229 * @param[in] seq_no Sequence number of the dynamic data (as received in the response to @c Read Dynamic Data)
\r
230 * @param[in] dynamic_data Pointer to the dynamic data
\r
231 * @param[in] dynamic_data_size Size of dynamic data
\r
235 void acil_encode_cmd_write_dynamic_data(uint8_t *buffer, uint8_t seq_no, uint8_t* dynamic_data, uint8_t dynamic_data_size);
\r
237 /** @brief Encode the ACI message to send data acknowledgement
\r
239 * @param[in,out] buffer Pointer to ACI message buffer
\r
240 * @param[in] pipe_number Pipe number for which the ack is to be sent
\r
244 void acil_encode_cmd_send_data_ack(uint8_t *buffer, const uint8_t pipe_number);
\r
246 /** @brief Encode the ACI message to send negative acknowledgement
\r
248 * @param[in,out] buffer Pointer to ACI message buffer
\r
249 * @param[in] pipe_number Pipe number for which the nack is to be sent
\r
250 * @param[in] error_code Error code that has to be sent in the NACK
\r
254 void acil_encode_cmd_send_data_nack(uint8_t *buffer, const uint8_t pipe_number,const uint8_t error_code);
\r
256 /** @brief Encode the ACI message to set the application latency
\r
258 * @param[in,out] buffer Pointer to ACI message buffer
\r
259 * @param[in] p_aci_cmd_params_set_app_latency Pointer to the set_application_latency command parameters in ::aci_cmd_params_dtm_cmd_t
\r
263 void acil_encode_cmd_set_app_latency(uint8_t *buffer, aci_cmd_params_set_app_latency_t *p_aci_cmd_params_set_app_latency);
\r
265 /** @brief Encode the ACI message for setup
\r
267 * @param[in,out] buffer Pointer to ACI message buffer
\r
268 * @param[in] p_cmd_params_set_run_behaviour Pointer to the setup data in ::aci_cmd_params_setup_t
\r
269 * @param[in] setup_data_size Size of setup message
\r
273 void acil_encode_cmd_setup(uint8_t *buffer, aci_cmd_params_setup_t *p_aci_cmd_params_setup, uint8_t setup_data_size);
\r
275 /** @brief Encode the ACI message for DTM command
\r
277 * @param[in,out] buffer Pointer to ACI message buffer
\r
278 * @param[in] p_cmd_params_set_run_behaviour Pointer to the DTM command parameters in ::aci_cmd_params_dtm_cmd_t
\r
282 void acil_encode_cmd_dtm_cmd(uint8_t *buffer, aci_cmd_params_dtm_cmd_t *p_aci_cmd_params_dtm_cmd);
\r
284 /** @brief Encode the ACI message for Set Key Request command
\r
286 * @param[in,out] buffer Pointer to ACI message buffer
\r
290 void acil_encode_cmd_set_key(uint8_t *buffer, aci_cmd_params_set_key_t *p_aci_cmd_params_set_key);
\r
292 /** @brief Encode the ACI message for Bond Security Request command
\r
294 * @param[in,out] buffer Pointer to ACI message buffer
\r
298 void acil_encode_cmd_bond_security_request(uint8_t *buffer);
\r
300 /** @brief Encode the ACI message
\r
302 * @param[in,out] buffer Pointer to ACI message buffer
\r
303 * @param[in] p_aci_cmd Pointer to ACI command data in ::aci_cmd_t
\r
306 * @return bool true, if succesful, else returns false
\r
308 bool acil_encode_cmd(uint8_t *buffer, aci_cmd_t *p_aci_cmd);
\r
310 /** @brief Encode the ACI message for Broadcast command
\r
312 * @param[in,out] buffer Pointer to ACI message buffer
\r
313 * @param[in] p_aci_cmd Pointer to ACI command data in ::aci_cmd_params_broadcast_t
\r
317 void acil_encode_cmd_broadcast(uint8_t *buffer, aci_cmd_params_broadcast_t * p_aci_cmd_params_broadcast);
\r
319 /** @brief Encode the ACI message for Open Adv Pipes
\r
321 * @param[in,out] buffer Pointer to ACI message buffer
\r
322 * @param[in] p_aci_cmd Pointer to ACI command data in ::aci_cmd_params_open_adv_pipe_t
\r
326 void acil_encode_cmd_open_adv_pipes(uint8_t *buffer, aci_cmd_params_open_adv_pipe_t * p_aci_cmd_params_set_adv_svc_data);
\r
328 /** @brief Decode the ACI event command response
\r
330 * @param[in] buffer_in Pointer to message received
\r
331 * @param[in,out] buffer Pointer to the decoded message in ::aci_evt_params_cmd_rsp_t
\r
335 void acil_decode_evt_command_response(uint8_t *buffer_in, aci_evt_params_cmd_rsp_t *p_evt_params_cmd_rsp);
\r
337 /** @brief Decode the ACI event device started
\r
339 * @param[in] buffer_in Pointer to message received
\r
340 * @param[in,out] p_aci_evt Pointer to the decoded message in ::aci_evt_params_device_started_t
\r
344 void acil_decode_evt_device_started(uint8_t *buffer_in, aci_evt_params_device_started_t *p_evt_params_device_started);
\r
346 /** @brief Decode the ACI event pipe status
\r
348 * @param[in] buffer_in Pointer to message received
\r
349 * @param[in,out] p_aci_evt_params_pipe_status Pointer to the decoded message in ::aci_evt_params_pipe_status_t
\r
353 void acil_decode_evt_pipe_status(uint8_t *buffer_in, aci_evt_params_pipe_status_t *p_aci_evt_params_pipe_status);
\r
355 /** @brief Decode the ACI event for disconnected
\r
357 * @param[in] buffer_in Pointer to message received
\r
358 * @param[in,out] p_aci_evt_params_disconnected Pointer to the decoded message in ::aci_evt_params_disconnected_t
\r
362 void acil_decode_evt_disconnected(uint8_t *buffer_in, aci_evt_params_disconnected_t *p_aci_evt_params_disconnected);
\r
364 /** @brief Decode the ACI event for bond status
\r
366 * @param[in] buffer_in Pointer to message received
\r
367 * @param[in,out] p_aci_evt_params_bond_status Pointer to the decoded message in ::aci_evt_params_bond_status_t
\r
371 void acil_decode_evt_bond_status(uint8_t *buffer_in, aci_evt_params_bond_status_t *p_aci_evt_params_bond_status);
\r
373 /** @brief Decode the ACI event for data received
\r
375 * @param[in] buffer_in Pointer to message received
\r
376 * @param[in,out] p_evt_params_data_received Pointer to the decoded message in ::aci_evt_params_data_received_t
\r
378 * @return size Received data size
\r
380 uint8_t acil_decode_evt_data_received(uint8_t *buffer_in, aci_evt_params_data_received_t *p_evt_params_data_received);
\r
382 /** @brief Decode the ACI event data acknowledgement
\r
384 * @param[in] buffer_in Pointer to message received
\r
385 * @param[in,out] p_evt_params_data_ack Pointer to the decoded message in ::aci_evt_params_data_ack_t
\r
389 void acil_decode_evt_data_ack(uint8_t *buffer_in, aci_evt_params_data_ack_t *p_evt_params_data_ack);
\r
391 /** @brief Decode the ACI event for hardware error
\r
393 * @param[in] buffer_in Pointer to message received
\r
394 * @param[in,out] p_aci_evt_params_hw_error Pointer to the decoded message in ::aci_evt_params_hw_error_t
\r
396 * @return size Size of debug information
\r
398 uint8_t acil_decode_evt_hw_error(uint8_t *buffer_in, aci_evt_params_hw_error_t *p_aci_evt_params_hw_error);
\r
400 /** @brief Decode the ACI event data credit
\r
402 * @param[in] buffer_in Pointer to message received
\r
403 * @param[in,out] p_evt_params_data_credit Pointer to the decoded message in ::aci_evt_params_data_credit_t
\r
407 void acil_decode_evt_credit(uint8_t *buffer_in, aci_evt_params_data_credit_t *p_evt_params_data_credit);
\r
409 /** @brief Decode the ACI event for connected
\r
411 * @param[in] buffer_in Pointer to message received
\r
412 * @param[in,out] p_aci_evt_params_connected Pointer to the decoded message in ::aci_evt_params_connected_t
\r
416 void acil_decode_evt_connected(uint8_t *buffer_in, aci_evt_params_connected_t *p_aci_evt_params_connected);
\r
418 /** @brief Decode the ACI event for timing
\r
420 * @param[in] buffer_in Pointer to message received
\r
421 * @param[in,out] p_evt_params_timing Pointer to the decoded message in ::aci_evt_params_timing_t
\r
425 void acil_decode_evt_timing(uint8_t *buffer_in, aci_evt_params_timing_t *p_evt_params_timing);
\r
427 /** @brief Decode the ACI event for pipe error
\r
429 * @param[in] buffer_in Pointer to message received
\r
430 * @param[in,out] p_evt_params_pipe_error Pointer to the decoded message in ::aci_evt_params_pipe_error_t
\r
433 void acil_decode_evt_pipe_error(uint8_t *buffer_in, aci_evt_params_pipe_error_t *p_evt_params_pipe_error);
\r
435 /** @brief Decode the ACI event for key request
\r
437 * @param[in] buffer_in Pointer to message received
\r
438 * @param[in,out] p_evt_params_key_type Pointer to the decoded message in ::aci_evt_params_key_type_t
\r
442 void acil_decode_evt_key_request(uint8_t *buffer_in, aci_evt_params_key_request_t *p_evt_params_key_request);
\r
444 /** @brief Decode the ACI event for echo
\r
446 * @param[in] buffer_in Pointer to message received
\r
447 * @param[in,out] buffer_out Pointer to the echo message (max size of buffer ::ACI_ECHO_DATA_MAX_LEN)
\r
449 * @return size Received echo message size
\r
451 uint8_t acil_decode_evt_echo(uint8_t *buffer_in, aci_evt_params_echo_t *buffer_out);
\r
453 /** @brief Decode the ACI event
\r
455 * @param[in] buffer_in Pointer to message received
\r
456 * @param[in,out] p_aci_evt Pointer to the decoded message in ::aci_evt_t
\r
458 * @return bool true, if succesful, else returns false
\r
460 bool acil_decode_evt(uint8_t *buffer_in, aci_evt_t *p_aci_evt);
\r
462 /** @brief Decode the Display Key Event
\r
464 * @param[in] buffer_in Pointer to message received
\r
465 * @param[in,out] p_aci_evt Pointer to the decoded message in ::aci_evt_params_display_passkey_t
\r
469 void acil_decode_evt_display_passkey(uint8_t *buffer_in, aci_evt_params_display_passkey_t *p_aci_evt_params_display_passkey);
\r
471 #endif /* _acilib_IF_H_ */
\r