ble_mesh: Remove some redundant functions

pull/5222/head
lly 2020-03-27 21:33:10 +08:00 zatwierdzone przez bot
rodzic f37bc1a515
commit 73804ef4d3
4 zmienionych plików z 24 dodań i 50 usunięć

Wyświetl plik

@ -1783,7 +1783,7 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
act = ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT;
param.provisioner_delete_node_with_addr_comp.unicast_addr = arg->delete_node_with_addr.unicast_addr;
param.provisioner_delete_node_with_addr_comp.err_code =
bt_mesh_provisioner_delete_node_with_addr(arg->delete_node_with_addr.unicast_addr);
bt_mesh_provisioner_delete_node_with_node_addr(arg->delete_node_with_addr.unicast_addr);
break;
#endif /* CONFIG_BLE_MESH_PROVISIONER */
#if CONFIG_BLE_MESH_FAST_PROV

Wyświetl plik

@ -424,41 +424,6 @@ static struct bt_mesh_node *provisioner_find_node_with_uuid(const u8_t uuid[16],
return NULL;
}
bool bt_mesh_provisioner_find_node_with_uuid(const u8_t uuid[16], bool reset)
{
struct bt_mesh_node *node = NULL;
u16_t index = 0U;
node = provisioner_find_node_with_uuid(uuid, &index);
if (!node) {
return false;
}
if (reset) {
provisioner_remove_node(index, true);
}
return true;
}
bool bt_mesh_provisioner_find_node_with_addr(const bt_mesh_addr_t *addr, bool reset)
{
int i;
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
if (mesh_nodes[i]) {
if (!memcmp(mesh_nodes[i]->addr, addr->val, BLE_MESH_ADDR_LEN) &&
mesh_nodes[i]->addr_type == addr->type) {
if (reset) {
provisioner_remove_node(i, true);
}
return true;
}
}
}
return false;
}
int bt_mesh_provisioner_remove_node(const u8_t uuid[16])
{
struct bt_mesh_node *node = NULL;
@ -580,7 +545,7 @@ int bt_mesh_provisioner_delete_node_with_uuid(const u8_t uuid[16])
return 0;
}
int bt_mesh_provisioner_delete_node_with_addr(u16_t unicast_addr)
int bt_mesh_provisioner_delete_node_with_node_addr(u16_t unicast_addr)
{
struct bt_mesh_node *node = NULL;
u16_t index = 0U;
@ -595,6 +560,21 @@ int bt_mesh_provisioner_delete_node_with_addr(u16_t unicast_addr)
return 0;
}
int bt_mesh_provisioner_delete_node_with_dev_addr(const bt_mesh_addr_t *addr)
{
int i;
for (i = 0; i < ARRAY_SIZE(mesh_nodes); i++) {
if (mesh_nodes[i] && mesh_nodes[i]->addr_type == addr->type &&
!memcmp(mesh_nodes[i]->addr, addr->val, BLE_MESH_ADDR_LEN)) {
return provisioner_remove_node(i, true);
}
}
BT_WARN("Node not exist, device address %s", bt_hex(addr->val, BLE_MESH_ADDR_LEN));
return -ENODEV;
}
static int provisioner_check_node_index(u16_t index)
{
BT_DBG("%s", __func__);

Wyświetl plik

@ -59,10 +59,6 @@ int bt_mesh_provisioner_provision(const bt_mesh_addr_t *addr, const u8_t uuid[16
u16_t unicast_addr, u8_t element_num, u16_t net_idx, u8_t flags,
u32_t iv_index, const u8_t dev_key[16], u16_t *index);
bool bt_mesh_provisioner_find_node_with_uuid(const u8_t uuid[16], bool reset);
bool bt_mesh_provisioner_find_node_with_addr(const bt_mesh_addr_t *addr, bool reset);
int bt_mesh_provisioner_remove_node(const u8_t uuid[16]);
int bt_mesh_provisioner_restore_node_name(u16_t addr, const char *name);
@ -75,7 +71,9 @@ struct bt_mesh_node *bt_mesh_provisioner_get_node_with_addr(u16_t unicast_addr);
int bt_mesh_provisioner_delete_node_with_uuid(const u8_t uuid[16]);
int bt_mesh_provisioner_delete_node_with_addr(u16_t unicast_addr);
int bt_mesh_provisioner_delete_node_with_node_addr(u16_t unicast_addr);
int bt_mesh_provisioner_delete_node_with_dev_addr(const bt_mesh_addr_t *addr);
int bt_mesh_provisioner_set_node_name(u16_t index, const char *name);

Wyświetl plik

@ -552,7 +552,7 @@ static bool is_unprov_dev_being_provision(const u8_t uuid[16])
* Unprovisioned Device Beacon when Transaction ACK for Provisioning Complete
* is received). So in Fast Provisioning the Provisioner should ignore this.
*/
if (bt_mesh_provisioner_find_node_with_uuid(uuid, false)) {
if (bt_mesh_provisioner_get_node_with_uuid(uuid)) {
BT_WARN("Device has already been provisioned");
return true;
}
@ -625,7 +625,7 @@ static int provisioner_check_unprov_dev_info(const u8_t uuid[16], bt_mesh_prov_b
}
/* Check if the device has already been provisioned */
if (bt_mesh_provisioner_find_node_with_uuid(uuid, false)) {
if (bt_mesh_provisioner_get_node_with_uuid(uuid)) {
BT_INFO("Provisioned before, start to provision again");
return 0;
}
@ -1063,15 +1063,11 @@ 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)) {
if (bt_mesh_provisioner_find_node_with_addr(&del_addr, true)) {
return 0;
}
bt_mesh_provisioner_delete_node_with_dev_addr(&del_addr);
}
if (uuid_cmp) {
if (bt_mesh_provisioner_find_node_with_uuid(del_dev->uuid, true)) {
return 0;
}
bt_mesh_provisioner_delete_node_with_uuid(del_dev->uuid);
}
return 0;