mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-04 15:39:59 +00:00
mesh: use mesh_subnet_setup_for_netkey_index only on start and for tests
This commit is contained in:
parent
0647177ff5
commit
85f6c8a0c0
@ -1096,9 +1096,12 @@ mesh_network_key_t * mesh_subnet_get_outgoing_network_key(mesh_subnet_t * subnet
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update subnet for given netkey index
|
||||
* @brief Setup subnet for given netkey index
|
||||
*/
|
||||
void mesh_subnet_update_for_netkey_index(uint16_t netkey_index){
|
||||
void mesh_subnet_setup_for_netkey_index(uint16_t netkey_index){
|
||||
mesh_subnet_t * subnet = mesh_subnet_get_by_netkey_index(netkey_index);
|
||||
if (subnet != NULL) return;
|
||||
|
||||
// find old / new keys
|
||||
mesh_network_key_t * old_key = NULL;
|
||||
mesh_network_key_t * new_key = NULL;
|
||||
@ -1120,20 +1123,11 @@ void mesh_subnet_update_for_netkey_index(uint16_t netkey_index){
|
||||
}
|
||||
}
|
||||
|
||||
// get subnet
|
||||
mesh_subnet_t * subnet = mesh_subnet_get_by_netkey_index(netkey_index);
|
||||
|
||||
// ignore if no key or no subnet
|
||||
if (old_key == NULL) return;
|
||||
// create subnet for netkey index
|
||||
subnet = btstack_memory_mesh_subnet_get();
|
||||
if (subnet == NULL) return;
|
||||
|
||||
// create subnet for netkey index if needed
|
||||
if (subnet == NULL){
|
||||
subnet = btstack_memory_mesh_subnet_get();
|
||||
if (subnet == NULL) return;
|
||||
subnet->netkey_index = netkey_index;
|
||||
mesh_subnet_add(subnet);
|
||||
}
|
||||
subnet->netkey_index = netkey_index;
|
||||
mesh_subnet_add(subnet);
|
||||
|
||||
// set keys
|
||||
subnet->old_key = old_key;
|
||||
@ -1146,8 +1140,6 @@ void mesh_subnet_update_for_netkey_index(uint16_t netkey_index){
|
||||
}
|
||||
else {
|
||||
// two keys -> at least phase 1
|
||||
if (subnet->key_refresh == MESH_KEY_REFRESH_NOT_ACTIVE){
|
||||
subnet->key_refresh = MESH_KEY_REFRESH_FIRST_PHASE;
|
||||
}
|
||||
subnet->key_refresh = MESH_KEY_REFRESH_FIRST_PHASE;
|
||||
}
|
||||
}
|
||||
|
@ -330,9 +330,9 @@ int mesh_subnet_iterator_has_more(mesh_subnet_iterator_t *it);
|
||||
mesh_subnet_t * mesh_subnet_iterator_get_next(mesh_subnet_iterator_t *it);
|
||||
|
||||
/**
|
||||
* @brief Update subnet for given netkey index
|
||||
* @brief Setup subnet for given netkey index
|
||||
*/
|
||||
void mesh_subnet_update_for_netkey_index(uint16_t netkey_index);
|
||||
void mesh_subnet_setup_for_netkey_index(uint16_t netkey_index);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -409,7 +409,7 @@ static void mesh_provisioning_message_handler (uint8_t packet_type, uint16_t cha
|
||||
mesh_network_key_add(primary_network_key);
|
||||
|
||||
// setup primary network
|
||||
mesh_subnet_update_for_netkey_index(primary_network_key->netkey_index);
|
||||
mesh_subnet_setup_for_netkey_index(primary_network_key->netkey_index);
|
||||
|
||||
// store provisioning data and primary network key in TLV
|
||||
btstack_tlv_singleton_impl->store_tag(btstack_tlv_singleton_context, 'PROV', (uint8_t *) &provisioning_data, sizeof(mesh_provisioning_data_t));
|
||||
|
@ -978,7 +978,7 @@ void mesh_load_network_keys(void){
|
||||
|
||||
mesh_network_key_add(network_key);
|
||||
|
||||
mesh_subnet_update_for_netkey_index(network_key->netkey_index);
|
||||
mesh_subnet_setup_for_netkey_index(network_key->netkey_index);
|
||||
|
||||
printf("- internal index 0x%x, NetKey Index 0x%06x, NID %02x: ", network_key->internal_index, network_key->netkey_index, network_key->nid);
|
||||
printf_hexdump(network_key->net_key, 16);
|
||||
|
@ -161,7 +161,7 @@ static void load_network_key_nid_68(void){
|
||||
btstack_parse_hex("0953fa93e7caac9638f58820220a398e", 16, network_key->encryption_key);
|
||||
btstack_parse_hex("8b84eedec100067d670971dd2aa700cf", 16, network_key->privacy_key);
|
||||
mesh_network_key_add(network_key);
|
||||
mesh_subnet_update_for_netkey_index(network_key->netkey_index);
|
||||
mesh_subnet_setup_for_netkey_index(network_key->netkey_index);
|
||||
}
|
||||
|
||||
static void load_network_key_nid_5e(void){
|
||||
@ -170,7 +170,7 @@ static void load_network_key_nid_5e(void){
|
||||
btstack_parse_hex("be635105434859f484fc798e043ce40e", 16, network_key->encryption_key);
|
||||
btstack_parse_hex("5d396d4b54d3cbafe943e051fe9a4eb8", 16, network_key->privacy_key);
|
||||
mesh_network_key_add(network_key);
|
||||
mesh_subnet_update_for_netkey_index(network_key->netkey_index);
|
||||
mesh_subnet_setup_for_netkey_index(network_key->netkey_index);
|
||||
}
|
||||
|
||||
static void load_network_key_nid_10(void){
|
||||
@ -179,7 +179,7 @@ static void load_network_key_nid_10(void){
|
||||
btstack_parse_hex("3a4fe84a6cc2c6a766ea93f1084d4039", 16, network_key->encryption_key);
|
||||
btstack_parse_hex("f695fcce709ccface4d8b7a1e6e39d25", 16, network_key->privacy_key);
|
||||
mesh_network_key_add(network_key);
|
||||
mesh_subnet_update_for_netkey_index(network_key->netkey_index);
|
||||
mesh_subnet_setup_for_netkey_index(network_key->netkey_index);
|
||||
}
|
||||
|
||||
static void load_provisioning_data_test_message(void){
|
||||
|
Loading…
x
Reference in New Issue
Block a user