mesh: pass netkey_index to mesh_application_key_set

This commit is contained in:
Matthias Ringwald 2019-04-25 21:39:19 +02:00
parent 8d3c795711
commit f747e0fc9d
5 changed files with 12 additions and 11 deletions

View File

@ -132,7 +132,7 @@ static void mesh_load_app_keys(void){
uint16_t appkey_index = little_endian_read_16(data, 0);
uint8_t aid = data[2];
uint8_t * application_key = &data[3];
mesh_application_key_set(appkey_index, aid, application_key);
mesh_application_key_set(0, appkey_index, aid, application_key);
printf("Load AppKey: AppKey Index 0x%06x, AID %02x: ", appkey_index, aid);
printf_hexdump(application_key, 16);
} else {
@ -346,7 +346,7 @@ static void load_pts_app_key(void){
uint8_t application_key[16];
const char * application_key_string = "3216D1509884B533248541792B877F98";
btstack_parse_hex(application_key_string, 16, application_key);
mesh_application_key_set(0, 0x38, application_key);
mesh_application_key_set(0, 0, 0x38, application_key);
printf("PTS Application Key (AID %02x): ", 0x38);
printf_hexdump(application_key, 16);
}
@ -1469,12 +1469,11 @@ static void config_netkey_delete_handler(mesh_model_t * mesh_model, mesh_pdu_t *
uint16_t netkey_index = mesh_access_parser_get_u16(&parser);
// get existing network_key
uint8_t status;
uint8_t status = MESH_FOUNDATION_STATUS_SUCCESS;
mesh_network_key_t * network_key = mesh_network_key_list_get(netkey_index);
if (network_key){
if (mesh_network_key_list_count() > 1){
mesh_network_key_remove(network_key);
status = MESH_FOUNDATION_STATUS_SUCCESS;
} else {
// we cannot remove the last network key
status = MESH_FOUNDATION_STATUS_CANNOT_REMOVE;
@ -1502,11 +1501,12 @@ static void config_appkey_add_aid(void * arg){
// store in TLV
mesh_store_app_key(new_appkey_index, new_aid, new_app_key.key);
// set as main app key
mesh_application_key_set(new_appkey_index, new_aid, new_app_key.key);
// TODO: find a way to get netkey_index
uint16_t netkey_index = 0;
// set as main app key
mesh_application_key_set(netkey_index, new_appkey_index, new_aid, new_app_key.key);
config_appkey_status(NULL, netkey_index, mesh_pdu_src(access_pdu_in_process), netkey_and_appkey_index, 0);
mesh_access_message_processed(access_pdu_in_process);

View File

@ -155,7 +155,7 @@ static mesh_transport_key_t test_application_key;
static mesh_transport_key_t mesh_transport_device_key;
static btstack_linked_list_t application_keys;
void mesh_application_key_set(uint16_t appkey_index, uint8_t aid, const uint8_t * application_key){
void mesh_application_key_set(uint16_t netkey_index, uint16_t appkey_index, uint8_t aid, const uint8_t *application_key) {
test_application_key.appkey_index = appkey_index;
test_application_key.aid = aid;
test_application_key.akf = 1;

View File

@ -215,7 +215,7 @@ int mesh_transport_key_remove(mesh_transport_key_t * transport_key);
* @param aid
* @param application_key
*/
void mesh_application_key_set(uint16_t appkey_index, uint8_t aid, const uint8_t * application_key);
void mesh_application_key_set(uint16_t netkey_index, uint16_t appkey_index, uint8_t aid, const uint8_t *application_key);
/**
* Get transport key for appkey_index

View File

@ -132,7 +132,7 @@ static void load_provisioning_data_test_message(void){
load_network_key_nid_68();
uint8_t application_key[16];
btstack_parse_hex("63964771734fbd76e3b40519d1d94a48", 16, application_key);
mesh_application_key_set( 0, 0x26, application_key);
mesh_application_key_set( 0, 0, 0x26, application_key);
uint8_t device_key[16];
btstack_parse_hex("9d6dd0e96eb25dc19a40ed9914f8f03f", 16, device_key);

View File

@ -55,7 +55,8 @@ void mesh_upper_transport_set_primary_element_address(uint16_t primary_element_a
void mesh_transport_set_device_key(const uint8_t * device_key);
void mesh_application_key_set(uint16_t appkey_index, uint8_t aid, const uint8_t * application_key);
void
mesh_application_key_set(uint16_t netkey_index, uint16_t appkey_index, uint8_t aid, const uint8_t *application_key);
void mesh_upper_transport_message_processed_by_higher_layer(mesh_pdu_t * pdu);