mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-30 07:21:20 +00:00
mesh: load provisioning data in mesh_node_startup_from_tlv
This commit is contained in:
parent
f46a0f51ed
commit
e18ba70aa9
@ -190,8 +190,6 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
UNUSED(size);
|
||||
bd_addr_t addr;
|
||||
int i;
|
||||
int prov_len;
|
||||
mesh_provisioning_data_t provisioning_data;
|
||||
|
||||
switch (packet_type) {
|
||||
case HCI_EVENT_PACKET:
|
||||
@ -205,35 +203,18 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
printf("%02x", addr[i]);
|
||||
}
|
||||
printf("\n");
|
||||
// get tlv
|
||||
btstack_tlv_get_instance(&btstack_tlv_singleton_impl, &btstack_tlv_singleton_context);
|
||||
// load provisioning data
|
||||
prov_len = btstack_tlv_singleton_impl->get_tag(btstack_tlv_singleton_context, 'PROV', (uint8_t *) &provisioning_data, sizeof(mesh_provisioning_data_t));
|
||||
printf("Provisioning data available: %u\n", prov_len ? 1 : 0);
|
||||
if (prov_len){
|
||||
provisioned = 1;
|
||||
|
||||
mesh_access_setup_from_provisioning_data(&provisioning_data);
|
||||
|
||||
mesh_node_startup_from_tlv();
|
||||
// startup from provisioning data stored in TLV
|
||||
provisioned = mesh_node_startup_from_tlv();
|
||||
|
||||
if (provisioned){
|
||||
// dump PTS MeshOptions.ini
|
||||
mesh_pts_dump_mesh_options();
|
||||
|
||||
} else {
|
||||
provisioned = 0;
|
||||
|
||||
mesh_access_setup_without_provisiong_data(test_device_uuid);
|
||||
}
|
||||
|
||||
#if defined(ENABLE_MESH_ADV_BEARER) || defined(ENABLE_MESH_PB_ADV)
|
||||
|
||||
// start sending Secure Network Beacon
|
||||
mesh_subnet_t * subnet = mesh_subnet_get_by_netkey_index(0);
|
||||
if (subnet){
|
||||
beacon_secure_network_start(subnet);
|
||||
}
|
||||
|
||||
// setup scanning
|
||||
gap_set_scan_parameters(0, 0x300, 0x300);
|
||||
gap_start_scan();
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include "mesh_proxy.h"
|
||||
#include "mesh/gatt_bearer.h"
|
||||
#include "mesh_iv_index_seq_number.h"
|
||||
#include "mesh/beacon.h"
|
||||
|
||||
#define MESH_HEARTBEAT_FEATURES_SUPPORTED_MASK 0x000f
|
||||
|
||||
@ -2283,22 +2284,44 @@ void mesh_node_reset(void){
|
||||
mesh_delete_publications();
|
||||
}
|
||||
|
||||
void mesh_node_startup_from_tlv(void){
|
||||
// load iv index
|
||||
mesh_restore_iv_index_and_sequence_number();
|
||||
// load network keys
|
||||
mesh_load_network_keys();
|
||||
// load app keys
|
||||
mesh_load_app_keys();
|
||||
// load model to appkey bindings
|
||||
mesh_load_appkey_lists();
|
||||
// load virtual addresses
|
||||
mesh_load_virtual_addresses();
|
||||
// load model subscriptions
|
||||
mesh_load_subscriptions();
|
||||
// load model publications
|
||||
mesh_load_publications();
|
||||
// load foundation state
|
||||
mesh_foundation_state_load();
|
||||
int mesh_node_startup_from_tlv(void){
|
||||
|
||||
mesh_provisioning_data_t provisioning_data;
|
||||
btstack_tlv_get_instance(&btstack_tlv_singleton_impl, &btstack_tlv_singleton_context);
|
||||
// load provisioning data
|
||||
uint32_t prov_len = btstack_tlv_singleton_impl->get_tag(btstack_tlv_singleton_context, 'PROV', (uint8_t *) &provisioning_data, sizeof(mesh_provisioning_data_t));
|
||||
printf("Provisioning data available: %u\n", prov_len ? 1 : 0);
|
||||
if (prov_len){
|
||||
|
||||
mesh_access_setup_from_provisioning_data(&provisioning_data);
|
||||
|
||||
// load iv index
|
||||
mesh_restore_iv_index_and_sequence_number();
|
||||
// load network keys
|
||||
mesh_load_network_keys();
|
||||
// load app keys
|
||||
mesh_load_app_keys();
|
||||
// load model to appkey bindings
|
||||
mesh_load_appkey_lists();
|
||||
// load virtual addresses
|
||||
mesh_load_virtual_addresses();
|
||||
// load model subscriptions
|
||||
mesh_load_subscriptions();
|
||||
// load model publications
|
||||
mesh_load_publications();
|
||||
// load foundation state
|
||||
mesh_foundation_state_load();
|
||||
|
||||
#if defined(ENABLE_MESH_ADV_BEARER) || defined(ENABLE_MESH_PB_ADV)
|
||||
// start sending Secure Network Beacon
|
||||
mesh_subnet_t * subnet = mesh_subnet_get_by_netkey_index(0);
|
||||
if (subnet){
|
||||
beacon_secure_network_start(subnet);
|
||||
}
|
||||
#endif
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ void mesh_delete_publications(void);
|
||||
//
|
||||
void mesh_node_reset(void);
|
||||
|
||||
void mesh_node_startup_from_tlv(void);
|
||||
int mesh_node_startup_from_tlv(void);
|
||||
|
||||
// PTS Testing
|
||||
void config_nekey_list_set_max(uint16_t max);
|
||||
|
Loading…
x
Reference in New Issue
Block a user