mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
mesh: move load/store model publication to mesh from configuration server
This commit is contained in:
parent
41787a596f
commit
d4c397cd4a
@ -438,6 +438,72 @@ void mesh_delete_subscriptions(void){
|
||||
}
|
||||
}
|
||||
|
||||
// Model Publication
|
||||
|
||||
static uint32_t mesh_model_publication_tag_for_index(uint16_t internal_model_id){
|
||||
return ((uint32_t) 'M' << 24) | ((uint32_t) 'P' << 16) | ((uint32_t) internal_model_id);
|
||||
}
|
||||
|
||||
static void mesh_model_load_publication(mesh_model_t * mesh_model){
|
||||
if (mesh_model->publication_model == NULL) return;
|
||||
|
||||
uint32_t tag = mesh_model_publication_tag_for_index(mesh_model->mid);
|
||||
btstack_tlv_singleton_impl->get_tag(btstack_tlv_singleton_context, tag, (uint8_t *) &mesh_model->publication_model, sizeof(mesh_publication_model_t));
|
||||
|
||||
// increase ref counts for current virtual publicataion address
|
||||
uint16_t src = mesh_model->publication_model->address;
|
||||
if (mesh_network_address_virtual(src)){
|
||||
mesh_virtual_address_t * virtual_address = mesh_virtual_address_for_pseudo_dst(src);
|
||||
mesh_virtual_address_increase_refcount(virtual_address);
|
||||
}
|
||||
|
||||
mesh_model_publication_start(mesh_model);
|
||||
}
|
||||
|
||||
void mesh_model_store_publication(mesh_model_t * mesh_model){
|
||||
if (mesh_model->publication_model == NULL) return;
|
||||
uint32_t tag = mesh_model_publication_tag_for_index(mesh_model->mid);
|
||||
btstack_tlv_singleton_impl->store_tag(btstack_tlv_singleton_context, tag, (uint8_t *) &mesh_model->subscriptions, sizeof(mesh_publication_model_t));
|
||||
}
|
||||
|
||||
static void mesh_model_delete_publication(mesh_model_t * mesh_model){
|
||||
if (mesh_model->publication_model == NULL) return;
|
||||
uint32_t tag = mesh_model_publication_tag_for_index(mesh_model->mid);
|
||||
btstack_tlv_singleton_impl->delete_tag(btstack_tlv_singleton_context, tag);
|
||||
}
|
||||
|
||||
void mesh_load_publications(void){
|
||||
printf("Load Model Publications\n");
|
||||
// iterate over elements and models
|
||||
mesh_element_iterator_t element_it;
|
||||
mesh_element_iterator_init(&element_it);
|
||||
while (mesh_element_iterator_has_next(&element_it)){
|
||||
mesh_element_t * element = mesh_element_iterator_next(&element_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);
|
||||
mesh_model_load_publication(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mesh_delete_publications(void){
|
||||
printf("Delete Model Publications\n");
|
||||
// iterate over elements and models
|
||||
mesh_element_iterator_t element_it;
|
||||
mesh_element_iterator_init(&element_it);
|
||||
while (mesh_element_iterator_has_next(&element_it)){
|
||||
mesh_element_t * element = mesh_element_iterator_next(&element_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);
|
||||
mesh_model_delete_publication(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mesh Network Keys
|
||||
static uint32_t mesh_network_key_tag_for_internal_index(uint16_t internal_index){
|
||||
return ((uint32_t) 'M' << 24) | ((uint32_t) 'N' << 16) | ((uint32_t) internal_index);
|
||||
|
@ -79,6 +79,11 @@ void mesh_load_subscriptions(void);
|
||||
void mesh_model_store_subscriptions(mesh_model_t * model);
|
||||
void mesh_delete_subscriptions(void);
|
||||
|
||||
// Mesh Model Publication
|
||||
void mesh_load_publications(void);
|
||||
void mesh_delete_publications(void);
|
||||
void mesh_model_store_publication(mesh_model_t * mesh_model);
|
||||
|
||||
// Mesh NetKey List
|
||||
void mesh_store_network_key(mesh_network_key_t * network_key);
|
||||
void mesh_delete_network_key(uint16_t internal_index);
|
||||
|
@ -164,76 +164,6 @@ static void mesh_subcription_decrease_virtual_address_ref_count(mesh_model_t *me
|
||||
}
|
||||
}
|
||||
|
||||
// Model Publication
|
||||
|
||||
static uint32_t mesh_model_publication_tag_for_index(uint16_t internal_model_id){
|
||||
return ((uint32_t) 'M' << 24) | ((uint32_t) 'P' << 16) | ((uint32_t) internal_model_id);
|
||||
}
|
||||
|
||||
static void mesh_model_load_publication(mesh_model_t * mesh_model){
|
||||
mesh_configuration_server_setup_tlv();
|
||||
if (mesh_model->publication_model == NULL) return;
|
||||
|
||||
uint32_t tag = mesh_model_publication_tag_for_index(mesh_model->mid);
|
||||
btstack_tlv_singleton_impl->get_tag(btstack_tlv_singleton_context, tag, (uint8_t *) &mesh_model->publication_model, sizeof(mesh_publication_model_t));
|
||||
|
||||
// increase ref counts for current virtual publicataion address
|
||||
uint16_t src = mesh_model->publication_model->address;
|
||||
if (mesh_network_address_virtual(src)){
|
||||
mesh_virtual_address_t * virtual_address = mesh_virtual_address_for_pseudo_dst(src);
|
||||
mesh_virtual_address_increase_refcount(virtual_address);
|
||||
}
|
||||
|
||||
mesh_model_publication_start(mesh_model);
|
||||
}
|
||||
|
||||
static void mesh_model_store_publication(mesh_model_t * mesh_model){
|
||||
mesh_configuration_server_setup_tlv();
|
||||
if (mesh_model->publication_model == NULL) return;
|
||||
uint32_t tag = mesh_model_publication_tag_for_index(mesh_model->mid);
|
||||
btstack_tlv_singleton_impl->store_tag(btstack_tlv_singleton_context, tag, (uint8_t *) &mesh_model->subscriptions, sizeof(mesh_publication_model_t));
|
||||
}
|
||||
|
||||
static void mesh_model_delete_publication(mesh_model_t * mesh_model){
|
||||
mesh_configuration_server_setup_tlv();
|
||||
if (mesh_model->publication_model == NULL) return;
|
||||
uint32_t tag = mesh_model_publication_tag_for_index(mesh_model->mid);
|
||||
btstack_tlv_singleton_impl->delete_tag(btstack_tlv_singleton_context, tag);
|
||||
}
|
||||
|
||||
void mesh_load_publications(void){
|
||||
printf("Load Model Publications\n");
|
||||
// iterate over elements and models
|
||||
mesh_element_iterator_t element_it;
|
||||
mesh_element_iterator_init(&element_it);
|
||||
while (mesh_element_iterator_has_next(&element_it)){
|
||||
mesh_element_t * element = mesh_element_iterator_next(&element_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);
|
||||
mesh_model_load_publication(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mesh_delete_publications(void){
|
||||
printf("Delete Model Publications\n");
|
||||
mesh_configuration_server_setup_tlv();
|
||||
// iterate over elements and models
|
||||
mesh_element_iterator_t element_it;
|
||||
mesh_element_iterator_init(&element_it);
|
||||
while (mesh_element_iterator_has_next(&element_it)){
|
||||
mesh_element_t * element = mesh_element_iterator_next(&element_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);
|
||||
mesh_model_delete_publication(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AppKeys Helper
|
||||
static void mesh_configuration_server_delete_appkey(mesh_transport_key_t * transport_key){
|
||||
uint16_t appkey_index = transport_key->appkey_index;
|
||||
|
@ -83,10 +83,6 @@ typedef struct {
|
||||
const mesh_operation_t * mesh_configuration_server_get_operations(void);
|
||||
|
||||
void mesh_configuration_server_feature_changed(void);
|
||||
|
||||
void mesh_load_publications(void);
|
||||
|
||||
void mesh_delete_publications(void);
|
||||
//
|
||||
void mesh_node_reset(void);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user