diff --git a/include/bluetooth/mesh/cfg_cli.h b/include/bluetooth/mesh/cfg_cli.h index d550c58e2a3..fe52babffb4 100644 --- a/include/bluetooth/mesh/cfg_cli.h +++ b/include/bluetooth/mesh/cfg_cli.h @@ -56,6 +56,10 @@ int bt_mesh_cfg_node_reset(uint16_t net_idx, uint16_t addr, bool *status); * return the largest page number it supports that is less than the requested * page index. The actual page the device responds with is returned in @c rsp. * + * This method can be used asynchronously by setting @p rsp and @p comp + * as NULL. This way the method will not wait for response and will return + * immediately after sending the command. + * * @param net_idx Network index to encrypt with. * @param addr Target node address. * @param page Composition data page, or 0xff to request the first available @@ -69,6 +73,10 @@ int bt_mesh_cfg_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page, uint8_t *rsp, struct net_buf_simple *comp); /** @brief Get the target node's network beacon state. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -81,6 +89,11 @@ int bt_mesh_cfg_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page, int bt_mesh_cfg_beacon_get(uint16_t net_idx, uint16_t addr, uint8_t *status); /** @brief Get the target node's network key refresh phase state. + * + * This method can be used asynchronously by setting @p status and @p phase + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. + * * @param net_idx Network index to encrypt with. * @param addr Target node address. * @param key_net_idx Network key index. @@ -93,6 +106,11 @@ int bt_mesh_cfg_krp_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, uint8_t *status, uint8_t *phase); /** @brief Set the target node's network key refresh phase parameters. + * + * This method can be used asynchronously by setting @p status and @p phase + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. + * * @param net_idx Network index to encrypt with. * @param addr Target node address. * @param key_net_idx Network key index. @@ -107,6 +125,10 @@ int bt_mesh_cfg_krp_set(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, uint8_t transition, uint8_t *status, uint8_t *phase); /** @brief Set the target node's network beacon state. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -121,6 +143,10 @@ int bt_mesh_cfg_krp_set(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, int bt_mesh_cfg_beacon_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status); /** @brief Get the target node's Time To Live value. + * + * This method can be used asynchronously by setting @p ttl + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -131,6 +157,10 @@ int bt_mesh_cfg_beacon_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t int bt_mesh_cfg_ttl_get(uint16_t net_idx, uint16_t addr, uint8_t *ttl); /** @brief Set the target node's Time To Live value. + * + * This method can be used asynchronously by setting @p ttl + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -142,6 +172,10 @@ int bt_mesh_cfg_ttl_get(uint16_t net_idx, uint16_t addr, uint8_t *ttl); int bt_mesh_cfg_ttl_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *ttl); /** @brief Get the target node's Friend feature status. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -154,6 +188,10 @@ int bt_mesh_cfg_ttl_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *t int bt_mesh_cfg_friend_get(uint16_t net_idx, uint16_t addr, uint8_t *status); /** @brief Set the target node's Friend feature state. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -169,6 +207,10 @@ int bt_mesh_cfg_friend_get(uint16_t net_idx, uint16_t addr, uint8_t *status); int bt_mesh_cfg_friend_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status); /** @brief Get the target node's Proxy feature state. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -182,6 +224,10 @@ int bt_mesh_cfg_friend_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t int bt_mesh_cfg_gatt_proxy_get(uint16_t net_idx, uint16_t addr, uint8_t *status); /** @brief Set the target node's Proxy feature state. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -199,6 +245,10 @@ int bt_mesh_cfg_gatt_proxy_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *status); /** @brief Get the target node's network_transmit state. + * + * This method can be used asynchronously by setting @p transmit + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -212,6 +262,10 @@ int bt_mesh_cfg_net_transmit_get(uint16_t net_idx, uint16_t addr, uint8_t *transmit); /** @brief Set the target node's network transmit parameters. + * + * This method can be used asynchronously by setting @p transmit + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -226,6 +280,10 @@ int bt_mesh_cfg_net_transmit_set(uint16_t net_idx, uint16_t addr, uint8_t val, uint8_t *transmit); /** @brief Get the target node's Relay feature state. + * + * This method can be used asynchronously by setting @p status and @p transmit + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -242,6 +300,10 @@ int bt_mesh_cfg_relay_get(uint16_t net_idx, uint16_t addr, uint8_t *status, uint8_t *transmit); /** @brief Set the target node's Relay parameters. + * + * This method can be used asynchronously by setting @p status + * and @p transmit as NULL. This way the method will not wait for + * response and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -264,6 +326,10 @@ int bt_mesh_cfg_relay_set(uint16_t net_idx, uint16_t addr, uint8_t new_relay, uint8_t new_transmit, uint8_t *status, uint8_t *transmit); /** @brief Add a network key to the target node. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -277,6 +343,10 @@ int bt_mesh_cfg_net_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_id const uint8_t net_key[16], uint8_t *status); /** @brief Get a list of the target node's network key indexes. + * + * This method can be used asynchronously by setting @p keys + * or @p key_cnt as NULL. This way the method will not wait + * for response and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -292,6 +362,10 @@ int bt_mesh_cfg_net_key_get(uint16_t net_idx, uint16_t addr, uint16_t *keys, size_t *key_cnt); /** @brief Delete a network key from the target node. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -304,6 +378,10 @@ int bt_mesh_cfg_net_key_del(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, uint8_t *status); /** @brief Add an application key to the target node. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -321,6 +399,10 @@ int bt_mesh_cfg_app_key_add(uint16_t net_idx, uint16_t addr, uint16_t key_net_id /** @brief Get a list of the target node's application key indexes for a * specific network key. * + * This method can be used asynchronously by setting @p status and + * ( @p keys or @p key_cnt ) as NULL. This way the method will not wait + * for response and will return immediately after sending the command. + * * @param net_idx Network index to encrypt with. * @param addr Target node address. * @param key_net_idx Network key index to request the app key indexes of. @@ -340,6 +422,10 @@ int bt_mesh_cfg_app_key_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_id /** @brief Delete an application key from the target node. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -353,6 +439,10 @@ int bt_mesh_cfg_app_key_del(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, uint16_t key_app_idx, uint8_t *status); /** @brief Bind an application to a SIG model on the target node. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -367,6 +457,10 @@ int bt_mesh_cfg_mod_app_bind(uint16_t net_idx, uint16_t addr, uint16_t elem_addr uint16_t mod_app_idx, uint16_t mod_id, uint8_t *status); /** @brief Unbind an application from a SIG model on the target node. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -382,6 +476,10 @@ int bt_mesh_cfg_mod_app_unbind(uint16_t net_idx, uint16_t addr, uint16_t mod_id, uint8_t *status); /** @brief Bind an application to a vendor model on the target node. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -398,6 +496,10 @@ int bt_mesh_cfg_mod_app_bind_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_ uint8_t *status); /** @brief Unbind an application from a vendor model on the target node. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -416,6 +518,10 @@ int bt_mesh_cfg_mod_app_unbind_vnd(uint16_t net_idx, uint16_t addr, /** @brief Get a list of all applications bound to a SIG model on the target * node. * + * This method can be used asynchronously by setting @p status + * and ( @p apps or @p app_cnt ) as NULL. This way the method will + * not wait for response and will return immediately after sending the command. + * * @param net_idx Network index to encrypt with. * @param addr Target node address. * @param elem_addr Element address the model is in. @@ -437,6 +543,10 @@ int bt_mesh_cfg_mod_app_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, /** @brief Get a list of all applications bound to a vendor model on the target * node. * + * This method can be used asynchronously by setting @p status + * and ( @p apps or @p app_cnt ) as NULL. This way the method will + * not wait for response and will return immediately after sending the command. + * * @param net_idx Network index to encrypt with. * @param addr Target node address. * @param elem_addr Element address the model is in. @@ -524,6 +634,10 @@ struct bt_mesh_cfg_mod_pub { }; /** @brief Get publish parameters for a SIG model on the target node. + * + * This method can be used asynchronously by setting @p status and + * @p pub as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -539,6 +653,10 @@ int bt_mesh_cfg_mod_pub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, uint8_t *status); /** @brief Get publish parameters for a vendor model on the target node. + * + * This method can be used asynchronously by setting @p status + * and @p pub as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -555,6 +673,12 @@ int bt_mesh_cfg_mod_pub_get_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_a struct bt_mesh_cfg_mod_pub *pub, uint8_t *status); /** @brief Set publish parameters for a SIG model on the target node. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. + * + * @p pub shall not be NULL. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -570,6 +694,12 @@ int bt_mesh_cfg_mod_pub_set(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, uint8_t *status); /** @brief Set publish parameters for a vendor model on the target node. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. + * + * @p pub shall not be NULL. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -586,6 +716,10 @@ int bt_mesh_cfg_mod_pub_set_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_a struct bt_mesh_cfg_mod_pub *pub, uint8_t *status); /** @brief Add a group address to a SIG model's subscription list. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -600,6 +734,10 @@ int bt_mesh_cfg_mod_sub_add(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, uint16_t sub_addr, uint16_t mod_id, uint8_t *status); /** @brief Add a group address to a vendor model's subscription list. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -616,6 +754,10 @@ int bt_mesh_cfg_mod_sub_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_a uint8_t *status); /** @brief Delete a group address in a SIG model's subscription list. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -630,6 +772,10 @@ int bt_mesh_cfg_mod_sub_del(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, uint16_t sub_addr, uint16_t mod_id, uint8_t *status); /** @brief Delete a group address in a vendor model's subscription list. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -651,6 +797,10 @@ int bt_mesh_cfg_mod_sub_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_a * Deletes all subscriptions in the model's subscription list, and adds a * single group address instead. * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. + * * @param net_idx Network index to encrypt with. * @param addr Target node address. * @param elem_addr Element address the model is in. @@ -669,6 +819,10 @@ int bt_mesh_cfg_mod_sub_overwrite(uint16_t net_idx, uint16_t addr, uint16_t elem * Deletes all subscriptions in the model's subscription list, and adds a * single group address instead. * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. + * * @param net_idx Network index to encrypt with. * @param addr Target node address. * @param elem_addr Element address the model is in. @@ -684,6 +838,10 @@ int bt_mesh_cfg_mod_sub_overwrite_vnd(uint16_t net_idx, uint16_t addr, uint16_t mod_id, uint16_t cid, uint8_t *status); /** @brief Add a virtual address to a SIG model's subscription list. + * + * This method can be used asynchronously by setting @p status + * and @p virt_addr as NULL. This way the method will not wait + * for response and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -700,6 +858,10 @@ int bt_mesh_cfg_mod_sub_va_add(uint16_t net_idx, uint16_t addr, uint16_t elem_ad uint16_t *virt_addr, uint8_t *status); /** @brief Add a virtual address to a vendor model's subscription list. + * + * This method can be used asynchronously by setting @p status + * and @p virt_addr as NULL. This way the method will not wait + * for response and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -717,6 +879,10 @@ int bt_mesh_cfg_mod_sub_va_add_vnd(uint16_t net_idx, uint16_t addr, uint16_t ele uint16_t cid, uint16_t *virt_addr, uint8_t *status); /** @brief Delete a virtual address in a SIG model's subscription list. + * + * This method can be used asynchronously by setting @p status + * and @p virt_addr as NULL. This way the method will not wait + * for response and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -733,6 +899,10 @@ int bt_mesh_cfg_mod_sub_va_del(uint16_t net_idx, uint16_t addr, uint16_t elem_ad uint16_t *virt_addr, uint8_t *status); /** @brief Delete a virtual address in a vendor model's subscription list. + * + * This method can be used asynchronously by setting @p status + * and @p virt_addr as NULL. This way the method will not wait + * for response and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -750,10 +920,14 @@ int bt_mesh_cfg_mod_sub_va_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t ele uint16_t cid, uint16_t *virt_addr, uint8_t *status); /** @brief Overwrite all addresses in a SIG model's subscription list with a - * virtual address. + * virtual address. * - * Deletes all subscriptions in the model's subscription list, and adds a - * single group address instead. + * Deletes all subscriptions in the model's subscription list, and adds a + * single group address instead. + * + * This method can be used asynchronously by setting @p status + * and @p virt_addr as NULL. This way the method will not wait + * for response and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -771,10 +945,14 @@ int bt_mesh_cfg_mod_sub_va_overwrite(uint16_t net_idx, uint16_t addr, uint8_t *status); /** @brief Overwrite all addresses in a vendor model's subscription list with a - * virtual address. + * virtual address. * - * Deletes all subscriptions in the model's subscription list, and adds a - * single group address instead. + * Deletes all subscriptions in the model's subscription list, and adds a + * single group address instead. + * + * This method can be used asynchronously by setting @p status + * and @p virt_addr as NULL. This way the method will not wait + * for response and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -793,6 +971,10 @@ int bt_mesh_cfg_mod_sub_va_overwrite_vnd(uint16_t net_idx, uint16_t addr, uint16_t *virt_addr, uint8_t *status); /** @brief Get the subscription list of a SIG model on the target node. + * + * This method can be used asynchronously by setting @p status and + * ( @p subs or @p sub_cnt ) as NULL. This way the method will + * not wait for response and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -812,6 +994,10 @@ int bt_mesh_cfg_mod_sub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, size_t *sub_cnt); /** @brief Get the subscription list of a vendor model on the target node. + * + * This method can be used asynchronously by setting @p status and + * ( @p subs or @p sub_cnt ) as NULL. This way the method will + * not wait for response and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -870,6 +1056,12 @@ struct bt_mesh_cfg_hb_sub { }; /** @brief Set the target node's Heartbeat subscription parameters. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. + * + * @p sub shall not be null. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -882,6 +1074,10 @@ int bt_mesh_cfg_hb_sub_set(uint16_t net_idx, uint16_t addr, struct bt_mesh_cfg_hb_sub *sub, uint8_t *status); /** @brief Get the target node's Heartbeta subscription parameters. + * + * This method can be used asynchronously by setting @p status + * and @p sub as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -932,6 +1128,12 @@ struct bt_mesh_cfg_hb_pub { * * @note The target node must already have received the specified network key. * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. + * + * @p pub shall not be NULL; + * * @param net_idx Network index to encrypt with. * @param addr Target node address. * @param pub New Heartbeat publication parameters. @@ -943,6 +1145,10 @@ int bt_mesh_cfg_hb_pub_set(uint16_t net_idx, uint16_t addr, const struct bt_mesh_cfg_hb_pub *pub, uint8_t *status); /** @brief Get the target node's Heartbeat publication parameters. + * + * This method can be used asynchronously by setting @p status + * and @p pub as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -955,6 +1161,10 @@ int bt_mesh_cfg_hb_pub_get(uint16_t net_idx, uint16_t addr, struct bt_mesh_cfg_hb_pub *pub, uint8_t *status); /** @brief Delete all group addresses in a SIG model's subscription list. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -969,6 +1179,10 @@ int bt_mesh_cfg_mod_sub_del_all(uint16_t net_idx, uint16_t addr, uint8_t *status); /** @brief Delete all group addresses in a vendor model's subscription list. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -984,6 +1198,10 @@ int bt_mesh_cfg_mod_sub_del_all_vnd(uint16_t net_idx, uint16_t addr, uint16_t cid, uint8_t *status); /** @brief Update a network key to the target node. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -998,6 +1216,10 @@ int bt_mesh_cfg_net_key_update(uint16_t net_idx, uint16_t addr, uint8_t *status); /** @brief Update an application key to the target node. + * + * This method can be used asynchronously by setting @p status + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -1013,6 +1235,10 @@ int bt_mesh_cfg_app_key_update(uint16_t net_idx, uint16_t addr, const uint8_t app_key[16], uint8_t *status); /** @brief Set the Node Identity parameters. + * + * This method can be used asynchronously by setting @p status + * and @p identity as NULL. This way the method will not wait + * for response and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -1030,6 +1256,10 @@ int bt_mesh_cfg_node_identity_set(uint16_t net_idx, uint16_t addr, uint8_t *status, uint8_t *identity); /** @brief Get the Node Identity parameters. + * + * This method can be used asynchronously by setting @p status + * and @p identity as NULL. This way the method will not wait + * for response and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. @@ -1046,6 +1276,10 @@ int bt_mesh_cfg_node_identity_get(uint16_t net_idx, uint16_t addr, uint8_t *identity); /** @brief Get the Low Power Node Polltimeout parameters. + * + * This method can be used asynchronously by setting @p polltimeout + * as NULL. This way the method will not wait for response + * and will return immediately after sending the command. * * @param net_idx Network index to encrypt with. * @param addr Target node address. diff --git a/include/bluetooth/mesh/health_cli.h b/include/bluetooth/mesh/health_cli.h index 2fda6f39429..c06bef05318 100644 --- a/include/bluetooth/mesh/health_cli.h +++ b/include/bluetooth/mesh/health_cli.h @@ -111,6 +111,14 @@ struct bt_mesh_health_cli { int bt_mesh_health_cli_set(struct bt_mesh_model *model); /** @brief Get the registered fault state for the given Company ID. + * + * This method can be used asynchronously by setting @p test_id + * and ( @p faults or @p fault_count ) as NULL This way the method + * will not wait for response and will return immediately after + * sending the command. + * + * To process the response arguments of an async method, register + * the @c fault_status callback in @c bt_mesh_health_cli struct. * * @see bt_mesh_health_faults * @@ -128,6 +136,14 @@ int bt_mesh_health_fault_get(uint16_t addr, uint16_t app_idx, uint16_t cid, size_t *fault_count); /** @brief Clear the registered faults for the given Company ID. + * + * This method can be used asynchronously by setting @p test_id + * and ( @p faults or @p fault_count ) as NULL This way the method + * will not wait for response and will return immediately after + * sending the command. + * + * To process the response arguments of an async method, register + * the @c fault_status callback in @c bt_mesh_health_cli struct. * * @see bt_mesh_health_faults * @@ -158,6 +174,13 @@ int bt_mesh_health_fault_clear_unack(uint16_t addr, uint16_t app_idx, uint16_t cid); /** @brief Invoke a self-test procedure for the given Company ID. + * + * This method can be used asynchronously by setting @p faults + * or @p fault_count as NULL This way the method will not wait + * for response and will return immediately after sending the command. + * + * To process the response arguments of an async method, register + * the @c fault_status callback in @c bt_mesh_health_cli struct. * * @param addr Target node element address. * @param app_idx Application index to encrypt with. @@ -194,6 +217,13 @@ int bt_mesh_health_fault_test_unack(uint16_t addr, uint16_t app_idx, * Health fast period divisor is 5, the Health server will publish with an * interval of 500 ms when a fault is registered. * + * This method can be used asynchronously by setting @p divisor + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. + * + * To process the response arguments of an async method, register + * the @c period_status callback in @c bt_mesh_health_cli struct. + * * @param addr Target node element address. * @param app_idx Application index to encrypt with. * @param divisor Health period divisor response buffer. @@ -213,6 +243,13 @@ int bt_mesh_health_period_get(uint16_t addr, uint16_t app_idx, * Health fast period divisor is 5, the Health server will publish with an * interval of 500 ms when a fault is registered. * + * This method can be used asynchronously by setting @p updated_divisor + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. + * + * To process the response arguments of an async method, register + * the @c period_status callback in @c bt_mesh_health_cli struct. + * * @param addr Target node element address. * @param app_idx Application index to encrypt with. * @param divisor New Health period divisor. @@ -237,6 +274,13 @@ int bt_mesh_health_period_set_unack(uint16_t addr, uint16_t app_idx, uint8_t divisor); /** @brief Get the current attention timer value. + * + * This method can be used asynchronously by setting @p attention + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. + * + * To process the response arguments of an async method, register + * the @c attention_status callback in @c bt_mesh_health_cli struct. * * @param addr Target node element address. * @param app_idx Application index to encrypt with. @@ -248,6 +292,13 @@ int bt_mesh_health_attention_get(uint16_t addr, uint16_t app_idx, uint8_t *attention); /** @brief Set the attention timer. + * + * This method can be used asynchronously by setting @p updated_attention + * as NULL. This way the method will not wait for response and will + * return immediately after sending the command. + * + * To process the response arguments of an async method, register + * the @c attention_status callback in @c bt_mesh_health_cli struct. * * @param addr Target node element address. * @param app_idx Application index to encrypt with. diff --git a/subsys/bluetooth/mesh/cfg_cli.c b/subsys/bluetooth/mesh/cfg_cli.c index 60cef467b01..5e41d467505 100644 --- a/subsys/bluetooth/mesh/cfg_cli.c +++ b/subsys/bluetooth/mesh/cfg_cli.c @@ -953,6 +953,11 @@ int bt_mesh_cfg_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page, return err; } + if (!rsp && !comp) { + bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&cli->ack_ctx, K_MSEC(msg_timeout)); } @@ -982,6 +987,11 @@ static int get_state_u8(uint16_t net_idx, uint16_t addr, uint32_t op, uint32_t r return err; } + if (!val) { + bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&cli->ack_ctx, K_MSEC(msg_timeout)); } @@ -1012,6 +1022,11 @@ static int set_state_u8(uint16_t net_idx, uint16_t addr, uint32_t op, uint32_t r return err; } + if (!val) { + bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&cli->ack_ctx, K_MSEC(msg_timeout)); } @@ -1052,6 +1067,11 @@ int bt_mesh_cfg_krp_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, return err; } + if (!status && !phase) { + bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&cli->ack_ctx, K_MSEC(msg_timeout)); } @@ -1087,6 +1107,11 @@ int bt_mesh_cfg_krp_set(uint16_t net_idx, uint16_t addr, uint16_t key_net_idx, return err; } + if (!status && !phase) { + bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&cli->ack_ctx, K_MSEC(msg_timeout)); } @@ -1164,10 +1189,6 @@ int bt_mesh_cfg_relay_get(uint16_t net_idx, uint16_t addr, uint8_t *status, }; int err; - if (!status || !transmit) { - return -EINVAL; - } - err = cli_prepare(¶m, OP_RELAY_STATUS, addr); if (err) { return err; @@ -1182,6 +1203,11 @@ int bt_mesh_cfg_relay_get(uint16_t net_idx, uint16_t addr, uint8_t *status, return err; } + if (!status && !transmit) { + bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&cli->ack_ctx, K_MSEC(msg_timeout)); } @@ -1217,6 +1243,11 @@ int bt_mesh_cfg_relay_set(uint16_t net_idx, uint16_t addr, uint8_t new_relay, return err; } + if (!status && !transmit) { + bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&cli->ack_ctx, K_MSEC(msg_timeout)); } @@ -1331,6 +1362,11 @@ int bt_mesh_cfg_net_key_get(uint16_t net_idx, uint16_t addr, uint16_t *keys, return err; } + if (!keys || !key_cnt) { + bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&cli->ack_ctx, K_MSEC(msg_timeout)); } @@ -1528,6 +1564,11 @@ int bt_mesh_cfg_app_key_get(uint16_t net_idx, uint16_t addr, uint16_t key_net_id return err; } + if (!status && (!keys || !key_cnt)) { + bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&cli->ack_ctx, K_MSEC(msg_timeout)); } @@ -1757,6 +1798,11 @@ static int mod_member_list_get(uint32_t op, uint32_t expect_op, uint16_t net_idx return err; } + if (!status && (!apps || !app_cnt)) { + bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&cli->ack_ctx, K_MSEC(msg_timeout)); } @@ -1969,7 +2015,7 @@ static int mod_sub_va(uint32_t op, uint16_t net_idx, uint16_t addr, uint16_t ele return err; } - if (!status) { + if (!status && !virt_addr) { bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); return 0; } @@ -2103,7 +2149,7 @@ static int mod_pub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, return err; } - if (!status) { + if (!status && !pub) { bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); return 0; } @@ -2244,6 +2290,10 @@ int bt_mesh_cfg_mod_pub_set(uint16_t net_idx, uint16_t addr, uint16_t elem_addr, uint16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, uint8_t *status) { + if (!pub) { + return -EINVAL; + } + if (pub->uuid) { return mod_pub_va_set(net_idx, addr, elem_addr, mod_id, CID_NVAL, pub, status); } else { @@ -2255,6 +2305,10 @@ int bt_mesh_cfg_mod_pub_set_vnd(uint16_t net_idx, uint16_t addr, uint16_t elem_a uint16_t mod_id, uint16_t cid, struct bt_mesh_cfg_mod_pub *pub, uint8_t *status) { + if (!pub) { + return -EINVAL; + } + if (cid == CID_NVAL) { return -EINVAL; } @@ -2282,6 +2336,10 @@ int bt_mesh_cfg_hb_sub_set(uint16_t net_idx, uint16_t addr, }; int err; + if (!sub) { + return -EINVAL; + } + err = cli_prepare(¶m, OP_HEARTBEAT_SUB_STATUS, addr); if (err) { return err; @@ -2337,7 +2395,7 @@ int bt_mesh_cfg_hb_sub_get(uint16_t net_idx, uint16_t addr, return err; } - if (!status) { + if (!status && !sub) { bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); return 0; } @@ -2360,6 +2418,10 @@ int bt_mesh_cfg_hb_pub_set(uint16_t net_idx, uint16_t addr, }; int err; + if (!pub) { + return -EINVAL; + } + err = cli_prepare(¶m, OP_HEARTBEAT_PUB_STATUS, addr); if (err) { return err; @@ -2418,7 +2480,7 @@ int bt_mesh_cfg_hb_pub_get(uint16_t net_idx, uint16_t addr, return err; } - if (!status) { + if (!status && !pub) { bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); return 0; } @@ -2460,7 +2522,7 @@ int bt_mesh_cfg_node_identity_set(uint16_t net_idx, uint16_t addr, return err; } - if (!status) { + if (!status && !identity) { bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); return 0; } @@ -2501,7 +2563,7 @@ int bt_mesh_cfg_node_identity_get(uint16_t net_idx, uint16_t addr, return err; } - if (!status) { + if (!status && !identity) { bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); return 0; } @@ -2540,6 +2602,11 @@ int bt_mesh_cfg_lpn_timeout_get(uint16_t net_idx, uint16_t addr, return err; } + if (!polltimeout) { + bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&cli->ack_ctx, K_MSEC(msg_timeout)); } diff --git a/subsys/bluetooth/mesh/health_cli.c b/subsys/bluetooth/mesh/health_cli.c index ae3bc66921d..3d85cef2c3b 100644 --- a/subsys/bluetooth/mesh/health_cli.c +++ b/subsys/bluetooth/mesh/health_cli.c @@ -66,13 +66,15 @@ static int health_fault_status(struct bt_mesh_model *model, *param->test_id = test_id; } - if (buf->len > *param->fault_count) { - BT_WARN("Got more faults than there's space for"); - } else { - *param->fault_count = buf->len; - } + if (param->faults && param->fault_count) { + if (buf->len > *param->fault_count) { + BT_WARN("Got more faults than there's space for"); + } else { + *param->fault_count = buf->len; + } - memcpy(param->faults, buf->data, *param->fault_count); + memcpy(param->faults, buf->data, *param->fault_count); + } bt_mesh_msg_ack_ctx_rx(&health_cli->ack_ctx); } @@ -131,7 +133,9 @@ static int health_period_status(struct bt_mesh_model *model, if (bt_mesh_msg_ack_ctx_match(&health_cli->ack_ctx, OP_HEALTH_PERIOD_STATUS, ctx->addr, (void **)¶m)) { - *param->divisor = divisor; + if (param->divisor) { + *param->divisor = divisor; + } bt_mesh_msg_ack_ctx_rx(&health_cli->ack_ctx); } @@ -215,6 +219,11 @@ int bt_mesh_health_attention_get(uint16_t addr, uint16_t app_idx, uint8_t *atten return err; } + if (!attention) { + bt_mesh_msg_ack_ctx_clear(&health_cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&health_cli->ack_ctx, K_MSEC(msg_timeout)); } @@ -312,6 +321,11 @@ int bt_mesh_health_period_get(uint16_t addr, uint16_t app_idx, uint8_t *divisor) return err; } + if (!divisor) { + bt_mesh_msg_ack_ctx_clear(&health_cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&health_cli->ack_ctx, K_MSEC(msg_timeout)); } @@ -418,7 +432,7 @@ int bt_mesh_health_fault_test(uint16_t addr, uint16_t app_idx, uint16_t cid, return err; } - if (!faults) { + if (!faults || !fault_count) { bt_mesh_msg_ack_ctx_clear(&health_cli->ack_ctx); return 0; } @@ -490,7 +504,7 @@ int bt_mesh_health_fault_clear(uint16_t addr, uint16_t app_idx, uint16_t cid, return err; } - if (!test_id) { + if (!test_id && (!faults || !fault_count)) { bt_mesh_msg_ack_ctx_clear(&health_cli->ack_ctx); return 0; } @@ -561,6 +575,11 @@ int bt_mesh_health_fault_get(uint16_t addr, uint16_t app_idx, uint16_t cid, return err; } + if (!test_id && (!faults || !fault_count)) { + bt_mesh_msg_ack_ctx_clear(&health_cli->ack_ctx); + return 0; + } + return bt_mesh_msg_ack_ctx_wait(&health_cli->ack_ctx, K_MSEC(msg_timeout)); }