1
0
mirror of https://github.com/bluekitchen/btstack.git synced 2025-04-01 04:20:33 +00:00

mesh: deliver messages addressed to ALL_X group addresses

This commit is contained in:
Matthias Ringwald 2019-07-08 15:42:03 +02:00
parent ce90ed1aac
commit b98d42d698

@ -818,26 +818,67 @@ static void mesh_access_message_process_handler(mesh_pdu_t * pdu){
return; return;
} }
} }
} else { }
// iterate over all elements / models, check subscription list else if (mesh_network_address_group(dst)){
mesh_element_iterator_t it;
mesh_element_iterator_init(&it); // handle fixed group address
while (mesh_element_iterator_has_next(&it)){ if (dst >= 0xff00){
mesh_element_t * element = (mesh_element_t *) mesh_element_iterator_next(&it); int deliver_to_primary_element = 1;
mesh_model_iterator_t model_it; switch (dst){
mesh_model_iterator_init(&model_it, element); case MESH_ADDRESS_ALL_PROXIES:
while (mesh_model_iterator_has_next(&model_it)){ if (mesh_foundation_gatt_proxy_get() == 1){
mesh_model_t * model = mesh_model_iterator_next(&model_it); deliver_to_primary_element = 1;
if (mesh_model_contains_subscription(model, dst)){ }
break;
case MESH_ADDRESS_ALL_FRIENDS:
// TODO: not implemented
break;
case MESH_ADDRESS_ALL_RELAYS:
if (mesh_foundation_relay_get() == 1){
deliver_to_primary_element =1;
}
break;
case MESH_ADDRESS_ALL_NODES:
deliver_to_primary_element = 1;
break;
default:
break;
}
if (deliver_to_primary_element){
mesh_model_iterator_t model_it;
mesh_model_iterator_init(&model_it, &primary_element);
while (mesh_model_iterator_has_next(&model_it)){
mesh_model_t * model = mesh_model_iterator_next(&model_it);
// find opcode in table // find opcode in table
const mesh_operation_t * operation = mesh_model_lookup_operation(model, pdu); const mesh_operation_t * operation = mesh_model_lookup_operation(model, pdu);
if (operation == NULL) break; if (operation == NULL) continue;
if (mesh_access_validate_appkey_index(model, appkey_index) == 0) break; if (mesh_access_validate_appkey_index(model, appkey_index) == 0) continue;
operation->handler(model, pdu); operation->handler(model, pdu);
return; return;
} }
} }
} }
else {
// iterate over all elements / models, check subscription list
mesh_element_iterator_t it;
mesh_element_iterator_init(&it);
while (mesh_element_iterator_has_next(&it)){
mesh_element_t * element = (mesh_element_t *) mesh_element_iterator_next(&it);
mesh_model_iterator_t model_it;
mesh_model_iterator_init(&model_it, element);
while (mesh_model_iterator_has_next(&model_it)){
mesh_model_t * model = mesh_model_iterator_next(&model_it);
if (mesh_model_contains_subscription(model, dst)){
// find opcode in table
const mesh_operation_t * operation = mesh_model_lookup_operation(model, pdu);
if (operation == NULL) continue;
if (mesh_access_validate_appkey_index(model, appkey_index) == 0) continue;
operation->handler(model, pdu);
return;
}
}
}
}
} }
// operation not found -> done // operation not found -> done