Bluetooth: Mesh: Fix Config/Health Client async API

The previous PR was not fully baked, so this PR fixes issues by:
- Adding checks when dereferncing pointers stored in params.
- Clearing ack context if a return argument is NULL to not block and
wait for response.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
This commit is contained in:
Michał Narajowski 2021-12-14 15:05:43 +01:00 committed by Carles Cufí
commit ef1fcd0e82
4 changed files with 396 additions and 25 deletions

View file

@ -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 * 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. * 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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
* @param page Composition data page, or 0xff to request the first available * @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); uint8_t *rsp, struct net_buf_simple *comp);
/** @brief Get the target node's network beacon state. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); 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. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
* @param key_net_idx Network key index. * @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); uint8_t *status, uint8_t *phase);
/** @brief Set the target node's network key refresh phase parameters. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
* @param key_net_idx Network key index. * @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); uint8_t transition, uint8_t *status, uint8_t *phase);
/** @brief Set the target node's network beacon state. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); 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. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); 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. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); 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. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); 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. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); 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. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); 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. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t *status);
/** @brief Get the target node's network_transmit state. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t *transmit);
/** @brief Set the target node's network transmit parameters. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t val, uint8_t *transmit);
/** @brief Get the target node's Relay feature state. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t *transmit);
/** @brief Set the target node's Relay parameters. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t new_transmit, uint8_t *status, uint8_t *transmit);
/** @brief Add a network key to the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); const uint8_t net_key[16], uint8_t *status);
/** @brief Get a list of the target node's network key indexes. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); size_t *key_cnt);
/** @brief Delete a network key from the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint16_t key_net_idx, uint8_t *status);
/** @brief Add an application key to the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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 /** @brief Get a list of the target node's application key indexes for a
* specific network key. * 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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
* @param key_net_idx Network key index to request the app key indexes of. * @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. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); 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. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint16_t mod_app_idx, uint16_t mod_id, uint8_t *status);
/** @brief Unbind an application from a SIG model on the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint16_t mod_id, uint8_t *status);
/** @brief Bind an application to a vendor model on the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t *status);
/** @brief Unbind an application from a vendor model on the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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 /** @brief Get a list of all applications bound to a SIG model on the target
* node. * 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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
* @param elem_addr Element address the model is in. * @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 /** @brief Get a list of all applications bound to a vendor model on the target
* node. * 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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
* @param elem_addr Element address the model is in. * @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. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t *status);
/** @brief Get publish parameters for a vendor model on the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); struct bt_mesh_cfg_mod_pub *pub, uint8_t *status);
/** @brief Set publish parameters for a SIG model on the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t *status);
/** @brief Set publish parameters for a vendor model on the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); struct bt_mesh_cfg_mod_pub *pub, uint8_t *status);
/** @brief Add a group address to a SIG model's subscription list. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint16_t sub_addr, uint16_t mod_id, uint8_t *status);
/** @brief Add a group address to a vendor model's subscription list. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t *status);
/** @brief Delete a group address in a SIG model's subscription list. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint16_t sub_addr, uint16_t mod_id, uint8_t *status);
/** @brief Delete a group address in a vendor model's subscription list. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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 * Deletes all subscriptions in the model's subscription list, and adds a
* single group address instead. * 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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
* @param elem_addr Element address the model is in. * @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 * Deletes all subscriptions in the model's subscription list, and adds a
* single group address instead. * 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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
* @param elem_addr Element address the model is in. * @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); uint16_t mod_id, uint16_t cid, uint8_t *status);
/** @brief Add a virtual address to a SIG model's subscription list. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint16_t *virt_addr, uint8_t *status);
/** @brief Add a virtual address to a vendor model's subscription list. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint16_t cid, uint16_t *virt_addr, uint8_t *status);
/** @brief Delete a virtual address in a SIG model's subscription list. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint16_t *virt_addr, uint8_t *status);
/** @brief Delete a virtual address in a vendor model's subscription list. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
@ -755,6 +925,10 @@ int bt_mesh_cfg_mod_sub_va_del_vnd(uint16_t net_idx, uint16_t addr, uint16_t ele
* Deletes all subscriptions in the model's subscription list, and adds a * Deletes all subscriptions in the model's subscription list, and adds a
* single group address instead. * 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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
* @param elem_addr Element address the model is in. * @param elem_addr Element address the model is in.
@ -776,6 +950,10 @@ int bt_mesh_cfg_mod_sub_va_overwrite(uint16_t net_idx, uint16_t addr,
* Deletes all subscriptions in the model's subscription list, and adds a * Deletes all subscriptions in the model's subscription list, and adds a
* single group address instead. * 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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
* @param elem_addr Element address the model is in. * @param elem_addr Element address the model is in.
@ -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); uint16_t *virt_addr, uint8_t *status);
/** @brief Get the subscription list of a SIG model on the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); size_t *sub_cnt);
/** @brief Get the subscription list of a vendor model on the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
@ -870,6 +1056,12 @@ struct bt_mesh_cfg_hb_sub {
}; };
/** @brief Set the target node's Heartbeat subscription parameters. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); struct bt_mesh_cfg_hb_sub *sub, uint8_t *status);
/** @brief Get the target node's Heartbeta subscription parameters. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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. * @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.
* @param pub New Heartbeat publication parameters. * @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); const struct bt_mesh_cfg_hb_pub *pub, uint8_t *status);
/** @brief Get the target node's Heartbeat publication parameters. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); struct bt_mesh_cfg_hb_pub *pub, uint8_t *status);
/** @brief Delete all group addresses in a SIG model's subscription list. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t *status);
/** @brief Delete all group addresses in a vendor model's subscription list. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint16_t cid, uint8_t *status);
/** @brief Update a network key to the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t *status);
/** @brief Update an application key to the target node. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); const uint8_t app_key[16], uint8_t *status);
/** @brief Set the Node Identity parameters. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t *status, uint8_t *identity);
/** @brief Get the Node Identity parameters. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @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); uint8_t *identity);
/** @brief Get the Low Power Node Polltimeout parameters. /** @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 net_idx Network index to encrypt with.
* @param addr Target node address. * @param addr Target node address.

View file

@ -111,6 +111,14 @@ struct bt_mesh_health_cli {
int bt_mesh_health_cli_set(struct bt_mesh_model *model); int bt_mesh_health_cli_set(struct bt_mesh_model *model);
/** @brief Get the registered fault state for the given Company ID. /** @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 * @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); size_t *fault_count);
/** @brief Clear the registered faults for the given Company ID. /** @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 * @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); uint16_t cid);
/** @brief Invoke a self-test procedure for the given Company ID. /** @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 addr Target node element address.
* @param app_idx Application index to encrypt with. * @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 * Health fast period divisor is 5, the Health server will publish with an
* interval of 500 ms when a fault is registered. * 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 addr Target node element address.
* @param app_idx Application index to encrypt with. * @param app_idx Application index to encrypt with.
* @param divisor Health period divisor response buffer. * @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 * Health fast period divisor is 5, the Health server will publish with an
* interval of 500 ms when a fault is registered. * 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 addr Target node element address.
* @param app_idx Application index to encrypt with. * @param app_idx Application index to encrypt with.
* @param divisor New Health period divisor. * @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); uint8_t divisor);
/** @brief Get the current attention timer value. /** @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 addr Target node element address.
* @param app_idx Application index to encrypt with. * @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); uint8_t *attention);
/** @brief Set the attention timer. /** @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 addr Target node element address.
* @param app_idx Application index to encrypt with. * @param app_idx Application index to encrypt with.

View file

@ -953,6 +953,11 @@ int bt_mesh_cfg_comp_data_get(uint16_t net_idx, uint16_t addr, uint8_t page,
return err; 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)); 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; 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)); 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; 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)); 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; 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)); 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; 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)); 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; int err;
if (!status || !transmit) {
return -EINVAL;
}
err = cli_prepare(&param, OP_RELAY_STATUS, addr); err = cli_prepare(&param, OP_RELAY_STATUS, addr);
if (err) { if (err) {
return 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; 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)); 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; 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)); 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; 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)); 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; 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)); 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; 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)); 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; return err;
} }
if (!status) { if (!status && !virt_addr) {
bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx);
return 0; return 0;
} }
@ -2103,7 +2149,7 @@ static int mod_pub_get(uint16_t net_idx, uint16_t addr, uint16_t elem_addr,
return err; return err;
} }
if (!status) { if (!status && !pub) {
bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx);
return 0; 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, uint16_t mod_id, struct bt_mesh_cfg_mod_pub *pub,
uint8_t *status) uint8_t *status)
{ {
if (!pub) {
return -EINVAL;
}
if (pub->uuid) { if (pub->uuid) {
return mod_pub_va_set(net_idx, addr, elem_addr, mod_id, CID_NVAL, pub, status); return mod_pub_va_set(net_idx, addr, elem_addr, mod_id, CID_NVAL, pub, status);
} else { } 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, uint16_t mod_id, uint16_t cid, struct bt_mesh_cfg_mod_pub *pub,
uint8_t *status) uint8_t *status)
{ {
if (!pub) {
return -EINVAL;
}
if (cid == CID_NVAL) { if (cid == CID_NVAL) {
return -EINVAL; return -EINVAL;
} }
@ -2282,6 +2336,10 @@ int bt_mesh_cfg_hb_sub_set(uint16_t net_idx, uint16_t addr,
}; };
int err; int err;
if (!sub) {
return -EINVAL;
}
err = cli_prepare(&param, OP_HEARTBEAT_SUB_STATUS, addr); err = cli_prepare(&param, OP_HEARTBEAT_SUB_STATUS, addr);
if (err) { if (err) {
return err; return err;
@ -2337,7 +2395,7 @@ int bt_mesh_cfg_hb_sub_get(uint16_t net_idx, uint16_t addr,
return err; return err;
} }
if (!status) { if (!status && !sub) {
bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx);
return 0; return 0;
} }
@ -2360,6 +2418,10 @@ int bt_mesh_cfg_hb_pub_set(uint16_t net_idx, uint16_t addr,
}; };
int err; int err;
if (!pub) {
return -EINVAL;
}
err = cli_prepare(&param, OP_HEARTBEAT_PUB_STATUS, addr); err = cli_prepare(&param, OP_HEARTBEAT_PUB_STATUS, addr);
if (err) { if (err) {
return err; return err;
@ -2418,7 +2480,7 @@ int bt_mesh_cfg_hb_pub_get(uint16_t net_idx, uint16_t addr,
return err; return err;
} }
if (!status) { if (!status && !pub) {
bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx);
return 0; return 0;
} }
@ -2460,7 +2522,7 @@ int bt_mesh_cfg_node_identity_set(uint16_t net_idx, uint16_t addr,
return err; return err;
} }
if (!status) { if (!status && !identity) {
bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx);
return 0; return 0;
} }
@ -2501,7 +2563,7 @@ int bt_mesh_cfg_node_identity_get(uint16_t net_idx, uint16_t addr,
return err; return err;
} }
if (!status) { if (!status && !identity) {
bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx); bt_mesh_msg_ack_ctx_clear(&cli->ack_ctx);
return 0; return 0;
} }
@ -2540,6 +2602,11 @@ int bt_mesh_cfg_lpn_timeout_get(uint16_t net_idx, uint16_t addr,
return err; 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)); return bt_mesh_msg_ack_ctx_wait(&cli->ack_ctx, K_MSEC(msg_timeout));
} }

View file

@ -66,6 +66,7 @@ static int health_fault_status(struct bt_mesh_model *model,
*param->test_id = test_id; *param->test_id = test_id;
} }
if (param->faults && param->fault_count) {
if (buf->len > *param->fault_count) { if (buf->len > *param->fault_count) {
BT_WARN("Got more faults than there's space for"); BT_WARN("Got more faults than there's space for");
} else { } else {
@ -73,6 +74,7 @@ static int health_fault_status(struct bt_mesh_model *model,
} }
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); 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, if (bt_mesh_msg_ack_ctx_match(&health_cli->ack_ctx,
OP_HEALTH_PERIOD_STATUS, ctx->addr, OP_HEALTH_PERIOD_STATUS, ctx->addr,
(void **)&param)) { (void **)&param)) {
if (param->divisor) {
*param->divisor = divisor; *param->divisor = divisor;
}
bt_mesh_msg_ack_ctx_rx(&health_cli->ack_ctx); 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; 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)); 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; 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, return bt_mesh_msg_ack_ctx_wait(&health_cli->ack_ctx,
K_MSEC(msg_timeout)); 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; return err;
} }
if (!faults) { if (!faults || !fault_count) {
bt_mesh_msg_ack_ctx_clear(&health_cli->ack_ctx); bt_mesh_msg_ack_ctx_clear(&health_cli->ack_ctx);
return 0; return 0;
} }
@ -490,7 +504,7 @@ int bt_mesh_health_fault_clear(uint16_t addr, uint16_t app_idx, uint16_t cid,
return err; return err;
} }
if (!test_id) { if (!test_id && (!faults || !fault_count)) {
bt_mesh_msg_ack_ctx_clear(&health_cli->ack_ctx); bt_mesh_msg_ack_ctx_clear(&health_cli->ack_ctx);
return 0; return 0;
} }
@ -561,6 +575,11 @@ int bt_mesh_health_fault_get(uint16_t addr, uint16_t app_idx, uint16_t cid,
return err; 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)); return bt_mesh_msg_ack_ctx_wait(&health_cli->ack_ctx, K_MSEC(msg_timeout));
} }