• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  *
25  * @ingroup aci-lib
26  *
27  * @brief Prototypes for the acilib interfaces.
28  */
29 
30 #ifndef _acilib_IF_H_
31 #define _acilib_IF_H_
32 
33 /** @brief Encode the ACI message for set test mode command
34  *
35  *  @param[in,out]  buffer      Pointer to ACI message buffer
36  *  @param[in]      test_mode   Pointer to the test mode in ::aci_cmd_params_test_t
37  *
38  *  @return         None
39  */
40 void acil_encode_cmd_set_test_mode(uint8_t *buffer, aci_cmd_params_test_t *p_aci_cmd_params_test);
41 
42 /** @brief Encode the ACI message for sleep command
43  *
44  *  @param[in,out]  buffer      Pointer to ACI message buffer
45  *
46  *  @return         None
47  */
48 void acil_encode_cmd_sleep(uint8_t *buffer);
49 
50 /** @brief Encode the ACI message for get device version
51  *
52  *  @param[in,out]  buffer      Pointer to ACI message buffer
53  *
54  *  @return         None
55  */
56 void acil_encode_cmd_get_device_version(uint8_t *buffer);
57 
58 /** @brief Encode the ACI message for set local data
59  *
60  *  @param[in,out]  buffer                           Pointer to ACI message buffer
61  *  @param[in]      p_aci_cmd_params_set_local_data  Pointer to the local data parameters in ::aci_cmd_params_set_local_data_t
62  *  @param[in]      data_size                        Size of data message
63  *
64  *  @return         None
65  */
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);
67 
68 /** @brief Encode the ACI message to connect
69  *
70  *  @param[in,out]  buffer                    Pointer to ACI message buffer
71  *  @param[in]      p_aci_cmd_params_connect  Pointer to the run parameters in ::aci_cmd_params_connect_t
72  *
73  *  @return         None
74  */
75 void acil_encode_cmd_connect(uint8_t *buffer, aci_cmd_params_connect_t *p_aci_cmd_params_connect);
76 
77 /** @brief Encode the ACI message to bond
78  *
79  *  @param[in,out]  buffer                 Pointer to ACI message buffer
80  *  @param[in]      p_aci_cmd_params_bond  Pointer to the run parameters in ::aci_cmd_params_bond_t
81  *
82  *  @return         None
83  */
84 void acil_encode_cmd_bond(uint8_t *buffer, aci_cmd_params_bond_t *p_aci_cmd_params_bond);
85 
86 /** @brief Encode the ACI message to disconnect
87  *
88  *  @param[in,out]  buffer                       Pointer to ACI message buffer
89  *  @param[in]      p_aci_cmd_params_disconnect  Pointer to the run parameters in ::aci_cmd_params_disconnect_t
90  *
91  *  @return         None
92  */
93 void acil_encode_cmd_disconnect(uint8_t *buffer, aci_cmd_params_disconnect_t *p_aci_cmd_params_disconnect);
94 
95 /** @brief Encode the ACI message to baseband reset
96  *
97  *  @param[in,out]  buffer        Pointer to ACI message buffer
98  *
99  *  @return         None
100  */
101  void acil_encode_baseband_reset(uint8_t *buffer);
102 
103  /** @brief Encode the ACI message for Directed Advertising
104  *
105  *  @param[in,out]  buffer        Pointer to ACI message buffer
106  *
107  *  @return         None
108  */
109  void acil_encode_direct_connect(uint8_t *buffer);
110 
111 /** @brief Encode the ACI message to wakeup
112  *
113  *  @param[in,out]  buffer        Pointer to ACI message buffer
114  *
115  *  @return         None
116  */
117 void acil_encode_cmd_wakeup(uint8_t *buffer);
118 
119 /** @brief Encode the ACI message for set radio Tx power
120  *
121  *  @param[in,out]  buffer                         Pointer to ACI message buffer
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
123  *
124  *  @return         None
125  */
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);
127 
128 /** @brief Encode the ACI message for get device address
129  *
130  *  @param[in,out]  buffer            Pointer to ACI message buffer
131  *
132  *  @return         None
133  */
134 void acil_encode_cmd_get_address(uint8_t *buffer);
135 
136 /** @brief Encode the ACI message for send data
137  *
138  *  @param[in,out]  buffer                        Pointer to ACI message buffer
139  *  @param[in]      p_aci_cmd_params_send_data_t  Pointer to the data parameters in ::aci_cmd_params_send_data_t
140  *  @param[in]      data_size                     Size of data message
141  *
142  *  @return         None
143  */
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);
145 
146 /** @brief Encode the ACI message for request data
147  *
148  *  @param[in,out]  buffer                          Pointer to ACI message buffer
149  *  @param[in]      p_aci_cmd_params_request_data   Pointer to the request data parameters in ::aci_cmd_params_request_data_t
150  *
151  *  @return         None
152  */
153 void acil_encode_cmd_request_data(uint8_t *buffer, aci_cmd_params_request_data_t *p_aci_cmd_params_request_data);
154 
155 /** @brief Encode the ACI message for open remote pipe
156  *
157  *  @param[in,out]  buffer                              Pointer to ACI message buffer
158  *  @param[in]      p_aci_cmd_params_open_remote_pipe   Pointer to the dynamic data parameters in ::aci_cmd_params_open_remote_pipe_t
159  *
160  *  @return         None
161  */
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);
163 
164 /** @brief Encode the ACI message for close remote pipe
165  *
166  *  @param[in,out]  buffer                              Pointer to ACI message buffer
167  *  @param[in]      p_aci_cmd_params_close_remote_pipe   Pointer to the dynamic data parameters in ::aci_cmd_params_close_remote_pipe_t
168  *
169  *  @return         None
170  */
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);
172 
173 /** @brief Encode the ACI message for echo message
174  *
175  *  @param[in,out]  buffer             Pointer to ACI message buffer
176  *  @param[in]      p_cmd_params_echo  Pointer to the dynamic data parameters in ::aci_cmd_params_echo_t
177  *  @param[in]      msg_size           Size of the message
178  *
179  *  @return         None
180  */
181 void acil_encode_cmd_echo_msg(uint8_t *buffer, aci_cmd_params_echo_t *p_cmd_params_echo, uint8_t msg_size);
182 
183 /** @brief Encode the ACI message to battery level
184  *
185  *  @param[in,out]  buffer  Pointer to ACI message buffer
186  *
187  *  @return         None
188  */
189 void acil_encode_cmd_battery_level(uint8_t *buffer);
190 
191 /** @brief Encode the ACI message to temparature
192  *
193  *  @param[in,out]  buffer  Pointer to ACI message buffer
194  *
195  *  @return         None
196  */
197 void acil_encode_cmd_temparature(uint8_t *buffer);
198 
199 /** @brief Encode the ACI message to read dynamic data
200  *
201  *  @param[in,out]  buffer  Pointer to ACI message buffer
202  *
203  *  @return         None
204  */
205 void acil_encode_cmd_read_dynamic_data(uint8_t *buffer);
206 
207 /** @brief Encode the ACI message to change timing request
208  *
209  *  @param[in,out]  buffer  Pointer to ACI message buffer
210  *  @param[in]      p_aci_cmd_params_change_timing  Pointer to the change timing parameters in ::aci_cmd_params_change_timing_t
211  *
212  *  @return         None
213  */
214 void acil_encode_cmd_change_timing_req(uint8_t *buffer, aci_cmd_params_change_timing_t *p_aci_cmd_params_change_timing);
215 
216 /** @brief Encode the ACI message to change timing request using the timing parameters from GAP PPCP
217  *
218  *  @param[in,out]  buffer  Pointer to ACI message buffer
219  *  @param[in]      p_aci_cmd_params_change_timing  Pointer to the change timing parameters in ::aci_cmd_params_change_timing_t
220  *
221  *  @return         None
222  */
223 void acil_encode_cmd_change_timing_req_GAP_PPCP(uint8_t *buffer);
224 
225 
226 /** @brief Encode the ACI message for write dynamic data
227  *
228  *  @param[in,out]  buffer                          Pointer to ACI message buffer
229  *  @param[in]      seq_no                          Sequence number of the dynamic data (as received in the response to @c Read Dynamic Data)
230  *  @param[in]      dynamic_data                    Pointer to the dynamic data
231  *  @param[in]      dynamic_data_size               Size of dynamic data
232  *
233  *  @return         None
234  */
235 void acil_encode_cmd_write_dynamic_data(uint8_t *buffer, uint8_t seq_no, uint8_t* dynamic_data, uint8_t dynamic_data_size);
236 
237 /** @brief Encode the ACI message to send data acknowledgement
238  *
239  *  @param[in,out]  buffer  Pointer to ACI message buffer
240  *  @param[in]      pipe_number Pipe number for which the ack is to be sent
241  *
242  *  @return         None
243  */
244 void acil_encode_cmd_send_data_ack(uint8_t *buffer, const uint8_t pipe_number);
245 
246 /** @brief Encode the ACI message to send negative acknowledgement
247  *
248  *  @param[in,out]  buffer  Pointer to ACI message buffer
249  *  @param[in]    pipe_number Pipe number for which the nack is to be sent
250  *  @param[in]    error_code Error code that has to be sent in the NACK
251  *
252  *  @return         None
253  */
254 void acil_encode_cmd_send_data_nack(uint8_t *buffer, const uint8_t pipe_number,const uint8_t error_code);
255 
256 /** @brief Encode the ACI message to set the application latency
257  *
258  *  @param[in,out]  buffer  Pointer to ACI message buffer
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
260  *
261  *  @return         None
262  */
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);
264 
265 /** @brief Encode the ACI message for setup
266  *
267  *  @param[in,out]  buffer                          Pointer to ACI message buffer
268  *  @param[in]      p_cmd_params_set_run_behaviour  Pointer to the setup data in ::aci_cmd_params_setup_t
269  *  @param[in]      setup_data_size                 Size of setup message
270  *
271  *  @return         None
272  */
273 void acil_encode_cmd_setup(uint8_t *buffer, aci_cmd_params_setup_t *p_aci_cmd_params_setup, uint8_t setup_data_size);
274 
275 /** @brief Encode the ACI message for DTM command
276  *
277  *  @param[in,out]  buffer                          Pointer to ACI message buffer
278  *  @param[in]      p_cmd_params_set_run_behaviour  Pointer to the DTM command parameters in ::aci_cmd_params_dtm_cmd_t
279  *
280  *  @return         None
281  */
282 void acil_encode_cmd_dtm_cmd(uint8_t *buffer, aci_cmd_params_dtm_cmd_t *p_aci_cmd_params_dtm_cmd);
283 
284 /** @brief Encode the ACI message for Set Key Request command
285  *
286  *  @param[in,out]  buffer      Pointer to ACI message buffer
287  *
288  *  @return         None
289  */
290 void acil_encode_cmd_set_key(uint8_t *buffer, aci_cmd_params_set_key_t *p_aci_cmd_params_set_key);
291 
292 /** @brief Encode the ACI message for Bond Security Request command
293  *
294  *  @param[in,out]  buffer      Pointer to ACI message buffer
295  *
296  *  @return         None
297  */
298 void acil_encode_cmd_bond_security_request(uint8_t *buffer);
299 
300 /** @brief Encode the ACI message
301  *
302  *  @param[in,out]  buffer      Pointer to ACI message buffer
303  *  @param[in]      p_aci_cmd   Pointer to ACI command data in ::aci_cmd_t
304  *  @param[in]      bool
305  *
306  *  @return         bool         true, if succesful, else returns false
307  */
308 bool acil_encode_cmd(uint8_t *buffer, aci_cmd_t *p_aci_cmd);
309 
310 /** @brief Encode the ACI message for Broadcast command
311  *
312  *  @param[in,out]  buffer      Pointer to ACI message buffer
313  *  @param[in]      p_aci_cmd   Pointer to ACI command data in ::aci_cmd_params_broadcast_t
314  *
315  *  @return         None
316  */
317 void acil_encode_cmd_broadcast(uint8_t *buffer,  aci_cmd_params_broadcast_t * p_aci_cmd_params_broadcast);
318 
319 /** @brief Encode the ACI message for Open Adv Pipes
320  *
321  *  @param[in,out]  buffer      Pointer to ACI message buffer
322  *  @param[in]      p_aci_cmd   Pointer to ACI command data in ::aci_cmd_params_open_adv_pipe_t
323  *
324  *  @return         None
325  */
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);
327 
328 /** @brief Decode the ACI event command response
329  *
330  *  @param[in]      buffer_in  Pointer to message received
331  *  @param[in,out]  buffer     Pointer to the decoded message in ::aci_evt_params_cmd_rsp_t
332  *
333  *  @return         None
334  */
335 void acil_decode_evt_command_response(uint8_t *buffer_in, aci_evt_params_cmd_rsp_t *p_evt_params_cmd_rsp);
336 
337 /** @brief Decode the ACI event device started
338  *
339  *  @param[in]      buffer_in  Pointer to message received
340  *  @param[in,out]  p_aci_evt  Pointer to the decoded message in ::aci_evt_params_device_started_t
341  *
342  *  @return         None
343  */
344 void acil_decode_evt_device_started(uint8_t *buffer_in, aci_evt_params_device_started_t *p_evt_params_device_started);
345 
346 /** @brief Decode the ACI event pipe status
347  *
348  *  @param[in]      buffer_in  Pointer to message received
349  *  @param[in,out]  p_aci_evt_params_pipe_status  Pointer to the decoded message in ::aci_evt_params_pipe_status_t
350  *
351  *  @return         None
352  */
353 void acil_decode_evt_pipe_status(uint8_t *buffer_in, aci_evt_params_pipe_status_t *p_aci_evt_params_pipe_status);
354 
355 /** @brief Decode the ACI event for disconnected
356  *
357  *  @param[in]      buffer_in                      Pointer to message received
358  *  @param[in,out]  p_aci_evt_params_disconnected  Pointer to the decoded message in ::aci_evt_params_disconnected_t
359  *
360  *  @return         None
361  */
362 void acil_decode_evt_disconnected(uint8_t *buffer_in, aci_evt_params_disconnected_t *p_aci_evt_params_disconnected);
363 
364 /** @brief Decode the ACI event for bond status
365  *
366  *  @param[in]      buffer_in                     Pointer to message received
367  *  @param[in,out]  p_aci_evt_params_bond_status  Pointer to the decoded message in ::aci_evt_params_bond_status_t
368  *
369  *  @return         None
370  */
371 void acil_decode_evt_bond_status(uint8_t *buffer_in, aci_evt_params_bond_status_t *p_aci_evt_params_bond_status);
372 
373 /** @brief Decode the ACI event for data received
374  *
375  *  @param[in]      buffer_in                   Pointer to message received
376  *  @param[in,out]  p_evt_params_data_received  Pointer to the decoded message in ::aci_evt_params_data_received_t
377  *
378  *  @return         size                        Received data size
379  */
380 uint8_t acil_decode_evt_data_received(uint8_t *buffer_in, aci_evt_params_data_received_t *p_evt_params_data_received);
381 
382 /** @brief Decode the ACI event data acknowledgement
383  *
384  *  @param[in]      buffer_in               Pointer to message received
385  *  @param[in,out]  p_evt_params_data_ack   Pointer to the decoded message in ::aci_evt_params_data_ack_t
386  *
387  *  @return         None
388  */
389 void acil_decode_evt_data_ack(uint8_t *buffer_in, aci_evt_params_data_ack_t *p_evt_params_data_ack);
390 
391 /** @brief Decode the ACI event for hardware error
392  *
393  *  @param[in]      buffer_in                  Pointer to message received
394  *  @param[in,out]  p_aci_evt_params_hw_error  Pointer to the decoded message in ::aci_evt_params_hw_error_t
395  *
396  *  @return         size                     Size of debug information
397  */
398 uint8_t acil_decode_evt_hw_error(uint8_t *buffer_in, aci_evt_params_hw_error_t *p_aci_evt_params_hw_error);
399 
400 /** @brief Decode the ACI event data credit
401  *
402  *  @param[in]      buffer_in                 Pointer to message received
403  *  @param[in,out]  p_evt_params_data_credit  Pointer to the decoded message in ::aci_evt_params_data_credit_t
404  *
405  *  @return         None
406  */
407 void acil_decode_evt_credit(uint8_t *buffer_in, aci_evt_params_data_credit_t *p_evt_params_data_credit);
408 
409 /** @brief Decode the ACI event for connected
410  *
411  *  @param[in]      buffer_in                   Pointer to message received
412  *  @param[in,out]  p_aci_evt_params_connected  Pointer to the decoded message in ::aci_evt_params_connected_t
413  *
414  *  @return         None
415  */
416 void acil_decode_evt_connected(uint8_t *buffer_in, aci_evt_params_connected_t *p_aci_evt_params_connected);
417 
418 /** @brief Decode the ACI event for timing
419  *
420  *  @param[in]      buffer_in             Pointer to message received
421  *  @param[in,out]  p_evt_params_timing   Pointer to the decoded message in ::aci_evt_params_timing_t
422  *
423  *  @return         None
424  */
425 void acil_decode_evt_timing(uint8_t *buffer_in, aci_evt_params_timing_t *p_evt_params_timing);
426 
427 /** @brief Decode the ACI event for pipe error
428  *
429  *  @param[in]      buffer_in                 Pointer to message received
430  *  @param[in,out]  p_evt_params_pipe_error   Pointer to the decoded message in ::aci_evt_params_pipe_error_t
431  *
432  */
433 void acil_decode_evt_pipe_error(uint8_t *buffer_in, aci_evt_params_pipe_error_t *p_evt_params_pipe_error);
434 
435 /** @brief Decode the ACI event for key request
436  *
437  *  @param[in]      buffer_in               Pointer to message received
438  *  @param[in,out]  p_evt_params_key_type   Pointer to the decoded message in ::aci_evt_params_key_type_t
439  *
440  *  @return         None
441  */
442 void acil_decode_evt_key_request(uint8_t *buffer_in, aci_evt_params_key_request_t *p_evt_params_key_request);
443 
444 /** @brief Decode the ACI event for echo
445  *
446  *  @param[in]      buffer_in    Pointer to message received
447  *  @param[in,out]  buffer_out   Pointer to the echo message (max size of buffer ::ACI_ECHO_DATA_MAX_LEN)
448  *
449  *  @return         size         Received echo message size
450  */
451 uint8_t acil_decode_evt_echo(uint8_t *buffer_in, aci_evt_params_echo_t *buffer_out);
452 
453 /** @brief Decode the ACI event
454  *
455  *  @param[in]      buffer_in   Pointer to message received
456  *  @param[in,out]  p_aci_evt   Pointer to the decoded message in ::aci_evt_t
457  *
458  *  @return         bool         true, if succesful, else returns false
459  */
460 bool acil_decode_evt(uint8_t *buffer_in, aci_evt_t *p_aci_evt);
461 
462 /** @brief Decode the Display Key Event
463  *
464  *  @param[in]      buffer_in   Pointer to message received
465  *  @param[in,out]  p_aci_evt   Pointer to the decoded message in ::aci_evt_params_display_passkey_t
466  *
467  *  @return         None
468  */
469 void acil_decode_evt_display_passkey(uint8_t *buffer_in, aci_evt_params_display_passkey_t *p_aci_evt_params_display_passkey);
470 
471 #endif /* _acilib_IF_H_ */
472