mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-01 04:20:33 +00:00
mesh: extract mesh_node_setup_default_models
This commit is contained in:
parent
6f175e0393
commit
8d6bf5eb54
@ -75,10 +75,6 @@ static void mesh_pts_dump_mesh_options(void);
|
||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||
static int provisioned;
|
||||
|
||||
static mesh_configuration_server_model_context_t mesh_configuration_server_model_context;
|
||||
|
||||
static mesh_model_t mesh_configuration_server_model;
|
||||
static mesh_model_t mesh_health_server_model;
|
||||
static mesh_model_t mesh_vendor_model;
|
||||
|
||||
static mesh_model_t mesh_generic_on_off_server_model;
|
||||
@ -605,6 +601,23 @@ static void stdin_process(char cmd){
|
||||
}
|
||||
}
|
||||
|
||||
static mesh_model_t mesh_configuration_server_model;
|
||||
static mesh_model_t mesh_health_server_model;
|
||||
|
||||
static mesh_configuration_server_model_context_t mesh_configuration_server_model_context;
|
||||
|
||||
static void mesh_node_setup_default_models(void){
|
||||
// configure Config Server
|
||||
mesh_configuration_server_model.model_identifier = mesh_model_get_model_identifier_bluetooth_sig(MESH_SIG_MODEL_ID_CONFIGURATION_SERVER);
|
||||
mesh_configuration_server_model.model_data = &mesh_configuration_server_model_context;
|
||||
mesh_configuration_server_model.operations = mesh_configuration_server_get_operations();
|
||||
mesh_element_add_model(mesh_node_get_primary_element(), &mesh_configuration_server_model);
|
||||
|
||||
// Config Health Server
|
||||
mesh_health_server_model.model_identifier = mesh_model_get_model_identifier_bluetooth_sig(MESH_SIG_MODEL_ID_HEALTH_SERVER);
|
||||
mesh_element_add_model(mesh_node_get_primary_element(), &mesh_health_server_model);
|
||||
}
|
||||
|
||||
int btstack_main(void);
|
||||
int btstack_main(void)
|
||||
{
|
||||
@ -674,29 +687,21 @@ int btstack_main(void)
|
||||
// Node Configuration
|
||||
mesh_node_init();
|
||||
|
||||
// Setup default models on primary element
|
||||
mesh_node_setup_default_models();
|
||||
|
||||
// Loc - bottom - https://www.bluetooth.com/specifications/assigned-numbers/gatt-namespace-descriptors
|
||||
mesh_node_set_element_location(mesh_node_get_primary_element(), 0x103);
|
||||
|
||||
// Setup models
|
||||
mesh_configuration_server_model.model_identifier = mesh_model_get_model_identifier_bluetooth_sig(MESH_SIG_MODEL_ID_CONFIGURATION_SERVER);
|
||||
mesh_model_reset_appkeys(&mesh_configuration_server_model);
|
||||
mesh_configuration_server_model.model_data = &mesh_configuration_server_model_context;
|
||||
mesh_configuration_server_model.operations = mesh_configuration_server_get_operations();
|
||||
mesh_element_add_model(mesh_node_get_primary_element(), &mesh_configuration_server_model);
|
||||
|
||||
mesh_health_server_model.model_identifier = mesh_model_get_model_identifier_bluetooth_sig(MESH_SIG_MODEL_ID_HEALTH_SERVER);
|
||||
mesh_model_reset_appkeys(&mesh_health_server_model);
|
||||
mesh_element_add_model(mesh_node_get_primary_element(), &mesh_health_server_model);
|
||||
|
||||
// Setup Generic On/Off model
|
||||
mesh_generic_on_off_server_model.model_identifier = mesh_model_get_model_identifier_bluetooth_sig(MESH_SIG_MODEL_ID_GENERIC_ON_OFF_SERVER);
|
||||
mesh_model_reset_appkeys(&mesh_generic_on_off_server_model);
|
||||
mesh_generic_on_off_server_model.operations = mesh_generic_on_off_server_get_operations();
|
||||
mesh_element_add_model(mesh_node_get_primary_element(), &mesh_generic_on_off_server_model);
|
||||
mesh_generic_on_off_server_model.model_data = (void *) &mesh_generic_on_off_state;
|
||||
mesh_generic_on_off_server_register_packet_handler(&mesh_generic_on_off_server_model, &mesh_state_update_message_handler);
|
||||
mesh_element_add_model(mesh_node_get_primary_element(), &mesh_generic_on_off_server_model);
|
||||
|
||||
// Setup our custom model
|
||||
mesh_vendor_model.model_identifier = mesh_model_get_model_identifier(BLUETOOTH_COMPANY_ID_BLUEKITCHEN_GMBH, MESH_BLUEKITCHEN_MODEL_ID_TEST_SERVER);
|
||||
mesh_model_reset_appkeys(&mesh_vendor_model);
|
||||
mesh_element_add_model(mesh_node_get_primary_element(), &mesh_vendor_model);
|
||||
|
||||
// Enable PROXY
|
||||
|
Loading…
x
Reference in New Issue
Block a user