mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-26 09:41:01 +00:00
mesh: add mesh_element_count and use in mesh_network
This commit is contained in:
parent
e8625ff1d4
commit
e4058622b0
@ -72,7 +72,6 @@
|
|||||||
|
|
||||||
// globals
|
// globals
|
||||||
|
|
||||||
static uint16_t mesh_network_num_elements;
|
|
||||||
static void (*mesh_network_higher_layer_handler)(mesh_network_callback_type_t callback_type, mesh_network_pdu_t * network_pdu);
|
static void (*mesh_network_higher_layer_handler)(mesh_network_callback_type_t callback_type, mesh_network_pdu_t * network_pdu);
|
||||||
static void (*mesh_network_proxy_message_handler)(mesh_network_callback_type_t callback_type, mesh_network_pdu_t * network_pdu);
|
static void (*mesh_network_proxy_message_handler)(mesh_network_callback_type_t callback_type, mesh_network_pdu_t * network_pdu);
|
||||||
|
|
||||||
@ -385,7 +384,7 @@ void mesh_network_message_processed_by_higher_layer(mesh_network_pdu_t * network
|
|||||||
|
|
||||||
uint16_t mesh_network_primary_address = mesh_node_primary_element_address_get();
|
uint16_t mesh_network_primary_address = mesh_node_primary_element_address_get();
|
||||||
|
|
||||||
if (((src < mesh_network_primary_address) || (src > (mesh_network_primary_address + mesh_network_num_elements))) && (ttl >= 2)){
|
if (((src < mesh_network_primary_address) || (src > (mesh_network_primary_address + mesh_element_count()))) && (ttl >= 2)){
|
||||||
|
|
||||||
if ((network_pdu->flags & MESH_NETWORK_PDU_FLAGS_GATT_BEARER) == 0){
|
if ((network_pdu->flags & MESH_NETWORK_PDU_FLAGS_GATT_BEARER) == 0){
|
||||||
|
|
||||||
@ -834,7 +833,6 @@ void mesh_network_init(void){
|
|||||||
gatt_bearer_register_for_network_pdu(&mesh_network_gatt_bearer_handle_network_event);
|
gatt_bearer_register_for_network_pdu(&mesh_network_gatt_bearer_handle_network_event);
|
||||||
gatt_bearer_register_for_mesh_proxy_configuration(&mesh_netework_gatt_bearer_handle_proxy_configuration);
|
gatt_bearer_register_for_mesh_proxy_configuration(&mesh_netework_gatt_bearer_handle_proxy_configuration);
|
||||||
#endif
|
#endif
|
||||||
mesh_network_num_elements = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mesh_network_set_higher_layer_handler(void (*packet_handler)(mesh_network_callback_type_t callback_type, mesh_network_pdu_t * network_pdu)){
|
void mesh_network_set_higher_layer_handler(void (*packet_handler)(mesh_network_callback_type_t callback_type, mesh_network_pdu_t * network_pdu)){
|
||||||
|
@ -67,6 +67,10 @@ void mesh_element_add(mesh_element_t * element){
|
|||||||
btstack_linked_list_add_tail(&mesh_elements, (void*) element);
|
btstack_linked_list_add_tail(&mesh_elements, (void*) element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t mesh_element_count(void){
|
||||||
|
return (uint16_t) btstack_linked_list_count(&mesh_elements);
|
||||||
|
}
|
||||||
|
|
||||||
mesh_element_t * mesh_primary_element(void){
|
mesh_element_t * mesh_primary_element(void){
|
||||||
return &primary_element;
|
return &primary_element;
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,12 @@ mesh_element_t * mesh_primary_element(void);
|
|||||||
*/
|
*/
|
||||||
void mesh_element_add(mesh_element_t * element);
|
void mesh_element_add(mesh_element_t * element);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get number elements
|
||||||
|
* @returns number of elements on this node
|
||||||
|
*/
|
||||||
|
uint16_t mesh_element_count(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get element for given unicast address
|
* @brief Get element for given unicast address
|
||||||
* @param unicast_address
|
* @param unicast_address
|
||||||
|
Loading…
x
Reference in New Issue
Block a user