mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ble_mesh: Remove some redundant functions
This commit is contained in:
parent
d35d765395
commit
fca4124f70
@ -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;
|
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.unicast_addr = arg->delete_node_with_addr.unicast_addr;
|
||||||
param.provisioner_delete_node_with_addr_comp.err_code =
|
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;
|
break;
|
||||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||||
#if CONFIG_BLE_MESH_FAST_PROV
|
#if CONFIG_BLE_MESH_FAST_PROV
|
||||||
|
@ -424,41 +424,6 @@ static struct bt_mesh_node *provisioner_find_node_with_uuid(const u8_t uuid[16],
|
|||||||
return NULL;
|
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])
|
int bt_mesh_provisioner_remove_node(const u8_t uuid[16])
|
||||||
{
|
{
|
||||||
struct bt_mesh_node *node = NULL;
|
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;
|
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;
|
struct bt_mesh_node *node = NULL;
|
||||||
u16_t index = 0U;
|
u16_t index = 0U;
|
||||||
@ -595,6 +560,21 @@ int bt_mesh_provisioner_delete_node_with_addr(u16_t unicast_addr)
|
|||||||
return 0;
|
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)
|
static int provisioner_check_node_index(u16_t index)
|
||||||
{
|
{
|
||||||
BT_DBG("%s", __func__);
|
BT_DBG("%s", __func__);
|
||||||
|
@ -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,
|
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);
|
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_remove_node(const u8_t uuid[16]);
|
||||||
|
|
||||||
int bt_mesh_provisioner_restore_node_name(u16_t addr, const char *name);
|
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_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);
|
int bt_mesh_provisioner_set_node_name(u16_t index, const char *name);
|
||||||
|
|
||||||
|
@ -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
|
* Unprovisioned Device Beacon when Transaction ACK for Provisioning Complete
|
||||||
* is received). So in Fast Provisioning the Provisioner should ignore this.
|
* 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");
|
BT_WARN("Device has already been provisioned");
|
||||||
return true;
|
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 */
|
/* 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");
|
BT_INFO("Provisioned before, start to provision again");
|
||||||
return 0;
|
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 */
|
/* Third: find if the device is been provisioned */
|
||||||
if (addr_cmp && (del_dev->addr_type <= BLE_MESH_ADDR_RANDOM)) {
|
if (addr_cmp && (del_dev->addr_type <= BLE_MESH_ADDR_RANDOM)) {
|
||||||
if (bt_mesh_provisioner_find_node_with_addr(&del_addr, true)) {
|
bt_mesh_provisioner_delete_node_with_dev_addr(&del_addr);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uuid_cmp) {
|
if (uuid_cmp) {
|
||||||
if (bt_mesh_provisioner_find_node_with_uuid(del_dev->uuid, true)) {
|
bt_mesh_provisioner_delete_node_with_uuid(del_dev->uuid);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user