PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lib_aci.cpp 17KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRENTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. * $LastChangedRevision: 4808 $
  12. */
  13. /* Attention!
  14. * To maintain compliance with Nordic Semiconductor ASA’s Bluetooth profile
  15. * qualification listings, this section of source code must not be modified.
  16. */
  17. /** @file
  18. @brief Implementation of the ACI library.
  19. */
  20. #include "hal_platform.h"
  21. #include "aci.h"
  22. #include "aci_cmds.h"
  23. #include "aci_evts.h"
  24. #include "aci_protocol_defines.h"
  25. #include "acilib_defs.h"
  26. #include "acilib_if.h"
  27. #include "hal/hal_aci_tl.h"
  28. #include "lib_aci.h"
  29. #define LIB_ACI_DEFAULT_CREDIT_NUMBER 1
  30. static services_pipe_type_mapping_t * p_services_pipe_type_map;
  31. static uint8_t pipe_count;
  32. static hal_aci_data_t * p_setup_msgs;
  33. static uint8_t setup_msgs_count;
  34. static hal_aci_data_t msg_to_send;
  35. static hal_aci_data_t *p_rcvd_evt;
  36. static uint8_t cur_transaction_cmd;
  37. static uint8_t memorized_rcvd_cmd_opcode;
  38. static uint8_t memorized_transaction_cmd_opcode;
  39. static bool is_cmd_response_expected;
  40. static uint16_t cx_rf_interval; // rf_interval = cx_rf_interval * 1.25 ms Range:0x0006 to 0x0C80
  41. static uint16_t current_slave_latency;
  42. static bool is_request_operation_pending;
  43. static bool is_indicate_operation_pending;
  44. static bool is_open_remote_pipe_pending;
  45. static bool is_close_remote_pipe_pending;
  46. static uint8_t request_operation_pipe = 0;
  47. static uint8_t indicate_operation_pipe = 0;
  48. // The following structure (aci_cmd_params_open_adv_pipe) will be used to store the complete command
  49. // including the pipes to be opened.
  50. static aci_cmd_params_open_adv_pipe_t aci_cmd_params_open_adv_pipe;
  51. static uint8_t cur_error_code;
  52. bool lib_aci_is_pipe_available(aci_state_t *aci_stat, uint8_t pipe)
  53. {
  54. uint8_t byte_idx;
  55. byte_idx = pipe / 8;
  56. if (aci_stat->pipes_open_bitmap[byte_idx] & (0x01 << (pipe % 8)))
  57. {
  58. return(true);
  59. }
  60. return(false);
  61. }
  62. bool lib_aci_is_pipe_closed(aci_state_t *aci_stat, uint8_t pipe)
  63. {
  64. uint8_t byte_idx;
  65. byte_idx = pipe / 8;
  66. if (aci_stat->pipes_closed_bitmap[byte_idx] & (0x01 << (pipe % 8)))
  67. {
  68. return(true);
  69. }
  70. return(false);
  71. }
  72. bool lib_aci_is_discovery_finished(aci_state_t *aci_stat)
  73. {
  74. return(aci_stat->pipes_open_bitmap[0]&0x01);
  75. }
  76. void lib_aci_init(aci_state_t *aci_stat)
  77. {
  78. uint8_t i;
  79. for (i = 0; i < PIPES_ARRAY_SIZE; i++)
  80. {
  81. aci_stat->pipes_open_bitmap[i] = 0;
  82. aci_stat->pipes_closed_bitmap[i] = 0;
  83. aci_cmd_params_open_adv_pipe.pipes[i] = 0;
  84. }
  85. is_request_operation_pending = false;
  86. is_indicate_operation_pending = false;
  87. is_open_remote_pipe_pending = false;
  88. is_close_remote_pipe_pending = false;
  89. cur_transaction_cmd = ACI_CMD_INVALID;
  90. memorized_rcvd_cmd_opcode = ACI_CMD_INVALID;
  91. memorized_transaction_cmd_opcode = ACI_CMD_INVALID;
  92. cx_rf_interval = 0;
  93. current_slave_latency = 0;
  94. request_operation_pipe = 0;
  95. indicate_operation_pipe = 0;
  96. cur_error_code = 0;
  97. p_rcvd_evt = NULL;
  98. p_services_pipe_type_map = aci_stat->aci_setup_info.services_pipe_type_mapping;
  99. pipe_count = aci_stat->aci_setup_info.number_of_pipes;
  100. p_setup_msgs = aci_stat->aci_setup_info.setup_msgs;
  101. setup_msgs_count = aci_stat->aci_setup_info.num_setup_msgs;
  102. hal_aci_tl_init();
  103. }
  104. uint8_t lib_aci_get_nb_available_credits(aci_state_t *aci_stat)
  105. {
  106. return aci_stat->data_credit_available;
  107. }
  108. uint16_t lib_aci_get_cx_interval_ms(aci_state_t *aci_stat)
  109. {
  110. uint32_t cx_rf_interval_ms_32bits;
  111. uint16_t cx_rf_interval_ms;
  112. cx_rf_interval_ms_32bits = aci_stat->connection_interval;
  113. cx_rf_interval_ms_32bits *= 125; // the connection interval is given in multiple of 0.125 milliseconds
  114. cx_rf_interval_ms = cx_rf_interval_ms_32bits / 100;
  115. return cx_rf_interval_ms;
  116. }
  117. uint16_t lib_aci_get_cx_interval(aci_state_t *aci_stat)
  118. {
  119. return aci_stat->connection_interval;
  120. }
  121. uint16_t lib_aci_get_slave_latency(aci_state_t *aci_stat)
  122. {
  123. return aci_stat->slave_latency;
  124. }
  125. bool lib_aci_set_app_latency(uint16_t latency, aci_app_latency_mode_t latency_mode)
  126. {
  127. aci_cmd_params_set_app_latency_t aci_set_app_latency;
  128. aci_set_app_latency.mode = latency_mode;
  129. aci_set_app_latency.latency = latency;
  130. acil_encode_cmd_set_app_latency(&(msg_to_send.buffer[0]), &aci_set_app_latency);
  131. return hal_aci_tl_send(&msg_to_send);
  132. }
  133. bool lib_aci_test(aci_test_mode_change_t enter_exit_test_mode)
  134. {
  135. aci_cmd_params_test_t aci_cmd_params_test;
  136. aci_cmd_params_test.test_mode_change = enter_exit_test_mode;
  137. acil_encode_cmd_set_test_mode(&(msg_to_send.buffer[0]), &aci_cmd_params_test);
  138. return hal_aci_tl_send(&msg_to_send);
  139. }
  140. bool lib_aci_sleep()
  141. {
  142. acil_encode_cmd_sleep(&(msg_to_send.buffer[0]));
  143. return hal_aci_tl_send(&msg_to_send);
  144. }
  145. bool lib_aci_radio_reset()
  146. {
  147. acil_encode_baseband_reset(&(msg_to_send.buffer[0]));
  148. return hal_aci_tl_send(&msg_to_send);
  149. }
  150. bool lib_aci_direct_connect()
  151. {
  152. acil_encode_direct_connect(&(msg_to_send.buffer[0]));
  153. return hal_aci_tl_send(&msg_to_send);
  154. }
  155. bool lib_aci_device_version()
  156. {
  157. acil_encode_cmd_get_device_version(&(msg_to_send.buffer[0]));
  158. return hal_aci_tl_send(&msg_to_send);
  159. }
  160. bool lib_aci_set_local_data(aci_state_t *aci_stat, uint8_t pipe, uint8_t *p_value, uint8_t size)
  161. {
  162. aci_cmd_params_set_local_data_t aci_cmd_params_set_local_data;
  163. if ((p_services_pipe_type_map[pipe-1].location != ACI_STORE_LOCAL)
  164. ||
  165. (size > ACI_PIPE_TX_DATA_MAX_LEN))
  166. {
  167. return false;
  168. }
  169. aci_cmd_params_set_local_data.tx_data.pipe_number = pipe;
  170. memcpy(&(aci_cmd_params_set_local_data.tx_data.aci_data[0]), p_value, size);
  171. acil_encode_cmd_set_local_data(&(msg_to_send.buffer[0]), &aci_cmd_params_set_local_data, size);
  172. return hal_aci_tl_send(&msg_to_send);
  173. }
  174. bool lib_aci_connect(uint16_t run_timeout, uint16_t adv_interval)
  175. {
  176. aci_cmd_params_connect_t aci_cmd_params_connect;
  177. aci_cmd_params_connect.timeout = run_timeout;
  178. aci_cmd_params_connect.adv_interval = adv_interval;
  179. acil_encode_cmd_connect(&(msg_to_send.buffer[0]), &aci_cmd_params_connect);
  180. return hal_aci_tl_send(&msg_to_send);
  181. }
  182. bool lib_aci_disconnect(aci_state_t *aci_stat, aci_disconnect_reason_t reason)
  183. {
  184. bool ret_val;
  185. uint8_t i;
  186. aci_cmd_params_disconnect_t aci_cmd_params_disconnect;
  187. aci_cmd_params_disconnect.reason = reason;
  188. acil_encode_cmd_disconnect(&(msg_to_send.buffer[0]), &aci_cmd_params_disconnect);
  189. ret_val = hal_aci_tl_send(&msg_to_send);
  190. // If we have actually sent the disconnect
  191. if (ret_val)
  192. {
  193. // Update pipes immediately so that while the disconnect is happening,
  194. // the application can't attempt sending another message
  195. // If the application sends another message before we updated this
  196. // a ACI Pipe Error Event will be received from nRF8001
  197. for (i=0; i < PIPES_ARRAY_SIZE; i++)
  198. {
  199. aci_stat->pipes_open_bitmap[i] = 0;
  200. aci_stat->pipes_closed_bitmap[i] = 0;
  201. }
  202. }
  203. return ret_val;
  204. }
  205. bool lib_aci_bond(uint16_t run_timeout, uint16_t adv_interval)
  206. {
  207. aci_cmd_params_bond_t aci_cmd_params_bond;
  208. aci_cmd_params_bond.timeout = run_timeout;
  209. aci_cmd_params_bond.adv_interval = adv_interval;
  210. acil_encode_cmd_bond(&(msg_to_send.buffer[0]), &aci_cmd_params_bond);
  211. return hal_aci_tl_send(&msg_to_send);
  212. }
  213. bool lib_aci_wakeup()
  214. {
  215. acil_encode_cmd_wakeup(&(msg_to_send.buffer[0]));
  216. return hal_aci_tl_send(&msg_to_send);
  217. }
  218. bool lib_aci_set_tx_power(aci_device_output_power_t tx_power)
  219. {
  220. aci_cmd_params_set_tx_power_t aci_cmd_params_set_tx_power;
  221. aci_cmd_params_set_tx_power.device_power = tx_power;
  222. acil_encode_cmd_set_radio_tx_power(&(msg_to_send.buffer[0]), &aci_cmd_params_set_tx_power);
  223. return hal_aci_tl_send(&msg_to_send);
  224. }
  225. bool lib_aci_get_address()
  226. {
  227. acil_encode_cmd_get_address(&(msg_to_send.buffer[0]));
  228. return hal_aci_tl_send(&msg_to_send);
  229. }
  230. bool lib_aci_get_temperature()
  231. {
  232. acil_encode_cmd_temparature(&(msg_to_send.buffer[0]));
  233. return hal_aci_tl_send(&msg_to_send);
  234. }
  235. bool lib_aci_get_battery_level()
  236. {
  237. acil_encode_cmd_battery_level(&(msg_to_send.buffer[0]));
  238. return hal_aci_tl_send(&msg_to_send);
  239. }
  240. bool lib_aci_send_data(uint8_t pipe, uint8_t *p_value, uint8_t size)
  241. {
  242. bool ret_val = false;
  243. aci_cmd_params_send_data_t aci_cmd_params_send_data;
  244. if(!((p_services_pipe_type_map[pipe-1].pipe_type == ACI_TX) ||
  245. (p_services_pipe_type_map[pipe-1].pipe_type == ACI_TX_ACK)))
  246. {
  247. return false;
  248. }
  249. if (size > ACI_PIPE_TX_DATA_MAX_LEN)
  250. {
  251. return false;
  252. }
  253. {
  254. aci_cmd_params_send_data.tx_data.pipe_number = pipe;
  255. memcpy(&(aci_cmd_params_send_data.tx_data.aci_data[0]), p_value, size);
  256. acil_encode_cmd_send_data(&(msg_to_send.buffer[0]), &aci_cmd_params_send_data, size);
  257. is_cmd_response_expected = false;
  258. ret_val = hal_aci_tl_send(&msg_to_send);
  259. }
  260. return ret_val;
  261. }
  262. bool lib_aci_request_data(aci_state_t *aci_stat, uint8_t pipe)
  263. {
  264. bool ret_val = false;
  265. aci_cmd_params_request_data_t aci_cmd_params_request_data;
  266. if(!((p_services_pipe_type_map[pipe-1].location == ACI_STORE_REMOTE)&&(p_services_pipe_type_map[pipe-1].pipe_type == ACI_RX_REQ)))
  267. {
  268. return false;
  269. }
  270. {
  271. {
  272. aci_cmd_params_request_data.pipe_number = pipe;
  273. acil_encode_cmd_request_data(&(msg_to_send.buffer[0]), &aci_cmd_params_request_data);
  274. ret_val = hal_aci_tl_send(&msg_to_send);
  275. }
  276. }
  277. return ret_val;
  278. }
  279. bool lib_aci_change_timing(uint16_t minimun_cx_interval, uint16_t maximum_cx_interval, uint16_t slave_latency, uint16_t timeout)
  280. {
  281. aci_cmd_params_change_timing_t aci_cmd_params_change_timing;
  282. aci_cmd_params_change_timing.conn_params.min_conn_interval = minimun_cx_interval;
  283. aci_cmd_params_change_timing.conn_params.max_conn_interval = maximum_cx_interval;
  284. aci_cmd_params_change_timing.conn_params.slave_latency = slave_latency;
  285. aci_cmd_params_change_timing.conn_params.timeout_mult = timeout;
  286. acil_encode_cmd_change_timing_req(&(msg_to_send.buffer[0]), &aci_cmd_params_change_timing);
  287. return hal_aci_tl_send(&msg_to_send);
  288. }
  289. bool lib_aci_change_timing_GAP_PPCP()
  290. {
  291. acil_encode_cmd_change_timing_req_GAP_PPCP(&(msg_to_send.buffer[0]));
  292. return hal_aci_tl_send(&msg_to_send);
  293. }
  294. bool lib_aci_open_remote_pipe(aci_state_t *aci_stat, uint8_t pipe)
  295. {
  296. bool ret_val = false;
  297. aci_cmd_params_open_remote_pipe_t aci_cmd_params_open_remote_pipe;
  298. if(!((p_services_pipe_type_map[pipe-1].location == ACI_STORE_REMOTE)&&
  299. ((p_services_pipe_type_map[pipe-1].pipe_type == ACI_RX)||
  300. (p_services_pipe_type_map[pipe-1].pipe_type == ACI_RX_ACK_AUTO)||
  301. (p_services_pipe_type_map[pipe-1].pipe_type == ACI_RX_ACK))))
  302. {
  303. return false;
  304. }
  305. {
  306. is_request_operation_pending = true;
  307. is_open_remote_pipe_pending = true;
  308. request_operation_pipe = pipe;
  309. aci_cmd_params_open_remote_pipe.pipe_number = pipe;
  310. acil_encode_cmd_open_remote_pipe(&(msg_to_send.buffer[0]), &aci_cmd_params_open_remote_pipe);
  311. ret_val = hal_aci_tl_send(&msg_to_send);
  312. }
  313. return ret_val;
  314. }
  315. bool lib_aci_close_remote_pipe(aci_state_t *aci_stat, uint8_t pipe)
  316. {
  317. bool ret_val = false;
  318. aci_cmd_params_close_remote_pipe_t aci_cmd_params_close_remote_pipe;
  319. if((p_services_pipe_type_map[pipe-1].location == ACI_STORE_REMOTE)&&
  320. ((p_services_pipe_type_map[pipe-1].pipe_type == ACI_RX)||
  321. (p_services_pipe_type_map[pipe-1].pipe_type == ACI_RX_ACK_AUTO)||
  322. (p_services_pipe_type_map[pipe-1].pipe_type == ACI_RX_ACK)))
  323. {
  324. return false;
  325. }
  326. {
  327. is_request_operation_pending = true;
  328. is_close_remote_pipe_pending = true;
  329. request_operation_pipe = pipe;
  330. aci_cmd_params_close_remote_pipe.pipe_number = pipe;
  331. acil_encode_cmd_close_remote_pipe(&(msg_to_send.buffer[0]), &aci_cmd_params_close_remote_pipe);
  332. ret_val = hal_aci_tl_send(&msg_to_send);
  333. }
  334. return ret_val;
  335. }
  336. bool lib_aci_set_key(aci_key_type_t key_rsp_type, uint8_t *key, uint8_t len)
  337. {
  338. aci_cmd_params_set_key_t aci_cmd_params_set_key;
  339. aci_cmd_params_set_key.key_type = key_rsp_type;
  340. memcpy((uint8_t*)&(aci_cmd_params_set_key.key), key, len);
  341. acil_encode_cmd_set_key(&(msg_to_send.buffer[0]), &aci_cmd_params_set_key);
  342. return hal_aci_tl_send(&msg_to_send);
  343. }
  344. bool lib_aci_echo_msg(uint8_t msg_size, uint8_t *p_msg_data)
  345. {
  346. aci_cmd_params_echo_t aci_cmd_params_echo;
  347. if(msg_size > (ACI_ECHO_DATA_MAX_LEN))
  348. {
  349. return false;
  350. }
  351. if (msg_size > (ACI_ECHO_DATA_MAX_LEN))
  352. {
  353. msg_size = ACI_ECHO_DATA_MAX_LEN;
  354. }
  355. memcpy(&(aci_cmd_params_echo.echo_data[0]), p_msg_data, msg_size);
  356. acil_encode_cmd_echo_msg(&(msg_to_send.buffer[0]), &aci_cmd_params_echo, msg_size);
  357. return hal_aci_tl_send(&msg_to_send);
  358. }
  359. bool lib_aci_bond_request()
  360. {
  361. acil_encode_cmd_bond_security_request(&(msg_to_send.buffer[0]));
  362. return hal_aci_tl_send(&msg_to_send);
  363. }
  364. bool lib_aci_event_get(aci_state_t *aci_stat, hal_aci_evt_t *p_aci_evt_data)
  365. {
  366. bool status;
  367. status = hal_aci_tl_event_get((hal_aci_data_t *)p_aci_evt_data);
  368. /**
  369. Update the state of the ACI witn the
  370. ACI Events -> Pipe Status, Disconnected, Connected, Bond Status, Pipe Error
  371. */
  372. {
  373. aci_evt_t * aci_evt;
  374. aci_evt = &p_aci_evt_data->evt;
  375. switch(aci_evt->evt_opcode)
  376. {
  377. case ACI_EVT_PIPE_STATUS:
  378. {
  379. uint8_t i=0;
  380. for (i=0; i < PIPES_ARRAY_SIZE; i++)
  381. {
  382. aci_stat->pipes_open_bitmap[i] = aci_evt->params.pipe_status.pipes_open_bitmap[i];
  383. aci_stat->pipes_closed_bitmap[i] = aci_evt->params.pipe_status.pipes_closed_bitmap[i];
  384. }
  385. }
  386. break;
  387. case ACI_EVT_DISCONNECTED:
  388. {
  389. uint8_t i=0;
  390. for (i=0; i < PIPES_ARRAY_SIZE; i++)
  391. {
  392. aci_stat->pipes_open_bitmap[i] = 0;
  393. aci_stat->pipes_closed_bitmap[i] = 0;
  394. }
  395. aci_stat->confirmation_pending = false;
  396. aci_stat->data_credit_available = aci_stat->data_credit_total;
  397. }
  398. break;
  399. case ACI_EVT_TIMING:
  400. aci_stat->connection_interval = aci_evt->params.timing.conn_rf_interval;
  401. aci_stat->slave_latency = aci_evt->params.timing.conn_slave_rf_latency;
  402. aci_stat->supervision_timeout = aci_evt->params.timing.conn_rf_timeout;
  403. break;
  404. }
  405. }
  406. return status;
  407. }
  408. bool lib_aci_send_ack(aci_state_t *aci_stat, const uint8_t pipe)
  409. {
  410. bool ret_val = false;
  411. {
  412. acil_encode_cmd_send_data_ack(&(msg_to_send.buffer[0]), pipe);
  413. is_cmd_response_expected = false;
  414. ret_val = hal_aci_tl_send(&msg_to_send);
  415. }
  416. return ret_val;
  417. }
  418. bool lib_aci_send_nack(aci_state_t *aci_stat, const uint8_t pipe, const uint8_t error_code)
  419. {
  420. bool ret_val = false;
  421. {
  422. is_cmd_response_expected = false;
  423. acil_encode_cmd_send_data_nack(&(msg_to_send.buffer[0]), pipe, error_code);
  424. ret_val = hal_aci_tl_send(&msg_to_send);
  425. }
  426. return ret_val;
  427. }
  428. bool lib_aci_broadcast(const uint16_t timeout, const uint16_t adv_interval)
  429. {
  430. aci_cmd_params_broadcast_t aci_cmd_params_broadcast;
  431. if (timeout > 16383)
  432. {
  433. return false;
  434. }
  435. // The adv_interval should be between 160 and 16384 (which translates to the advertisement
  436. // interval values 100 ms and 10.24 s.
  437. if ((160 > adv_interval) || (adv_interval > 16384))
  438. {
  439. return false;
  440. }
  441. aci_cmd_params_broadcast.timeout = timeout;
  442. aci_cmd_params_broadcast.adv_interval = adv_interval;
  443. acil_encode_cmd_broadcast(&(msg_to_send.buffer[0]), &aci_cmd_params_broadcast);
  444. return hal_aci_tl_send(&msg_to_send);
  445. }
  446. bool lib_aci_open_adv_pipes(const uint8_t * const adv_service_data_pipes)
  447. {
  448. uint8_t i;
  449. for (i = 0; i < PIPES_ARRAY_SIZE; i++)
  450. {
  451. aci_cmd_params_open_adv_pipe.pipes[i] = adv_service_data_pipes[i];
  452. }
  453. acil_encode_cmd_open_adv_pipes(&(msg_to_send.buffer[0]), &aci_cmd_params_open_adv_pipe);
  454. return hal_aci_tl_send(&msg_to_send);
  455. }
  456. bool lib_aci_open_adv_pipe(const uint8_t pipe)
  457. {
  458. uint8_t byte_idx = pipe / 8;
  459. aci_cmd_params_open_adv_pipe.pipes[byte_idx] |= (0x01 << (pipe % 8));
  460. acil_encode_cmd_open_adv_pipes(&(msg_to_send.buffer[0]), &aci_cmd_params_open_adv_pipe);
  461. return hal_aci_tl_send(&msg_to_send);
  462. }
  463. bool lib_aci_read_dynamic_data()
  464. {
  465. acil_encode_cmd_read_dynamic_data(&(msg_to_send.buffer[0]));
  466. return hal_aci_tl_send(&msg_to_send);
  467. }
  468. bool lib_aci_write_dynamic_data(uint8_t sequence_number, uint8_t* dynamic_data, uint8_t length)
  469. {
  470. acil_encode_cmd_write_dynamic_data(&(msg_to_send.buffer[0]), sequence_number, dynamic_data, length);
  471. return hal_aci_tl_send(&msg_to_send);
  472. }
  473. bool lib_aci_dtm_command(uint8_t dtm_command_msbyte, uint8_t dtm_command_lsbyte)
  474. {
  475. aci_cmd_params_dtm_cmd_t aci_cmd_params_dtm_cmd;
  476. aci_cmd_params_dtm_cmd.cmd_msb = dtm_command_msbyte;
  477. aci_cmd_params_dtm_cmd.cmd_lsb = dtm_command_lsbyte;
  478. acil_encode_cmd_dtm_cmd(&(msg_to_send.buffer[0]), &aci_cmd_params_dtm_cmd);
  479. return hal_aci_tl_send(&msg_to_send);
  480. }
  481. void lib_aci_flush(void)
  482. {
  483. m_aci_q_flush();
  484. }
  485. void lib_aci_debug_print(bool enable)
  486. {
  487. hal_aci_debug_print(enable);
  488. }