1 /** @file 2 * @brief Configuration Client Model APIs. 3 */ 4 5 /* 6 * Copyright (c) 2017 Intel Corporation 7 * 8 * SPDX-License-Identifier: Apache-2.0 9 */ 10 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_CLI_H_ 11 #define ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_CLI_H_ 12 13 /** 14 * @brief Configuration Client Model 15 * @defgroup bt_mesh_cfg_cli Configuration Client Model 16 * @ingroup bt_mesh 17 * @{ 18 */ 19 20 #include <stdint.h> 21 #include <stdbool.h> 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 struct bt_mesh_cfg_cli; 28 struct bt_mesh_cfg_cli_hb_pub; 29 struct bt_mesh_cfg_cli_hb_sub; 30 struct bt_mesh_cfg_cli_mod_pub; 31 32 /** Mesh Configuration Client Status messages callback */ 33 struct bt_mesh_cfg_cli_cb { 34 35 /** @brief Optional callback for Composition data messages. 36 * 37 * Handles received Composition data messages from a server. 38 * 39 * @note For decoding @c buf, please refer to 40 * @ref bt_mesh_comp_p0_get and 41 * @ref bt_mesh_comp_p1_elem_pull. 42 * 43 * @param cli Client that received the status message. 44 * @param addr Address of the sender. 45 * @param page Composition data page. 46 * @param buf Composition data buffer. 47 */ 48 void (*comp_data)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t page, 49 struct net_buf_simple *buf); 50 51 /** @brief Optional callback for Model Pub status messages. 52 * 53 * Handles received Model Pub status messages from a server. 54 * 55 * @param cli Client that received the status message. 56 * @param addr Address of the sender. 57 * @param status Status code for the message. 58 * @param elem_addr Address of the element. 59 * @param mod_id Model ID. 60 * @param cid Company ID. 61 * @param pub Publication configuration parameters. 62 */ 63 void (*mod_pub_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status, 64 uint16_t elem_addr, uint16_t mod_id, uint16_t cid, 65 struct bt_mesh_cfg_cli_mod_pub *pub); 66 67 /** @brief Optional callback for Model Sub Status messages. 68 * 69 * Handles received Model Sub Status messages from a server. 70 * 71 * @param cli Client that received the status message. 72 * @param addr Address of the sender. 73 * @param status Status Code for requesting message. 74 * @param elem_addr The unicast address of the element. 75 * @param sub_addr The sub address. 76 * @param mod_id The model ID within the element. 77 */ 78 void (*mod_sub_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 79 uint8_t status, uint16_t elem_addr, 80 uint16_t sub_addr, uint32_t mod_id); 81 82 /** @brief Optional callback for Model Sub list messages. 83 * 84 * Handles received Model Sub list messages from a server. 85 * 86 * @note The @c buf parameter should be decoded using 87 * @ref net_buf_simple_pull_le16 in iteration, as long 88 * as @c buf->len is greater than or equal to 2. 89 * 90 * @param cli Client that received the status message. 91 * @param addr Address of the sender. 92 * @param status Status code for the message. 93 * @param elem_addr Address of the element. 94 * @param mod_id Model ID. 95 * @param cid Company ID. 96 * @param buf Message buffer containing subscription addresses. 97 */ 98 void (*mod_sub_list)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status, 99 uint16_t elem_addr, uint16_t mod_id, uint16_t cid, 100 struct net_buf_simple *buf); 101 102 /** @brief Optional callback for Node Reset Status messages. 103 * 104 * Handles received Node Reset Status messages from a server. 105 * 106 * @param cli Client that received the status message. 107 * @param addr Address of the sender. 108 */ 109 void (*node_reset_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr); 110 111 /** @brief Optional callback for Beacon Status messages. 112 * 113 * Handles received Beacon Status messages from a server. 114 * 115 * @param cli Client that received the status message. 116 * @param addr Address of the sender. 117 * @param status Status Code for requesting message. 118 */ 119 void (*beacon_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 120 uint8_t status); 121 122 /** @brief Optional callback for Default TTL Status messages. 123 * 124 * Handles received Default TTL Status messages from a server. 125 * 126 * @param cli Client that received the status message. 127 * @param addr Address of the sender. 128 * @param status Status Code for requesting message. 129 */ 130 void (*ttl_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 131 uint8_t status); 132 133 /** @brief Optional callback for Friend Status messages. 134 * 135 * Handles received Friend Status messages from a server. 136 * 137 * @param cli Client that received the status message. 138 * @param addr Address of the sender. 139 * @param status Status Code for requesting message. 140 */ 141 void (*friend_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 142 uint8_t status); 143 144 /** @brief Optional callback for GATT Proxy Status messages. 145 * 146 * Handles received GATT Proxy Status messages from a server. 147 * 148 * @param cli Client that received the status message. 149 * @param addr Address of the sender. 150 * @param status Status Code for requesting message. 151 */ 152 void (*gatt_proxy_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 153 uint8_t status); 154 155 /** @brief Optional callback for Network Transmit Status messages. 156 * 157 * Handles received Network Transmit Status messages from a server. 158 * 159 * @param cli Client that received the status message. 160 * @param addr Address of the sender. 161 * @param status Status Code for requesting message. 162 */ 163 void (*network_transmit_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 164 uint8_t status); 165 166 /** @brief Optional callback for Relay Status messages. 167 * 168 * Handles received Relay Status messages from a server. 169 * 170 * @param cli Client that received the status message. 171 * @param addr Address of the sender. 172 * @param status Status Code for requesting message. 173 * @param transmit The relay retransmit count and interval steps. 174 */ 175 void (*relay_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 176 uint8_t status, uint8_t transmit); 177 178 /** @brief Optional callback for NetKey Status messages. 179 * 180 * Handles received NetKey Status messages from a server. 181 * 182 * @param cli Client that received the status message. 183 * @param addr Address of the sender. 184 * @param status Status Code for requesting message. 185 * @param net_idx The index of the NetKey. 186 */ 187 void (*net_key_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 188 uint8_t status, uint16_t net_idx); 189 190 /** @brief Optional callback for Netkey list messages. 191 * 192 * Handles received Netkey list messages from a server. 193 * 194 * @note The @c buf parameter should be decoded using the 195 * @ref bt_mesh_key_idx_unpack_list helper function. 196 * 197 * @param cli Client that received the status message. 198 * @param addr Address of the sender. 199 * @param buf Message buffer containing key indexes. 200 */ 201 void (*net_key_list)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 202 struct net_buf_simple *buf); 203 204 /** @brief Optional callback for AppKey Status messages. 205 * 206 * Handles received AppKey Status messages from a server. 207 * 208 * @param cli Client that received the status message. 209 * @param addr Address of the sender. 210 * @param status Status Code for requesting message. 211 * @param net_idx The index of the NetKey. 212 * @param app_idx The index of the AppKey. 213 */ 214 void (*app_key_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 215 uint8_t status, uint16_t net_idx, 216 uint16_t app_idx); 217 218 /** @brief Optional callback for Appkey list messages. 219 * 220 * Handles received Appkey list messages from a server. 221 * 222 * @note The @c buf parameter should be decoded using the 223 * @ref bt_mesh_key_idx_unpack_list helper function. 224 * 225 * @param cli Client that received the status message. 226 * @param addr Address of the sender. 227 * @param status Status code for the message. 228 * @param net_idx The index of the NetKey. 229 * @param buf Message buffer containing key indexes. 230 */ 231 void (*app_key_list)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status, 232 uint16_t net_idx, struct net_buf_simple *buf); 233 234 /** @brief Optional callback for Model App Status messages. 235 * 236 * Handles received Model App Status messages from a server. 237 * 238 * @param cli Client that received the status message. 239 * @param addr Address of the sender. 240 * @param status Status Code for requesting message. 241 * @param elem_addr The unicast address of the element. 242 * @param app_idx The sub address. 243 * @param mod_id The model ID within the element. 244 */ 245 void (*mod_app_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 246 uint8_t status, uint16_t elem_addr, 247 uint16_t app_idx, uint32_t mod_id); 248 249 /** @brief Optional callback for Model App list messages. 250 * 251 * Handles received Model App list messages from a server. 252 * 253 * @note The @c buf parameter should be decoded using the 254 * @ref bt_mesh_key_idx_unpack_list helper function. 255 * 256 * @param cli Client that received the status message. 257 * @param addr Address of the sender. 258 * @param status Status code for the message. 259 * @param elem_addr Address of the element. 260 * @param mod_id Model ID. 261 * @param cid Company ID. 262 * @param buf Message buffer containing key indexes. 263 */ 264 void (*mod_app_list)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status, 265 uint16_t elem_addr, uint16_t mod_id, uint16_t cid, 266 struct net_buf_simple *buf); 267 268 /** @brief Optional callback for Node Identity Status messages. 269 * 270 * Handles received Node Identity Status messages from a server. 271 * 272 * @param cli Client that received the status message. 273 * @param addr Address of the sender. 274 * @param status Status Code for requesting message. 275 * @param net_idx The index of the NetKey. 276 * @param identity The node identity state. 277 */ 278 void (*node_identity_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 279 uint8_t status, uint16_t net_idx, 280 uint8_t identity); 281 282 /** @brief Optional callback for LPN PollTimeout Status messages. 283 * 284 * Handles received LPN PollTimeout Status messages from a server. 285 * 286 * @param cli Client that received the status message. 287 * @param addr Address of the sender. 288 * @param elem_addr The unicast address of the LPN. 289 * @param timeout Current value of PollTimeout timer of the LPN. 290 */ 291 void (*lpn_timeout_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, 292 uint16_t elem_addr, uint32_t timeout); 293 294 /** @brief Optional callback for Key Refresh Phase status messages. 295 * 296 * Handles received Key Refresh Phase status messages from a server. 297 * 298 * @param cli Client that received the status message. 299 * @param addr Address of the sender. 300 * @param status Status code for the message. 301 * @param net_idx The index of the NetKey. 302 * @param phase Phase of the KRP. 303 */ 304 void (*krp_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status, 305 uint16_t net_idx, uint8_t phase); 306 307 /** @brief Optional callback for Heartbeat pub status messages. 308 * 309 * Handles received Heartbeat pub status messages from a server. 310 * 311 * @param cli Client that received the status message. 312 * @param addr Address of the sender. 313 * @param status Status code for the message. 314 * @param pub HB publication configuration parameters. 315 */ 316 void (*hb_pub_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status, 317 struct bt_mesh_cfg_cli_hb_pub *pub); 318 319 /** @brief Optional callback for Heartbeat Sub status messages. 320 * 321 * Handles received Heartbeat Sub status messages from a server. 322 * 323 * @param cli Client that received the status message. 324 * @param addr Address of the sender. 325 * @param status Status code for the message. 326 * @param sub HB subscription configuration parameters. 327 */ 328 void (*hb_sub_status)(struct bt_mesh_cfg_cli *cli, uint16_t addr, uint8_t status, 329 struct bt_mesh_cfg_cli_hb_sub *sub); 330 }; 331 332 /** Mesh Configuration Client Model Context */ 333 struct bt_mesh_cfg_cli { 334 /** Composition data model entry pointer. */ 335 const struct bt_mesh_model *model; 336 337 /** Optional callback for Mesh Configuration Client Status messages. */ 338 const struct bt_mesh_cfg_cli_cb *cb; 339 340 /* Internal parameters for tracking message responses. */ 341 struct bt_mesh_msg_ack_ctx ack_ctx; 342 }; 343 344 /** 345 * @brief Generic Configuration Client model composition data entry. 346 * 347 * @param cli_data Pointer to a @ref bt_mesh_cfg_cli instance. 348 */ 349 #define BT_MESH_MODEL_CFG_CLI(cli_data) \ 350 BT_MESH_MODEL_CNT_CB(BT_MESH_MODEL_ID_CFG_CLI, \ 351 bt_mesh_cfg_cli_op, NULL, \ 352 cli_data, 1, 0, &bt_mesh_cfg_cli_cb) 353 354 /** 355 * 356 * @brief Helper macro to encode model publication period in units of 100ms 357 * 358 * @param steps Number of 100ms steps. 359 * 360 * @return Encoded value that can be assigned to bt_mesh_cfg_cli_mod_pub.period 361 */ 362 #define BT_MESH_PUB_PERIOD_100MS(steps) ((steps) & BIT_MASK(6)) 363 364 /** 365 * @brief Helper macro to encode model publication period in units of 1 second 366 * 367 * @param steps Number of 1 second steps. 368 * 369 * @return Encoded value that can be assigned to bt_mesh_cfg_cli_mod_pub.period 370 */ 371 #define BT_MESH_PUB_PERIOD_SEC(steps) (((steps) & BIT_MASK(6)) | (1 << 6)) 372 373 /** 374 * 375 * @brief Helper macro to encode model publication period in units of 10 376 * seconds 377 * 378 * @param steps Number of 10 second steps. 379 * 380 * @return Encoded value that can be assigned to bt_mesh_cfg_cli_mod_pub.period 381 */ 382 #define BT_MESH_PUB_PERIOD_10SEC(steps) (((steps) & BIT_MASK(6)) | (2 << 6)) 383 384 /** 385 * 386 * @brief Helper macro to encode model publication period in units of 10 387 * minutes 388 * 389 * @param steps Number of 10 minute steps. 390 * 391 * @return Encoded value that can be assigned to bt_mesh_cfg_cli_mod_pub.period 392 */ 393 #define BT_MESH_PUB_PERIOD_10MIN(steps) (((steps) & BIT_MASK(6)) | (3 << 6)) 394 395 /** Model publication configuration parameters. */ 396 struct bt_mesh_cfg_cli_mod_pub { 397 /** Publication destination address. */ 398 uint16_t addr; 399 /** Virtual address UUID, or NULL if this is not a virtual address. */ 400 const uint8_t *uuid; 401 /** Application index to publish with. */ 402 uint16_t app_idx; 403 /** Friendship credential flag. */ 404 bool cred_flag; 405 /** Time To Live to publish with. */ 406 uint8_t ttl; 407 /** 408 * Encoded publish period. 409 * @see BT_MESH_PUB_PERIOD_100MS, BT_MESH_PUB_PERIOD_SEC, 410 * BT_MESH_PUB_PERIOD_10SEC, 411 * BT_MESH_PUB_PERIOD_10MIN 412 */ 413 uint8_t period; 414 /** 415 * Encoded transmit parameters. 416 * @see BT_MESH_TRANSMIT 417 */ 418 uint8_t transmit; 419 }; 420 421 /** Heartbeat subscription configuration parameters. */ 422 struct bt_mesh_cfg_cli_hb_sub { 423 /** Source address to receive Heartbeat messages from. */ 424 uint16_t src; 425 /** Destination address to receive Heartbeat messages on. */ 426 uint16_t dst; 427 /** 428 * Logarithmic subscription period to keep listening for. 429 * The decoded subscription period is (1 << (period - 1)) seconds, or 0 430 * seconds if period is 0. 431 */ 432 uint8_t period; 433 /** 434 * Logarithmic Heartbeat subscription receive count. 435 * The decoded Heartbeat count is (1 << (count - 1)) if count is 436 * between 1 and 0xfe, 0 if count is 0 and 0xffff if count is 0xff. 437 * 438 * Ignored in Heartbeat subscription set. 439 */ 440 uint8_t count; 441 /** 442 * Minimum hops in received messages, ie the shortest registered path 443 * from the publishing node to the subscribing node. A Heartbeat 444 * received from an immediate neighbor has hop count = 1. 445 * 446 * Ignored in Heartbeat subscription set. 447 */ 448 uint8_t min; 449 /** 450 * Maximum hops in received messages, ie the longest registered path 451 * from the publishing node to the subscribing node. A Heartbeat 452 * received from an immediate neighbor has hop count = 1. 453 * 454 * Ignored in Heartbeat subscription set. 455 */ 456 uint8_t max; 457 }; 458 459 /** Heartbeat publication configuration parameters. */ 460 struct bt_mesh_cfg_cli_hb_pub { 461 /** Heartbeat destination address. */ 462 uint16_t dst; 463 /** 464 * Logarithmic Heartbeat count. Decoded as (1 << (count - 1)) if count 465 * is between 1 and 0x11, 0 if count is 0, or "indefinitely" if count is 466 * 0xff. 467 * 468 * When used in Heartbeat publication set, this parameter denotes the 469 * number of Heartbeat messages to send. 470 * 471 * When returned from Heartbeat publication get, this parameter denotes 472 * the number of Heartbeat messages remaining to be sent. 473 */ 474 uint8_t count; 475 /** 476 * Logarithmic Heartbeat publication transmit interval in seconds. 477 * Decoded as (1 << (period - 1)) if period is between 1 and 0x11. 478 * If period is 0, Heartbeat publication is disabled. 479 */ 480 uint8_t period; 481 /** Publication message Time To Live value. */ 482 uint8_t ttl; 483 /** 484 * Bitmap of features that trigger Heartbeat publications. 485 * Legal values are @ref BT_MESH_FEAT_RELAY, 486 * @ref BT_MESH_FEAT_PROXY, @ref BT_MESH_FEAT_FRIEND and 487 * @ref BT_MESH_FEAT_LOW_POWER 488 */ 489 uint16_t feat; 490 /** Network index to publish with. */ 491 uint16_t net_idx; 492 }; 493 494 /** @brief Reset the target node and remove it from the network. 495 * 496 * @param net_idx Network index to encrypt with. 497 * @param addr Target node address. 498 * @param status Status response parameter 499 * 500 * @return 0 on success, or (negative) error code on failure. 501 */ 502 int bt_mesh_cfg_cli_node_reset(uint16_t net_idx, uint16_t addr, bool *status); 503 504 /** @brief Get the target node's composition data. 505 * 506 * If the other device does not have the given composition data page, it will 507 * return the largest page number it supports that is less than the requested 508 * page index. The actual page the device responds with is returned in @c rsp. 509 * 510 * This method can be used asynchronously by setting @p rsp and @p comp 511 * as NULL. This way the method will not wait for response and will return 512 * immediately after sending the command. 513 * 514 * @param net_idx Network index to encrypt with. 515 * @param addr Target node address. 516 * @param page Composition data page, or 0xff to request the first available 517 * page. 518 * @param rsp Return parameter for the returned page number, or NULL. 519 * @param comp Composition data buffer to fill. 520 * 521 * @return 0 on success, or (negative) error code on failure. 522 */ 523 int bt_mesh_cfg_cli_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page, uint8_t *rsp, 524 struct net_buf_simple *comp); 525 526 /** @brief Get the target node's network beacon state. 527 * 528 * This method can be used asynchronously by setting @p status 529 * as NULL. This way the method will not wait for response and will 530 * return immediately after sending the command. 531 * 532 * @param net_idx Network index to encrypt with. 533 * @param addr Target node address. 534 * @param status Status response parameter, returns one of 535 * @ref BT_MESH_BEACON_DISABLED or @ref BT_MESH_BEACON_ENABLED 536 * on success. 537 * 538 * @return 0 on success, or (negative) error code on failure. 539 */ 540 int bt_mesh_cfg_cli_beacon_get(uint16_t net_idx, uint16_t addr, uint8_t *status); 541 542 /** @brief Get the target node's network key refresh phase state. 543 * 544 * This method can be used asynchronously by setting @p status and @p phase 545 * as NULL. This way the method will not wait for response and will 546 * return immediately after sending the command. 547 * 548 * @param net_idx Network index to encrypt with. 549 * @param addr Target node address. 550 * @param key_net_idx Network key index. 551 * @param status Status response parameter. 552 * @param phase Pointer to the Key Refresh variable to fill. 553 * 554 * @return 0 on success, or (negative) error code on failure. 555 */ 556 int bt_mesh_cfg_cli_krp_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, uint8_t *status, 557 uint8_t *phase); 558 559 /** @brief Set the target node's network key refresh phase parameters. 560 * 561 * This method can be used asynchronously by setting @p status and @p phase 562 * as NULL. This way the method will not wait for response and will 563 * return immediately after sending the command. 564 * 565 * @param net_idx Network index to encrypt with. 566 * @param addr Target node address. 567 * @param key_net_idx Network key index. 568 * @param transition Transition parameter. 569 * @param status Status response parameter. 570 * @param phase Pointer to the new Key Refresh phase. Will return the actual 571 * Key Refresh phase after updating. 572 * 573 * @return 0 on success, or (negative) error code on failure. 574 */ 575 int bt_mesh_cfg_cli_krp_set(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, 576 uint8_t transition, uint8_t *status, uint8_t *phase); 577 578 /** @brief Set the target node's network beacon state. 579 * 580 * This method can be used asynchronously by setting @p status 581 * as NULL. This way the method will not wait for response and will 582 * return immediately after sending the command. 583 * 584 * @param net_idx Network index to encrypt with. 585 * @param addr Target node address. 586 * @param val New network beacon state, should be one of 587 * @ref BT_MESH_BEACON_DISABLED or @ref BT_MESH_BEACON_ENABLED. 588 * @param status Status response parameter. Returns one of 589 * @ref BT_MESH_BEACON_DISABLED or @ref BT_MESH_BEACON_ENABLED 590 * on success. 591 * 592 * @return 0 on success, or (negative) error code on failure. 593 */ 594 int bt_mesh_cfg_cli_beacon_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status); 595 596 /** @brief Get the target node's Time To Live value. 597 * 598 * This method can be used asynchronously by setting @p ttl 599 * as NULL. This way the method will not wait for response and will 600 * return immediately after sending the command. 601 * 602 * @param net_idx Network index to encrypt with. 603 * @param addr Target node address. 604 * @param ttl TTL response buffer. 605 * 606 * @return 0 on success, or (negative) error code on failure. 607 */ 608 int bt_mesh_cfg_cli_ttl_get(uint16_t net_idx, uint16_t addr, uint8_t *ttl); 609 610 /** @brief Set the target node's Time To Live value. 611 * 612 * This method can be used asynchronously by setting @p ttl 613 * as NULL. This way the method will not wait for response and will 614 * return immediately after sending the command. 615 * 616 * @param net_idx Network index to encrypt with. 617 * @param addr Target node address. 618 * @param val New Time To Live value. 619 * @param ttl TTL response buffer. 620 * 621 * @return 0 on success, or (negative) error code on failure. 622 */ 623 int bt_mesh_cfg_cli_ttl_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *ttl); 624 625 /** @brief Get the target node's Friend feature status. 626 * 627 * This method can be used asynchronously by setting @p status 628 * as NULL. This way the method will not wait for response and will 629 * return immediately after sending the command. 630 * 631 * @param net_idx Network index to encrypt with. 632 * @param addr Target node address. 633 * @param status Status response parameter. Returns one of 634 * @ref BT_MESH_FRIEND_DISABLED, @ref BT_MESH_FRIEND_ENABLED or 635 * @ref BT_MESH_FRIEND_NOT_SUPPORTED on success. 636 * 637 * @return 0 on success, or (negative) error code on failure. 638 */ 639 int bt_mesh_cfg_cli_friend_get(uint16_t net_idx, uint16_t addr, uint8_t *status); 640 641 /** @brief Set the target node's Friend feature state. 642 * 643 * This method can be used asynchronously by setting @p status 644 * as NULL. This way the method will not wait for response and will 645 * return immediately after sending the command. 646 * 647 * @param net_idx Network index to encrypt with. 648 * @param addr Target node address. 649 * @param val New Friend feature state. Should be one of 650 * @ref BT_MESH_FRIEND_DISABLED or 651 * @ref BT_MESH_FRIEND_ENABLED. 652 * @param status Status response parameter. Returns one of 653 * @ref BT_MESH_FRIEND_DISABLED, @ref BT_MESH_FRIEND_ENABLED or 654 * @ref BT_MESH_FRIEND_NOT_SUPPORTED on success. 655 * 656 * @return 0 on success, or (negative) error code on failure. 657 */ 658 int bt_mesh_cfg_cli_friend_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status); 659 660 /** @brief Get the target node's Proxy feature state. 661 * 662 * This method can be used asynchronously by setting @p status 663 * as NULL. This way the method will not wait for response and will 664 * return immediately after sending the command. 665 * 666 * @param net_idx Network index to encrypt with. 667 * @param addr Target node address. 668 * @param status Status response parameter. Returns one of 669 * @ref BT_MESH_GATT_PROXY_DISABLED, 670 * @ref BT_MESH_GATT_PROXY_ENABLED or 671 * @ref BT_MESH_GATT_PROXY_NOT_SUPPORTED on success. 672 * 673 * @return 0 on success, or (negative) error code on failure. 674 */ 675 int bt_mesh_cfg_cli_gatt_proxy_get(uint16_t net_idx, uint16_t addr, uint8_t *status); 676 677 /** @brief Set the target node's Proxy feature state. 678 * 679 * This method can be used asynchronously by setting @p status 680 * as NULL. This way the method will not wait for response and will 681 * return immediately after sending the command. 682 * 683 * @param net_idx Network index to encrypt with. 684 * @param addr Target node address. 685 * @param val New Proxy feature state. Must be one of 686 * @ref BT_MESH_GATT_PROXY_DISABLED or 687 * @ref BT_MESH_GATT_PROXY_ENABLED. 688 * @param status Status response parameter. Returns one of 689 * @ref BT_MESH_GATT_PROXY_DISABLED, 690 * @ref BT_MESH_GATT_PROXY_ENABLED or 691 * @ref BT_MESH_GATT_PROXY_NOT_SUPPORTED on success. 692 * 693 * @return 0 on success, or (negative) error code on failure. 694 */ 695 int bt_mesh_cfg_cli_gatt_proxy_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status); 696 697 /** @brief Get the target node's network_transmit state. 698 * 699 * This method can be used asynchronously by setting @p transmit 700 * as NULL. This way the method will not wait for response and will 701 * return immediately after sending the command. 702 * 703 * @param net_idx Network index to encrypt with. 704 * @param addr Target node address. 705 * @param transmit Network transmit response parameter. Returns the encoded 706 * network transmission parameters on success. Decoded with 707 * @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT. 708 * 709 * @return 0 on success, or (negative) error code on failure. 710 */ 711 int bt_mesh_cfg_cli_net_transmit_get(uint16_t net_idx, uint16_t addr, uint8_t *transmit); 712 713 /** @brief Set the target node's network transmit parameters. 714 * 715 * This method can be used asynchronously by setting @p transmit 716 * as NULL. This way the method will not wait for response and will 717 * return immediately after sending the command. 718 * 719 * @param net_idx Network index to encrypt with. 720 * @param addr Target node address. 721 * @param val New encoded network transmit parameters. 722 * @see BT_MESH_TRANSMIT. 723 * @param transmit Network transmit response parameter. Returns the encoded 724 * network transmission parameters on success. Decoded with 725 * @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT. 726 * @return 0 on success, or (negative) error code on failure. 727 */ 728 int bt_mesh_cfg_cli_net_transmit_set(uint16_t net_idx, uint16_t addr, uint8_t val, 729 uint8_t *transmit); 730 731 /** @brief Get the target node's Relay feature state. 732 * 733 * This method can be used asynchronously by setting @p status and @p transmit 734 * as NULL. This way the method will not wait for response and will 735 * return immediately after sending the command. 736 * 737 * @param net_idx Network index to encrypt with. 738 * @param addr Target node address. 739 * @param status Status response parameter. Returns one of 740 * @ref BT_MESH_RELAY_DISABLED, @ref BT_MESH_RELAY_ENABLED or 741 * @ref BT_MESH_RELAY_NOT_SUPPORTED on success. 742 * @param transmit Transmit response parameter. Returns the encoded relay 743 * transmission parameters on success. Decoded with 744 * @ref BT_MESH_TRANSMIT_COUNT and @ref BT_MESH_TRANSMIT_INT. 745 * 746 * @return 0 on success, or (negative) error code on failure. 747 */ 748 int bt_mesh_cfg_cli_relay_get(uint16_t net_idx, uint16_t addr, uint8_t *status, uint8_t *transmit); 749 750 /** @brief Set the target node's Relay parameters. 751 * 752 * This method can be used asynchronously by setting @p status 753 * and @p transmit as NULL. This way the method will not wait for 754 * response and will return immediately after sending the command. 755 * 756 * @param net_idx Network index to encrypt with. 757 * @param addr Target node address. 758 * @param new_relay New relay state. Must be one of 759 * @ref BT_MESH_RELAY_DISABLED or 760 * @ref BT_MESH_RELAY_ENABLED. 761 * @param new_transmit New encoded relay transmit parameters. 762 * @see BT_MESH_TRANSMIT. 763 * @param status Status response parameter. Returns one of 764 * @ref BT_MESH_RELAY_DISABLED, @ref BT_MESH_RELAY_ENABLED 765 * or @ref BT_MESH_RELAY_NOT_SUPPORTED on success. 766 * @param transmit Transmit response parameter. Returns the encoded relay 767 * transmission parameters on success. Decoded with 768 * @ref BT_MESH_TRANSMIT_COUNT and 769 * @ref BT_MESH_TRANSMIT_INT. 770 * 771 * @return 0 on success, or (negative) error code on failure. 772 */ 773 int bt_mesh_cfg_cli_relay_set(uint16_t net_idx, uint16_t addr, uint8_t new_relay, 774 uint8_t new_transmit, uint8_t *status, uint8_t *transmit); 775 776 /** @brief Add a network key to the target node. 777 * 778 * This method can be used asynchronously by setting @p status 779 * as NULL. This way the method will not wait for response and will 780 * return immediately after sending the command. 781 * 782 * @param net_idx Network index to encrypt with. 783 * @param addr Target node address. 784 * @param key_net_idx Network key index. 785 * @param net_key Network key. 786 * @param status Status response parameter. 787 * 788 * @return 0 on success, or (negative) error code on failure. 789 */ 790 int bt_mesh_cfg_cli_net_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, 791 const uint8_t net_key[16], uint8_t *status); 792 793 /** @brief Get a list of the target node's network key indexes. 794 * 795 * This method can be used asynchronously by setting @p keys 796 * or @p key_cnt as NULL. This way the method will not wait 797 * for response and will return immediately after sending the command. 798 * 799 * @param net_idx Network index to encrypt with. 800 * @param addr Target node address. 801 * @param keys Net key index list response parameter. Will be filled with 802 * all the returned network key indexes it can fill. 803 * @param key_cnt Net key index list length. Should be set to the 804 * capacity of the @c keys list when calling. Will return the 805 * number of returned network key indexes upon success. 806 * 807 * @return 0 on success, or (negative) error code on failure. 808 */ 809 int bt_mesh_cfg_cli_net_key_get(uint16_t net_idx, uint16_t addr, uint16_t *keys, size_t *key_cnt); 810 811 /** @brief Delete a network key from the target node. 812 * 813 * This method can be used asynchronously by setting @p status 814 * as NULL. This way the method will not wait for response and will 815 * return immediately after sending the command. 816 * 817 * @param net_idx Network index to encrypt with. 818 * @param addr Target node address. 819 * @param key_net_idx Network key index. 820 * @param status Status response parameter. 821 * 822 * @return 0 on success, or (negative) error code on failure. 823 */ 824 int bt_mesh_cfg_cli_net_key_del(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, 825 uint8_t *status); 826 827 /** @brief Add an application key to the target node. 828 * 829 * This method can be used asynchronously by setting @p status 830 * as NULL. This way the method will not wait for response and will 831 * return immediately after sending the command. 832 * 833 * @param net_idx Network index to encrypt with. 834 * @param addr Target node address. 835 * @param key_net_idx Network key index the application key belongs to. 836 * @param key_app_idx Application key index. 837 * @param app_key Application key. 838 * @param status Status response parameter. 839 * 840 * @return 0 on success, or (negative) error code on failure. 841 */ 842 int bt_mesh_cfg_cli_app_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, 843 uint16_t key_app_idx, const uint8_t app_key[16], uint8_t *status); 844 845 /** @brief Get a list of the target node's application key indexes for a 846 * specific network key. 847 * 848 * This method can be used asynchronously by setting @p status and 849 * ( @p keys or @p key_cnt ) as NULL. This way the method will not wait 850 * for response and will return immediately after sending the command. 851 * 852 * @param net_idx Network index to encrypt with. 853 * @param addr Target node address. 854 * @param key_net_idx Network key index to request the app key indexes of. 855 * @param status Status response parameter. 856 * @param keys App key index list response parameter. Will be filled 857 * with all the returned application key indexes it can 858 * fill. 859 * @param key_cnt App key index list length. Should be set to the 860 * capacity of the @c keys list when calling. Will return 861 * the number of returned application key indexes upon 862 * success. 863 * 864 * @return 0 on success, or (negative) error code on failure. 865 */ 866 int bt_mesh_cfg_cli_app_key_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, 867 uint8_t *status, uint16_t *keys, size_t *key_cnt); 868 869 /** @brief Delete an application key from the target node. 870 * 871 * This method can be used asynchronously by setting @p status 872 * as NULL. This way the method will not wait for response and will 873 * return immediately after sending the command. 874 * 875 * @param net_idx Network index to encrypt with. 876 * @param addr Target node address. 877 * @param key_net_idx Network key index the application key belongs to. 878 * @param key_app_idx Application key index. 879 * @param status Status response parameter. 880 * 881 * @return 0 on success, or (negative) error code on failure. 882 */ 883 int bt_mesh_cfg_cli_app_key_del(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, 884 uint16_t key_app_idx, uint8_t *status); 885 886 /** @brief Bind an application to a SIG model on the target node. 887 * 888 * This method can be used asynchronously by setting @p status 889 * as NULL. This way the method will not wait for response and will 890 * return immediately after sending the command. 891 * 892 * @param net_idx Network index to encrypt with. 893 * @param addr Target node address. 894 * @param elem_addr Element address the model is in. 895 * @param mod_app_idx Application index to bind. 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_cli_mod_app_bind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 902 uint16_t mod_app_idx, uint16_t mod_id, uint8_t *status); 903 904 /** @brief Unbind an application from a SIG model on the target node. 905 * 906 * This method can be used asynchronously by setting @p status 907 * as NULL. This way the method will not wait for response and will 908 * return immediately after sending the command. 909 * 910 * @param net_idx Network index to encrypt with. 911 * @param addr Target node address. 912 * @param elem_addr Element address the model is in. 913 * @param mod_app_idx Application index to unbind. 914 * @param mod_id Model ID. 915 * @param status Status response parameter. 916 * 917 * @return 0 on success, or (negative) error code on failure. 918 */ 919 int bt_mesh_cfg_cli_mod_app_unbind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 920 uint16_t mod_app_idx, uint16_t mod_id, uint8_t *status); 921 922 /** @brief Bind an application to a vendor model on the target node. 923 * 924 * This method can be used asynchronously by setting @p status 925 * as NULL. This way the method will not wait for response and will 926 * return immediately after sending the command. 927 * 928 * @param net_idx Network index to encrypt with. 929 * @param addr Target node address. 930 * @param elem_addr Element address the model is in. 931 * @param mod_app_idx Application index to bind. 932 * @param mod_id Model ID. 933 * @param cid Company ID of the model. 934 * @param status Status response parameter. 935 * 936 * @return 0 on success, or (negative) error code on failure. 937 */ 938 int bt_mesh_cfg_cli_mod_app_bind_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 939 uint16_t mod_app_idx, uint16_t mod_id, uint16_t cid, 940 uint8_t *status); 941 942 /** @brief Unbind an application from a vendor model on the target node. 943 * 944 * This method can be used asynchronously by setting @p status 945 * as NULL. This way the method will not wait for response and will 946 * return immediately after sending the command. 947 * 948 * @param net_idx Network index to encrypt with. 949 * @param addr Target node address. 950 * @param elem_addr Element address the model is in. 951 * @param mod_app_idx Application index to unbind. 952 * @param mod_id Model ID. 953 * @param cid Company ID of the model. 954 * @param status Status response parameter. 955 * 956 * @return 0 on success, or (negative) error code on failure. 957 */ 958 int bt_mesh_cfg_cli_mod_app_unbind_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 959 uint16_t mod_app_idx, uint16_t mod_id, uint16_t cid, 960 uint8_t *status); 961 962 /** @brief Get a list of all applications bound to a SIG model on the target 963 * node. 964 * 965 * This method can be used asynchronously by setting @p status 966 * and ( @p apps or @p app_cnt ) as NULL. This way the method will 967 * not wait for response and will return immediately after sending the command. 968 * 969 * @param net_idx Network index to encrypt with. 970 * @param addr Target node address. 971 * @param elem_addr Element address the model is in. 972 * @param mod_id Model ID. 973 * @param status Status response parameter. 974 * @param apps App index list response parameter. Will be filled with all 975 * the returned application key indexes it can fill. 976 * @param app_cnt App index list length. Should be set to the capacity of the 977 * @c apps list when calling. Will return the number of 978 * returned application key indexes upon success. 979 * 980 * @return 0 on success, or (negative) error code on failure. 981 */ 982 int bt_mesh_cfg_cli_mod_app_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 983 uint16_t mod_id, uint8_t *status, uint16_t *apps, size_t *app_cnt); 984 985 /** @brief Get a list of all applications bound to a vendor model on the target 986 * node. 987 * 988 * This method can be used asynchronously by setting @p status 989 * and ( @p apps or @p app_cnt ) as NULL. This way the method will 990 * not wait for response and will return immediately after sending the command. 991 * 992 * @param net_idx Network index to encrypt with. 993 * @param addr Target node address. 994 * @param elem_addr Element address the model is in. 995 * @param mod_id Model ID. 996 * @param cid Company ID of the model. 997 * @param status Status response parameter. 998 * @param apps App index list response parameter. Will be filled with all 999 * the returned application key indexes it can fill. 1000 * @param app_cnt App index list length. Should be set to the capacity of the 1001 * @c apps list when calling. Will return the number of 1002 * returned application key indexes upon success. 1003 * 1004 * @return 0 on success, or (negative) error code on failure. 1005 */ 1006 int bt_mesh_cfg_cli_mod_app_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1007 uint16_t mod_id, uint16_t cid, uint8_t *status, uint16_t *apps, 1008 size_t *app_cnt); 1009 1010 /** @brief Get publish parameters for a SIG model on the target node. 1011 * 1012 * This method can be used asynchronously by setting @p status and 1013 * @p pub as NULL. This way the method will not wait for response 1014 * and will return immediately after sending the command. 1015 * 1016 * @param net_idx Network index to encrypt with. 1017 * @param addr Target node address. 1018 * @param elem_addr Element address the model is in. 1019 * @param mod_id Model ID. 1020 * @param pub Publication parameter return buffer. 1021 * @param status Status response parameter. 1022 * 1023 * @return 0 on success, or (negative) error code on failure. 1024 */ 1025 int bt_mesh_cfg_cli_mod_pub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1026 uint16_t mod_id, struct bt_mesh_cfg_cli_mod_pub *pub, 1027 uint8_t *status); 1028 1029 /** @brief Get publish parameters for a vendor model on the target node. 1030 * 1031 * This method can be used asynchronously by setting @p status 1032 * and @p pub as NULL. This way the method will not wait for response 1033 * and will return immediately after sending the command. 1034 * 1035 * @param net_idx Network index to encrypt with. 1036 * @param addr Target node address. 1037 * @param elem_addr Element address the model is in. 1038 * @param mod_id Model ID. 1039 * @param cid Company ID of the model. 1040 * @param pub Publication parameter return buffer. 1041 * @param status Status response parameter. 1042 * 1043 * @return 0 on success, or (negative) error code on failure. 1044 */ 1045 int bt_mesh_cfg_cli_mod_pub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1046 uint16_t mod_id, uint16_t cid, 1047 struct bt_mesh_cfg_cli_mod_pub *pub, uint8_t *status); 1048 1049 /** @brief Set publish parameters for a SIG model on the target node. 1050 * 1051 * This method can be used asynchronously by setting @p status 1052 * as NULL. This way the method will not wait for response 1053 * and will return immediately after sending the command. 1054 * 1055 * @p pub shall not be NULL. 1056 * 1057 * @param net_idx Network index to encrypt with. 1058 * @param addr Target node address. 1059 * @param elem_addr Element address the model is in. 1060 * @param mod_id Model ID. 1061 * @param pub Publication parameters. 1062 * @param status Status response parameter. 1063 * 1064 * @return 0 on success, or (negative) error code on failure. 1065 */ 1066 int bt_mesh_cfg_cli_mod_pub_set(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1067 uint16_t mod_id, struct bt_mesh_cfg_cli_mod_pub *pub, 1068 uint8_t *status); 1069 1070 /** @brief Set publish parameters for a vendor model on the target node. 1071 * 1072 * This method can be used asynchronously by setting @p status 1073 * as NULL. This way the method will not wait for response 1074 * and will return immediately after sending the command. 1075 * 1076 * @p pub shall not be NULL. 1077 * 1078 * @param net_idx Network index to encrypt with. 1079 * @param addr Target node address. 1080 * @param elem_addr Element address the model is in. 1081 * @param mod_id Model ID. 1082 * @param cid Company ID of the model. 1083 * @param pub Publication parameters. 1084 * @param status Status response parameter. 1085 * 1086 * @return 0 on success, or (negative) error code on failure. 1087 */ 1088 int bt_mesh_cfg_cli_mod_pub_set_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1089 uint16_t mod_id, uint16_t cid, 1090 struct bt_mesh_cfg_cli_mod_pub *pub, uint8_t *status); 1091 1092 /** @brief Add a group address to a SIG model's subscription list. 1093 * 1094 * This method can be used asynchronously by setting @p status 1095 * as NULL. This way the method will not wait for response 1096 * and will return immediately after sending the command. 1097 * 1098 * @param net_idx Network index to encrypt with. 1099 * @param addr Target node address. 1100 * @param elem_addr Element address the model is in. 1101 * @param sub_addr Group address to add to the subscription list. 1102 * @param mod_id Model ID. 1103 * @param status Status response parameter. 1104 * 1105 * @return 0 on success, or (negative) error code on failure. 1106 */ 1107 int bt_mesh_cfg_cli_mod_sub_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1108 uint16_t sub_addr, uint16_t mod_id, uint8_t *status); 1109 1110 /** @brief Add a group address to a vendor model's subscription list. 1111 * 1112 * This method can be used asynchronously by setting @p status 1113 * as NULL. This way the method will not wait for response 1114 * and will return immediately after sending the command. 1115 * 1116 * @param net_idx Network index to encrypt with. 1117 * @param addr Target node address. 1118 * @param elem_addr Element address the model is in. 1119 * @param sub_addr Group address to add to the subscription list. 1120 * @param mod_id Model ID. 1121 * @param cid Company ID of the model. 1122 * @param status Status response parameter. 1123 * 1124 * @return 0 on success, or (negative) error code on failure. 1125 */ 1126 int bt_mesh_cfg_cli_mod_sub_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1127 uint16_t sub_addr, uint16_t mod_id, uint16_t cid, 1128 uint8_t *status); 1129 1130 /** @brief Delete a group address in a SIG model's subscription list. 1131 * 1132 * This method can be used asynchronously by setting @p status 1133 * as NULL. This way the method will not wait for response 1134 * and will return immediately after sending the command. 1135 * 1136 * @param net_idx Network index to encrypt with. 1137 * @param addr Target node address. 1138 * @param elem_addr Element address the model is in. 1139 * @param sub_addr Group address to add to the subscription list. 1140 * @param mod_id Model ID. 1141 * @param status Status response parameter. 1142 * 1143 * @return 0 on success, or (negative) error code on failure. 1144 */ 1145 int bt_mesh_cfg_cli_mod_sub_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1146 uint16_t sub_addr, uint16_t mod_id, uint8_t *status); 1147 1148 /** @brief Delete a group address in a vendor model's subscription list. 1149 * 1150 * This method can be used asynchronously by setting @p status 1151 * as NULL. This way the method will not wait for response 1152 * and will return immediately after sending the command. 1153 * 1154 * @param net_idx Network index to encrypt with. 1155 * @param addr Target node address. 1156 * @param elem_addr Element address the model is in. 1157 * @param sub_addr Group address to add to the subscription list. 1158 * @param mod_id Model ID. 1159 * @param cid Company ID of the model. 1160 * @param status Status response parameter. 1161 * 1162 * @return 0 on success, or (negative) error code on failure. 1163 */ 1164 int bt_mesh_cfg_cli_mod_sub_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1165 uint16_t sub_addr, uint16_t mod_id, uint16_t cid, 1166 uint8_t *status); 1167 1168 /** @brief Overwrite all addresses in a SIG model's subscription list with a 1169 * group address. 1170 * 1171 * Deletes all subscriptions in the model's subscription list, and adds a 1172 * single group address instead. 1173 * 1174 * This method can be used asynchronously by setting @p status 1175 * as NULL. This way the method will not wait for response 1176 * and will return immediately after sending the command. 1177 * 1178 * @param net_idx Network index to encrypt with. 1179 * @param addr Target node address. 1180 * @param elem_addr Element address the model is in. 1181 * @param sub_addr Group address to add to the subscription list. 1182 * @param mod_id Model ID. 1183 * @param status Status response parameter. 1184 * 1185 * @return 0 on success, or (negative) error code on failure. 1186 */ 1187 int bt_mesh_cfg_cli_mod_sub_overwrite(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1188 uint16_t sub_addr, uint16_t mod_id, uint8_t *status); 1189 1190 /** @brief Overwrite all addresses in a vendor model's subscription list with a 1191 * group address. 1192 * 1193 * Deletes all subscriptions in the model's subscription list, and adds a 1194 * single group address instead. 1195 * 1196 * This method can be used asynchronously by setting @p status 1197 * as NULL. This way the method will not wait for response 1198 * and will return immediately after sending the command. 1199 * 1200 * @param net_idx Network index to encrypt with. 1201 * @param addr Target node address. 1202 * @param elem_addr Element address the model is in. 1203 * @param sub_addr Group address to add to the subscription list. 1204 * @param mod_id Model ID. 1205 * @param cid Company ID of the model. 1206 * @param status Status response parameter. 1207 * 1208 * @return 0 on success, or (negative) error code on failure. 1209 */ 1210 int bt_mesh_cfg_cli_mod_sub_overwrite_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1211 uint16_t sub_addr, uint16_t mod_id, uint16_t cid, 1212 uint8_t *status); 1213 1214 /** @brief Add a virtual address to a SIG model's subscription list. 1215 * 1216 * This method can be used asynchronously by setting @p status 1217 * and @p virt_addr as NULL. This way the method will not wait 1218 * for response and will return immediately after sending the command. 1219 * 1220 * @param net_idx Network index to encrypt with. 1221 * @param addr Target node address. 1222 * @param elem_addr Element address the model is in. 1223 * @param label Virtual address label to add to the subscription list. 1224 * @param mod_id Model ID. 1225 * @param virt_addr Virtual address response parameter. 1226 * @param status Status response parameter. 1227 * 1228 * @return 0 on success, or (negative) error code on failure. 1229 */ 1230 int bt_mesh_cfg_cli_mod_sub_va_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1231 const uint8_t label[16], uint16_t mod_id, uint16_t *virt_addr, 1232 uint8_t *status); 1233 1234 /** @brief Add a virtual address to a vendor model's subscription list. 1235 * 1236 * This method can be used asynchronously by setting @p status 1237 * and @p virt_addr as NULL. This way the method will not wait 1238 * for response and will return immediately after sending the command. 1239 * 1240 * @param net_idx Network index to encrypt with. 1241 * @param addr Target node address. 1242 * @param elem_addr Element address the model is in. 1243 * @param label Virtual address label to add to the subscription list. 1244 * @param mod_id Model ID. 1245 * @param cid Company ID of the model. 1246 * @param virt_addr Virtual address response parameter. 1247 * @param status Status response parameter. 1248 * 1249 * @return 0 on success, or (negative) error code on failure. 1250 */ 1251 int bt_mesh_cfg_cli_mod_sub_va_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1252 const uint8_t label[16], uint16_t mod_id, uint16_t cid, 1253 uint16_t *virt_addr, uint8_t *status); 1254 1255 /** @brief Delete a virtual address in a SIG model's subscription list. 1256 * 1257 * This method can be used asynchronously by setting @p status 1258 * and @p virt_addr as NULL. This way the method will not wait 1259 * for response and will return immediately after sending the command. 1260 * 1261 * @param net_idx Network index to encrypt with. 1262 * @param addr Target node address. 1263 * @param elem_addr Element address the model is in. 1264 * @param label Virtual address parameter to add to the subscription list. 1265 * @param mod_id Model ID. 1266 * @param virt_addr Virtual address response parameter. 1267 * @param status Status response parameter. 1268 * 1269 * @return 0 on success, or (negative) error code on failure. 1270 */ 1271 int bt_mesh_cfg_cli_mod_sub_va_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1272 const uint8_t label[16], uint16_t mod_id, uint16_t *virt_addr, 1273 uint8_t *status); 1274 1275 /** @brief Delete a virtual address in a vendor model's subscription list. 1276 * 1277 * This method can be used asynchronously by setting @p status 1278 * and @p virt_addr as NULL. This way the method will not wait 1279 * for response and will return immediately after sending the command. 1280 * 1281 * @param net_idx Network index to encrypt with. 1282 * @param addr Target node address. 1283 * @param elem_addr Element address the model is in. 1284 * @param label Virtual address label to add to the subscription list. 1285 * @param mod_id Model ID. 1286 * @param cid Company ID of the model. 1287 * @param virt_addr Virtual address response parameter. 1288 * @param status Status response parameter. 1289 * 1290 * @return 0 on success, or (negative) error code on failure. 1291 */ 1292 int bt_mesh_cfg_cli_mod_sub_va_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1293 const uint8_t label[16], uint16_t mod_id, uint16_t cid, 1294 uint16_t *virt_addr, uint8_t *status); 1295 1296 /** @brief Overwrite all addresses in a SIG model's subscription list with a 1297 * virtual address. 1298 * 1299 * Deletes all subscriptions in the model's subscription list, and adds a 1300 * single group address instead. 1301 * 1302 * This method can be used asynchronously by setting @p status 1303 * and @p virt_addr as NULL. This way the method will not wait 1304 * for response and will return immediately after sending the command. 1305 * 1306 * @param net_idx Network index to encrypt with. 1307 * @param addr Target node address. 1308 * @param elem_addr Element address the model is in. 1309 * @param label Virtual address label to add to the subscription list. 1310 * @param mod_id Model ID. 1311 * @param virt_addr Virtual address response parameter. 1312 * @param status Status response parameter. 1313 * 1314 * @return 0 on success, or (negative) error code on failure. 1315 */ 1316 int bt_mesh_cfg_cli_mod_sub_va_overwrite(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1317 const uint8_t label[16], uint16_t mod_id, 1318 uint16_t *virt_addr, uint8_t *status); 1319 1320 /** @brief Overwrite all addresses in a vendor model's subscription list with a 1321 * virtual address. 1322 * 1323 * Deletes all subscriptions in the model's subscription list, and adds a 1324 * single group address instead. 1325 * 1326 * This method can be used asynchronously by setting @p status 1327 * and @p virt_addr as NULL. This way the method will not wait 1328 * for response and will return immediately after sending the command. 1329 * 1330 * @param net_idx Network index to encrypt with. 1331 * @param addr Target node address. 1332 * @param elem_addr Element address the model is in. 1333 * @param label Virtual address label to add to the subscription list. 1334 * @param mod_id Model ID. 1335 * @param cid Company ID of the model. 1336 * @param virt_addr Virtual address response parameter. 1337 * @param status Status response parameter. 1338 * 1339 * @return 0 on success, or (negative) error code on failure. 1340 */ 1341 int bt_mesh_cfg_cli_mod_sub_va_overwrite_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1342 const uint8_t label[16], uint16_t mod_id, uint16_t cid, 1343 uint16_t *virt_addr, uint8_t *status); 1344 1345 /** @brief Get the subscription list of a SIG model on the target node. 1346 * 1347 * This method can be used asynchronously by setting @p status and 1348 * ( @p subs or @p sub_cnt ) as NULL. This way the method will 1349 * not wait for response and will return immediately after sending the command. 1350 * 1351 * @param net_idx Network index to encrypt with. 1352 * @param addr Target node address. 1353 * @param elem_addr Element address the model is in. 1354 * @param mod_id Model ID. 1355 * @param status Status response parameter. 1356 * @param subs Subscription list response parameter. Will be filled with 1357 * all the returned subscriptions it can fill. 1358 * @param sub_cnt Subscription list element count. Should be set to the 1359 * capacity of the @c subs list when calling. Will return the 1360 * number of returned subscriptions upon success. 1361 * 1362 * @return 0 on success, or (negative) error code on failure. 1363 */ 1364 int bt_mesh_cfg_cli_mod_sub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1365 uint16_t mod_id, uint8_t *status, uint16_t *subs, size_t *sub_cnt); 1366 1367 /** @brief Get the subscription list of a vendor model on the target node. 1368 * 1369 * This method can be used asynchronously by setting @p status and 1370 * ( @p subs or @p sub_cnt ) as NULL. This way the method will 1371 * not wait for response and will return immediately after sending the command. 1372 * 1373 * @param net_idx Network index to encrypt with. 1374 * @param addr Target node address. 1375 * @param elem_addr Element address the model is in. 1376 * @param mod_id Model ID. 1377 * @param cid Company ID of the model. 1378 * @param status Status response parameter. 1379 * @param subs Subscription list response parameter. Will be filled with 1380 * all the returned subscriptions it can fill. 1381 * @param sub_cnt Subscription list element count. Should be set to the 1382 * capacity of the @c subs list when calling. Will return the 1383 * number of returned subscriptions upon success. 1384 * 1385 * @return 0 on success, or (negative) error code on failure. 1386 */ 1387 int bt_mesh_cfg_cli_mod_sub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1388 uint16_t mod_id, uint16_t cid, uint8_t *status, uint16_t *subs, 1389 size_t *sub_cnt); 1390 1391 /** @brief Set the target node's Heartbeat subscription parameters. 1392 * 1393 * This method can be used asynchronously by setting @p status 1394 * as NULL. This way the method will not wait for response 1395 * and will return immediately after sending the command. 1396 * 1397 * @p sub shall not be null. 1398 * 1399 * @param net_idx Network index to encrypt with. 1400 * @param addr Target node address. 1401 * @param sub New Heartbeat subscription parameters. 1402 * @param status Status response parameter. 1403 * 1404 * @return 0 on success, or (negative) error code on failure. 1405 */ 1406 int bt_mesh_cfg_cli_hb_sub_set(uint16_t net_idx, uint16_t addr, struct bt_mesh_cfg_cli_hb_sub *sub, 1407 uint8_t *status); 1408 1409 /** @brief Get the target node's Heartbeat subscription parameters. 1410 * 1411 * This method can be used asynchronously by setting @p status 1412 * and @p sub as NULL. This way the method will not wait for response 1413 * and will return immediately after sending the command. 1414 * 1415 * @param net_idx Network index to encrypt with. 1416 * @param addr Target node address. 1417 * @param sub Heartbeat subscription parameter return buffer. 1418 * @param status Status response parameter. 1419 * 1420 * @return 0 on success, or (negative) error code on failure. 1421 */ 1422 int bt_mesh_cfg_cli_hb_sub_get(uint16_t net_idx, uint16_t addr, struct bt_mesh_cfg_cli_hb_sub *sub, 1423 uint8_t *status); 1424 1425 /** @brief Set the target node's Heartbeat publication parameters. 1426 * 1427 * @note The target node must already have received the specified network key. 1428 * 1429 * This method can be used asynchronously by setting @p status 1430 * as NULL. This way the method will not wait for response 1431 * and will return immediately after sending the command. 1432 * 1433 * @p pub shall not be NULL; 1434 * 1435 * @param net_idx Network index to encrypt with. 1436 * @param addr Target node address. 1437 * @param pub New Heartbeat publication parameters. 1438 * @param status Status response parameter. 1439 * 1440 * @return 0 on success, or (negative) error code on failure. 1441 */ 1442 int bt_mesh_cfg_cli_hb_pub_set(uint16_t net_idx, uint16_t addr, 1443 const struct bt_mesh_cfg_cli_hb_pub *pub, uint8_t *status); 1444 1445 /** @brief Get the target node's Heartbeat publication parameters. 1446 * 1447 * This method can be used asynchronously by setting @p status 1448 * and @p pub as NULL. This way the method will not wait for response 1449 * and will return immediately after sending the command. 1450 * 1451 * @param net_idx Network index to encrypt with. 1452 * @param addr Target node address. 1453 * @param pub Heartbeat publication parameter return buffer. 1454 * @param status Status response parameter. 1455 * 1456 * @return 0 on success, or (negative) error code on failure. 1457 */ 1458 int bt_mesh_cfg_cli_hb_pub_get(uint16_t net_idx, uint16_t addr, struct bt_mesh_cfg_cli_hb_pub *pub, 1459 uint8_t *status); 1460 1461 /** @brief Delete all group addresses in a SIG model's subscription list. 1462 * 1463 * This method can be used asynchronously by setting @p status 1464 * as NULL. This way the method will not wait for response 1465 * and will return immediately after sending the command. 1466 * 1467 * @param net_idx Network index to encrypt with. 1468 * @param addr Target node address. 1469 * @param elem_addr Element address the model is in. 1470 * @param mod_id Model ID. 1471 * @param status Status response parameter. 1472 * 1473 * @return 0 on success, or (negative) error code on failure. 1474 */ 1475 int bt_mesh_cfg_cli_mod_sub_del_all(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1476 uint16_t mod_id, uint8_t *status); 1477 1478 /** @brief Delete all group addresses in a vendor model's subscription list. 1479 * 1480 * This method can be used asynchronously by setting @p status 1481 * as NULL. This way the method will not wait for response 1482 * and will return immediately after sending the command. 1483 * 1484 * @param net_idx Network index to encrypt with. 1485 * @param addr Target node address. 1486 * @param elem_addr Element address the model is in. 1487 * @param mod_id Model ID. 1488 * @param cid Company ID of the model. 1489 * @param status Status response parameter. 1490 * 1491 * @return 0 on success, or (negative) error code on failure. 1492 */ 1493 int bt_mesh_cfg_cli_mod_sub_del_all_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, 1494 uint16_t mod_id, uint16_t cid, uint8_t *status); 1495 1496 /** @brief Update a network key to the target node. 1497 * 1498 * This method can be used asynchronously by setting @p status 1499 * as NULL. This way the method will not wait for response 1500 * and will return immediately after sending the command. 1501 * 1502 * @param net_idx Network index to encrypt with. 1503 * @param addr Target node address. 1504 * @param key_net_idx Network key index. 1505 * @param net_key Network key. 1506 * @param status Status response parameter. 1507 * 1508 * @return 0 on success, or (negative) error code on failure. 1509 */ 1510 int bt_mesh_cfg_cli_net_key_update(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, 1511 const uint8_t net_key[16], uint8_t *status); 1512 1513 /** @brief Update an application key to the target node. 1514 * 1515 * This method can be used asynchronously by setting @p status 1516 * as NULL. This way the method will not wait for response 1517 * and will return immediately after sending the command. 1518 * 1519 * @param net_idx Network index to encrypt with. 1520 * @param addr Target node address. 1521 * @param key_net_idx Network key index the application key belongs to. 1522 * @param key_app_idx Application key index. 1523 * @param app_key Application key. 1524 * @param status Status response parameter. 1525 * 1526 * @return 0 on success, or (negative) error code on failure. 1527 */ 1528 int bt_mesh_cfg_cli_app_key_update(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, 1529 uint16_t key_app_idx, const uint8_t app_key[16], 1530 uint8_t *status); 1531 1532 /** @brief Set the Node Identity parameters. 1533 * 1534 * This method can be used asynchronously by setting @p status 1535 * and @p identity as NULL. This way the method will not wait 1536 * for response and will return immediately after sending the command. 1537 * 1538 * @param net_idx Network index to encrypt with. 1539 * @param addr Target node address. 1540 * @param new_identity New identity state. Must be one of 1541 * @ref BT_MESH_NODE_IDENTITY_STOPPED or 1542 * @ref BT_MESH_NODE_IDENTITY_RUNNING 1543 * @param key_net_idx Network key index the application key belongs to. 1544 * @param status Status response parameter. 1545 * @param identity Identity response parameter. 1546 * 1547 * @return 0 on success, or (negative) error code on failure. 1548 */ 1549 int bt_mesh_cfg_cli_node_identity_set(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, 1550 uint8_t new_identity, uint8_t *status, uint8_t *identity); 1551 1552 /** @brief Get the Node Identity parameters. 1553 * 1554 * This method can be used asynchronously by setting @p status 1555 * and @p identity as NULL. This way the method will not wait 1556 * for response and will return immediately after sending the command. 1557 * 1558 * @param net_idx Network index to encrypt with. 1559 * @param addr Target node address. 1560 * @param key_net_idx Network key index the application key belongs to. 1561 * @param status Status response parameter. 1562 * @param identity Identity response parameter. Must be one of 1563 * @ref BT_MESH_NODE_IDENTITY_STOPPED or 1564 * @ref BT_MESH_NODE_IDENTITY_RUNNING 1565 * 1566 * @return 0 on success, or (negative) error code on failure. 1567 */ 1568 int bt_mesh_cfg_cli_node_identity_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, 1569 uint8_t *status, uint8_t *identity); 1570 1571 /** @brief Get the Low Power Node Polltimeout parameters. 1572 * 1573 * This method can be used asynchronously by setting @p polltimeout 1574 * as NULL. This way the method will not wait for response 1575 * and will return immediately after sending the command. 1576 * 1577 * @param net_idx Network index to encrypt with. 1578 * @param addr Target node address. 1579 * @param unicast_addr LPN unicast address. 1580 * @param polltimeout Poll timeout response parameter. 1581 * 1582 * @return 0 on success, or (negative) error code on failure. 1583 */ 1584 int bt_mesh_cfg_cli_lpn_timeout_get(uint16_t net_idx, uint16_t addr, uint16_t unicast_addr, 1585 int32_t *polltimeout); 1586 1587 /** @brief Get the current transmission timeout value. 1588 * 1589 * @return The configured transmission timeout in milliseconds. 1590 */ 1591 int32_t bt_mesh_cfg_cli_timeout_get(void); 1592 1593 /** @brief Set the transmission timeout value. 1594 * 1595 * @param timeout The new transmission timeout. 1596 */ 1597 void bt_mesh_cfg_cli_timeout_set(int32_t timeout); 1598 1599 /** Parsed Composition data page 0 representation. 1600 * 1601 * Should be pulled from the return buffer passed to 1602 * @ref bt_mesh_cfg_cli_comp_data_get using 1603 * @ref bt_mesh_comp_p0_get. 1604 */ 1605 struct bt_mesh_comp_p0 { 1606 /** Company ID */ 1607 uint16_t cid; 1608 /** Product ID */ 1609 uint16_t pid; 1610 /** Version ID */ 1611 uint16_t vid; 1612 /** Replay protection list size */ 1613 uint16_t crpl; 1614 /** Supported features, see @ref BT_MESH_FEAT_SUPPORTED. */ 1615 uint16_t feat; 1616 1617 struct net_buf_simple *_buf; 1618 }; 1619 1620 /** Composition data page 0 element representation */ 1621 struct bt_mesh_comp_p0_elem { 1622 /** Element location */ 1623 uint16_t loc; 1624 /** The number of SIG models in this element */ 1625 size_t nsig; 1626 /** The number of vendor models in this element */ 1627 size_t nvnd; 1628 1629 uint8_t *_buf; 1630 }; 1631 1632 /** @brief Create a composition data page 0 representation from a buffer. 1633 * 1634 * The composition data page object will take ownership over the buffer, which 1635 * should not be manipulated directly after this call. 1636 * 1637 * This function can be used in combination with @ref bt_mesh_cfg_cli_comp_data_get 1638 * to read out composition data page 0 from other devices: 1639 * 1640 * @code 1641 * NET_BUF_SIMPLE_DEFINE(buf, BT_MESH_RX_SDU_MAX); 1642 * struct bt_mesh_comp_p0 comp; 1643 * 1644 * err = bt_mesh_cfg_cli_comp_data_get(net_idx, addr, 0, &page, &buf); 1645 * if (!err) { 1646 * bt_mesh_comp_p0_get(&comp, &buf); 1647 * } 1648 * @endcode 1649 * 1650 * @param buf Network buffer containing composition data. 1651 * @param comp Composition data structure to fill. 1652 * 1653 * @return 0 on success, or (negative) error code on failure. 1654 */ 1655 int bt_mesh_comp_p0_get(struct bt_mesh_comp_p0 *comp, 1656 struct net_buf_simple *buf); 1657 1658 /** @brief Pull a composition data page 0 element from a composition data page 0 1659 * instance. 1660 * 1661 * Each call to this function will pull out a new element from the composition 1662 * data page, until all elements have been pulled. 1663 * 1664 * @param comp Composition data page 1665 * @param elem Element to fill. 1666 * 1667 * @return A pointer to @c elem on success, or NULL if no more elements could 1668 * be pulled. 1669 */ 1670 struct bt_mesh_comp_p0_elem *bt_mesh_comp_p0_elem_pull(const struct bt_mesh_comp_p0 *comp, 1671 struct bt_mesh_comp_p0_elem *elem); 1672 1673 /** @brief Get a SIG model from the given composition data page 0 element. 1674 * 1675 * @param elem Element to read the model from. 1676 * @param idx Index of the SIG model to read. 1677 * 1678 * @return The Model ID of the SIG model at the given index, or 0xffff if the 1679 * index is out of bounds. 1680 */ 1681 uint16_t bt_mesh_comp_p0_elem_mod(struct bt_mesh_comp_p0_elem *elem, int idx); 1682 1683 /** @brief Get a vendor model from the given composition data page 0 element. 1684 * 1685 * @param elem Element to read the model from. 1686 * @param idx Index of the vendor model to read. 1687 * 1688 * @return The model ID of the vendor model at the given index, or 1689 * {0xffff, 0xffff} if the index is out of bounds. 1690 */ 1691 struct bt_mesh_mod_id_vnd bt_mesh_comp_p0_elem_mod_vnd(struct bt_mesh_comp_p0_elem *elem, int idx); 1692 1693 /** Composition data page 1 element representation */ 1694 struct bt_mesh_comp_p1_elem { 1695 /** The number of SIG models in this element */ 1696 size_t nsig; 1697 /** The number of vendor models in this element */ 1698 size_t nvnd; 1699 /** Buffer containig SIG and Vendor Model Items */ 1700 struct net_buf_simple *_buf; 1701 }; 1702 1703 /** Composition data page 1 model item representation */ 1704 struct bt_mesh_comp_p1_model_item { 1705 /** Corresponding_Group_ID field indicator */ 1706 bool cor_present; 1707 /** Determines the format of Extended Model Item */ 1708 bool format; 1709 /** Number of items in Extended Model Items*/ 1710 uint8_t ext_item_cnt : 6; 1711 /** Buffer containing Extended Model Items. 1712 * If cor_present is set to 1 it starts with 1713 * Corresponding_Group_ID 1714 */ 1715 uint8_t cor_id; 1716 struct net_buf_simple *_buf; 1717 }; 1718 1719 /** Extended Model Item in short representation */ 1720 struct bt_mesh_comp_p1_item_short { 1721 /** Element address modifier */ 1722 uint8_t elem_offset : 3; 1723 /** Model Index */ 1724 uint8_t mod_item_idx : 5; 1725 }; 1726 1727 /** Extended Model Item in long representation */ 1728 struct bt_mesh_comp_p1_item_long { 1729 /** Element address modifier */ 1730 uint8_t elem_offset; 1731 /** Model Index */ 1732 uint8_t mod_item_idx; 1733 }; 1734 1735 /** Extended Model Item */ 1736 struct bt_mesh_comp_p1_ext_item { 1737 enum { SHORT, LONG } type; 1738 1739 union { 1740 /** Item in short representation */ 1741 struct bt_mesh_comp_p1_item_short short_item; 1742 /** Item in long representation */ 1743 struct bt_mesh_comp_p1_item_long long_item; 1744 }; 1745 }; 1746 1747 /** @brief Pull a Composition Data Page 1 Element from a composition data page 1 1748 * instance. 1749 * 1750 * Each call to this function will pull out a new element from the composition 1751 * data page, until all elements have been pulled. 1752 * 1753 * @param buf Composition data page 1 buffer 1754 * @param elem Element to fill. 1755 * 1756 * @return A pointer to @c elem on success, or NULL if no more elements could 1757 * be pulled. 1758 */ 1759 struct bt_mesh_comp_p1_elem *bt_mesh_comp_p1_elem_pull( 1760 struct net_buf_simple *buf, struct bt_mesh_comp_p1_elem *elem); 1761 1762 /** @brief Pull a Composition Data Page 1 Model Item from a Composition Data 1763 * Page 1 Element 1764 * 1765 * Each call to this function will pull out a new item from the Composition Data 1766 * Page 1 Element, until all items have been pulled. 1767 * 1768 * @param elem Composition data page 1 Element 1769 * @param item Model Item to fill. 1770 * 1771 * @return A pointer to @c item on success, or NULL if no more elements could 1772 * be pulled. 1773 */ 1774 struct bt_mesh_comp_p1_model_item *bt_mesh_comp_p1_item_pull( 1775 struct bt_mesh_comp_p1_elem *elem, struct bt_mesh_comp_p1_model_item *item); 1776 1777 /** @brief Pull Extended Model Item contained in Model Item 1778 * 1779 * Each call to this function will pull out a new element 1780 * from the Extended Model Item, until all elements have been pulled. 1781 * 1782 * @param item Model Item to pull Extended Model Items from 1783 * @param ext_item Extended Model Item to fill 1784 * 1785 * @return A pointer to @c ext_item on success, or NULL if item could not be pulled 1786 */ 1787 struct bt_mesh_comp_p1_ext_item *bt_mesh_comp_p1_pull_ext_item( 1788 struct bt_mesh_comp_p1_model_item *item, struct bt_mesh_comp_p1_ext_item *ext_item); 1789 1790 /** Composition data page 2 record parsing structure. */ 1791 struct bt_mesh_comp_p2_record { 1792 /** Mesh profile ID. */ 1793 uint16_t id; 1794 /** Mesh Profile Version. */ 1795 struct { 1796 /** Major version. */ 1797 uint8_t x; 1798 /** Minor version. */ 1799 uint8_t y; 1800 /** Z version. */ 1801 uint8_t z; 1802 } version; 1803 /** Element offset buffer. */ 1804 struct net_buf_simple *elem_buf; 1805 /** Additional data buffer. */ 1806 struct net_buf_simple *data_buf; 1807 }; 1808 1809 /** @brief Pull a Composition Data Page 2 Record from a composition data page 2 1810 * instance. 1811 * 1812 * Each call to this function will pull out a new element from the composition 1813 * data page, until all elements have been pulled. 1814 * 1815 * @param buf Composition data page 2 buffer 1816 * @param record Record to fill. 1817 * 1818 * @return A pointer to @c record on success, or NULL if no more elements could 1819 * be pulled. 1820 */ 1821 struct bt_mesh_comp_p2_record *bt_mesh_comp_p2_record_pull(struct net_buf_simple *buf, 1822 struct bt_mesh_comp_p2_record *record); 1823 1824 /** @brief Unpack a list of key index entries from a buffer. 1825 * 1826 * On success, @c dst_cnt is set to the amount of unpacked key index entries. 1827 * 1828 * @param buf Message buffer containing encoded AppKey or NetKey Indexes. 1829 * @param dst_arr Destination array for the unpacked list. 1830 * @param dst_cnt Size of the destination array. 1831 * 1832 * @return 0 on success. 1833 * @return -EMSGSIZE if dst_arr size is to small to parse full message. 1834 */ 1835 int bt_mesh_key_idx_unpack_list(struct net_buf_simple *buf, uint16_t *dst_arr, size_t *dst_cnt); 1836 1837 /** @cond INTERNAL_HIDDEN */ 1838 extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[]; 1839 extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb; 1840 /** @endcond */ 1841 1842 #ifdef __cplusplus 1843 } 1844 #endif 1845 /** 1846 * @} 1847 */ 1848 1849 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_CFG_CLI_H_ */ 1850