mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ble_mesh: make unicast elem lookup O(1)
This commit is contained in:
parent
89e848c820
commit
77f186a7b9
@ -505,17 +505,21 @@ static struct bt_mesh_model *bt_mesh_elem_find_group(struct bt_mesh_elem *elem,
|
|||||||
|
|
||||||
struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr)
|
struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr)
|
||||||
{
|
{
|
||||||
int i;
|
u16_t index;
|
||||||
|
|
||||||
for (i = 0; i < dev_comp->elem_count; i++) {
|
if (BLE_MESH_ADDR_IS_UNICAST(addr)) {
|
||||||
struct bt_mesh_elem *elem = &dev_comp->elem[i];
|
index = (addr - dev_comp->elem[0].addr);
|
||||||
|
if (index < dev_comp->elem_count) {
|
||||||
if (BLE_MESH_ADDR_IS_GROUP(addr) ||
|
return &dev_comp->elem[index];
|
||||||
BLE_MESH_ADDR_IS_VIRTUAL(addr)) {
|
} else {
|
||||||
if (bt_mesh_elem_find_group(elem, addr)) {
|
return NULL;
|
||||||
return elem;
|
|
||||||
}
|
}
|
||||||
} else if (elem->addr == addr) {
|
}
|
||||||
|
|
||||||
|
for (index = 0; index < dev_comp->elem_count; index++) {
|
||||||
|
struct bt_mesh_elem *elem = &dev_comp->elem[index];
|
||||||
|
|
||||||
|
if (bt_mesh_elem_find_group(elem, addr)) {
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user