mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 21:35:16 +00:00
mesh: store unicast addr in provisioning data
This commit is contained in:
parent
bcb111ffa5
commit
2264eafe8f
@ -75,6 +75,7 @@ static uint8_t beacon_key[16];
|
||||
static uint8_t network_id[8];
|
||||
|
||||
static void mesh_provisioning_dump( mesh_provisioning_data_t * data){
|
||||
printf("UnicastAddr: 0x%02x\n", data->unicast_address);
|
||||
printf("NID: 0x%02x\n", data->nid);
|
||||
printf("IV Index: 0x%08x\n", data->iv_index);
|
||||
printf("NetworkID: "); printf_hexdump(data->network_id, 8);
|
||||
@ -111,6 +112,8 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
if (prov_len){
|
||||
// add to network key list
|
||||
mesh_network_key_list_add_from_provisioning_data(&provisioning_data);
|
||||
// set unicast address
|
||||
mesh_network_set_primary_element_address(provisioning_data.unicast_address);
|
||||
// set iv_index
|
||||
mesh_set_iv_index(provisioning_data.iv_index);
|
||||
// copy beacon key and network id
|
||||
@ -162,11 +165,16 @@ static void mesh_message_handler (uint8_t packet_type, uint16_t channel, uint8_t
|
||||
memcpy(provisioning_data.privacy_key, provisioning_device_data_get_privacy_key(), 16);
|
||||
mesh_set_iv_index(provisioning_device_data_get_iv_index());
|
||||
provisioning_data.nid = provisioning_device_data_get_nid();
|
||||
mesh_flags = provisioning_device_data_get_flags();
|
||||
provisioning_data.flags = provisioning_device_data_get_flags();
|
||||
provisioning_data.unicast_address = provisioning_device_data_get_unicast_address();
|
||||
// store in TLV
|
||||
btstack_tlv_singleton_impl->store_tag(btstack_tlv_singleton_context, 'PROV', (uint8_t *) &provisioning_data, sizeof(mesh_provisioning_data_t));
|
||||
// add to network key list
|
||||
mesh_network_key_list_add_from_provisioning_data(&provisioning_data);
|
||||
// set unicast address
|
||||
mesh_network_set_primary_element_address(provisioning_data.unicast_address);
|
||||
// for secure beacon
|
||||
mesh_flags = provisioning_device_data_get_flags();
|
||||
// dump
|
||||
mesh_provisioning_dump(&provisioning_data);
|
||||
break;
|
||||
@ -502,9 +510,6 @@ int btstack_main(void)
|
||||
// Network layer
|
||||
mesh_network_init();
|
||||
|
||||
// hack
|
||||
mesh_network_set_primary_element_address(0x28);
|
||||
|
||||
//
|
||||
btstack_parse_hex(pts_device_uuid_string, 16, pts_device_uuid);
|
||||
btstack_print_hex(pts_device_uuid, 16, 0);
|
||||
|
@ -81,11 +81,13 @@ extern "C"
|
||||
|
||||
|
||||
typedef struct {
|
||||
// uint8_t network_key[16] // not used yet
|
||||
uint8_t network_key[16];
|
||||
uint8_t flags;
|
||||
uint32_t iv_index;
|
||||
uint16_t unicast_address;
|
||||
|
||||
// k1
|
||||
// uint8_t identity_key[16] // not used yet
|
||||
uint8_t identity_key[16];
|
||||
uint8_t beacon_key[16];
|
||||
// k2
|
||||
uint8_t nid;
|
||||
@ -93,6 +95,7 @@ typedef struct {
|
||||
uint8_t privacy_key[16];
|
||||
// k3
|
||||
uint8_t network_id[8];
|
||||
|
||||
} mesh_provisioning_data_t;
|
||||
|
||||
|
||||
|
@ -893,6 +893,9 @@ void provisioning_device_input_oob_complete_alphanumeric(uint16_t pb_adv_cid, co
|
||||
uint8_t provisioning_device_data_get_flags(void){
|
||||
return flags;
|
||||
}
|
||||
uint16_t provisioning_device_data_get_unicast_address(void){
|
||||
return unicast_address;
|
||||
}
|
||||
const uint8_t * provisioning_device_data_get_network_id(void){
|
||||
return network_id;
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ void provisioning_device_input_oob_complete_alphanumeric(uint16_t pb_adv_cid, co
|
||||
|
||||
// Query provisioning data
|
||||
uint8_t provisioning_device_data_get_flags(void);
|
||||
uint16_t provisioning_device_data_get_unicast_address(void);
|
||||
uint8_t provisioning_device_data_get_nid(void);
|
||||
const uint8_t * provisioning_device_data_get_encryption_key(void);
|
||||
const uint8_t * provisioning_device_data_get_privacy_key(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user