mesh: store element ref in model

This commit is contained in:
Matthias Ringwald 2019-06-10 22:46:33 +02:00
parent 2ea7db52ab
commit a66a8cb39b
3 changed files with 9 additions and 5 deletions

View File

@ -133,6 +133,7 @@ void mesh_element_add_model(mesh_element_t * element, mesh_model_t * mesh_model)
element->models_count_vendor++; element->models_count_vendor++;
} }
mesh_model->mid = mid_counter++; mesh_model->mid = mid_counter++;
mesh_model->element = element;
btstack_linked_list_add_tail(&element->models, (btstack_linked_item_t *) mesh_model); btstack_linked_list_add_tail(&element->models, (btstack_linked_item_t *) mesh_model);
} }

View File

@ -52,6 +52,9 @@ extern "C"
#define MESH_APPKEY_INVALID 0xffffu #define MESH_APPKEY_INVALID 0xffffu
struct mesh_model;
struct mesh_element;
typedef struct { typedef struct {
uint16_t address; uint16_t address;
uint16_t appkey_index; uint16_t appkey_index;
@ -61,9 +64,6 @@ typedef struct {
uint8_t retransmit; uint8_t retransmit;
} mesh_publication_model_t; } mesh_publication_model_t;
struct mesh_model;
typedef void (*mesh_operation_handler)(struct mesh_model * mesh_model, mesh_pdu_t * pdu); typedef void (*mesh_operation_handler)(struct mesh_model * mesh_model, mesh_pdu_t * pdu);
typedef struct { typedef struct {
@ -76,6 +76,9 @@ typedef struct mesh_model {
// linked list item // linked list item
btstack_linked_item_t item; btstack_linked_item_t item;
// element
struct mesh_element * element;
// internal model enumeration // internal model enumeration
uint16_t mid; uint16_t mid;
@ -106,7 +109,7 @@ typedef struct {
btstack_linked_list_iterator_t it; btstack_linked_list_iterator_t it;
} mesh_element_iterator_t; } mesh_element_iterator_t;
typedef struct { typedef struct mesh_element {
// linked list item // linked list item
btstack_linked_item_t item; btstack_linked_item_t item;

View File

@ -1813,5 +1813,5 @@ const static mesh_operation_t mesh_configuration_server_model_operations[] = {
}; };
const mesh_operation_t * mesh_configuration_server_get_operations(void){ const mesh_operation_t * mesh_configuration_server_get_operations(void){
return &mesh_configuration_server_model_operations; return mesh_configuration_server_model_operations;
} }