ble_conn.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. /**
  2. * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #include <string.h>
  41. #include "ble_conn.h"
  42. #include "ble_serialization.h"
  43. #include "cond_field_serialization.h"
  44. #include "ble_struct_serialization.h"
  45. #include "ble_gap_struct_serialization.h"
  46. #include "ble_gatt_struct_serialization.h"
  47. #include "ble_gattc_struct_serialization.h"
  48. #include "ble_gatts_struct_serialization.h"
  49. #include "ble_l2cap_struct_serialization.h"
  50. #include "app_util.h"
  51. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4
  52. uint32_t ble_enable_req_dec(uint8_t const * const p_buf,
  53. uint32_t packet_len,
  54. ble_enable_params_t * * const pp_ble_enable_params)
  55. {
  56. SER_REQ_DEC_BEGIN(SD_BLE_ENABLE);
  57. SER_PULL_COND(pp_ble_enable_params, ble_enable_params_t_dec);
  58. SER_REQ_DEC_END;
  59. }
  60. #else
  61. uint32_t ble_enable_req_dec(uint8_t const * const p_buf,
  62. uint32_t packet_len)
  63. {
  64. SER_REQ_DEC_BEGIN(SD_BLE_ENABLE);
  65. SER_REQ_DEC_END;
  66. }
  67. #endif
  68. uint32_t ble_enable_rsp_enc(uint32_t return_code,
  69. uint8_t * const p_buf,
  70. uint32_t * const p_buf_len)
  71. {
  72. SER_RSP_ENC_RESULT_ONLY(SD_BLE_ENABLE);
  73. }
  74. uint32_t ble_opt_get_req_dec(uint8_t const * const p_buf,
  75. uint16_t packet_len,
  76. uint32_t * const p_opt_id,
  77. ble_opt_t **const pp_opt )
  78. {
  79. SER_REQ_DEC_BEGIN(SD_BLE_OPT_GET);
  80. SER_ASSERT_NOT_NULL(p_opt_id);
  81. SER_ASSERT_NOT_NULL(pp_opt);
  82. SER_ASSERT_NOT_NULL(*pp_opt);
  83. SER_PULL_uint32(p_opt_id);
  84. SER_PULL_COND(pp_opt, NULL);
  85. SER_REQ_DEC_END;
  86. }
  87. uint32_t ble_opt_get_rsp_enc(uint32_t return_code,
  88. uint8_t * const p_buf,
  89. uint32_t * const p_buf_len,
  90. uint32_t opt_id,
  91. ble_opt_t const * const p_opt)
  92. {
  93. SER_RSP_ENC_BEGIN(SD_BLE_OPT_GET);
  94. SER_ASSERT_NOT_NULL(p_opt);
  95. SER_PUSH_uint32(&opt_id);
  96. field_encoder_handler_t fp_encoder = NULL;
  97. void const * p_struct = NULL;
  98. switch (opt_id)
  99. {
  100. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4
  101. case BLE_COMMON_OPT_CONN_BW:
  102. fp_encoder = ble_common_opt_conn_bw_t_enc;
  103. p_struct = &p_opt->common_opt.conn_bw;
  104. break;
  105. #endif
  106. case BLE_COMMON_OPT_PA_LNA:
  107. fp_encoder = ble_common_opt_pa_lna_t_enc;
  108. p_struct = &p_opt->common_opt.pa_lna;
  109. break;
  110. case BLE_COMMON_OPT_CONN_EVT_EXT:
  111. fp_encoder = ble_common_opt_conn_evt_ext_t_enc;
  112. p_struct = &p_opt->common_opt.conn_evt_ext;
  113. break;
  114. case BLE_GAP_OPT_CH_MAP:
  115. fp_encoder = ble_gap_opt_ch_map_t_enc;
  116. p_struct = &p_opt->gap_opt.ch_map;
  117. break;
  118. case BLE_GAP_OPT_LOCAL_CONN_LATENCY:
  119. fp_encoder = ble_gap_opt_local_conn_latency_t_enc;
  120. p_struct = &p_opt->gap_opt.local_conn_latency;
  121. break;
  122. case BLE_GAP_OPT_PASSKEY:
  123. fp_encoder = ble_gap_opt_passkey_t_enc;
  124. p_struct = &p_opt->gap_opt.passkey;
  125. break;
  126. case BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT:
  127. fp_encoder = ble_gap_opt_auth_payload_timeout_t_enc;
  128. p_struct = &p_opt->gap_opt.auth_payload_timeout;
  129. break;
  130. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4
  131. case BLE_GAP_OPT_EXT_LEN:
  132. fp_encoder = ble_gap_opt_ext_len_t_enc;
  133. p_struct = &p_opt->gap_opt.ext_len;
  134. break;
  135. #endif
  136. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6
  137. case BLE_GAP_OPT_SCAN_REQ_REPORT:
  138. fp_encoder = ble_gap_opt_scan_req_report_t_enc;
  139. p_struct = &p_opt->gap_opt.scan_req_report;
  140. break;
  141. #endif
  142. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4
  143. case BLE_GAP_OPT_COMPAT_MODE:
  144. fp_encoder = ble_gap_opt_compat_mode_t_enc;
  145. p_struct = &p_opt->gap_opt.compat_mode;
  146. break;
  147. #else
  148. #ifndef S112
  149. case BLE_GAP_OPT_COMPAT_MODE_1:
  150. fp_encoder = ble_gap_opt_compat_mode_1_t_enc;
  151. p_struct = &p_opt->gap_opt.compat_mode_1;
  152. break;
  153. #endif
  154. #endif
  155. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION == 4
  156. case BLE_GAP_OPT_COMPAT_MODE_2:
  157. fp_encoder = ble_gap_opt_compat_mode_2_t_enc;
  158. p_struct = &p_opt->gap_opt.compat_mode_2;
  159. break;
  160. #endif
  161. default:
  162. SER_ASSERT(NRF_ERROR_INVALID_PARAM, NRF_ERROR_INVALID_PARAM);
  163. break;
  164. }
  165. SER_PUSH_FIELD(p_struct, fp_encoder);
  166. SER_RSP_ENC_END;
  167. }
  168. uint32_t ble_opt_set_req_dec(uint8_t const * const p_buf,
  169. uint16_t packet_len,
  170. uint32_t * const p_opt_id,
  171. ble_opt_t **const pp_opt )
  172. {
  173. SER_REQ_DEC_BEGIN(SD_BLE_OPT_SET);
  174. SER_ASSERT_NOT_NULL(p_opt_id);
  175. SER_ASSERT_NOT_NULL(pp_opt);
  176. SER_ASSERT_NOT_NULL(*pp_opt);
  177. SER_PULL_uint32(p_opt_id);
  178. SER_PULL_COND(pp_opt, NULL);
  179. if (*pp_opt)
  180. {
  181. field_decoder_handler_t fp_decoder = NULL;
  182. void * p_struct = NULL;
  183. switch (*p_opt_id)
  184. {
  185. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4
  186. case BLE_COMMON_OPT_CONN_BW:
  187. fp_decoder = ble_common_opt_conn_bw_t_dec;
  188. p_struct = &((*pp_opt)->common_opt.conn_bw);
  189. break;
  190. #endif
  191. case BLE_COMMON_OPT_PA_LNA:
  192. fp_decoder = ble_common_opt_pa_lna_t_dec;
  193. p_struct = &((*pp_opt)->common_opt.pa_lna);
  194. break;
  195. case BLE_COMMON_OPT_CONN_EVT_EXT:
  196. fp_decoder = ble_common_opt_conn_evt_ext_t_dec;
  197. p_struct = &((*pp_opt)->common_opt.conn_evt_ext);
  198. break;
  199. case BLE_GAP_OPT_CH_MAP:
  200. fp_decoder = ble_gap_opt_ch_map_t_dec;
  201. p_struct = &((*pp_opt)->gap_opt.ch_map);
  202. break;
  203. case BLE_GAP_OPT_LOCAL_CONN_LATENCY:
  204. fp_decoder = ble_gap_opt_local_conn_latency_t_dec;
  205. p_struct = &((*pp_opt)->gap_opt.local_conn_latency);
  206. break;
  207. case BLE_GAP_OPT_PASSKEY:
  208. fp_decoder = ble_gap_opt_passkey_t_dec;
  209. p_struct = &((*pp_opt)->gap_opt.passkey);
  210. break;
  211. case BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT:
  212. fp_decoder = ble_gap_opt_auth_payload_timeout_t_dec;
  213. p_struct = &((*pp_opt)->gap_opt.auth_payload_timeout);
  214. break;
  215. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4
  216. case BLE_GAP_OPT_EXT_LEN:
  217. fp_decoder = ble_gap_opt_ext_len_t_dec;
  218. p_struct = &((*pp_opt)->gap_opt.ext_len);
  219. break;
  220. #endif
  221. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 6
  222. case BLE_GAP_OPT_SCAN_REQ_REPORT:
  223. fp_decoder = ble_gap_opt_scan_req_report_t_dec;
  224. p_struct = &((*pp_opt)->gap_opt.scan_req_report);
  225. break;
  226. #endif
  227. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4
  228. case BLE_GAP_OPT_COMPAT_MODE:
  229. fp_decoder = ble_gap_opt_compat_mode_t_dec;
  230. p_struct = &((*pp_opt)->gap_opt.compat_mode);
  231. break;
  232. #else
  233. #ifndef S112
  234. case BLE_GAP_OPT_COMPAT_MODE_1:
  235. fp_decoder = ble_gap_opt_compat_mode_1_t_dec;
  236. p_struct = &((*pp_opt)->gap_opt.compat_mode_1);
  237. break;
  238. #endif
  239. case BLE_GAP_OPT_SLAVE_LATENCY_DISABLE:
  240. fp_decoder = ble_gap_opt_slave_latency_disable_t_dec;
  241. p_struct = &((*pp_opt)->gap_opt.slave_latency_disable);
  242. break;
  243. #endif
  244. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION == 4
  245. case BLE_GAP_OPT_COMPAT_MODE_2:
  246. fp_decoder = ble_gap_opt_compat_mode_2_t_dec;
  247. p_struct = &((*pp_opt)->gap_opt.compat_mode_2);
  248. break;
  249. #endif
  250. default:
  251. SER_ASSERT(NRF_ERROR_INVALID_PARAM,NRF_ERROR_INVALID_PARAM);
  252. break;
  253. }
  254. SER_PULL_FIELD(p_struct, fp_decoder);
  255. }
  256. SER_REQ_DEC_END;
  257. }
  258. uint32_t ble_opt_set_rsp_enc(uint32_t return_code,
  259. uint8_t * const p_buf,
  260. uint32_t * const p_buf_len)
  261. {
  262. SER_RSP_ENC_RESULT_ONLY(SD_BLE_OPT_SET);
  263. }
  264. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4
  265. uint32_t ble_tx_packet_count_get_req_dec(uint8_t const * const p_buf,
  266. uint16_t packet_len,
  267. uint16_t * const p_conn_handle,
  268. uint8_t * * const pp_count)
  269. {
  270. SER_REQ_DEC_BEGIN(SD_BLE_TX_PACKET_COUNT_GET);
  271. SER_PULL_uint16(p_conn_handle);
  272. SER_PULL_COND(pp_count, NULL);
  273. SER_REQ_DEC_END;
  274. }
  275. uint32_t ble_tx_packet_count_get_rsp_enc(uint32_t return_code,
  276. uint8_t * const p_buf,
  277. uint32_t * const p_buf_len,
  278. uint8_t const * const p_count)
  279. {
  280. SER_RSP_ENC_BEGIN(SD_BLE_TX_PACKET_COUNT_GET);
  281. SER_PUSH_COND(p_count, uint8_t_enc);
  282. SER_RSP_ENC_END;
  283. }
  284. #endif
  285. uint32_t ble_user_mem_reply_req_dec(uint8_t const * const p_buf,
  286. uint32_t packet_len,
  287. uint16_t * const p_conn_handle,
  288. ble_user_mem_block_t * * const pp_mem_block)
  289. {
  290. SER_REQ_DEC_BEGIN(SD_BLE_USER_MEM_REPLY);
  291. SER_ASSERT_NOT_NULL(p_conn_handle);
  292. SER_ASSERT_NOT_NULL(pp_mem_block);
  293. SER_ASSERT_NOT_NULL(*pp_mem_block);
  294. SER_PULL_uint16(p_conn_handle);
  295. SER_PULL_COND(pp_mem_block, ble_user_mem_block_t_dec);
  296. SER_REQ_DEC_END;
  297. }
  298. uint32_t ble_user_mem_reply_rsp_enc(uint32_t return_code,
  299. uint8_t * const p_buf,
  300. uint32_t * const p_buf_len)
  301. {
  302. SER_RSP_ENC_RESULT_ONLY(SD_BLE_USER_MEM_REPLY);
  303. }
  304. uint32_t ble_uuid_decode_req_dec(uint8_t const * const p_buf,
  305. uint32_t const packet_len,
  306. uint8_t * p_uuid_le_len,
  307. uint8_t * * const pp_uuid_le,
  308. ble_uuid_t * * const pp_uuid)
  309. {
  310. SER_REQ_DEC_BEGIN(SD_BLE_UUID_DECODE);
  311. SER_PULL_len8data(pp_uuid_le, p_uuid_le_len);
  312. SER_PULL_COND(pp_uuid, NULL);
  313. SER_REQ_DEC_END;
  314. }
  315. uint32_t ble_uuid_decode_rsp_enc(uint32_t return_code,
  316. uint8_t * const p_buf,
  317. uint32_t * const p_buf_len,
  318. ble_uuid_t const * const p_uuid)
  319. {
  320. SER_RSP_ENC_BEGIN(SD_BLE_UUID_DECODE);
  321. SER_PUSH_COND(p_uuid, ble_uuid_t_enc);
  322. SER_RSP_ENC_END;
  323. }
  324. uint32_t ble_uuid_encode_req_dec(uint8_t const * const p_buf,
  325. uint16_t packet_len,
  326. ble_uuid_t * * const pp_uuid,
  327. uint8_t * * const pp_uuid_le_len,
  328. uint8_t * * const pp_uuid_le)
  329. {
  330. SER_REQ_DEC_BEGIN(SD_BLE_UUID_ENCODE);
  331. SER_ASSERT_NOT_NULL(pp_uuid);
  332. SER_ASSERT_NOT_NULL(pp_uuid_le_len);
  333. SER_ASSERT_NOT_NULL(pp_uuid_le);
  334. SER_ASSERT_NOT_NULL(*pp_uuid);
  335. SER_ASSERT_NOT_NULL(*pp_uuid_le_len);
  336. SER_ASSERT_NOT_NULL(*pp_uuid_le);
  337. SER_PULL_COND(pp_uuid, ble_uuid_t_dec);
  338. SER_PULL_COND(pp_uuid_le_len, NULL);
  339. SER_PULL_COND(pp_uuid_le, NULL);
  340. SER_REQ_DEC_END;
  341. }
  342. uint32_t ble_uuid_encode_rsp_enc(uint32_t return_code,
  343. uint8_t * const p_buf,
  344. uint32_t * const p_buf_len,
  345. uint8_t uuid_le_len,
  346. uint8_t const * const p_uuid_le)
  347. {
  348. SER_RSP_ENC_BEGIN(SD_BLE_UUID_ENCODE);
  349. SER_PUSH_uint8(&uuid_le_len);
  350. if (p_uuid_le != NULL)
  351. {
  352. SER_PUSH_uint8array(p_uuid_le, uuid_le_len);
  353. }
  354. SER_RSP_ENC_END;
  355. }
  356. uint32_t ble_uuid_vs_add_req_dec(uint8_t const * const p_buf,
  357. uint16_t packet_len,
  358. ble_uuid128_t * * const pp_uuid,
  359. uint8_t * * const pp_uuid_type)
  360. {
  361. SER_REQ_DEC_BEGIN(SD_BLE_UUID_VS_ADD);
  362. SER_ASSERT_NOT_NULL(pp_uuid);
  363. SER_ASSERT_NOT_NULL(pp_uuid_type);
  364. SER_ASSERT_NOT_NULL(*pp_uuid);
  365. SER_ASSERT_NOT_NULL(*pp_uuid_type);
  366. SER_PULL_COND(pp_uuid, ble_uuid128_t_dec);
  367. SER_PULL_COND(pp_uuid_type, NULL);
  368. SER_REQ_DEC_END;
  369. }
  370. uint32_t ble_uuid_vs_add_rsp_enc(uint32_t return_code,
  371. uint8_t * const p_buf,
  372. uint32_t * const p_buf_len,
  373. uint8_t const * const p_uuid_type)
  374. {
  375. SER_RSP_ENC_BEGIN(SD_BLE_UUID_VS_ADD);
  376. SER_PUSH_COND(p_uuid_type, uint8_t_enc);
  377. SER_RSP_ENC_END;
  378. }
  379. uint32_t ble_version_get_req_dec(uint8_t const * const p_buf,
  380. uint16_t packet_len,
  381. ble_version_t * * const pp_version)
  382. {
  383. SER_REQ_DEC_BEGIN(SD_BLE_VERSION_GET);
  384. SER_ASSERT_NOT_NULL(pp_version);
  385. SER_ASSERT_NOT_NULL(*pp_version);
  386. SER_PULL_COND(pp_version, NULL);
  387. SER_REQ_DEC_END;
  388. }
  389. uint32_t ble_version_get_rsp_enc(uint32_t return_code,
  390. uint8_t * const p_buf,
  391. uint32_t * const p_buf_len,
  392. ble_version_t const * const p_version)
  393. {
  394. SER_RSP_ENC_BEGIN(SD_BLE_VERSION_GET);
  395. SER_PUSH_FIELD(p_version, ble_version_t_enc);
  396. SER_RSP_ENC_END;
  397. }
  398. uint32_t ble_opt_id_pre_dec(uint8_t const * const p_buf,
  399. uint16_t packet_len,
  400. uint32_t * const p_opt_id)
  401. {
  402. SER_REQ_DEC_BEGIN(SD_BLE_OPT_SET);
  403. SER_ASSERT_NOT_NULL(p_opt_id);
  404. SER_PULL_uint32(p_opt_id);
  405. // Pre-decoding; do not check if the whole packet was processed.
  406. return NRF_SUCCESS;
  407. }
  408. #if NRF_SD_BLE_API_VERSION >= 4
  409. uint32_t ble_cfg_set_req_dec(uint8_t const * const p_buf,
  410. uint32_t packet_len,
  411. uint32_t * p_cfg_id,
  412. ble_cfg_t * * const pp_cfg)
  413. {
  414. SER_REQ_DEC_BEGIN(SD_BLE_CFG_SET);
  415. SER_PULL_uint32(p_cfg_id);
  416. SER_PULL_COND(pp_cfg, NULL);
  417. if (*pp_cfg)
  418. {
  419. field_decoder_handler_t fp_decoder = NULL;
  420. void * p_struct = NULL;
  421. switch (*p_cfg_id)
  422. {
  423. case BLE_CONN_CFG_GAP:
  424. fp_decoder = ble_gap_conn_cfg_t_dec;
  425. p_struct = &((*pp_cfg)->conn_cfg.params.gap_conn_cfg);
  426. break;
  427. case BLE_CONN_CFG_GATTC:
  428. fp_decoder = ble_gattc_conn_cfg_t_dec;
  429. p_struct = &((*pp_cfg)->conn_cfg.params.gattc_conn_cfg);
  430. break;
  431. case BLE_CONN_CFG_GATTS:
  432. fp_decoder = ble_gatts_conn_cfg_t_dec;
  433. p_struct = &((*pp_cfg)->conn_cfg.params.gatts_conn_cfg);
  434. break;
  435. case BLE_CONN_CFG_GATT:
  436. fp_decoder = ble_gatt_conn_cfg_t_dec;
  437. p_struct = &((*pp_cfg)->conn_cfg.params.gatt_conn_cfg);
  438. break;
  439. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION >= 5 && !defined(S112)
  440. case BLE_CONN_CFG_L2CAP:
  441. fp_decoder = ble_l2cap_conn_cfg_t_dec;
  442. p_struct = &((*pp_cfg)->conn_cfg.params.l2cap_conn_cfg);
  443. break;
  444. #endif
  445. case BLE_COMMON_CFG_VS_UUID:
  446. fp_decoder = ble_common_cfg_vs_uuid_t_dec;
  447. p_struct = &((*pp_cfg)->common_cfg.vs_uuid_cfg);
  448. break;
  449. case BLE_GAP_CFG_ROLE_COUNT:
  450. fp_decoder = ble_gap_cfg_role_count_t_dec;
  451. p_struct = &((*pp_cfg)->gap_cfg.role_count_cfg);
  452. break;
  453. case BLE_GAP_CFG_DEVICE_NAME:
  454. fp_decoder = ble_gap_cfg_device_name_t_dec;
  455. p_struct = &((*pp_cfg)->gap_cfg.device_name_cfg);
  456. break;
  457. case BLE_GATTS_CFG_SERVICE_CHANGED:
  458. fp_decoder = ble_gatts_cfg_service_changed_t_dec;
  459. p_struct = &((*pp_cfg)->gatts_cfg.service_changed);
  460. break;
  461. case BLE_GATTS_CFG_ATTR_TAB_SIZE:
  462. fp_decoder = ble_gatts_cfg_attr_tab_size_t_dec;
  463. p_struct = &((*pp_cfg)->gatts_cfg.attr_tab_size);
  464. break;
  465. default:
  466. SER_ASSERT(NRF_ERROR_INVALID_PARAM,NRF_ERROR_INVALID_PARAM);
  467. break;
  468. }
  469. if (*p_cfg_id >= BLE_CONN_CFG_BASE && *p_cfg_id <= BLE_CONN_CFG_GATT)
  470. {
  471. SER_PULL_uint8(&(*pp_cfg)->conn_cfg.conn_cfg_tag);
  472. }
  473. SER_PULL_FIELD(p_struct, fp_decoder);
  474. }
  475. SER_REQ_DEC_END;
  476. }
  477. uint32_t ble_cfg_set_rsp_enc(uint32_t return_code,
  478. uint8_t * const p_buf,
  479. uint32_t * const p_buf_len)
  480. {
  481. SER_RSP_ENC_RESULT_ONLY(SD_BLE_CFG_SET);
  482. }
  483. #endif