mesh: move advertisement_with_network_id from mesh_network_key_t to mesh_subnet_t

This commit is contained in:
Matthias Ringwald 2019-07-02 18:01:22 +02:00
parent e378fa650f
commit 2b7de14bb0
8 changed files with 25 additions and 43 deletions

View File

@ -76,17 +76,6 @@ static mesh_msg_type_t msg_type;
static uint16_t gatt_bearer_mtu;
static hci_con_handle_t gatt_bearer_con_handle;
static const uint8_t adv_data_with_network_id_template[] = {
// Flags general discoverable, BR/EDR not supported
0x02, BLUETOOTH_DATA_TYPE_FLAGS, 0x06,
// 16-bit Service UUIDs
0x03, BLUETOOTH_DATA_TYPE_COMPLETE_LIST_OF_16_BIT_SERVICE_CLASS_UUIDS, ORG_BLUETOOTH_SERVICE_MESH_PROXY & 0xff, ORG_BLUETOOTH_SERVICE_MESH_PROXY >> 8,
// Service Data
0x0C, BLUETOOTH_DATA_TYPE_SERVICE_DATA, ORG_BLUETOOTH_SERVICE_MESH_PROXY & 0xff, ORG_BLUETOOTH_SERVICE_MESH_PROXY >> 8,
// MESH_IDENTIFICATION_NETWORK_ID_TYPE
MESH_IDENTIFICATION_NETWORK_ID_TYPE
};
// round-robin
static void gatt_bearer_emit_can_send_now(void){
// if (gatt_active) return;
@ -341,8 +330,3 @@ void gatt_bearer_send_mesh_proxy_configuration(const uint8_t * data, uint16_t da
gatt_bearer_send_pdu(gatt_bearer_con_handle, data, data_len);
}
uint8_t gatt_bearer_setup_advertising_with_network_id(uint8_t * buffer, uint8_t * network_id){
memcpy(&buffer[0], adv_data_with_network_id_template, 12);
memcpy(&buffer[12], network_id, 8);
return 20;
}

View File

@ -74,14 +74,6 @@ void gatt_bearer_send_network_pdu(const uint8_t * network_pdu, uint16_t size);
void gatt_bearer_send_beacon(const uint8_t * beacon_update, uint16_t size);
void gatt_bearer_send_mesh_proxy_configuration(const uint8_t * proxy_configuration, uint16_t size);
/* Utility functions */
/**
* Setup Proxy Advertisement for given network id
* @param buffer (20 bytes)
* @param network_id (8 bytes)
*/
uint8_t gatt_bearer_setup_advertising_with_network_id(uint8_t * buffer, uint8_t * network_id);
#if defined __cplusplus
}
#endif

View File

@ -1139,8 +1139,6 @@ void mesh_subnet_update_for_netkey_index(uint16_t netkey_index){
}
}
// TODO: advertisement using node id active
// TODO: advertisement using network id (used by proxy)
// TODO: secure network beacons
}

View File

