ble_mesh: stack: Optimize Provisioner delete device function

Since we have provided separate functions for deleting node
information with node's unicast address, device uuid, etc.
So we update the behavior of this function, which will only
be used to delete device information which is not provisioned
or just under provisioning.
This commit is contained in:
lly 2020-09-22 16:57:16 +08:00
parent fcadbaf97c
commit 81354cf24f
3 changed files with 7 additions and 25 deletions

View file

@ -263,12 +263,11 @@ esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16],
uint16_t oob_info, uint16_t unicast_addr);
/**
* @brief Delete device from queue, reset current provisioning link and reset the node.
* @brief Delete device from queue, and reset current provisioning link with the device.
*
* @note If the device is in the queue, remove it from the queue; if the device is being
* provisioned, terminate the provisioning procedure; if the device has already
* been provisioned, reset the device. And either one of the addr or device UUID
* can be input.
* @note If the device is in the queue, remove it from the queue; if the device is
* being provisioned, terminate the provisioning procedure. Either one of the
* device address or device UUID can be used as input.
*
* @param[in] del_dev: Pointer to a struct containing the device information.
*

View file

@ -829,7 +829,7 @@ typedef enum {
ESP_BLE_MESH_PROVISIONER_PROV_COMPLETE_EVT, /*!< Provisioner provisioning done event */
ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT, /*!< Provisioner add a device to the list which contains devices that are waiting/going to be provisioned completion event */
ESP_BLE_MESH_PROVISIONER_PROV_DEV_WITH_ADDR_COMP_EVT, /*!< Provisioner start to provision an unprovisioned device completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device if it exists and remove the device from network completion event */
ESP_BLE_MESH_PROVISIONER_DELETE_DEV_COMP_EVT, /*!< Provisioner delete a device from the list, close provisioning link with the device completion event */
ESP_BLE_MESH_PROVISIONER_SET_DEV_UUID_MATCH_COMP_EVT, /*!< Provisioner set the value to be compared with part of the unprovisioned device UUID completion event */
ESP_BLE_MESH_PROVISIONER_SET_PROV_DATA_INFO_COMP_EVT, /*!< Provisioner set net_idx/flags/iv_index used for provisioning completion event */
ESP_BLE_MESH_PROVISIONER_SET_STATIC_OOB_VALUE_COMP_EVT, /*!< Provisioner set static oob value used for provisioning completion event */

View file

@ -1001,18 +1001,10 @@ int bt_mesh_provisioner_prov_device_with_addr(const u8_t uuid[16], const u8_t ad
int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev)
{
/**
* Three Situations:
* 1. device is not being/been provisioned, just remove from device queue.
* 2. device is being provisioned, need to close link & remove from device queue.
* 3. device is been provisioned, need to send config_node_reset and may need to
* remove from device queue. config _node_reset can be added in function
* provisioner_reset_node() in provisioner_main.c.
*/
bt_mesh_addr_t del_addr = {0};
u8_t zero[16] = {0};
bool addr_match = false;
bool uuid_match = false;
u8_t zero[16] = {0};
int addr_cmp = 0;
int uuid_cmp = 0;
u16_t i = 0U;
@ -1046,7 +1038,7 @@ int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev)
for (i = 0U; i < ARRAY_SIZE(link); i++) {
if (addr_cmp && (del_dev->addr_type <= BLE_MESH_ADDR_RANDOM)) {
if (!memcmp(link[i].addr.val, del_dev->addr, BLE_MESH_ADDR_LEN) &&
link[i].addr.type == del_dev->addr_type) {
link[i].addr.type == del_dev->addr_type) {
addr_match = true;
}
}
@ -1061,15 +1053,6 @@ int bt_mesh_provisioner_delete_device(struct bt_mesh_device_delete *del_dev)
}
}
/* Third: find if the device is been provisioned */
if (addr_cmp && (del_dev->addr_type <= BLE_MESH_ADDR_RANDOM)) {
bt_mesh_provisioner_delete_node_with_dev_addr(&del_addr);
}
if (uuid_cmp) {
bt_mesh_provisioner_delete_node_with_uuid(del_dev->uuid);
}
return 0;
}