cfg_cli.h 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178
  1. /** @file
  2. * @brief Configuration Client Model APIs.
  3. */
  4. /*
  5. * Copyright (c) 2017 Intel Corporation
  6. *
  7. * SPDX-License-Identifier: Apache-2.0
  8. */
  9. #ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_CLI_H_
  10. #define ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_CLI_H_
  11. /**
  12. * @brief Configuration Client Model
  13. * @defgroup bt_mesh_cfg_cli Configuration Client Model
  14. * @ingroup bt_mesh
  15. * @{
  16. */
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /** Mesh Configuration Client Model Context */
  21. struct bt_mesh_cfg_cli {
  22. /** Composition data model entry pointer. */
  23. struct bt_mesh_model *model;
  24. /* Internal parameters for tracking message responses. */
  25. struct bt_mesh_msg_ack_ctx ack_ctx;
  26. };
  27. /** @def BT_MESH_MODEL_CFG_CLI
  28. *
  29. * @brief Generic Configuration Client model composition data entry.
  30. *
  31. * @param cli_data Pointer to a @ref bt_mesh_cfg_cli instance.
  32. */
  33. #define BT_MESH_MODEL_CFG_CLI(cli_data) \
  34. BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_op, NULL, \
  35. cli_data, &bt_mesh_cfg_cli_cb)
  36. /** @brief Reset the target node and remove it from the network.
  37. *
  38. * @param net_idx Network index to encrypt with.
  39. * @param addr Target node address.
  40. * @param status Status response parameter
  41. *
  42. * @return 0 on success, or (negative) error code on failure.
  43. */
  44. int bt_mesh_cfg_node_reset(uint16_t net_idx, uint16_t addr, bool *status);
  45. /** @brief Get the target node's composition data.
  46. *
  47. * If the other device does not have the given composition data page, it will
  48. * return the largest page number it supports that is less than the requested
  49. * page index. The actual page the device responds with is returned in @c rsp.
  50. *
  51. * @param net_idx Network index to encrypt with.
  52. * @param addr Target node address.
  53. * @param page Composition data page, or 0xff to request the first available
  54. * page.
  55. * @param rsp Return parameter for the returned page number, or NULL.
  56. * @param comp Composition data buffer to fill.
  57. *
  58. * @return 0 on success, or (negative) error code on failure.
  59. */
  60. int bt_mesh_cfg_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page,
  61. uint8_t *rsp, struct net_buf_simple *comp);
  62. /** @brief Get the target node's network beacon state.
  63. *
  64. * @param net_idx Network index to encrypt with.
  65. * @param addr Target node address.
  66. * @param status Status response parameter, returns one of
  67. * @ref BT_MESH_BEACON_DISABLED or @ref BT_MESH_BEACON_ENABLED
  68. * on success.
  69. *
  70. * @return 0 on success, or (negative) error code on failure.
  71. */
  72. int bt_mesh_cfg_beacon_get(uint16_t net_idx, uint16_t addr, uint8_t *status);
  73. /** @brief Get the target node's network key refresh phase state.
  74. * @param net_idx Network index to encrypt with.
  75. * @param addr Target node address.
  76. * @param key_net_idx Network key index.
  77. * @param status Status response parameter.
  78. * @param phase Pointer to the Key Refresh variable to fill.
  79. *
  80. * @return 0 on success, or (negative) error code on failure.
  81. */
  82. int bt_mesh_cfg_krp_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
  83. uint8_t *status, uint8_t *phase);
  84. /** @brief Set the target node's network key refresh phase parameters.
  85. * @param net_idx Network index to encrypt with.
  86. * @param addr Target node address.
  87. * @param key_net_idx Network key index.
  88. * @param transition Transition parameter.
  89. * @param status Status response parameter.
  90. * @param phase Pointer to the new Key Refresh phase. Will return the actual
  91. * Key Refresh phase after updating.
  92. *
  93. * @return 0 on success, or (negative) error code on failure.
  94. */
  95. int bt_mesh_cfg_krp_set(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
  96. uint8_t transition, uint8_t *status, uint8_t *phase);
  97. /** @brief Set the target node's network beacon state.
  98. *
  99. * @param net_idx Network index to encrypt with.
  100. * @param addr Target node address.
  101. * @param val New network beacon state, should be one of
  102. * @ref BT_MESH_BEACON_DISABLED or @ref BT_MESH_BEACON_ENABLED.
  103. * @param status Status response parameter. Returns one of
  104. * @ref BT_MESH_BEACON_DISABLED or @ref BT_MESH_BEACON_ENABLED
  105. * on success.
  106. *
  107. * @return 0 on success, or (negative) error code on failure.
  108. */
  109. int bt_mesh_cfg_beacon_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status);
  110. /** @brief Get the target node's Time To Live value.
  111. *
  112. * @param net_idx Network index to encrypt with.
  113. * @param addr Target node address.
  114. * @param ttl TTL response buffer.
  115. *
  116. * @return 0 on success, or (negative) error code on failure.
  117. */
  118. int bt_mesh_cfg_ttl_get(uint16_t net_idx, uint16_t addr, uint8_t *ttl);
  119. /** @brief Set the target node's Time To Live value.
  120. *
  121. * @param net_idx Network index to encrypt with.
  122. * @param addr Target node address.
  123. * @param val New Time To Live value.
  124. * @param ttl TTL response buffer.
  125. *
  126. * @return 0 on success, or (negative) error code on failure.
  127. */
  128. int bt_mesh_cfg_ttl_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *ttl);
  129. /** @brief Get the target node's Friend feature status.
  130. *
  131. * @param net_idx Network index to encrypt with.
  132. * @param addr Target node address.
  133. * @param status Status response parameter. Returns one of
  134. * @ref BT_MESH_FRIEND_DISABLED, @ref BT_MESH_FRIEND_ENABLED or
  135. * @ref BT_MESH_FRIEND_NOT_SUPPORTED on success.
  136. *
  137. * @return 0 on success, or (negative) error code on failure.
  138. */
  139. int bt_mesh_cfg_friend_get(uint16_t net_idx, uint16_t addr, uint8_t *status);
  140. /** @brief Set the target node's Friend feature state.
  141. *
  142. * @param net_idx Network index to encrypt with.
  143. * @param addr Target node address.
  144. * @param val New Friend feature state. Should be one of
  145. * @ref BT_MESH_FRIEND_DISABLED or
  146. * @ref BT_MESH_FRIEND_ENABLED.
  147. * @param status Status response parameter. Returns one of
  148. * @ref BT_MESH_FRIEND_DISABLED, @ref BT_MESH_FRIEND_ENABLED or
  149. * @ref BT_MESH_FRIEND_NOT_SUPPORTED on success.
  150. *
  151. * @return 0 on success, or (negative) error code on failure.
  152. */
  153. int bt_mesh_cfg_friend_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status);
  154. /** @brief Get the target node's Proxy feature state.
  155. *
  156. * @param net_idx Network index to encrypt with.
  157. * @param addr Target node address.
  158. * @param status Status response parameter. Returns one of
  159. * @ref BT_MESH_GATT_PROXY_DISABLED,
  160. * @ref BT_MESH_GATT_PROXY_ENABLED or
  161. * @ref BT_MESH_GATT_PROXY_NOT_SUPPORTED on success.
  162. *
  163. * @return 0 on success, or (negative) error code on failure.
  164. */
  165. int bt_mesh_cfg_gatt_proxy_get(uint16_t net_idx, uint16_t addr, uint8_t *status);
  166. /** @brief Set the target node's Proxy feature state.
  167. *
  168. * @param net_idx Network index to encrypt with.
  169. * @param addr Target node address.
  170. * @param val New Proxy feature state. Must be one of
  171. * @ref BT_MESH_GATT_PROXY_DISABLED or
  172. * @ref BT_MESH_GATT_PROXY_ENABLED.
  173. * @param status Status response parameter. Returns one of
  174. * @ref BT_MESH_GATT_PROXY_DISABLED,
  175. * @ref BT_MESH_GATT_PROXY_ENABLED or
  176. * @ref BT_MESH_GATT_PROXY_NOT_SUPPORTED on success.
  177. *
  178. * @return 0 on success, or (negative) error code on failure.
  179. */
  180. int bt_mesh_cfg_gatt_proxy_set(uint16_t net_idx, uint16_t addr, uint8_t val,
  181. uint8_t *status);
  182. /** @brief Get the target node's network_transmit state.
  183. *
  184. * @param net_idx Network index to encrypt with.
  185. * @param addr Target node address.
  186. * @param transmit Network transmit response parameter. Returns the encoded
  187. * network transmission parameters on success. Decoded with
  188. * @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT.
  189. *
  190. * @return 0 on success, or (negative) error code on failure.
  191. */
  192. int bt_mesh_cfg_net_transmit_get(uint16_t net_idx, uint16_t addr,
  193. uint8_t *transmit);
  194. /** @brief Set the target node's network transmit parameters.
  195. *
  196. * @param net_idx Network index to encrypt with.
  197. * @param addr Target node address.
  198. * @param val New encoded network transmit parameters.
  199. * @see BT_MESH_TRANSMIT.
  200. * @param transmit Network transmit response parameter. Returns the encoded
  201. * network transmission parameters on success. Decoded with
  202. * @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT.
  203. * @return 0 on success, or (negative) error code on failure.
  204. */
  205. int bt_mesh_cfg_net_transmit_set(uint16_t net_idx, uint16_t addr,
  206. uint8_t val, uint8_t *transmit);
  207. /** @brief Get the target node's Relay feature state.
  208. *
  209. * @param net_idx Network index to encrypt with.
  210. * @param addr Target node address.
  211. * @param status Status response parameter. Returns one of
  212. * @ref BT_MESH_RELAY_DISABLED, @ref BT_MESH_RELAY_ENABLED or
  213. * @ref BT_MESH_RELAY_NOT_SUPPORTED on success.
  214. * @param transmit Transmit response parameter. Returns the encoded relay
  215. * transmission parameters on success. Decoded with
  216. * @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT.
  217. *
  218. * @return 0 on success, or (negative) error code on failure.
  219. */
  220. int bt_mesh_cfg_relay_get(uint16_t net_idx, uint16_t addr, uint8_t *status,
  221. uint8_t *transmit);
  222. /** @brief Set the target node's Relay parameters.
  223. *
  224. * @param net_idx Network index to encrypt with.
  225. * @param addr Target node address.
  226. * @param new_relay New relay state. Must be one of
  227. * @ref BT_MESH_RELAY_DISABLED or
  228. * @ref BT_MESH_RELAY_ENABLED.
  229. * @param new_transmit New encoded relay transmit parameters.
  230. * @see BT_MESH_TRANSMIT.
  231. * @param status Status response parameter. Returns one of
  232. * @ref BT_MESH_RELAY_DISABLED, @ref BT_MESH_RELAY_ENABLED
  233. * or @ref BT_MESH_RELAY_NOT_SUPPORTED on success.
  234. * @param transmit Transmit response parameter. Returns the encoded relay
  235. * transmission parameters on success. Decoded with
  236. * @ref BT_MESH_TRANSMIT_COUNT and
  237. * @ref BT_MESH_TRANSMIT_INT.
  238. *
  239. * @return 0 on success, or (negative) error code on failure.
  240. */
  241. int bt_mesh_cfg_relay_set(uint16_t net_idx, uint16_t addr, uint8_t new_relay,
  242. uint8_t new_transmit, uint8_t *status, uint8_t *transmit);
  243. /** @brief Add a network key to the target node.
  244. *
  245. * @param net_idx Network index to encrypt with.
  246. * @param addr Target node address.
  247. * @param key_net_idx Network key index.
  248. * @param net_key Network key.
  249. * @param status Status response parameter.
  250. *
  251. * @return 0 on success, or (negative) error code on failure.
  252. */
  253. int bt_mesh_cfg_net_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
  254. const uint8_t net_key[16], uint8_t *status);
  255. /** @brief Get a list of the target node's network key indexes.
  256. *
  257. * @param net_idx Network index to encrypt with.
  258. * @param addr Target node address.
  259. * @param keys Net key index list response parameter. Will be filled with
  260. * all the returned network key indexes it can fill.
  261. * @param key_cnt Net key index list length. Should be set to the
  262. * capacity of the @c keys list when calling. Will return the
  263. * number of returned network key indexes upon success.
  264. *
  265. * @return 0 on success, or (negative) error code on failure.
  266. */
  267. int bt_mesh_cfg_net_key_get(uint16_t net_idx, uint16_t addr, uint16_t *keys,
  268. size_t *key_cnt);
  269. /** @brief Delete a network key from the target node.
  270. *
  271. * @param net_idx Network index to encrypt with.
  272. * @param addr Target node address.
  273. * @param key_net_idx Network key index.
  274. * @param status Status response parameter.
  275. *
  276. * @return 0 on success, or (negative) error code on failure.
  277. */
  278. int bt_mesh_cfg_net_key_del(uint16_t net_idx, uint16_t addr,
  279. uint16_t key_net_idx, uint8_t *status);
  280. /** @brief Add an application key to the target node.
  281. *
  282. * @param net_idx Network index to encrypt with.
  283. * @param addr Target node address.
  284. * @param key_net_idx Network key index the application key belongs to.
  285. * @param key_app_idx Application key index.
  286. * @param app_key Application key.
  287. * @param status Status response parameter.
  288. *
  289. * @return 0 on success, or (negative) error code on failure.
  290. */
  291. int bt_mesh_cfg_app_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
  292. uint16_t key_app_idx, const uint8_t app_key[16],
  293. uint8_t *status);
  294. /** @brief Get a list of the target node's application key indexes for a
  295. * specific network key.
  296. *
  297. * @param net_idx Network index to encrypt with.
  298. * @param addr Target node address.
  299. * @param key_net_idx Network key index to request the app key indexes of.
  300. * @param status Status response parameter.
  301. * @param keys App key index list response parameter. Will be filled
  302. * with all the returned application key indexes it can
  303. * fill.
  304. * @param key_cnt App key index list length. Should be set to the
  305. * capacity of the @c keys list when calling. Will return
  306. * the number of returned application key indexes upon
  307. * success.
  308. *
  309. * @return 0 on success, or (negative) error code on failure.
  310. */
  311. int bt_mesh_cfg_app_key_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx,
  312. uint8_t *status, uint16_t *keys, size_t *key_cnt);
  313. /** @brief Delete an application key from the target node.
  314. *
  315. * @param net_idx Network index to encrypt with.
  316. * @param addr Target node address.
  317. * @param key_net_idx Network key index the application key belongs to.
  318. * @param key_app_idx Application key index.
  319. * @param status Status response parameter.
  320. *
  321. * @return 0 on success, or (negative) error code on failure.
  322. */
  323. int bt_mesh_cfg_app_key_del(uint16_t net_idx, uint16_t addr,
  324. uint16_t key_net_idx, uint16_t key_app_idx, uint8_t *status);
  325. /** @brief Bind an application to a SIG model on the target node.
  326. *
  327. * @param net_idx Network index to encrypt with.
  328. * @param addr Target node address.
  329. * @param elem_addr Element address the model is in.
  330. * @param mod_app_idx Application index to bind.
  331. * @param mod_id Model ID.
  332. * @param status Status response parameter.
  333. *
  334. * @return 0 on success, or (negative) error code on failure.
  335. */
  336. int bt_mesh_cfg_mod_app_bind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  337. uint16_t mod_app_idx, uint16_t mod_id, uint8_t *status);
  338. /** @brief Unbind an application from a SIG model on the target node.
  339. *
  340. * @param net_idx Network index to encrypt with.
  341. * @param addr Target node address.
  342. * @param elem_addr Element address the model is in.
  343. * @param mod_app_idx Application index to unbind.
  344. * @param mod_id Model ID.
  345. * @param status Status response parameter.
  346. *
  347. * @return 0 on success, or (negative) error code on failure.
  348. */
  349. int bt_mesh_cfg_mod_app_unbind(uint16_t net_idx, uint16_t addr,
  350. uint16_t elem_addr, uint16_t mod_app_idx,
  351. uint16_t mod_id, uint8_t *status);
  352. /** @brief Bind an application to a vendor model on the target node.
  353. *
  354. * @param net_idx Network index to encrypt with.
  355. * @param addr Target node address.
  356. * @param elem_addr Element address the model is in.
  357. * @param mod_app_idx Application index to bind.
  358. * @param mod_id Model ID.
  359. * @param cid Company ID of the model.
  360. * @param status Status response parameter.
  361. *
  362. * @return 0 on success, or (negative) error code on failure.
  363. */
  364. int bt_mesh_cfg_mod_app_bind_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  365. uint16_t mod_app_idx, uint16_t mod_id, uint16_t cid,
  366. uint8_t *status);
  367. /** @brief Unbind an application from a vendor model on the target node.
  368. *
  369. * @param net_idx Network index to encrypt with.
  370. * @param addr Target node address.
  371. * @param elem_addr Element address the model is in.
  372. * @param mod_app_idx Application index to unbind.
  373. * @param mod_id Model ID.
  374. * @param cid Company ID of the model.
  375. * @param status Status response parameter.
  376. *
  377. * @return 0 on success, or (negative) error code on failure.
  378. */
  379. int bt_mesh_cfg_mod_app_unbind_vnd(uint16_t net_idx, uint16_t addr,
  380. uint16_t elem_addr, uint16_t mod_app_idx, uint16_t mod_id,
  381. uint16_t cid, uint8_t *status);
  382. /** @brief Get a list of all applications bound to a SIG model on the target
  383. * node.
  384. *
  385. * @param net_idx Network index to encrypt with.
  386. * @param addr Target node address.
  387. * @param elem_addr Element address the model is in.
  388. * @param mod_id Model ID.
  389. * @param status Status response parameter.
  390. * @param apps App index list response parameter. Will be filled with all
  391. * the returned application key indexes it can fill.
  392. * @param app_cnt App index list length. Should be set to the capacity of the
  393. * @c apps list when calling. Will return the number of
  394. * returned application key indexes upon success.
  395. *
  396. * @return 0 on success, or (negative) error code on failure.
  397. */
  398. int bt_mesh_cfg_mod_app_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  399. uint16_t mod_id, uint8_t *status, uint16_t *apps,
  400. size_t *app_cnt);
  401. /** @brief Get a list of all applications bound to a vendor model on the target
  402. * node.
  403. *
  404. * @param net_idx Network index to encrypt with.
  405. * @param addr Target node address.
  406. * @param elem_addr Element address the model is in.
  407. * @param mod_id Model ID.
  408. * @param cid Company ID of the model.
  409. * @param status Status response parameter.
  410. * @param apps App index list response parameter. Will be filled with all
  411. * the returned application key indexes it can fill.
  412. * @param app_cnt App index list length. Should be set to the capacity of the
  413. * @c apps list when calling. Will return the number of
  414. * returned application key indexes upon success.
  415. *
  416. * @return 0 on success, or (negative) error code on failure.
  417. */
  418. int bt_mesh_cfg_mod_app_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  419. uint16_t mod_id, uint16_t cid, uint8_t *status,
  420. uint16_t *apps, size_t *app_cnt);
  421. /** @def BT_MESH_PUB_PERIOD_100MS
  422. *
  423. * @brief Helper macro to encode model publication period in units of 100ms
  424. *
  425. * @param steps Number of 100ms steps.
  426. *
  427. * @return Encoded value that can be assigned to bt_mesh_cfg_mod_pub.period
  428. */
  429. #define BT_MESH_PUB_PERIOD_100MS(steps) ((steps) & BIT_MASK(6))
  430. /** @def BT_MESH_PUB_PERIOD_SEC
  431. *
  432. * @brief Helper macro to encode model publication period in units of 1 second
  433. *
  434. * @param steps Number of 1 second steps.
  435. *
  436. * @return Encoded value that can be assigned to bt_mesh_cfg_mod_pub.period
  437. */
  438. #define BT_MESH_PUB_PERIOD_SEC(steps) (((steps) & BIT_MASK(6)) | (1 << 6))
  439. /** @def BT_MESH_PUB_PERIOD_10SEC
  440. *
  441. * @brief Helper macro to encode model publication period in units of 10
  442. * seconds
  443. *
  444. * @param steps Number of 10 second steps.
  445. *
  446. * @return Encoded value that can be assigned to bt_mesh_cfg_mod_pub.period
  447. */
  448. #define BT_MESH_PUB_PERIOD_10SEC(steps) (((steps) & BIT_MASK(6)) | (2 << 6))
  449. /** @def BT_MESH_PUB_PERIOD_10MIN
  450. *
  451. * @brief Helper macro to encode model publication period in units of 10
  452. * minutes
  453. *
  454. * @param steps Number of 10 minute steps.
  455. *
  456. * @return Encoded value that can be assigned to bt_mesh_cfg_mod_pub.period
  457. */
  458. #define BT_MESH_PUB_PERIOD_10MIN(steps) (((steps) & BIT_MASK(6)) | (3 << 6))
  459. /** Model publication configuration parameters. */
  460. struct bt_mesh_cfg_mod_pub {
  461. /** Publication destination address. */
  462. uint16_t addr;
  463. /** Virtual address UUID, or NULL if this is not a virtual address. */
  464. const uint8_t *uuid;
  465. /** Application index to publish with. */
  466. uint16_t app_idx;
  467. /** Friendship credential flag. */
  468. bool cred_flag;
  469. /** Time To Live to publish with. */
  470. uint8_t ttl;
  471. /**
  472. * Encoded publish period.
  473. * @see BT_MESH_PUB_PERIOD_100MS, BT_MESH_PUB_PERIOD_SEC,
  474. * BT_MESH_PUB_PERIOD_10SEC,
  475. * BT_MESH_PUB_PERIOD_10MIN
  476. */
  477. uint8_t period;
  478. /**
  479. * Encoded transmit parameters.
  480. * @see BT_MESH_TRANSMIT
  481. */
  482. uint8_t transmit;
  483. };
  484. /** @brief Get publish parameters for a SIG model on the target node.
  485. *
  486. * @param net_idx Network index to encrypt with.
  487. * @param addr Target node address.
  488. * @param elem_addr Element address the model is in.
  489. * @param mod_id Model ID.
  490. * @param pub Publication parameter return buffer.
  491. * @param status Status response parameter.
  492. *
  493. * @return 0 on success, or (negative) error code on failure.
  494. */
  495. int bt_mesh_cfg_mod_pub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  496. uint16_t mod_id, struct bt_mesh_cfg_mod_pub *pub,
  497. uint8_t *status);
  498. /** @brief Get publish parameters for a vendor model on the target node.
  499. *
  500. * @param net_idx Network index to encrypt with.
  501. * @param addr Target node address.
  502. * @param elem_addr Element address the model is in.
  503. * @param mod_id Model ID.
  504. * @param cid Company ID of the model.
  505. * @param pub Publication parameter return buffer.
  506. * @param status Status response parameter.
  507. *
  508. * @return 0 on success, or (negative) error code on failure.
  509. */
  510. int bt_mesh_cfg_mod_pub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  511. uint16_t mod_id, uint16_t cid,
  512. struct bt_mesh_cfg_mod_pub *pub, uint8_t *status);
  513. /** @brief Set publish parameters for a SIG model on the target node.
  514. *
  515. * @param net_idx Network index to encrypt with.
  516. * @param addr Target node address.
  517. * @param elem_addr Element address the model is in.
  518. * @param mod_id Model ID.
  519. * @param pub Publication parameters.
  520. * @param status Status response parameter.
  521. *
  522. * @return 0 on success, or (negative) error code on failure.
  523. */
  524. int bt_mesh_cfg_mod_pub_set(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  525. uint16_t mod_id, struct bt_mesh_cfg_mod_pub *pub,
  526. uint8_t *status);
  527. /** @brief Set publish parameters for a vendor model on the target node.
  528. *
  529. * @param net_idx Network index to encrypt with.
  530. * @param addr Target node address.
  531. * @param elem_addr Element address the model is in.
  532. * @param mod_id Model ID.
  533. * @param cid Company ID of the model.
  534. * @param pub Publication parameters.
  535. * @param status Status response parameter.
  536. *
  537. * @return 0 on success, or (negative) error code on failure.
  538. */
  539. int bt_mesh_cfg_mod_pub_set_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  540. uint16_t mod_id, uint16_t cid,
  541. struct bt_mesh_cfg_mod_pub *pub, uint8_t *status);
  542. /** @brief Add a group address to a SIG model's subscription list.
  543. *
  544. * @param net_idx Network index to encrypt with.
  545. * @param addr Target node address.
  546. * @param elem_addr Element address the model is in.
  547. * @param sub_addr Group address to add to the subscription list.
  548. * @param mod_id Model ID.
  549. * @param status Status response parameter.
  550. *
  551. * @return 0 on success, or (negative) error code on failure.
  552. */
  553. int bt_mesh_cfg_mod_sub_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  554. uint16_t sub_addr, uint16_t mod_id, uint8_t *status);
  555. /** @brief Add a group address to a vendor model's subscription list.
  556. *
  557. * @param net_idx Network index to encrypt with.
  558. * @param addr Target node address.
  559. * @param elem_addr Element address the model is in.
  560. * @param sub_addr Group address to add to the subscription list.
  561. * @param mod_id Model ID.
  562. * @param cid Company ID of the model.
  563. * @param status Status response parameter.
  564. *
  565. * @return 0 on success, or (negative) error code on failure.
  566. */
  567. int bt_mesh_cfg_mod_sub_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  568. uint16_t sub_addr, uint16_t mod_id, uint16_t cid,
  569. uint8_t *status);
  570. /** @brief Delete a group address in a SIG model's subscription list.
  571. *
  572. * @param net_idx Network index to encrypt with.
  573. * @param addr Target node address.
  574. * @param elem_addr Element address the model is in.
  575. * @param sub_addr Group address to add to the subscription list.
  576. * @param mod_id Model ID.
  577. * @param status Status response parameter.
  578. *
  579. * @return 0 on success, or (negative) error code on failure.
  580. */
  581. int bt_mesh_cfg_mod_sub_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  582. uint16_t sub_addr, uint16_t mod_id, uint8_t *status);
  583. /** @brief Delete a group address in a vendor model's subscription list.
  584. *
  585. * @param net_idx Network index to encrypt with.
  586. * @param addr Target node address.
  587. * @param elem_addr Element address the model is in.
  588. * @param sub_addr Group address to add to the subscription list.
  589. * @param mod_id Model ID.
  590. * @param cid Company ID of the model.
  591. * @param status Status response parameter.
  592. *
  593. * @return 0 on success, or (negative) error code on failure.
  594. */
  595. int bt_mesh_cfg_mod_sub_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  596. uint16_t sub_addr, uint16_t mod_id, uint16_t cid,
  597. uint8_t *status);
  598. /** @brief Overwrite all addresses in a SIG model's subscription list with a
  599. * group address.
  600. *
  601. * Deletes all subscriptions in the model's subscription list, and adds a
  602. * single group address instead.
  603. *
  604. * @param net_idx Network index to encrypt with.
  605. * @param addr Target node address.
  606. * @param elem_addr Element address the model is in.
  607. * @param sub_addr Group address to add to the subscription list.
  608. * @param mod_id Model ID.
  609. * @param status Status response parameter.
  610. *
  611. * @return 0 on success, or (negative) error code on failure.
  612. */
  613. int bt_mesh_cfg_mod_sub_overwrite(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  614. uint16_t sub_addr, uint16_t mod_id, uint8_t *status);
  615. /** @brief Overwrite all addresses in a vendor model's subscription list with a
  616. * group address.
  617. *
  618. * Deletes all subscriptions in the model's subscription list, and adds a
  619. * single group address instead.
  620. *
  621. * @param net_idx Network index to encrypt with.
  622. * @param addr Target node address.
  623. * @param elem_addr Element address the model is in.
  624. * @param sub_addr Group address to add to the subscription list.
  625. * @param mod_id Model ID.
  626. * @param cid Company ID of the model.
  627. * @param status Status response parameter.
  628. *
  629. * @return 0 on success, or (negative) error code on failure.
  630. */
  631. int bt_mesh_cfg_mod_sub_overwrite_vnd(uint16_t net_idx, uint16_t addr,
  632. uint16_t elem_addr, uint16_t sub_addr,
  633. uint16_t mod_id, uint16_t cid, uint8_t *status);
  634. /** @brief Add a virtual address to a SIG model's subscription list.
  635. *
  636. * @param net_idx Network index to encrypt with.
  637. * @param addr Target node address.
  638. * @param elem_addr Element address the model is in.
  639. * @param label Virtual address label to add to the subscription list.
  640. * @param mod_id Model ID.
  641. * @param virt_addr Virtual address response parameter.
  642. * @param status Status response parameter.
  643. *
  644. * @return 0 on success, or (negative) error code on failure.
  645. */
  646. int bt_mesh_cfg_mod_sub_va_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  647. const uint8_t label[16], uint16_t mod_id,
  648. uint16_t *virt_addr, uint8_t *status);
  649. /** @brief Add a virtual address to a vendor model's subscription list.
  650. *
  651. * @param net_idx Network index to encrypt with.
  652. * @param addr Target node address.
  653. * @param elem_addr Element address the model is in.
  654. * @param label Virtual address label to add to the subscription list.
  655. * @param mod_id Model ID.
  656. * @param cid Company ID of the model.
  657. * @param virt_addr Virtual address response parameter.
  658. * @param status Status response parameter.
  659. *
  660. * @return 0 on success, or (negative) error code on failure.
  661. */
  662. int bt_mesh_cfg_mod_sub_va_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  663. const uint8_t label[16], uint16_t mod_id,
  664. uint16_t cid, uint16_t *virt_addr, uint8_t *status);
  665. /** @brief Delete a virtual address in a SIG model's subscription list.
  666. *
  667. * @param net_idx Network index to encrypt with.
  668. * @param addr Target node address.
  669. * @param elem_addr Element address the model is in.
  670. * @param label Virtual address parameter to add to the subscription list.
  671. * @param mod_id Model ID.
  672. * @param virt_addr Virtual address response parameter.
  673. * @param status Status response parameter.
  674. *
  675. * @return 0 on success, or (negative) error code on failure.
  676. */
  677. int bt_mesh_cfg_mod_sub_va_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  678. const uint8_t label[16], uint16_t mod_id,
  679. uint16_t *virt_addr, uint8_t *status);
  680. /** @brief Delete a virtual address in a vendor model's subscription list.
  681. *
  682. * @param net_idx Network index to encrypt with.
  683. * @param addr Target node address.
  684. * @param elem_addr Element address the model is in.
  685. * @param label Virtual address label to add to the subscription list.
  686. * @param mod_id Model ID.
  687. * @param cid Company ID of the model.
  688. * @param virt_addr Virtual address response parameter.
  689. * @param status Status response parameter.
  690. *
  691. * @return 0 on success, or (negative) error code on failure.
  692. */
  693. int bt_mesh_cfg_mod_sub_va_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  694. const uint8_t label[16], uint16_t mod_id,
  695. uint16_t cid, uint16_t *virt_addr, uint8_t *status);
  696. /** @brief Overwrite all addresses in a SIG model's subscription list with a
  697. * virtual address.
  698. *
  699. * Deletes all subscriptions in the model's subscription list, and adds a
  700. * single group address instead.
  701. *
  702. * @param net_idx Network index to encrypt with.
  703. * @param addr Target node address.
  704. * @param elem_addr Element address the model is in.
  705. * @param label Virtual address label to add to the subscription list.
  706. * @param mod_id Model ID.
  707. * @param virt_addr Virtual address response parameter.
  708. * @param status Status response parameter.
  709. *
  710. * @return 0 on success, or (negative) error code on failure.
  711. */
  712. int bt_mesh_cfg_mod_sub_va_overwrite(uint16_t net_idx, uint16_t addr,
  713. uint16_t elem_addr, const uint8_t label[16],
  714. uint16_t mod_id, uint16_t *virt_addr,
  715. uint8_t *status);
  716. /** @brief Overwrite all addresses in a vendor model's subscription list with a
  717. * virtual address.
  718. *
  719. * Deletes all subscriptions in the model's subscription list, and adds a
  720. * single group address instead.
  721. *
  722. * @param net_idx Network index to encrypt with.
  723. * @param addr Target node address.
  724. * @param elem_addr Element address the model is in.
  725. * @param label Virtual address label to add to the subscription list.
  726. * @param mod_id Model ID.
  727. * @param cid Company ID of the model.
  728. * @param virt_addr Virtual address response parameter.
  729. * @param status Status response parameter.
  730. *
  731. * @return 0 on success, or (negative) error code on failure.
  732. */
  733. int bt_mesh_cfg_mod_sub_va_overwrite_vnd(uint16_t net_idx, uint16_t addr,
  734. uint16_t elem_addr, const uint8_t label[16],
  735. uint16_t mod_id, uint16_t cid,
  736. uint16_t *virt_addr, uint8_t *status);
  737. /** @brief Get the subscription list of a SIG model on the target node.
  738. *
  739. * @param net_idx Network index to encrypt with.
  740. * @param addr Target node address.
  741. * @param elem_addr Element address the model is in.
  742. * @param mod_id Model ID.
  743. * @param status Status response parameter.
  744. * @param subs Subscription list response parameter. Will be filled with
  745. * all the returned subscriptions it can fill.
  746. * @param sub_cnt Subscription list element count. Should be set to the
  747. * capacity of the @c subs list when calling. Will return the
  748. * number of returned subscriptions upon success.
  749. *
  750. * @return 0 on success, or (negative) error code on failure.
  751. */
  752. int bt_mesh_cfg_mod_sub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  753. uint16_t mod_id, uint8_t *status, uint16_t *subs,
  754. size_t *sub_cnt);
  755. /** @brief Get the subscription list of a vendor model on the target node.
  756. *
  757. * @param net_idx Network index to encrypt with.
  758. * @param addr Target node address.
  759. * @param elem_addr Element address the model is in.
  760. * @param mod_id Model ID.
  761. * @param cid Company ID of the model.
  762. * @param status Status response parameter.
  763. * @param subs Subscription list response parameter. Will be filled with
  764. * all the returned subscriptions it can fill.
  765. * @param sub_cnt Subscription list element count. Should be set to the
  766. * capacity of the @c subs list when calling. Will return the
  767. * number of returned subscriptions upon success.
  768. *
  769. * @return 0 on success, or (negative) error code on failure.
  770. */
  771. int bt_mesh_cfg_mod_sub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
  772. uint16_t mod_id, uint16_t cid, uint8_t *status,
  773. uint16_t *subs, size_t *sub_cnt);
  774. /** Heartbeat subscription configuration parameters. */
  775. struct bt_mesh_cfg_hb_sub {
  776. /** Source address to receive Heartbeat messages from. */
  777. uint16_t src;
  778. /** Destination address to receive Heartbeat messages on. */
  779. uint16_t dst;
  780. /**
  781. * Logarithmic subscription period to keep listening for.
  782. * The decoded subscription period is (1 << (period - 1)) seconds, or 0
  783. * seconds if period is 0.
  784. */
  785. uint8_t period;
  786. /**
  787. * Logarithmic Heartbeat subscription receive count.
  788. * The decoded Heartbeat count is (1 << (count - 1)) if count is
  789. * between 1 and 0xfe, 0 if count is 0 and 0xffff if count is 0xff.
  790. *
  791. * Ignored in Heartbeat subscription set.
  792. */
  793. uint8_t count;
  794. /**
  795. * Minimum hops in received messages, ie the shortest registered path
  796. * from the publishing node to the subscribing node. A Heartbeat
  797. * received from an immediate neighbor has hop count = 1.
  798. *
  799. * Ignored in Heartbeat subscription set.
  800. */
  801. uint8_t min;
  802. /**
  803. * Maximum hops in received messages, ie the longest registered path
  804. * from the publishing node to the subscribing node. A Heartbeat
  805. * received from an immediate neighbor has hop count = 1.
  806. *
  807. * Ignored in Heartbeat subscription set.
  808. */
  809. uint8_t max;
  810. };
  811. /** @brief Set the target node's Heartbeat subscription parameters.
  812. *
  813. * @param net_idx Network index to encrypt with.
  814. * @param addr Target node address.
  815. * @param sub New Heartbeat subscription parameters.
  816. * @param status Status response parameter.
  817. *
  818. * @return 0 on success, or (negative) error code on failure.
  819. */
  820. int bt_mesh_cfg_hb_sub_set(uint16_t net_idx, uint16_t addr,
  821. struct bt_mesh_cfg_hb_sub *sub, uint8_t *status);
  822. /** @brief Get the target node's Heartbeta subscription parameters.
  823. *
  824. * @param net_idx Network index to encrypt with.
  825. * @param addr Target node address.
  826. * @param sub Heartbeat subscription parameter return buffer.
  827. * @param status Status response parameter.
  828. *
  829. * @return 0 on success, or (negative) error code on failure.
  830. */
  831. int bt_mesh_cfg_hb_sub_get(uint16_t net_idx, uint16_t addr,
  832. struct bt_mesh_cfg_hb_sub *sub, uint8_t *status);
  833. /** Heartbeat publication configuration parameters. */
  834. struct bt_mesh_cfg_hb_pub {
  835. /** Heartbeat destination address. */
  836. uint16_t dst;
  837. /**
  838. * Logarithmic Heartbeat count. Decoded as (1 << (count - 1)) if count
  839. * is between 1 and 0x11, 0 if count is 0, or "indefinitely" if count is
  840. * 0xff.
  841. *
  842. * When used in Heartbeat publication set, this parameter denotes the
  843. * number of Heartbeat messages to send.
  844. *
  845. * When returned from Heartbeat publication get, this parameter denotes
  846. * the number of Heartbeat messages remaining to be sent.
  847. */
  848. uint8_t count;
  849. /**
  850. * Logarithmic Heartbeat publication transmit interval in seconds.
  851. * Decoded as (1 << (period - 1)) if period is between 1 and 0x11.
  852. * If period is 0, Heartbeat publication is disabled.
  853. */
  854. uint8_t period;
  855. /** Publication message Time To Live value. */
  856. uint8_t ttl;
  857. /**
  858. * Bitmap of features that trigger Heartbeat publications.
  859. * Legal values are @ref BT_MESH_FEAT_RELAY,
  860. * @ref BT_MESH_FEAT_PROXY, @ref BT_MESH_FEAT_FRIEND and
  861. * @ref BT_MESH_FEAT_LOW_POWER
  862. */
  863. uint16_t feat;
  864. /** Network index to publish with. */
  865. uint16_t net_idx;
  866. };
  867. /** @brief Set the target node's Heartbeat publication parameters.
  868. *
  869. * @note The target node must already have received the specified network key.
  870. *
  871. * @param net_idx Network index to encrypt with.
  872. * @param addr Target node address.
  873. * @param pub New Heartbeat publication parameters.
  874. * @param status Status response parameter.
  875. *
  876. * @return 0 on success, or (negative) error code on failure.
  877. */
  878. int bt_mesh_cfg_hb_pub_set(uint16_t net_idx, uint16_t addr,
  879. const struct bt_mesh_cfg_hb_pub *pub, uint8_t *status);
  880. /** @brief Get the target node's Heartbeat publication parameters.
  881. *
  882. * @param net_idx Network index to encrypt with.
  883. * @param addr Target node address.
  884. * @param pub Heartbeat publication parameter return buffer.
  885. * @param status Status response parameter.
  886. *
  887. * @return 0 on success, or (negative) error code on failure.
  888. */
  889. int bt_mesh_cfg_hb_pub_get(uint16_t net_idx, uint16_t addr,
  890. struct bt_mesh_cfg_hb_pub *pub, uint8_t *status);
  891. /** @brief Delete all group addresses in a SIG model's subscription list.
  892. *
  893. * @param net_idx Network index to encrypt with.
  894. * @param addr Target node address.
  895. * @param elem_addr Element address the model is in.
  896. * @param mod_id Model ID.
  897. * @param status Status response parameter.
  898. *
  899. * @return 0 on success, or (negative) error code on failure.
  900. */
  901. int bt_mesh_cfg_mod_sub_del_all(uint16_t net_idx, uint16_t addr,
  902. uint16_t elem_addr, uint16_t mod_id,
  903. uint8_t *status);
  904. /** @brief Delete all group addresses in a vendor model's subscription list.
  905. *
  906. * @param net_idx Network index to encrypt with.
  907. * @param addr Target node address.
  908. * @param elem_addr Element address the model is in.
  909. * @param mod_id Model ID.
  910. * @param cid Company ID of the model.
  911. * @param status Status response parameter.
  912. *
  913. * @return 0 on success, or (negative) error code on failure.
  914. */
  915. int bt_mesh_cfg_mod_sub_del_all_vnd(uint16_t net_idx, uint16_t addr,
  916. uint16_t elem_addr, uint16_t mod_id,
  917. uint16_t cid, uint8_t *status);
  918. /** @brief Update a network key to the target node.
  919. *
  920. * @param net_idx Network index to encrypt with.
  921. * @param addr Target node address.
  922. * @param key_net_idx Network key index.
  923. * @param net_key Network key.
  924. * @param status Status response parameter.
  925. *
  926. * @return 0 on success, or (negative) error code on failure.
  927. */
  928. int bt_mesh_cfg_net_key_update(uint16_t net_idx, uint16_t addr,
  929. uint16_t key_net_idx, const uint8_t net_key[16],
  930. uint8_t *status);
  931. /** @brief Update an application key to the target node.
  932. *
  933. * @param net_idx Network index to encrypt with.
  934. * @param addr Target node address.
  935. * @param key_net_idx Network key index the application key belongs to.
  936. * @param key_app_idx Application key index.
  937. * @param app_key Application key.
  938. * @param status Status response parameter.
  939. *
  940. * @return 0 on success, or (negative) error code on failure.
  941. */
  942. int bt_mesh_cfg_app_key_update(uint16_t net_idx, uint16_t addr,
  943. uint16_t key_net_idx, uint16_t key_app_idx,
  944. const uint8_t app_key[16], uint8_t *status);
  945. /** @brief Set the Node Identity parameters.
  946. *
  947. * @param net_idx Network index to encrypt with.
  948. * @param addr Target node address.
  949. * @param new_identity New identity state. Must be one of
  950. * @ref BT_MESH_NODE_IDENTITY_STOPPED or
  951. * @ref BT_MESH_NODE_IDENTITY_RUNNING
  952. * @param key_net_idx Network key index the application key belongs to.
  953. * @param status Status response parameter.
  954. * @param identity Identity response parameter.
  955. *
  956. * @return 0 on success, or (negative) error code on failure.
  957. */
  958. int bt_mesh_cfg_node_identity_set(uint16_t net_idx, uint16_t addr,
  959. uint16_t key_net_idx, uint8_t new_identity,
  960. uint8_t *status, uint8_t *identity);
  961. /** @brief Get the Node Identity parameters.
  962. *
  963. * @param net_idx Network index to encrypt with.
  964. * @param addr Target node address.
  965. * @param key_net_idx Network key index the application key belongs to.
  966. * @param status Status response parameter.
  967. * @param identity Identity response parameter. Must be one of
  968. * @ref BT_MESH_NODE_IDENTITY_STOPPED or
  969. * @ref BT_MESH_NODE_IDENTITY_RUNNING
  970. *
  971. * @return 0 on success, or (negative) error code on failure.
  972. */
  973. int bt_mesh_cfg_node_identity_get(uint16_t net_idx, uint16_t addr,
  974. uint16_t key_net_idx, uint8_t *status,
  975. uint8_t *identity);
  976. /** @brief Get the Low Power Node Polltimeout parameters.
  977. *
  978. * @param net_idx Network index to encrypt with.
  979. * @param addr Target node address.
  980. * @param unicast_addr LPN unicast address.
  981. * @param polltimeout Poltimeout response parameter.
  982. *
  983. * @return 0 on success, or (negative) error code on failure.
  984. */
  985. int bt_mesh_cfg_lpn_timeout_get(uint16_t net_idx, uint16_t addr,
  986. uint16_t unicast_addr, int32_t *polltimeout);
  987. /** @brief Get the current transmission timeout value.
  988. *
  989. * @return The configured transmission timeout in milliseconds.
  990. */
  991. int32_t bt_mesh_cfg_cli_timeout_get(void);
  992. /** @brief Set the transmission timeout value.
  993. *
  994. * @param timeout The new transmission timeout.
  995. */
  996. void bt_mesh_cfg_cli_timeout_set(int32_t timeout);
  997. /** Parsed Composition data page 0 representation.
  998. *
  999. * Should be pulled from the return buffer passed to
  1000. * @ref bt_mesh_cfg_comp_data_get using
  1001. * @ref bt_mesh_comp_p0_get.
  1002. */
  1003. struct bt_mesh_comp_p0 {
  1004. /** Company ID */
  1005. uint16_t cid;
  1006. /** Product ID */
  1007. uint16_t pid;
  1008. /** Version ID */
  1009. uint16_t vid;
  1010. /** Replay protection list size */
  1011. uint16_t crpl;
  1012. /** Supported features, see @ref BT_MESH_FEAT_SUPPORTED. */
  1013. uint16_t feat;
  1014. struct net_buf_simple *_buf;
  1015. };
  1016. /** Composition data page 0 element representation */
  1017. struct bt_mesh_comp_p0_elem {
  1018. /** Element location */
  1019. uint16_t loc;
  1020. /** The number of SIG models in this element */
  1021. size_t nsig;
  1022. /** The number of vendor models in this element */
  1023. size_t nvnd;
  1024. uint8_t *_buf;
  1025. };
  1026. /** @brief Create a composition data page 0 representation from a buffer.
  1027. *
  1028. * The composition data page object will take ownership over the buffer, which
  1029. * should not be manipulated directly after this call.
  1030. *
  1031. * This function can be used in combination with @ref bt_mesh_cfg_comp_data_get
  1032. * to read out composition data page 0 from other devices:
  1033. *
  1034. * @code
  1035. * NET_BUF_SIMPLE_DEFINE(buf, BT_MESH_RX_SDU_MAX);
  1036. * struct bt_mesh_comp_p0 comp;
  1037. *
  1038. * err = bt_mesh_cfg_comp_data_get(net_idx, addr, 0, &page, &buf);
  1039. * if (!err) {
  1040. * bt_mesh_comp_p0_get(&comp, &buf);
  1041. * }
  1042. * @endcode
  1043. *
  1044. * @param buf Network buffer containing composition data.
  1045. * @param comp Composition data structure to fill.
  1046. *
  1047. * @return 0 on success, or (negative) error code on failure.
  1048. */
  1049. int bt_mesh_comp_p0_get(struct bt_mesh_comp_p0 *comp,
  1050. struct net_buf_simple *buf);
  1051. /** @brief Pull a composition data page 0 element from a composition data page 0
  1052. * instance.
  1053. *
  1054. * Each call to this function will pull out a new element from the composition
  1055. * data page, until all elements have been pulled.
  1056. *
  1057. * @param comp Composition data page
  1058. * @param elem Element to fill.
  1059. *
  1060. * @return A pointer to @c elem on success, or NULL if no more elements could
  1061. * be pulled.
  1062. */
  1063. struct bt_mesh_comp_p0_elem *bt_mesh_comp_p0_elem_pull(const struct bt_mesh_comp_p0 *comp,
  1064. struct bt_mesh_comp_p0_elem *elem);
  1065. /** @brief Get a SIG model from the given composition data page 0 element.
  1066. *
  1067. * @param elem Element to read the model from.
  1068. * @param idx Index of the SIG model to read.
  1069. *
  1070. * @return The Model ID of the SIG model at the given index, or 0xffff if the
  1071. * index is out of bounds.
  1072. */
  1073. uint16_t bt_mesh_comp_p0_elem_mod(struct bt_mesh_comp_p0_elem *elem, int idx);
  1074. /** @brief Get a vendor model from the given composition data page 0 element.
  1075. *
  1076. * @param elem Element to read the model from.
  1077. * @param idx Index of the vendor model to read.
  1078. *
  1079. * @return The model ID of the vendor model at the given index, or
  1080. * {0xffff, 0xffff} if the index is out of bounds.
  1081. */
  1082. struct bt_mesh_mod_id_vnd bt_mesh_comp_p0_elem_mod_vnd(struct bt_mesh_comp_p0_elem *elem, int idx);
  1083. /** @cond INTERNAL_HIDDEN */
  1084. extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[];
  1085. extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb;
  1086. /** @endcond */
  1087. #ifdef __cplusplus
  1088. }
  1089. #endif
  1090. /**
  1091. * @}
  1092. */
  1093. #endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_CLI_H_ */