mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-05 09:40:00 +00:00
mesh: remove mesh_network_key_list_add_from_provisioning_data from mesh_keys.h
This commit is contained in:
parent
ff1c8a81b3
commit
574ec93036
@ -240,6 +240,38 @@ static void mesh_provisioning_dump(const mesh_provisioning_data_t * data){
|
||||
printf("IdentityKey: "); printf_hexdump(data->identity_key, 16);
|
||||
}
|
||||
|
||||
static void mesh_network_key_list_add_from_provisioning_data(const mesh_provisioning_data_t * provisioning_data){
|
||||
|
||||
// get key
|
||||
mesh_network_key_t * network_key = btstack_memory_mesh_network_key_get();
|
||||
|
||||
// get single instance
|
||||
memset(network_key, 0, sizeof(mesh_network_key_t));
|
||||
|
||||
// NetKey
|
||||
memcpy(network_key->net_key, provisioning_data->net_key, 16);
|
||||
|
||||
// IdentityKey
|
||||
memcpy(network_key->identity_key, provisioning_data->identity_key, 16);
|
||||
|
||||
// BeaconKey
|
||||
memcpy(network_key->beacon_key, provisioning_data->beacon_key, 16);
|
||||
|
||||
// NID
|
||||
network_key->nid = provisioning_data->nid;
|
||||
|
||||
// EncryptionKey
|
||||
memcpy(network_key->encryption_key, provisioning_data->encryption_key, 16);
|
||||
|
||||
// PrivacyKey
|
||||
memcpy(network_key->privacy_key, provisioning_data->privacy_key, 16);
|
||||
|
||||
// NetworkID
|
||||
memcpy(network_key->network_id, provisioning_data->network_id, 8);
|
||||
|
||||
mesh_network_key_add(network_key);
|
||||
}
|
||||
|
||||
static void mesh_setup_from_provisioning_data(const mesh_provisioning_data_t * provisioning_data){
|
||||
provisioned = 1;
|
||||
|
||||
|
@ -114,39 +114,6 @@ mesh_network_key_t * mesh_network_key_nid_iterator_get_next(mesh_network_key_ite
|
||||
return key;
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
void mesh_network_key_list_add_from_provisioning_data(const mesh_provisioning_data_t * provisioning_data){
|
||||
|
||||
// get key
|
||||
mesh_network_key_t * network_key = btstack_memory_mesh_network_key_get();
|
||||
|
||||
// get single instance
|
||||
memset(network_key, 0, sizeof(mesh_network_key_t));
|
||||
|
||||
// NetKey
|
||||
memcpy(network_key->net_key, provisioning_data->net_key, 16);
|
||||
|
||||
// IdentityKey
|
||||
memcpy(network_key->identity_key, provisioning_data->identity_key, 16);
|
||||
|
||||
// BeaconKey
|
||||
memcpy(network_key->beacon_key, provisioning_data->beacon_key, 16);
|
||||
|
||||
// NID
|
||||
network_key->nid = provisioning_data->nid;
|
||||
|
||||
// EncryptionKey
|
||||
memcpy(network_key->encryption_key, provisioning_data->encryption_key, 16);
|
||||
|
||||
// PrivacyKey
|
||||
memcpy(network_key->privacy_key, provisioning_data->privacy_key, 16);
|
||||
|
||||
// NetworkID
|
||||
memcpy(network_key->network_id, provisioning_data->network_id, 8);
|
||||
|
||||
mesh_network_key_add(network_key);
|
||||
}
|
||||
|
||||
// application key list
|
||||
|
||||
|
@ -48,6 +48,7 @@ extern "C"
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ble/mesh/mesh_network.h"
|
||||
#include "ble/mesh/adv_bearer.h"
|
||||
|
||||
typedef struct {
|
||||
btstack_linked_item_t item;
|
||||
@ -77,6 +78,10 @@ typedef struct {
|
||||
|
||||
// subnet state
|
||||
uint8_t node_id_advertisement_running;
|
||||
|
||||
// advertisement data for proxy
|
||||
adv_bearer_connectable_advertisement_data_item_t advertisement_with_network_id;
|
||||
|
||||
} mesh_network_key_t;
|
||||
|
||||
typedef struct {
|
||||
@ -149,12 +154,6 @@ mesh_network_key_t * mesh_network_key_list_get(uint16_t netkey_index);
|
||||
*/
|
||||
int mesh_network_key_list_count(void);
|
||||
|
||||
/**
|
||||
* @brief Initialize network key list from provisioning data
|
||||
* @param provisioning_data
|
||||
*/
|
||||
void mesh_network_key_list_add_from_provisioning_data(const mesh_provisioning_data_t * provisioning_data);
|
||||
|
||||
/**
|
||||
* @brief Iterate over all network keys
|
||||
* @param it
|
||||
|
@ -128,6 +128,20 @@ static void btstack_print_hex(const uint8_t * data, uint16_t len, char separator
|
||||
}
|
||||
#endif
|
||||
|
||||
static void add_network_key_from_provisioning_data(const mesh_provisioning_data_t * provisioning_data){
|
||||
|
||||
// get key
|
||||
mesh_network_key_t * network_key = btstack_memory_mesh_network_key_get();
|
||||
|
||||
// get single instance
|
||||
memset(network_key, 0, sizeof(mesh_network_key_t));
|
||||
|
||||
// EncryptionKey
|
||||
memcpy(network_key->encryption_key, provisioning_data->encryption_key, 16);
|
||||
|
||||
mesh_network_key_add(network_key);
|
||||
}
|
||||
|
||||
static mesh_transport_key_t test_application_key;
|
||||
static void mesh_application_key_set(uint16_t netkey_index, uint16_t appkey_index, uint8_t aid, const uint8_t *application_key) {
|
||||
test_application_key.netkey_index = netkey_index;
|
||||
@ -143,7 +157,7 @@ static void load_network_key_nid_68(void){
|
||||
provisioning_data.nid = 0x68;
|
||||
btstack_parse_hex("0953fa93e7caac9638f58820220a398e", 16, provisioning_data.encryption_key);
|
||||
btstack_parse_hex("8b84eedec100067d670971dd2aa700cf", 16, provisioning_data.privacy_key);
|
||||
mesh_network_key_list_add_from_provisioning_data(&provisioning_data);
|
||||
add_network_key_from_provisioning_data(&provisioning_data);
|
||||
}
|
||||
|
||||
static void load_network_key_nid_5e(void){
|
||||
@ -151,7 +165,7 @@ static void load_network_key_nid_5e(void){
|
||||
provisioning_data.nid = 0x5e;
|
||||
btstack_parse_hex("be635105434859f484fc798e043ce40e", 16, provisioning_data.encryption_key);
|
||||
btstack_parse_hex("5d396d4b54d3cbafe943e051fe9a4eb8", 16, provisioning_data.privacy_key);
|
||||
mesh_network_key_list_add_from_provisioning_data(&provisioning_data);
|
||||
add_network_key_from_provisioning_data(&provisioning_data);
|
||||
}
|
||||
|
||||
static void load_network_key_nid_10(void){
|
||||
@ -159,7 +173,7 @@ static void load_network_key_nid_10(void){
|
||||
provisioning_data.nid = 0x10;
|
||||
btstack_parse_hex("3a4fe84a6cc2c6a766ea93f1084d4039", 16, provisioning_data.encryption_key);
|
||||
btstack_parse_hex("f695fcce709ccface4d8b7a1e6e39d25", 16, provisioning_data.privacy_key);
|
||||
mesh_network_key_list_add_from_provisioning_data(&provisioning_data);
|
||||
add_network_key_from_provisioning_data(&provisioning_data);
|
||||
}
|
||||
|
||||
static void load_provisioning_data_test_message(void){
|
||||
|
@ -351,9 +351,41 @@ static void packet_handler_for_mesh_proxy_configuration(uint8_t packet_type, uin
|
||||
}
|
||||
}
|
||||
|
||||
static void add_network_key_from_provisioning_data(const mesh_provisioning_data_t * provisioning_data){
|
||||
|
||||
// get key
|
||||
mesh_network_key_t * network_key = btstack_memory_mesh_network_key_get();
|
||||
|
||||
// get single instance
|
||||
memset(network_key, 0, sizeof(mesh_network_key_t));
|
||||
|
||||
// NetKey
|
||||
memcpy(network_key->net_key, provisioning_data->net_key, 16);
|
||||
|
||||
// IdentityKey
|
||||
memcpy(network_key->identity_key, provisioning_data->identity_key, 16);
|
||||
|
||||
// BeaconKey
|
||||
memcpy(network_key->beacon_key, provisioning_data->beacon_key, 16);
|
||||
|
||||
// NID
|
||||
network_key->nid = provisioning_data->nid;
|
||||
|
||||
// EncryptionKey
|
||||
memcpy(network_key->encryption_key, provisioning_data->encryption_key, 16);
|
||||
|
||||
// PrivacyKey
|
||||
memcpy(network_key->privacy_key, provisioning_data->privacy_key, 16);
|
||||
|
||||
// NetworkID
|
||||
memcpy(network_key->network_id, provisioning_data->network_id, 8);
|
||||
|
||||
mesh_network_key_add(network_key);
|
||||
}
|
||||
|
||||
static void mesh_setup_from_provisioning_data(const mesh_provisioning_data_t * provisioning_data){
|
||||
// add to network key list
|
||||
mesh_network_key_list_add_from_provisioning_data(provisioning_data);
|
||||
add_network_key_from_provisioning_data(provisioning_data);
|
||||
// set unicast address
|
||||
mesh_network_set_primary_element_address(provisioning_data->unicast_address);
|
||||
// mesh_upper_transport_set_primary_element_address(provisioning_data->unicast_address);
|
||||
|
Loading…
x
Reference in New Issue
Block a user