ble_gap_app.h 86 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667
  1. /**
  2. * Copyright (c) 2013 - 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. #ifndef BLE_GAP_APP_H__
  41. #define BLE_GAP_APP_H__
  42. /**@file
  43. *
  44. * @defgroup ble_gap_app GAP Application command request encoders and command response decoders
  45. * @{
  46. * @ingroup ser_app_s130_codecs
  47. *
  48. * @brief GAP Application command request encoders and command response decoders.
  49. */
  50. #include "ble.h"
  51. #include "ble_gap.h"
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. #if defined(NRF_SD_BLE_API_VERSION) && (NRF_SD_BLE_API_VERSION <= 5)
  56. /**
  57. * @brief Encodes @ref sd_ble_gap_adv_data_set command request.
  58. *
  59. * @sa @ref ble_gap_adv_data_set_rsp_dec for command response decoder.
  60. *
  61. * @param[in] p_data Raw data to be placed in advertisement packet. If NULL, no changes
  62. * are made to the current advertisement packet data.
  63. * @param[in] dlen Data length for p_data. Max size: @ref BLE_GAP_ADV_SR_MAX_LEN_DEFAULT octets.
  64. * Should be 0 if p_data is NULL, can be 0 if p_data is not NULL.
  65. * @param[in] p_sr_data Raw data to be placed in scan response packet. If NULL,
  66. * no changes are made to the current scan response packet data.
  67. * @param[in] srdlen Data length for p_sr_data. Max size: @ref BLE_GAP_ADV_SR_MAX_LEN_DEFAULT octets.
  68. * Should be 0 if p_sr_data is NULL, can be 0 if p_data is not NULL.
  69. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  70. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  71. * \c out: Length of encoded command packet.
  72. *
  73. * @retval NRF_SUCCESS Encoding success.
  74. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  75. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  76. */
  77. uint32_t ble_gap_adv_data_set_req_enc(uint8_t const * const p_data,
  78. uint8_t dlen,
  79. uint8_t const * const p_sr_data,
  80. uint8_t srdlen,
  81. uint8_t * const p_buf,
  82. uint32_t * const p_buf_len);
  83. /**
  84. * @brief Decodes response to @ref sd_ble_gap_adv_data_set command.
  85. *
  86. * @sa @ref ble_gap_adv_data_set_req_enc for command request encoder.
  87. *
  88. * @param[in] p_buf Pointer to beginning of command response packet.
  89. * @param[in] packet_len Length (in bytes) of response packet.
  90. * @param[out] p_result_code Command result code.
  91. *
  92. * @retval NRF_SUCCESS Decoding success.
  93. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  94. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  95. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  96. * expected operation code.
  97. */
  98. uint32_t ble_gap_adv_data_set_rsp_dec(uint8_t const * const p_buf,
  99. uint32_t packet_len,
  100. uint32_t * const p_result_code);
  101. #endif
  102. /**
  103. * @brief Encodes @ref sd_ble_gap_adv_start command request.
  104. *
  105. * @sa @ref ble_gap_adv_start_rsp_dec for command response decoder.
  106. *
  107. * @param[in] p_adv_params Pointer to advertising parameters structure.
  108. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  109. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  110. * \c out: Length of encoded command packet.
  111. *
  112. * @retval NRF_SUCCESS Encoding success.
  113. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  114. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  115. */
  116. uint32_t ble_gap_adv_start_req_enc(
  117. #if NRF_SD_BLE_API_VERSION > 5
  118. uint8_t adv_handle,
  119. #else
  120. ble_gap_adv_params_t const * const p_adv_params,
  121. #endif
  122. #if NRF_SD_BLE_API_VERSION >= 4
  123. uint8_t conn_cfg_tag,
  124. #endif
  125. uint8_t * const p_buf,
  126. uint32_t * const p_buf_len);
  127. /**
  128. * @brief Decodes response to @ref sd_ble_gap_adv_start command.
  129. *
  130. * @sa @ref ble_gap_adv_start_req_enc for command request encoder.
  131. *
  132. * @param[in] p_buf Pointer to beginning of command response packet.
  133. * @param[in] packet_len Length (in bytes) of response packet.
  134. * @param[out] p_result_code Command result code.
  135. *
  136. * @retval NRF_SUCCESS Decoding success.
  137. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  138. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  139. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  140. * expected operation code.
  141. */
  142. uint32_t ble_gap_adv_start_rsp_dec(uint8_t const * const p_buf,
  143. uint32_t packet_len,
  144. uint32_t * const p_result_code);
  145. /**
  146. * @brief Encodes @ref sd_ble_gap_tx_power_set command request.
  147. *
  148. * @sa @ref ble_gap_tx_power_set_rsp_dec for command response decoder.
  149. *
  150. * @param[in] tx_power Radio transmit power in dBm (accepted values are -40, -30, -20, -16, -12, -8, -4, 0, and 4 dBm).
  151. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  152. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  153. * \c out: Length of encoded command packet.
  154. *
  155. * @retval NRF_SUCCESS Encoding success.
  156. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  157. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  158. */
  159. uint32_t ble_gap_tx_power_set_req_enc(
  160. #if NRF_SD_BLE_API_VERSION > 5
  161. uint8_t role, uint16_t handle,
  162. #endif
  163. int8_t tx_power,
  164. uint8_t * const p_buf,
  165. uint32_t * const p_buf_len);
  166. /**
  167. * @brief Decodes response to @ref sd_ble_gap_tx_power_set command.
  168. *
  169. * @sa @ref ble_gap_tx_power_set_req_enc for command request encoder.
  170. *
  171. * @param[in] p_buf Pointer to beginning of command response packet.
  172. * @param[in] packet_len Length (in bytes) of response packet.
  173. * @param[out] p_result_code Command result code.
  174. *
  175. * @retval NRF_SUCCESS Decoding success.
  176. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  177. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  178. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  179. * expected operation code.
  180. */
  181. uint32_t ble_gap_tx_power_set_rsp_dec(uint8_t const * const p_buf,
  182. uint32_t packet_len,
  183. uint32_t * const p_result_code);
  184. /**
  185. * @brief Encodes @ref sd_ble_gap_appearance_get command request.
  186. *
  187. * @sa @ref ble_gap_appearance_get_rsp_dec for command response decoder.
  188. *
  189. * @param[in] p_appearance Appearance (16 bit), see @ref BLE_APPEARANCES.
  190. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  191. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  192. * \c out: Length of encoded command packet.
  193. *
  194. * @note \p p_appearance will not be updated by the command
  195. * request encoder. Updated values are set by @ref ble_gap_appearance_get_rsp_dec.
  196. *
  197. * @retval NRF_SUCCESS Encoding success.
  198. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  199. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  200. */
  201. uint32_t ble_gap_appearance_get_req_enc(uint16_t const * const p_appearance,
  202. uint8_t * const p_buf,
  203. uint32_t * const p_buf_len);
  204. /**
  205. * @brief Decodes response to @ref sd_ble_gap_appearance_get command.
  206. *
  207. * @sa @ref ble_gap_appearance_get_req_enc for command request encoder.
  208. *
  209. * @param[in] p_buf Pointer to beginning of command response packet.
  210. * @param[in] packet_len Length (in bytes) of response packet.
  211. * @param[out] p_appearance Appearance (16 bit), see @ref BLE_APPEARANCES.
  212. * @param[out] p_result_code Command result code.
  213. *
  214. * @retval NRF_SUCCESS Decoding success.
  215. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  216. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  217. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  218. * expected operation code.
  219. */
  220. uint32_t ble_gap_appearance_get_rsp_dec(uint8_t const * const p_buf,
  221. uint32_t packet_len,
  222. uint16_t * const p_appearance,
  223. uint32_t * const p_result_code);
  224. /**
  225. * @brief Encodes @ref sd_ble_gap_appearance_set command request.
  226. *
  227. * @sa @ref ble_gap_appearance_set_rsp_dec for command response decoder.
  228. *
  229. * @param[in] appearance Appearance (16 bit), see @ref BLE_APPEARANCES.
  230. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  231. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  232. * \c out: Length of encoded command packet.
  233. *
  234. * @retval NRF_SUCCESS Encoding success.
  235. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  236. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  237. */
  238. uint32_t ble_gap_appearance_set_req_enc(uint16_t appearance,
  239. uint8_t * const p_buf,
  240. uint32_t * const p_buf_len);
  241. /**
  242. * @brief Decodes response to @ref sd_ble_gap_appearance_set command.
  243. *
  244. * @sa @ref ble_gap_appearance_set_req_enc for command request encoder.
  245. *
  246. * @param[in] p_buf Pointer to beginning of command response packet.
  247. * @param[in] packet_len Length (in bytes) of response packet.
  248. * @param[out] p_result_code Command result code.
  249. *
  250. * @retval NRF_SUCCESS Decoding success.
  251. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  252. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  253. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  254. * expected operation code.
  255. */
  256. uint32_t ble_gap_appearance_set_rsp_dec(uint8_t const * const p_buf,
  257. uint32_t packet_len,
  258. uint32_t * const p_result_code);
  259. /**
  260. * @brief Encodes @ref sd_ble_gap_device_name_get command request.
  261. *
  262. * @sa @ref ble_gap_device_name_get_rsp_dec for command response decoder.
  263. *
  264. * @param[in] p_dev_name Pointer to an empty buffer where the UTF-8 <b>non NULL-terminated</b>
  265. * string will be placed. Set to NULL to obtain the complete device
  266. * name length.
  267. * @param[in] p_dev_name_len Length of the buffer pointed by p_dev_name.
  268. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  269. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  270. * \c out: Length of encoded command packet.
  271. *
  272. * @note \p p_dev_name and \p p_len will not be updated by the command
  273. * request encoder. Updated values are set by @ref ble_gap_device_name_get_rsp_dec.
  274. *
  275. * @retval NRF_SUCCESS Encoding success.
  276. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  277. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  278. */
  279. uint32_t ble_gap_device_name_get_req_enc(uint8_t const * const p_dev_name,
  280. uint16_t const * const p_dev_name_len,
  281. uint8_t * const p_buf,
  282. uint32_t * const p_buf_len);
  283. /**
  284. * @brief Decodes response to @ref sd_ble_gap_device_name_get command.
  285. *
  286. * @sa @ref ble_gap_device_name_get_req_enc for command request encoder.
  287. *
  288. * @param[in] p_buf Pointer to beginning of command response packet.
  289. * @param[in] packet_len Length (in bytes) of response packet.
  290. * @param[out] p_dev_name Pointer to an empty buffer where the UTF-8
  291. * <b>non NULL-terminated</b> string will be placed.
  292. * @param[in,out] p_dev_name_len Length of the buffer pointed by p_dev_name, complete device name
  293. * length on output.
  294. * @param[out] p_result_code Command result code.
  295. *
  296. * @retval NRF_SUCCESS Decoding success.
  297. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  298. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  299. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  300. * expected operation code.
  301. */
  302. uint32_t ble_gap_device_name_get_rsp_dec(uint8_t const * const p_buf,
  303. uint32_t packet_len,
  304. uint8_t * const p_dev_name,
  305. uint16_t * const p_dev_name_len,
  306. uint32_t * const p_result_code);
  307. /**
  308. * @brief Encodes @ref sd_ble_gap_device_name_set command request.
  309. *
  310. * @sa @ref ble_gap_device_name_set_rsp_dec for command response decoder.
  311. *
  312. * @param[in] p_write_perm Write permissions for the Device Name characteristic, see
  313. * @ref ble_gap_conn_sec_mode_t.
  314. * @param[in] p_dev_name Pointer to a UTF-8 encoded, <b>non NULL-terminated</b> string.
  315. * @param[in] len Length of the UTF-8, <b>non NULL-terminated</b> string pointed
  316. * to by p_dev_name in octets (must be smaller or equal
  317. * than @ref BLE_GAP_DEVNAME_MAX_LEN).
  318. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  319. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  320. * \c out: Length of encoded command packet.
  321. *
  322. * @retval NRF_SUCCESS Encoding success.
  323. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  324. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  325. */
  326. uint32_t ble_gap_device_name_set_req_enc(ble_gap_conn_sec_mode_t const * const p_write_perm,
  327. uint8_t const * const p_dev_name,
  328. uint16_t len,
  329. uint8_t * const p_buf,
  330. uint32_t * const p_buf_len);
  331. /**
  332. * @brief Decodes response to @ref sd_ble_gap_device_name_set command.
  333. *
  334. * @sa @ref ble_gap_device_name_set_req_enc for command request encoder.
  335. *
  336. * @param[in] p_buf Pointer to beginning of command response packet.
  337. * @param[in] packet_len Length (in bytes) of response packet.
  338. * @param[out] p_result_code Command result code.
  339. *
  340. * @retval NRF_SUCCESS Decoding success.
  341. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  342. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  343. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  344. * expected operation code.
  345. */
  346. uint32_t ble_gap_device_name_set_rsp_dec(uint8_t const * const p_buf,
  347. uint32_t packet_len,
  348. uint32_t * const p_result_code);
  349. /**
  350. * @brief Encodes @ref sd_ble_gap_ppcp_set command request.
  351. *
  352. * @sa @ref ble_gap_ppcp_set_rsp_dec for command response decoder.
  353. *
  354. * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure with the
  355. * desired parameters.
  356. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  357. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  358. * \c out: Length of encoded command packet.
  359. *
  360. * @retval NRF_SUCCESS Encoding success.
  361. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  362. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  363. */
  364. uint32_t ble_gap_ppcp_set_req_enc(ble_gap_conn_params_t const * const p_conn_params,
  365. uint8_t * const p_buf,
  366. uint32_t * const p_buf_len);
  367. /**
  368. * @brief Decodes response to @ref sd_ble_gap_ppcp_set command.
  369. *
  370. * @sa @ref ble_gap_ppcp_set_req_enc for command request encoder.
  371. *
  372. * @param[in] p_buf Pointer to beginning of command response packet.
  373. * @param[in] packet_len Length (in bytes) of response packet.
  374. * @param[out] p_result_code Command result code.
  375. *
  376. * @retval NRF_SUCCESS Decoding success.
  377. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  378. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  379. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  380. * expected operation code.
  381. */
  382. uint32_t ble_gap_ppcp_set_rsp_dec(uint8_t const * const p_buf,
  383. uint32_t packet_len,
  384. uint32_t * const p_result_code);
  385. /**@brief Encodes @ref sd_ble_gap_conn_param_update command request.
  386. *
  387. * @sa @ref ble_gap_conn_param_update_rsp_dec for command response decoder.
  388. *
  389. * @param[in] conn_handle Connection handle of the connection.
  390. * @param[in] p_conn_params Pointer to desired connection parameters.
  391. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  392. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  393. * \c out: Length of encoded command packet.
  394. *
  395. * @retval NRF_SUCCESS Encoding success.
  396. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  397. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  398. */
  399. uint32_t ble_gap_conn_param_update_req_enc(uint16_t conn_handle,
  400. ble_gap_conn_params_t const * const p_conn_params,
  401. uint8_t * const p_buf,
  402. uint32_t * const p_buf_len);
  403. /**@brief Decodes response to @ref sd_ble_gap_conn_param_update command.
  404. *
  405. * @sa @ref ble_gap_conn_param_update_req_enc for command request encoder.
  406. *
  407. * @param[in] p_buf Pointer to beginning of command response packet.
  408. * @param[in] packet_len Length (in bytes) of response packet.
  409. * @param[out] p_result_code Command response result code.
  410. *
  411. * @retval NRF_SUCCESS Decoding success.
  412. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  413. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  414. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  415. * operation code.
  416. */
  417. uint32_t ble_gap_conn_param_update_rsp_dec(uint8_t const * const p_buf,
  418. uint32_t packet_len,
  419. uint32_t * const p_result_code);
  420. /**@brief Encodes @ref sd_ble_gap_disconnect command request.
  421. *
  422. * @sa @ref ble_gap_disconnect_rsp_dec for command response decoder.
  423. *
  424. * @param[in] conn_handle Connection handle of the connection.
  425. * @param[in] hci_status_code HCI status code, see @ref BLE_HCI_STATUS_CODES.
  426. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  427. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  428. * \c out: Length of encoded command packet.
  429. *
  430. * @retval NRF_SUCCESS Encoding success.
  431. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  432. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  433. */
  434. uint32_t ble_gap_disconnect_req_enc(uint16_t conn_handle,
  435. uint8_t hci_status_code,
  436. uint8_t * const p_buf,
  437. uint32_t * const p_buf_len);
  438. /**@brief Decodes response to @ref sd_ble_gap_disconnect command.
  439. *
  440. * @sa @ref ble_gap_disconnect_req_enc for command request encoder.
  441. *
  442. * @param[in] p_buf Pointer to beginning of command response packet.
  443. * @param[in] packet_len Length (in bytes) of response packet.
  444. * @param[out] p_result_code Command response result code.
  445. *
  446. * @retval NRF_SUCCESS Decoding success.
  447. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  448. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  449. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  450. * operation code.
  451. */
  452. uint32_t ble_gap_disconnect_rsp_dec(uint8_t const * const p_buf,
  453. uint32_t packet_len,
  454. uint32_t * const p_result_code);
  455. /**@brief Encodes @ref sd_ble_gap_rssi_stop command request.
  456. *
  457. * @sa @ref ble_gap_rssi_stop_rsp_dec for command response decoder.
  458. *
  459. * @param[in] conn_handle Connection handle of the connection.
  460. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  461. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  462. * \c out: Length of encoded command packet.
  463. *
  464. * @retval NRF_SUCCESS Encoding success.
  465. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  466. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  467. */
  468. uint32_t ble_gap_rssi_stop_req_enc(uint16_t conn_handle,
  469. uint8_t * const p_buf,
  470. uint32_t * const p_buf_len);
  471. /**@brief Decodes response to @ref sd_ble_gap_rssi_stop command.
  472. *
  473. * @sa @ref ble_gap_rssi_stop_rsp_dec for command response decoder.
  474. *
  475. * @param[in] p_buf Pointer to beginning of command response packet.
  476. * @param[in] packet_len Length (in bytes) of response packet.
  477. * @param[out] p_result_code Command response result code.
  478. *
  479. * @retval NRF_SUCCESS Decoding success.
  480. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  481. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  482. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  483. * operation code.
  484. */
  485. uint32_t ble_gap_rssi_stop_rsp_dec(uint8_t const * const p_buf,
  486. uint32_t packet_len,
  487. uint32_t * const p_result_code);
  488. /**@brief Encodes @ref sd_ble_gap_ppcp_get command request.
  489. *
  490. * @sa @ref ble_gap_ppcp_get_rsp_dec for command response decoder.
  491. *
  492. * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the
  493. * parameters will be stored.
  494. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  495. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  496. * \c out: Length of encoded command packet.
  497. *
  498. * @note \p p_conn_params will not be updated by the command request encoder. Updated values are
  499. * set by @ref ble_gap_ppcp_get_rsp_dec.
  500. *
  501. * @retval NRF_SUCCESS Encoding success.
  502. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  503. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  504. */
  505. uint32_t ble_gap_ppcp_get_req_enc(ble_gap_conn_params_t const * const p_conn_params,
  506. uint8_t * const p_buf,
  507. uint32_t * const p_buf_len);
  508. /**@brief Decodes response to @ref sd_ble_gap_ppcp_get command.
  509. *
  510. * @sa @ref ble_gap_ppcp_get_req_enc for command request encoder.
  511. *
  512. * @param[in] p_buf Pointer to beginning of command response packet.
  513. * @param[in] packet_len Length (in bytes) of response packet.
  514. * @param[out] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the parameters
  515. * will be stored.
  516. * @param[out] p_result_code Command response result code.
  517. *
  518. * @retval NRF_SUCCESS Decoding success.
  519. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  520. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  521. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  522. * operation code.
  523. */
  524. uint32_t ble_gap_ppcp_get_rsp_dec(uint8_t const * const p_buf,
  525. uint32_t packet_len,
  526. ble_gap_conn_params_t * const p_conn_params,
  527. uint32_t * const p_result_code);
  528. /**@brief Encodes @ref sd_ble_gap_auth_key_reply command request.
  529. *
  530. * @sa @ref ble_gap_auth_key_reply_rsp_dec for command response decoder.
  531. *
  532. * @param[in] conn_handle Connection handle of the connection.
  533. * @param[in] key_type Key type which defines length of key data as defined for
  534. * @ref sd_ble_gap_auth_key_reply .
  535. * @param[in] p_key Pointer to a buffer which contains key
  536. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  537. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  538. * \c out: Length of encoded command packet.
  539. *
  540. * @retval NRF_SUCCESS Encoding success.
  541. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  542. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  543. * @retval NRF_ERROR_INVALID_PARAM Encoding failure. Incorrect param provided (key_type).
  544. */
  545. uint32_t ble_gap_auth_key_reply_req_enc(uint16_t conn_handle,
  546. uint8_t key_type,
  547. uint8_t const * const p_key,
  548. uint8_t * const p_buf,
  549. uint32_t * const p_buf_len);
  550. /**@brief Decodes response to @ref sd_ble_gap_auth_key_reply command.
  551. *
  552. * @sa @ref ble_gap_auth_key_reply_req_enc for command request encoder.
  553. *
  554. * @param[in] p_buf Pointer to beginning of command response packet.
  555. * @param[in] packet_len Length (in bytes) of response packet.
  556. * @param[out] p_result_code Command response result code.
  557. *
  558. * @retval NRF_SUCCESS Decoding success.
  559. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  560. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  561. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  562. * operation code.
  563. */
  564. uint32_t ble_gap_auth_key_reply_rsp_dec(uint8_t const * const p_buf,
  565. uint32_t packet_len,
  566. uint32_t * const p_result_code);
  567. /**@brief Encodes @ref sd_ble_gap_sec_info_reply command request.
  568. *
  569. * @sa @ref ble_gap_sec_info_reply_rsp_dec for command response decoder.
  570. *
  571. * @param[in] conn_handle Connection handle of the connection.
  572. * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information
  573. * structure.
  574. * @param[in] p_id_info Pointer to a @ref ble_gap_irk_t id information
  575. * structure.
  576. * @param[in] p_sign_info Pointer to a @ref ble_gap_sign_info_t signing information
  577. * structure.
  578. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  579. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  580. * \c out: Length of encoded command packet.
  581. *
  582. * @retval NRF_SUCCESS Encoding success.
  583. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  584. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  585. */
  586. uint32_t ble_gap_sec_info_reply_req_enc(uint16_t conn_handle,
  587. ble_gap_enc_info_t const * p_enc_info,
  588. ble_gap_irk_t const * p_id_info,
  589. ble_gap_sign_info_t const * p_sign_info,
  590. uint8_t * const p_buf,
  591. uint32_t * const p_buf_len);
  592. /**@brief Decodes response to @ref sd_ble_gap_sec_info_reply command.
  593. *
  594. * @sa @ref ble_gap_sec_info_reply_req_enc for command request encoder.
  595. *
  596. * @param[in] p_buf Pointer to beginning of command response packet.
  597. * @param[in] packet_len Length (in bytes) of response packet.
  598. * @param[out] p_result_code Command response result code.
  599. *
  600. * @retval NRF_SUCCESS Decoding success.
  601. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  602. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  603. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  604. * operation code.
  605. */
  606. uint32_t ble_gap_sec_info_reply_rsp_dec(uint8_t const * const p_buf,
  607. uint32_t packet_len,
  608. uint32_t * const p_result_code);
  609. /**@brief Encodes @ref sd_ble_gap_sec_params_reply command request.
  610. *
  611. * @sa @ref ble_gap_sec_params_reply_rsp_dec for command response decoder.
  612. *
  613. * @param[in] conn_handle Connection handle of the connection.
  614. * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS.
  615. * @param[in] p_sec_params Pointer to @ref ble_gap_sec_params_t security parameters
  616. * structure.
  617. * @param[in] p_sec_keyset Pointer to @ref ble_gap_sec_keyset_t security keys
  618. * structure.
  619. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  620. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  621. * \c out: Length of encoded command packet.
  622. *
  623. * @retval NRF_SUCCESS Encoding success.
  624. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  625. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  626. */
  627. uint32_t ble_gap_sec_params_reply_req_enc(uint16_t conn_handle,
  628. uint8_t sec_status,
  629. ble_gap_sec_params_t const * const p_sec_params,
  630. ble_gap_sec_keyset_t const * const p_sec_keyset,
  631. uint8_t * const p_buf,
  632. uint32_t * const p_buf_len);
  633. /**@brief Decodes response to @ref sd_ble_gap_sec_params_reply command.
  634. *
  635. * @sa @ref ble_gap_sec_params_reply_req_enc for command request encoder.
  636. *
  637. * @param[in] p_buf Pointer to beginning of command response packet.
  638. * @param[in] packet_len Length (in bytes) of response packet.
  639. * @param[in] p_sec_keyset Pointer to @ref ble_gap_sec_keyset_t security keys
  640. * @param[out] p_result_code Command response result code.
  641. *
  642. * @retval NRF_SUCCESS Decoding success.
  643. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  644. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  645. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  646. * operation code.
  647. */
  648. uint32_t ble_gap_sec_params_reply_rsp_dec(uint8_t const * const p_buf,
  649. uint32_t packet_len,
  650. ble_gap_sec_keyset_t const * const p_sec_keyset,
  651. uint32_t * const p_result_code);
  652. /**@brief Encodes @ref sd_ble_gap_authenticate command request.
  653. *
  654. * @sa @ref ble_gap_authenticate_rsp_dec for command response decoder.
  655. *
  656. * @param[in] conn_handle Connection handle of the connection.
  657. * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters
  658. * structure.
  659. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  660. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  661. * \c out: Length of encoded command packet.
  662. *
  663. * @retval NRF_SUCCESS Encoding success.
  664. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  665. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  666. */
  667. uint32_t ble_gap_authenticate_req_enc(uint16_t conn_handle,
  668. ble_gap_sec_params_t const * const p_sec_params,
  669. uint8_t * const p_buf,
  670. uint32_t * const p_buf_len);
  671. /**@brief Decodes response to @ref sd_ble_gap_authenticate command.
  672. *
  673. * @sa @ref ble_gap_authenticate_req_enc for command request encoder.
  674. *
  675. * @param[in] p_buf Pointer to beginning of command response packet.
  676. * @param[in] packet_len Length (in bytes) of response packet.
  677. * @param[out] p_result_code Command response result code.
  678. *
  679. * @retval NRF_SUCCESS Decoding success.
  680. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  681. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  682. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  683. * operation code.
  684. */
  685. uint32_t ble_gap_authenticate_rsp_dec(uint8_t const * const p_buf,
  686. uint32_t packet_len,
  687. uint32_t * const p_result_code);
  688. /**@brief Encodes @ref sd_ble_gap_adv_stop command request.
  689. *
  690. * @sa @ref ble_gap_adv_stop_rsp_dec for command response decoder.
  691. *
  692. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  693. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  694. * \c out: Length of encoded command packet.
  695. *
  696. * @retval NRF_SUCCESS Encoding success.
  697. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  698. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  699. */
  700. uint32_t ble_gap_adv_stop_req_enc(
  701. #if NRF_SD_BLE_API_VERSION > 5
  702. uint8_t adv_handle,
  703. #endif
  704. uint8_t * const p_buf,
  705. uint32_t * const p_buf_len);
  706. /**@brief Decodes response to @ref sd_ble_gap_adv_stop command.
  707. *
  708. * @sa @ref ble_gap_adv_stop_req_enc for command request encoder.
  709. *
  710. * @param[in] p_buf Pointer to beginning of command response packet.
  711. * @param[in] packet_len Length (in bytes) of response packet.
  712. * @param[out] p_result_code Command response result code.
  713. *
  714. * @retval NRF_SUCCESS Decoding success.
  715. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  716. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  717. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  718. * operation code.
  719. */
  720. uint32_t ble_gap_adv_stop_rsp_dec(uint8_t const * const p_buf,
  721. uint32_t packet_len,
  722. uint32_t * const p_result_code);
  723. /**@brief Encodes @ref sd_ble_gap_conn_sec_get command request.
  724. *
  725. * @sa @ref ble_gap_conn_sec_get_rsp_dec for command response decoder.
  726. *
  727. * @param[in] conn_handle Connection handle of the connection.
  728. * @param[in] p_conn_sec Pointer to \ref ble_gap_conn_sec_t which will be filled in
  729. * response.
  730. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  731. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  732. * \c out: Length of encoded command packet.
  733. *
  734. * @retval NRF_SUCCESS Encoding success.
  735. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  736. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  737. */
  738. uint32_t ble_gap_conn_sec_get_req_enc(uint16_t conn_handle,
  739. ble_gap_conn_sec_t const * const p_conn_sec,
  740. uint8_t * const p_buf,
  741. uint32_t * const p_buf_len);
  742. /**@brief Decodes response to @ref sd_ble_gap_conn_sec_get command.
  743. *
  744. * @sa @ref ble_gap_conn_sec_get_req_enc for command request encoder.
  745. *
  746. * @param[in] p_buf Pointer to beginning of command response packet.
  747. * @param[in] packet_len Length (in bytes) of response packet.
  748. * @param[out] pp_conn_sec Pointer to pointer to \ref ble_gap_conn_sec_t which will be filled by
  749. * the decoded data (if present).
  750. * @param[out] p_result_code Command response result code.
  751. *
  752. * @retval NRF_SUCCESS Decoding success.
  753. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  754. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  755. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  756. * operation code.
  757. */
  758. uint32_t ble_gap_conn_sec_get_rsp_dec(uint8_t const * const p_buf,
  759. uint32_t packet_len,
  760. ble_gap_conn_sec_t * * const pp_conn_sec,
  761. uint32_t * const p_result_code);
  762. /**@brief Encodes @ref sd_ble_gap_rssi_start command request.
  763. *
  764. * @sa @ref ble_gap_rssi_start_rsp_dec for command response decoder.
  765. *
  766. * @param[in] conn_handle Connection handle of the connection.
  767. * @param[in] threshold_dbm Threshold in dBm.
  768. * @param[in] skip_count Sample skip count.
  769. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  770. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  771. * \c out: Length of encoded command packet.
  772. *
  773. * @retval NRF_SUCCESS Encoding success.
  774. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  775. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  776. */
  777. uint32_t ble_gap_rssi_start_req_enc(uint16_t conn_handle,
  778. uint8_t threshold_dbm,
  779. uint8_t skip_count,
  780. uint8_t * const p_buf,
  781. uint32_t * const p_buf_len);
  782. /**@brief Decodes response to @ref sd_ble_gap_rssi_start command.
  783. *
  784. * @sa @ref ble_gap_rssi_start_req_enc for command request encoder.
  785. *
  786. * @param[in] p_buf Pointer to beginning of command response packet.
  787. * @param[in] packet_len Length (in bytes) of response packet.
  788. * @param[out] p_result_code Command response result code.
  789. *
  790. * @retval NRF_SUCCESS Decoding success.
  791. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  792. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  793. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  794. * operation code.
  795. */
  796. uint32_t ble_gap_rssi_start_rsp_dec(uint8_t const * const p_buf,
  797. uint32_t packet_len,
  798. uint32_t * const p_result_code);
  799. #ifndef S112
  800. /**@brief Encodes @ref sd_ble_gap_scan_stop command request.
  801. *
  802. * @sa @ref ble_gap_scan_stop_rsp_dec for command response decoder.
  803. *
  804. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  805. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  806. * \c out: Length of encoded command packet.
  807. *
  808. * @retval NRF_SUCCESS Encoding success.
  809. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  810. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  811. */
  812. uint32_t ble_gap_scan_stop_req_enc(uint8_t * const p_buf, uint32_t * const p_buf_len);
  813. /**@brief Decodes response to @ref sd_ble_gap_scan_stop command.
  814. *
  815. * @sa @ref ble_gap_scan_stop_req_enc for command request encoder.
  816. *
  817. * @param[in] p_buf Pointer to beginning of command response packet.
  818. * @param[in] packet_len Length (in bytes) of response packet.
  819. * @param[out] p_result_code Command response result code.
  820. *
  821. * @retval NRF_SUCCESS Decoding success.
  822. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  823. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  824. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  825. * operation code.
  826. */
  827. uint32_t ble_gap_scan_stop_rsp_dec(uint8_t const * const p_buf,
  828. uint32_t packet_len,
  829. uint32_t * const p_result_code);
  830. /**@brief Encodes @ref sd_ble_gap_scan_start command request.
  831. *
  832. * @sa @ref ble_gap_scan_start_rsp_dec for command response decoder.
  833. *
  834. * @param[in] p_scan_params Pointer to scan params structure.
  835. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  836. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  837. * \c out: Length of encoded command packet.
  838. *
  839. * @retval NRF_SUCCESS Encoding success.
  840. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  841. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  842. */
  843. uint32_t ble_gap_scan_start_req_enc(ble_gap_scan_params_t const * p_scan_params,
  844. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION > 5
  845. ble_data_t const * p_adv_report_buffer,
  846. #endif
  847. uint8_t * const p_buf,
  848. uint32_t * const p_buf_len);
  849. /**@brief Decodes response to @ref sd_ble_gap_scan_start command.
  850. *
  851. * @sa @ref ble_gap_scan_start_req_enc for command request encoder.
  852. *
  853. * @param[in] p_buf Pointer to beginning of command response packet.
  854. * @param[in] packet_len Length (in bytes) of response packet.
  855. * @param[out] p_result_code Command response result code.
  856. *
  857. * @retval NRF_SUCCESS Decoding success.
  858. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  859. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  860. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  861. * operation code.
  862. */
  863. uint32_t ble_gap_scan_start_rsp_dec(uint8_t const * const p_buf,
  864. uint32_t packet_len,
  865. uint32_t * const p_result_code);
  866. /**@brief Encodes @ref sd_ble_gap_connect command request.
  867. *
  868. * @sa @ref ble_gap_connect_rsp_dec for command response decoder.
  869. *
  870. * @param[in] p_peer_addr Pointer to peer address.
  871. * @param[in] p_scan_params Pointer to scan params structure.
  872. * @param[in] p_conn_params Pointer to desired connection parameters.
  873. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  874. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  875. * \c out: Length of encoded command packet.
  876. *
  877. * @retval NRF_SUCCESS Encoding success.
  878. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  879. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  880. */
  881. uint32_t ble_gap_connect_req_enc(ble_gap_addr_t const * const p_peer_addr,
  882. ble_gap_scan_params_t const * const p_scan_params,
  883. ble_gap_conn_params_t const * const p_conn_params,
  884. #if NRF_SD_BLE_API_VERSION >= 4
  885. uint8_t conn_cfg_tag,
  886. #endif
  887. uint8_t * const p_buf,
  888. uint32_t * const p_buf_len);
  889. /**@brief Decodes response to @ref sd_ble_gap_connect command.
  890. *
  891. * @sa @ref ble_gap_connect_req_enc for command request encoder.
  892. *
  893. * @param[in] p_buf Pointer to beginning of command response packet.
  894. * @param[in] packet_len Length (in bytes) of response packet.
  895. * @param[out] p_result_code Command response result code.
  896. *
  897. * @retval NRF_SUCCESS Decoding success.
  898. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  899. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  900. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  901. * operation code.
  902. */
  903. uint32_t ble_gap_connect_rsp_dec(uint8_t const * const p_buf,
  904. uint32_t packet_len,
  905. uint32_t * const p_result_code);
  906. /**@brief Encodes @ref sd_ble_gap_connect_cancel command request.
  907. *
  908. * @sa @ref ble_gap_connect_cancel_rsp_dec for command response decoder.
  909. *
  910. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  911. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  912. * \c out: Length of encoded command packet.
  913. *
  914. * @retval NRF_SUCCESS Encoding success.
  915. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  916. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  917. */
  918. uint32_t ble_gap_connect_cancel_req_enc(uint8_t * const p_buf,
  919. uint32_t * const p_buf_len);
  920. /**@brief Decodes response to @ref sd_ble_gap_connect_cancel command.
  921. *
  922. * @sa @ref ble_gap_connect_cancel_req_enc for command request encoder.
  923. *
  924. * @param[in] p_buf Pointer to beginning of command response packet.
  925. * @param[in] packet_len Length (in bytes) of response packet.
  926. * @param[out] p_result_code Command response result code.
  927. *
  928. * @retval NRF_SUCCESS Decoding success.
  929. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  930. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  931. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  932. * operation code.
  933. */
  934. uint32_t ble_gap_connect_cancel_rsp_dec(uint8_t const * const p_buf,
  935. uint32_t packet_len,
  936. uint32_t * const p_result_code);
  937. /**@brief Encodes @ref sd_ble_gap_encrypt command request.
  938. *
  939. * @sa @ref ble_gap_encrypt_rsp_dec for command response decoder.
  940. *
  941. * @param[in] conn_handle Connection handle.
  942. * @param[in] p_master_id Pointer to a master identification structure.
  943. * @param[in] p_enc_info Pointer to desired connection parameters.
  944. * @param[in] p_buf Pointer to a ble_gap_enc_info_t encryption information structure.
  945. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  946. * \c out: Length of encoded command packet.
  947. *
  948. * @retval NRF_SUCCESS Encoding success.
  949. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  950. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  951. */
  952. uint32_t ble_gap_encrypt_req_enc(uint16_t conn_handle,
  953. ble_gap_master_id_t const * const p_master_id,
  954. ble_gap_enc_info_t const * const p_enc_info,
  955. uint8_t * const p_buf,
  956. uint32_t * const p_buf_len);
  957. /**@brief Decodes response to @ref sd_ble_gap_encrypt command.
  958. *
  959. * @sa @ref ble_gap_encrypt_req_enc for command request encoder.
  960. *
  961. * @param[in] p_buf Pointer to beginning of command response packet.
  962. * @param[in] packet_len Length (in bytes) of response packet.
  963. * @param[out] p_result_code Command response result code.
  964. *
  965. * @retval NRF_SUCCESS Decoding success.
  966. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  967. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  968. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  969. * operation code.
  970. */
  971. uint32_t ble_gap_encrypt_rsp_dec(uint8_t const * const p_buf,
  972. uint32_t packet_len,
  973. uint32_t * const p_result_code);
  974. #endif //!S112
  975. /**@brief Encodes @ref sd_ble_gap_rssi_get command request.
  976. *
  977. * @sa @ref ble_gap_rssi_get_rsp_dec for command response decoder.
  978. *
  979. * @param[in] conn_handle Connection handle.
  980. * @param[in] p_rssi Pointer to the RSSI value.
  981. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  982. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  983. * \c out: Length of encoded command packet.
  984. *
  985. * @retval NRF_SUCCESS Encoding success.
  986. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  987. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  988. */
  989. uint32_t ble_gap_rssi_get_req_enc(uint16_t conn_handle,
  990. int8_t const * const p_rssi,
  991. #if NRF_SD_BLE_API_VERSION > 5
  992. uint8_t const * const p_ch_index,
  993. #endif
  994. uint8_t * const p_buf,
  995. uint32_t * const p_buf_len);
  996. /**@brief Decodes response to @ref sd_ble_gap_rssi_get command.
  997. *
  998. * @sa @ref ble_gap_rssi_get_req_enc for command request encoder.
  999. *
  1000. * @param[in] p_buf Pointer to beginning of command response packet.
  1001. * @param[in] packet_len Length (in bytes) of response packet.
  1002. * @param[out] p_rssi Pointer to RSSI value.
  1003. * @param[out] p_result_code Command response result code.
  1004. *
  1005. * @retval NRF_SUCCESS Decoding success.
  1006. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1007. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  1008. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  1009. * operation code.
  1010. */
  1011. uint32_t ble_gap_rssi_get_rsp_dec(uint8_t const * const p_buf,
  1012. uint32_t packet_len,
  1013. int8_t * const p_rssi,
  1014. #if NRF_SD_BLE_API_VERSION > 5
  1015. uint8_t * const p_ch_index,
  1016. #endif
  1017. uint32_t * const p_result_code);
  1018. /**@brief Encodes @ref sd_ble_gap_keypress_notify command request.
  1019. *
  1020. * @sa @ref ble_gap_keypress_notify_rsp_dec for command response decoder.
  1021. *
  1022. * @param[in] conn_handle Connection handle.
  1023. * @param[in] kp_not See @ref sd_ble_gap_keypress_notify.
  1024. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  1025. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  1026. * \c out: Length of encoded command packet.
  1027. *
  1028. * @retval NRF_SUCCESS Encoding success.
  1029. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1030. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1031. */
  1032. uint32_t ble_gap_keypress_notify_req_enc(uint16_t conn_handle,
  1033. uint8_t kp_not,
  1034. uint8_t * const p_buf,
  1035. uint32_t * const p_buf_len);
  1036. /**@brief Decodes response to @ref sd_ble_gap_keypress_notify command.
  1037. *
  1038. * @sa @ref ble_gap_keypress_notify_req_enc for command request encoder.
  1039. *
  1040. * @param[in] p_buf Pointer to beginning of command response packet.
  1041. * @param[in] packet_len Length (in bytes) of response packet.
  1042. * @param[out] p_result_code Command response result code.
  1043. *
  1044. * @retval NRF_SUCCESS Decoding success.
  1045. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1046. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  1047. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  1048. * operation code.
  1049. */
  1050. uint32_t ble_gap_keypress_notify_rsp_dec(uint8_t const * const p_buf,
  1051. uint32_t packet_len,
  1052. uint32_t * const p_result_code);
  1053. /**@brief Encodes @ref sd_ble_gap_lesc_dhkey_reply command request.
  1054. *
  1055. * @sa @ref ble_gap_lesc_dhkey_reply_rsp_dec for command response decoder.
  1056. *
  1057. * @param[in] conn_handle Connection handle.
  1058. * @param[in] p_dhkey See @ref sd_ble_gap_lesc_dhkey_reply.
  1059. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  1060. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  1061. * \c out: Length of encoded command packet.
  1062. *
  1063. * @retval NRF_SUCCESS Encoding success.
  1064. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1065. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1066. */
  1067. uint32_t ble_gap_lesc_dhkey_reply_req_enc(uint16_t conn_handle,
  1068. ble_gap_lesc_dhkey_t const *p_dhkey,
  1069. uint8_t * const p_buf,
  1070. uint32_t * const p_buf_len);
  1071. /**@brief Decodes response to @ref sd_ble_gap_lesc_dhkey_reply command.
  1072. *
  1073. * @sa @ref ble_gap_lesc_dhkey_reply_req_enc for command request encoder.
  1074. *
  1075. * @param[in] p_buf Pointer to beginning of command response packet.
  1076. * @param[in] packet_len Length (in bytes) of response packet.
  1077. * @param[out] p_result_code Command response result code.
  1078. *
  1079. * @retval NRF_SUCCESS Decoding success.
  1080. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1081. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  1082. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  1083. * operation code.
  1084. */
  1085. uint32_t ble_gap_lesc_dhkey_reply_rsp_dec(uint8_t const * const p_buf,
  1086. uint32_t packet_len,
  1087. uint32_t * const p_result_code);
  1088. /**@brief Encodes @ref sd_ble_gap_lesc_oob_data_set command request.
  1089. *
  1090. * @sa @ref ble_gap_lesc_oob_data_set_rsp_dec for command response decoder.
  1091. *
  1092. * @param[in] conn_handle Connection handle.
  1093. * @param[in] p_oobd_own See @ref sd_ble_gap_lesc_oob_data_set.
  1094. * @param[in] p_oobd_peer See @ref sd_ble_gap_lesc_oob_data_set.
  1095. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  1096. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  1097. * \c out: Length of encoded command packet.
  1098. *
  1099. * @retval NRF_SUCCESS Encoding success.
  1100. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1101. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1102. */
  1103. uint32_t ble_gap_lesc_oob_data_set_req_enc(uint16_t conn_handle,
  1104. ble_gap_lesc_oob_data_t const *p_oobd_own,
  1105. ble_gap_lesc_oob_data_t const *p_oobd_peer,
  1106. uint8_t * const p_buf,
  1107. uint32_t * const p_buf_len);
  1108. /**@brief Decodes response to @ref sd_ble_gap_lesc_oob_data_set command.
  1109. *
  1110. * @sa @ref ble_gap_lesc_oob_data_set_req_enc for command request encoder.
  1111. *
  1112. * @param[in] p_buf Pointer to beginning of command response packet.
  1113. * @param[in] packet_len Length (in bytes) of response packet.
  1114. * @param[out] p_result_code Command response result code.
  1115. *
  1116. * @retval NRF_SUCCESS Decoding success.
  1117. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1118. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  1119. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  1120. * operation code.
  1121. */
  1122. uint32_t ble_gap_lesc_oob_data_set_rsp_dec(uint8_t const * const p_buf,
  1123. uint32_t packet_len,
  1124. uint32_t * const p_result_code);
  1125. /**@brief Encodes @ref sd_ble_gap_lesc_oob_data_get command request.
  1126. *
  1127. * @sa @ref ble_gap_lesc_oob_data_get_rsp_dec for command response decoder.
  1128. *
  1129. * @param[in] conn_handle Connection handle.
  1130. * @param[in] p_pk_own See @ref sd_ble_gap_lesc_oob_data_get.
  1131. * @param[in] p_oobd_own See @ref sd_ble_gap_lesc_oob_data_get.
  1132. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  1133. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  1134. * \c out: Length of encoded command packet.
  1135. *
  1136. * @retval NRF_SUCCESS Encoding success.
  1137. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1138. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1139. */
  1140. uint32_t ble_gap_lesc_oob_data_get_req_enc(uint16_t conn_handle,
  1141. ble_gap_lesc_p256_pk_t const *p_pk_own,
  1142. ble_gap_lesc_oob_data_t *p_oobd_own,
  1143. uint8_t * const p_buf,
  1144. uint32_t * const p_buf_len);
  1145. /**@brief Decodes response to @ref sd_ble_gap_lesc_oob_data_get command.
  1146. *
  1147. * @sa @ref ble_gap_lesc_oob_data_get_req_enc for command request encoder.
  1148. *
  1149. * @param[in] p_buf Pointer to beginning of command response packet.
  1150. * @param[in] packet_len Length (in bytes) of response packet.
  1151. * @param[out] pp_oobd_own Pointer to pointer to location where OOB data is decoded.
  1152. * @param[out] p_result_code Command response result code.
  1153. *
  1154. * @retval NRF_SUCCESS Decoding success.
  1155. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1156. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  1157. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  1158. * operation code.
  1159. */
  1160. uint32_t ble_gap_lesc_oob_data_get_rsp_dec(uint8_t const * const p_buf,
  1161. uint32_t packet_len,
  1162. ble_gap_lesc_oob_data_t * *pp_oobd_own,
  1163. uint32_t * const p_result_code);
  1164. /**
  1165. * @brief Encodes @ref sd_ble_gap_addr_get command request.
  1166. *
  1167. * @sa @ref ble_gap_addr_get_rsp_dec for command response decoder.
  1168. *
  1169. * @param[in] p_address Pointer to address.
  1170. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  1171. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  1172. * \c out: Length of encoded command packet.
  1173. *
  1174. * @note \p p_address will not be updated by the command
  1175. * request encoder. Updated values are set by @ref ble_gap_addr_get_rsp_dec.
  1176. *
  1177. * @retval NRF_SUCCESS Encoding success.
  1178. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1179. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1180. */
  1181. uint32_t ble_gap_addr_get_req_enc(ble_gap_addr_t const * const p_address,
  1182. uint8_t * const p_buf,
  1183. uint32_t * const p_buf_len);
  1184. /**
  1185. * @brief Decodes response to @ref sd_ble_gap_addr_get command.
  1186. *
  1187. * @sa @ref ble_gap_addr_get_req_enc for command request encoder.
  1188. *
  1189. * @param[in] p_buf Pointer to beginning of command response packet.
  1190. * @param[in] packet_len Length (in bytes) of response packet.
  1191. * @param[out] p_address Pointer to address.
  1192. * @param[out] p_result_code Command result code.
  1193. *
  1194. * @retval NRF_SUCCESS Decoding success.
  1195. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1196. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  1197. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  1198. * expected operation code.
  1199. */
  1200. uint32_t ble_gap_addr_get_rsp_dec(uint8_t const * const p_buf,
  1201. uint32_t packet_len,
  1202. ble_gap_addr_t * const p_address,
  1203. uint32_t * const p_result_code);
  1204. /**
  1205. * @brief Encodes @ref sd_ble_gap_addr_set command request.
  1206. *
  1207. * @sa @ref ble_gap_addr_set_rsp_dec for command response decoder.
  1208. *
  1209. * @param[in] p_addr Pointer to address structure.
  1210. * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned.
  1211. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  1212. * \c out: Length of encoded command packet.
  1213. *
  1214. * @retval NRF_SUCCESS Encoding success.
  1215. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1216. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1217. */
  1218. uint32_t ble_gap_addr_set_req_enc(ble_gap_addr_t const * const p_addr,
  1219. uint8_t * const p_buf,
  1220. uint32_t * const p_buf_len);
  1221. /**
  1222. * @brief Decodes response to @ref sd_ble_gap_addr_set command.
  1223. *
  1224. * @sa @ref ble_gap_addr_set_req_enc for command request encoder.
  1225. *
  1226. * @param[in] p_buf Pointer to beginning of command response packet.
  1227. * @param[in] packet_len Length (in bytes) of response packet.
  1228. * @param[out] p_result_code Command result code.
  1229. *
  1230. * @retval NRF_SUCCESS Decoding success.
  1231. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1232. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  1233. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  1234. * expected operation code.
  1235. */
  1236. uint32_t ble_gap_addr_set_rsp_dec(uint8_t const * const p_buf,
  1237. uint32_t packet_len,
  1238. uint32_t * const p_result_code);
  1239. /**
  1240. * @brief Encodes @ref sd_ble_gap_privacy_set command request.
  1241. *
  1242. * @sa @ref ble_gap_privacy_set_rsp_dec for command response decoder.
  1243. *
  1244. * @param[in] p_privacy_params Pointer to privacy settings structure.
  1245. * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned.
  1246. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  1247. * \c out: Length of encoded command packet.
  1248. *
  1249. * @retval NRF_SUCCESS Encoding success.
  1250. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1251. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1252. */
  1253. uint32_t ble_gap_privacy_set_req_enc(ble_gap_privacy_params_t const * p_privacy_params,
  1254. uint8_t * const p_buf,
  1255. uint32_t * const p_buf_len);
  1256. /**
  1257. * @brief Decodes response to @ref sd_ble_gap_privacy_set command.
  1258. *
  1259. * @sa @ref ble_gap_privacy_set_req_enc for command request encoder.
  1260. *
  1261. * @param[in] p_buf Pointer to beginning of command response packet.
  1262. * @param[in] packet_len Length (in bytes) of response packet.
  1263. * @param[out] p_result_code Command result code.
  1264. *
  1265. * @retval NRF_SUCCESS Decoding success.
  1266. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1267. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  1268. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  1269. * expected operation code.
  1270. */
  1271. uint32_t ble_gap_privacy_set_rsp_dec(uint8_t const * const p_buf,
  1272. uint32_t packet_len,
  1273. uint32_t * const p_result_code);
  1274. /**
  1275. * @brief Encodes @ref sd_ble_gap_privacy_get command request.
  1276. *
  1277. * @sa @ref ble_gap_privacy_get_rsp_dec for command response decoder.
  1278. *
  1279. * @param[in] p_privacy_params Pointer to privacy settings structure.
  1280. * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned.
  1281. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  1282. * \c out: Length of encoded command packet.
  1283. *
  1284. * @retval NRF_SUCCESS Encoding success.
  1285. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1286. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1287. */
  1288. uint32_t ble_gap_privacy_get_req_enc(ble_gap_privacy_params_t const * const p_privacy_params,
  1289. uint8_t * const p_buf,
  1290. uint32_t * const p_buf_len);
  1291. /**
  1292. * @brief Decodes response to @ref sd_ble_gap_privacy_get command.
  1293. *
  1294. * @sa @ref ble_gap_privacy_get_req_enc for command request encoder.
  1295. *
  1296. * @param[in] p_buf Pointer to beginning of command response packet.
  1297. * @param[in] packet_len Length (in bytes) of response packet.
  1298. * @param[out] p_privacy_params Pointer to privacy settings structure.
  1299. * @param[out] p_result_code Command result code.
  1300. *
  1301. * @retval NRF_SUCCESS Decoding success.
  1302. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1303. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  1304. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  1305. * expected operation code.
  1306. */
  1307. uint32_t ble_gap_privacy_get_rsp_dec(uint8_t const * const p_buf,
  1308. uint32_t packet_len,
  1309. ble_gap_privacy_params_t const * const p_privacy_params,
  1310. uint32_t * const p_result_code);
  1311. /**
  1312. * @brief Encodes @ref sd_ble_gap_whitelist_set command request.
  1313. *
  1314. * @sa @ref ble_gap_whitelist_set_rsp_dec for command response decoder.
  1315. *
  1316. * @param[in] pp_wl_addrs Pointer to a whitelist of peer addresses.
  1317. * @param[out] len Pointer to a length of the whitelist.
  1318. * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned.
  1319. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  1320. * \c out: Length of encoded command packet.
  1321. *
  1322. * @retval NRF_SUCCESS Encoding success.
  1323. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1324. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1325. */
  1326. uint32_t ble_gap_whitelist_set_req_enc(ble_gap_addr_t const * const * const pp_wl_addrs,
  1327. uint8_t const len,
  1328. uint8_t * const p_buf,
  1329. uint32_t * const p_buf_len);
  1330. /**
  1331. * @brief Decodes response to @ref sd_ble_gap_whitelist_set command.
  1332. *
  1333. * @sa @ref ble_gap_whitelist_set_req_enc for command request encoder.
  1334. *
  1335. * @param[in] p_buf Pointer to beginning of command response packet.
  1336. * @param[in] packet_len Length (in bytes) of response packet.
  1337. * @param[out] p_result_code Command result code.
  1338. *
  1339. * @retval NRF_SUCCESS Decoding success.
  1340. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1341. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  1342. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  1343. * expected operation code.
  1344. */
  1345. uint32_t ble_gap_whitelist_set_rsp_dec(uint8_t const * const p_buf,
  1346. uint32_t packet_len,
  1347. uint32_t * const p_result_code);
  1348. /**
  1349. * @brief Encodes @ref sd_ble_gap_device_identities_set command request.
  1350. *
  1351. * @sa @ref ble_gap_device_identities_set_rsp_dec for command response decoder.
  1352. *
  1353. * @param[in] pp_id_keys Pointer to an array of peer identity addresses and peer IRKs.
  1354. * @param[in] pp_local_irks Pointer to an array of local IRKs.
  1355. * @param[out] len Pointer to a length of the device identity list.
  1356. * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned.
  1357. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  1358. * \c out: Length of encoded command packet.
  1359. *
  1360. * @retval NRF_SUCCESS Encoding success.
  1361. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1362. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1363. */
  1364. uint32_t ble_gap_device_identities_set_req_enc(ble_gap_id_key_t const * const * const pp_id_keys,
  1365. ble_gap_irk_t const * const * const pp_local_irks,
  1366. uint8_t const len,
  1367. uint8_t * const p_buf,
  1368. uint32_t * const p_buf_len);
  1369. /**
  1370. * @brief Decodes response to @ref sd_ble_gap_device_identities_set command.
  1371. *
  1372. * @sa @ref ble_gap_device_identities_set_req_enc for command request encoder.
  1373. *
  1374. * @param[in] p_buf Pointer to beginning of command response packet.
  1375. * @param[in] packet_len Length (in bytes) of response packet.
  1376. * @param[out] p_result_code Command result code.
  1377. *
  1378. * @retval NRF_SUCCESS Decoding success.
  1379. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1380. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  1381. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  1382. * expected operation code.
  1383. */
  1384. uint32_t ble_gap_device_identities_set_rsp_dec(uint8_t const * const p_buf,
  1385. uint32_t packet_len,
  1386. uint32_t * const p_result_code);
  1387. #if NRF_SD_BLE_API_VERSION >= 4 && !defined(S112)
  1388. /**
  1389. * @brief Encodes @ref sd_ble_gap_data_length_update command request.
  1390. *
  1391. * @sa @ref ble_gap_data_length_update_rsp_dec for command response decoder.
  1392. *
  1393. * @param[in] conn_handle Connection handle.
  1394. * @param[in] p_dl_params Pointer to a data length params structure.
  1395. * @param[out] p_dl_limitation Pointer to a data length limitation structure.
  1396. * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned.
  1397. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  1398. * \c out: Length of encoded command packet.
  1399. *
  1400. * @retval NRF_SUCCESS Encoding success.
  1401. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1402. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1403. */
  1404. uint32_t ble_gap_data_length_update_req_enc(uint16_t conn_handle,
  1405. ble_gap_data_length_params_t const * p_dl_params,
  1406. ble_gap_data_length_limitation_t * p_dl_limitation,
  1407. uint8_t * const p_buf,
  1408. uint32_t * const p_buf_len);
  1409. /**
  1410. * @brief Decodes response to @ref sd_ble_gap_data_length_update command.
  1411. *
  1412. * @sa @ref ble_gap_data_length_update_req_enc for command request encoder.
  1413. *
  1414. * @param[in] p_buf Pointer to beginning of command response packet.
  1415. * @param[in] packet_len Length (in bytes) of response packet.
  1416. * @param[out] p_dl_limitation Pointer to a data length limitation structure.
  1417. * @param[out] p_result_code Command result code.
  1418. *
  1419. * @retval NRF_SUCCESS Decoding success.
  1420. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1421. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  1422. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  1423. * expected operation code.
  1424. */
  1425. uint32_t ble_gap_data_length_update_rsp_dec(uint8_t const * const p_buf,
  1426. uint32_t packet_len,
  1427. ble_gap_data_length_limitation_t * p_dl_limitation,
  1428. uint32_t * const p_result_code);
  1429. #endif
  1430. #if NRF_SD_BLE_API_VERSION >= 5
  1431. /**@brief Encodes @ref sd_ble_gap_phy_update command request.
  1432. *
  1433. * @sa @ref ble_gap_phy_update_rsp_dec for command response decoder.
  1434. *
  1435. * @param[in] conn_handle Connection handle of the connection.
  1436. * @param[in] p_gap_phys Pointer to a @ref ble_gap_phys_t
  1437. * structure.
  1438. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  1439. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  1440. * \c out: Length of encoded command packet.
  1441. *
  1442. * @retval NRF_SUCCESS Encoding success.
  1443. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1444. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1445. */
  1446. uint32_t ble_gap_phy_update_req_enc(uint16_t conn_handle,
  1447. ble_gap_phys_t const * p_gap_phys,
  1448. uint8_t * const p_buf,
  1449. uint32_t * const p_buf_len);
  1450. /**@brief Decodes response to @ref sd_ble_gap_phy_update command.
  1451. *
  1452. * @sa @ref ble_gap_phy_update_req_enc for command request encoder.
  1453. *
  1454. * @param[in] p_buf Pointer to beginning of command response packet.
  1455. * @param[in] packet_len Length (in bytes) of response packet.
  1456. * @param[out] p_result_code Command response result code.
  1457. *
  1458. * @retval NRF_SUCCESS Decoding success.
  1459. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1460. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  1461. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  1462. * operation code.
  1463. */
  1464. uint32_t ble_gap_phy_update_rsp_dec(uint8_t const * const p_buf,
  1465. uint32_t packet_len,
  1466. uint32_t * const p_result_code);
  1467. #endif
  1468. #if NRF_SD_BLE_API_VERSION >= 6
  1469. /**@brief Encodes @ref sd_ble_gap_adv_set_configure command request.
  1470. *
  1471. * @sa @ref ble_gap_adv_set_configure_rsp_dec for command response decoder.
  1472. *
  1473. * @param[in] p_adv_handle Advertising handle.
  1474. * @param[in] p_adv_data Pointer to a @ref ble_gap_adv_data_t structure.
  1475. * @param[in] p_adv_params Pointer to a @ref ble_gap_adv_params_t structure.
  1476. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  1477. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  1478. * \c out: Length of encoded command packet.
  1479. *
  1480. * @retval NRF_SUCCESS Encoding success.
  1481. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1482. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1483. */
  1484. uint32_t ble_gap_adv_set_configure_req_enc(uint8_t * p_adv_handle,
  1485. ble_gap_adv_data_t const * p_adv_data,
  1486. ble_gap_adv_params_t const *p_adv_params,
  1487. uint8_t * const p_buf,
  1488. uint32_t * const p_buf_len);
  1489. /**@brief Decodes response to @ref sd_ble_gap_adv_set_configure command.
  1490. *
  1491. * @sa @ref ble_gap_adv_set_configure_req_enc for command request encoder.
  1492. *
  1493. * @param[in] p_buf Pointer to beginning of command response packet.
  1494. * @param[in] packet_len Length (in bytes) of response packet.
  1495. * @param[out] p_adv_handle Advertising handle.
  1496. * @param[out] p_result_code Command response result code.
  1497. *
  1498. * @retval NRF_SUCCESS Decoding success.
  1499. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1500. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  1501. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  1502. * operation code.
  1503. */
  1504. uint32_t ble_gap_adv_set_configure_rsp_dec(uint8_t const * const p_buf,
  1505. uint32_t packet_len,
  1506. uint8_t * p_adv_handle,
  1507. uint32_t * const p_result_code);
  1508. /**@brief Encodes @ref sd_ble_gap_qos_channel_survey_start command request.
  1509. *
  1510. * @sa @ref ble_gap_qos_channel_survey_start_rsp_dec for command response decoder.
  1511. *
  1512. * @param[in] interval_us Interval.
  1513. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  1514. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  1515. * \c out: Length of encoded command packet.
  1516. *
  1517. * @retval NRF_SUCCESS Encoding success.
  1518. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1519. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1520. */
  1521. uint32_t ble_gap_qos_channel_survey_start_req_enc(uint32_t interval_us,
  1522. uint8_t * const p_buf,
  1523. uint32_t * const p_buf_len);
  1524. /**@brief Decodes response to @ref sd_ble_gap_qos_channel_survey_start command.
  1525. *
  1526. * @sa @ref ble_gap_qos_channel_survey_start_req_enc for command request encoder.
  1527. *
  1528. * @param[in] p_buf Pointer to beginning of command response packet.
  1529. * @param[in] packet_len Length (in bytes) of response packet.
  1530. * @param[out] p_result_code Command response result code.
  1531. *
  1532. * @retval NRF_SUCCESS Decoding success.
  1533. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1534. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  1535. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  1536. * operation code.
  1537. */
  1538. uint32_t ble_gap_qos_channel_survey_start_rsp_dec(uint8_t const * const p_buf,
  1539. uint32_t packet_len,
  1540. uint32_t * const p_result_code);
  1541. /**@brief Encodes @ref sd_ble_gap_qos_channel_survey_stop command request.
  1542. *
  1543. * @sa @ref ble_gap_qos_channel_survey_stop_rsp_dec for command response decoder.
  1544. *
  1545. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  1546. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  1547. * \c out: Length of encoded command packet.
  1548. *
  1549. * @retval NRF_SUCCESS Encoding success.
  1550. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  1551. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  1552. */
  1553. uint32_t ble_gap_qos_channel_survey_stop_req_enc(uint8_t * const p_buf,
  1554. uint32_t * const p_buf_len);
  1555. /**@brief Decodes response to @ref sd_ble_gap_qos_channel_survey_stop command.
  1556. *
  1557. * @sa @ref ble_gap_qos_channel_survey_stop_req_enc for command request encoder.
  1558. *
  1559. * @param[in] p_buf Pointer to beginning of command response packet.
  1560. * @param[in] packet_len Length (in bytes) of response packet.
  1561. * @param[out] p_result_code Command response result code.
  1562. *
  1563. * @retval NRF_SUCCESS Decoding success.
  1564. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  1565. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Incorrect buffer length.
  1566. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected
  1567. * operation code.
  1568. */
  1569. uint32_t ble_gap_qos_channel_survey_stop_rsp_dec(uint8_t const * const p_buf,
  1570. uint32_t packet_len,
  1571. uint32_t * const p_result_code);
  1572. #endif
  1573. /** @} */
  1574. #ifdef __cplusplus
  1575. }
  1576. #endif
  1577. #endif