diff --git a/src/mesh/gatt_bearer.c b/src/mesh/gatt_bearer.c index f1c070fda..ef1c7b2d7 100644 --- a/src/mesh/gatt_bearer.c +++ b/src/mesh/gatt_bearer.c @@ -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; -} diff --git a/src/mesh/gatt_bearer.h b/src/mesh/gatt_bearer.h index ac7750b6f..2469adb0b 100644 --- a/src/mesh/gatt_bearer.h +++ b/src/mesh/gatt_bearer.h @@ -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 diff --git a/src/mesh/mesh_network.c b/src/mesh/mesh_network.c index e27236132..585d32d72 100644 --- a/src/mesh/mesh_network.c +++ b/src/mesh/mesh_network.c @@ -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 } diff --git a/test/mesh/mesh_access.c b/test/mesh/mesh_access.c index 7a6f6006c..75e2b3e1c 100644 --- a/test/mesh/mesh_access.c +++ b/test/mesh/mesh_access.c @@ -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); diff --git a/test/mesh/mesh_configuration_server.c b/test/mesh/mesh_configuration_server.c index 03259a8da..f1d41e0b1 100644 --- a/test/mesh/mesh_configuration_server.c +++ b/test/mesh/mesh_configuration_server.c @@ -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); diff --git a/test/mesh/mesh_keys.h b/test/mesh/mesh_keys.h index 63dd7944e..685688dd4 100644 --- a/test/mesh/mesh_keys.h +++ b/test/mesh/mesh_keys.h @@ -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 { diff --git a/test/mesh/mesh_proxy.c b/test/mesh/mesh_proxy.c index 120fdc888..f5cc7866d 100644 --- a/test/mesh/mesh_proxy.c +++ b/test/mesh/mesh_proxy.c @@ -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 diff --git a/test/mesh/mesh_proxy.h b/test/mesh/mesh_proxy.h index abdbb6946..b1e5f7987 100644 --- a/test/mesh/mesh_proxy.h +++ b/test/mesh/mesh_proxy.h @@ -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