From e9ea9d588d10d1542b4f3a56579fac4f81edcf79 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 12 Jul 2019 19:37:20 +0200 Subject: [PATCH] mesh: collect init code in mesh_init --- src/btstack.h | 1 + test/mesh/.gitignore | 2 +- test/mesh/mesh_pts.c | 63 ++++++++++++++++---------------------------- 3 files changed, 25 insertions(+), 41 deletions(-) diff --git a/src/btstack.h b/src/btstack.h index ab510d08c..fdbc04bfb 100644 --- a/src/btstack.h +++ b/src/btstack.h @@ -139,6 +139,7 @@ #include "mesh/mesh_upper_transport.h" #include "mesh/pb_adv.h" #include "mesh/pb_gatt.h" +#include "mesh.h" #include "mesh_access.h" #include "mesh_configuration_server.h" #include "mesh_foundation.h" diff --git a/test/mesh/.gitignore b/test/mesh/.gitignore index 0b49cd322..b96b5bfcc 100644 --- a/test/mesh/.gitignore +++ b/test/mesh/.gitignore @@ -1,4 +1,4 @@ -mesh +mesh_pts mesh_message_test mesh_provisioning_device mesh_provisioning_device.h diff --git a/test/mesh/mesh_pts.c b/test/mesh/mesh_pts.c index 610f1bcda..62e311afb 100644 --- a/test/mesh/mesh_pts.c +++ b/test/mesh/mesh_pts.c @@ -617,11 +617,15 @@ int btstack_main(void) // setup le device db le_device_db_init(); + // setup ATT server + att_server_init(profile_data, NULL, NULL); + // sm_init(); + // mesh - adv_bearer_init(); + mesh_init(); // setup connectable advertisments bd_addr_t null_addr; @@ -631,42 +635,9 @@ int btstack_main(void) uint16_t adv_int_max = 0x0030; adv_bearer_advertisements_set_params(adv_int_min, adv_int_max, adv_type, 0, null_addr, 0x07, 0x00); - // setup ATT server - att_server_init(profile_data, NULL, NULL); - - // Setup GATT bearer - gatt_bearer_init(); - -#ifdef ENABLE_MESH_ADV_BEARER - // Setup Unprovisioned Device Beacon - beacon_init(); - // Register for Unprovisioned Device Beacons provisioner - beacon_register_for_unprovisioned_device_beacons(&mesh_unprovisioned_beacon_handler); -#endif - - // Parse PTS Device UUID - uint8_t pts_device_uuid[16]; - btstack_parse_hex(pts_device_uuid_string, 16, pts_device_uuid); - mesh_node_set_device_uuid(pts_device_uuid); - btstack_print_hex(pts_device_uuid, 16, 0); - // Provisioning in device role - provisioning_device_init(); provisioning_device_register_packet_handler(&mesh_provisioning_message_handler); - // Network layer - mesh_network_init(); - - // Transport layers (lower + upper)) - mesh_lower_transport_init(); - mesh_upper_transport_init(); - - // Access layer - mesh_access_init(); - - // Node Configuration - mesh_node_init(); - // Setup default models on primary element mesh_node_setup_default_models(); @@ -687,6 +658,24 @@ int btstack_main(void) // Enable PROXY mesh_foundation_gatt_proxy_set(1); +#if defined(ENABLE_MESH_ADV_BEARER) + // setup scanning when supporting ADV Bearer + gap_set_scan_parameters(0, 0x300, 0x300); + gap_start_scan(); +#endif + + // PTS add-on + +#ifdef ENABLE_MESH_ADV_BEARER + // Register for Unprovisioned Device Beacons provisioner + beacon_register_for_unprovisioned_device_beacons(&mesh_unprovisioned_beacon_handler); +#endif + + // Set PTS Device UUID + uint8_t pts_device_uuid[16]; + btstack_parse_hex(pts_device_uuid_string, 16, pts_device_uuid); + mesh_node_set_device_uuid(pts_device_uuid); + btstack_print_hex(pts_device_uuid, 16, 0); // PTS Virtual Address Label UUID - without Config Model, PTS uses our device uuid uint8_t label_uuid[16]; @@ -694,12 +683,6 @@ int btstack_main(void) mesh_virtual_address_t * virtual_addresss = mesh_virtual_address_register(label_uuid, 0x9779); pts_proxy_dst = virtual_addresss->pseudo_dst; -#if defined(ENABLE_MESH_ADV_BEARER) - // setup scanning when supporting ADV Bearer - gap_set_scan_parameters(0, 0x300, 0x300); - gap_start_scan(); -#endif - // turn on! hci_power_control(HCI_POWER_ON);