@ -973,7 +973,7 @@ void mesh_load_network_keys(void){
#ifdef ENABLE_GATT_BEARER
// setup advertisement with network id
network_key->advertisement_with_network_id.adv_length = gatt_bearer_setup_advertising_with_network_id(network_key->advertisement_with_network_id.adv_data, network_key->network_id);
network_key->advertisement_with_network_id.adv_length = mesh_proxy_setup_advertising_with_network_id(network_key->advertisement_with_network_id.adv_data, network_key->network_id);
#endif
mesh_network_key_add(network_key);

View File

@ -794,11 +794,6 @@ static void config_netkey_add_or_update_derived(void * arg){
mesh_network_key_t * network_key = (mesh_network_key_t *) arg;
#ifdef ENABLE_MESH_PROXY_SERVER
// setup advertisement with network id
network_key->advertisement_with_network_id.adv_length = gatt_bearer_setup_advertising_with_network_id(network_key->advertisement_with_network_id.adv_data, network_key->network_id);
#endif
// store network key
mesh_store_network_key(network_key);

View File

@ -73,17 +73,16 @@ typedef struct {
// internal index [0..MAX_NR_MESH_NETWORK_KEYS-1]
uint16_t internal_index;
// index into shared global key list
uint16_t netkey_index;
// internal version - allows for newer relation between keys with same netkey_index
// internal version - allows for newer-than relation between keys with same netkey_index
uint8_t version;
// net_key from provisioner or Config Model Client
uint8_t net_key[16];
// derivative data
// derived data
// k1
uint8_t identity_key[16];
@ -97,9 +96,6 @@ typedef struct {
uint8_t encryption_key[16];
uint8_t privacy_key[16];
// advertisement data for proxy
adv_bearer_connectable_advertisement_data_item_t advertisement_with_network_id;
} mesh_network_key_t;
typedef struct {

View File

@ -87,6 +87,23 @@ static const uint8_t adv_data_with_node_identity_template[] = {
// Random - 8 bytes
};
static const uint8_t adv_data_with_network_id_template[] = {
// Flags general discoverable, BR/EDR not supported
0x02, BLUETOOTH_DATA_TYPE_FLAGS, 0x06,
// 16-bit Service UUIDs
0x03, BLUETOOTH_DATA_TYPE_COMPLETE_LIST_OF_16_BIT_SERVICE_CLASS_UUIDS, ORG_BLUETOOTH_SERVICE_MESH_PROXY & 0xff, ORG_BLUETOOTH_SERVICE_MESH_PROXY >> 8,
// Service Data
0x0C, BLUETOOTH_DATA_TYPE_SERVICE_DATA, ORG_BLUETOOTH_SERVICE_MESH_PROXY & 0xff, ORG_BLUETOOTH_SERVICE_MESH_PROXY >> 8,
// MESH_IDENTIFICATION_NETWORK_ID_TYPE
MESH_IDENTIFICATION_NETWORK_ID_TYPE
};
static uint8_t mesh_proxy_setup_advertising_with_network_id(uint8_t * buffer, uint8_t * network_id){
memcpy(&buffer[0], adv_data_with_network_id_template, 12);
memcpy(&buffer[12], network_id, 8);
return 20;
}
static void mesh_proxy_stop_all_advertising_with_node_id(void){
adv_bearer_advertisements_remove_item(&connectable_advertisement_with_node_id);
mesh_subnet_iterator_t it;
@ -202,9 +219,11 @@ void mesh_proxy_start_advertising_with_network_id(void){
mesh_subnet_iterator_t it;
mesh_subnet_iterator_init(&it);
while (mesh_subnet_iterator_has_more(&it)){
mesh_subnet_t * network_key = mesh_subnet_iterator_get_next(&it);
log_info("Proxy start advertising with network id, netkey index %04x", network_key->netkey_index);
adv_bearer_advertisements_add_item(&network_key->advertisement_with_network_id);
mesh_subnet_t * subnet = mesh_subnet_iterator_get_next(&it);
log_info("Proxy start advertising with network id, netkey index %04x", subnet->netkey_index);
// setup advertisement with network id (used by proxy)
subnet->advertisement_with_network_id.adv_length = mesh_proxy_setup_advertising_with_network_id(subnet->advertisement_with_network_id.adv_data, subnet->old_key->network_id);
adv_bearer_advertisements_add_item(&subnet->advertisement_with_network_id);
}
adv_bearer_advertisements_enable(1);
}
@ -315,6 +334,5 @@ void mesh_proxy_init(uint16_t primary_unicast_address){
// mesh proxy configuration
mesh_network_set_proxy_message_handler(proxy_configuration_message_handler);
}
#endif

View File

@ -82,7 +82,6 @@ void mesh_proxy_start_advertising_with_network_id(void);
*/
void mesh_proxy_stop_advertising_with_network_id(void);
#ifdef __cplusplus
} /* end of extern "C" */
#endif