mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-10 06:44:32 +00:00
mesh: add mesh_proxy_start_advertising_unprovisioned_device, mesh_proxy_stop_advertising_unprovisioned_device
This commit is contained in:
parent
3c98fbc84d
commit
7b5b1264b4
@ -72,9 +72,6 @@ static void show_usage(void);
|
|||||||
|
|
||||||
const static uint8_t test_device_uuid[] = { 0x00, 0x1B, 0xDC, 0x08, 0x10, 0x21, 0x0B, 0x0E, 0x0A, 0x0C, 0x00, 0x0B, 0x0E, 0x0A, 0x0C, 0x00 };
|
const static uint8_t test_device_uuid[] = { 0x00, 0x1B, 0xDC, 0x08, 0x10, 0x21, 0x0B, 0x0E, 0x0A, 0x0C, 0x00, 0x0B, 0x0E, 0x0A, 0x0C, 0x00 };
|
||||||
|
|
||||||
// Mesh Proxy, advertise with node id
|
|
||||||
static adv_bearer_connectable_advertisement_data_item_t connectable_advertisement_item;
|
|
||||||
|
|
||||||
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||||
|
|
||||||
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||||
@ -167,11 +164,7 @@ static void mesh_setup_without_provisiong_data(void){
|
|||||||
beacon_unprovisioned_device_start(device_uuid, 0);
|
beacon_unprovisioned_device_start(device_uuid, 0);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_MESH_PB_GATT
|
#ifdef ENABLE_MESH_PB_GATT
|
||||||
// PB_GATT
|
mesh_proxy_start_advertising_unprovisioned_device(test_device_uuid);
|
||||||
mesh_proxy_setup_advertising_unprovisioned(&connectable_advertisement_item, test_device_uuid);
|
|
||||||
// start advertisements
|
|
||||||
adv_bearer_advertisements_add_item(&connectable_advertisement_item);
|
|
||||||
adv_bearer_advertisements_enable(1);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,10 +299,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
||||||
// enable PB_GATT
|
// enable PB_GATT
|
||||||
if (provisioned == 0){
|
if (provisioned == 0){
|
||||||
mesh_proxy_setup_advertising_unprovisioned(&connectable_advertisement_item, test_device_uuid);
|
mesh_proxy_start_advertising_unprovisioned_device(test_device_uuid);
|
||||||
// setup advertisements
|
|
||||||
adv_bearer_advertisements_add_item(&connectable_advertisement_item);
|
|
||||||
adv_bearer_advertisements_enable(1);
|
|
||||||
} else {
|
} else {
|
||||||
#ifdef ENABLE_MESH_PROXY_SERVER
|
#ifdef ENABLE_MESH_PROXY_SERVER
|
||||||
printf("Advertise Mesh Proxy Service with Network ID\n");
|
printf("Advertise Mesh Proxy Service with Network ID\n");
|
||||||
@ -321,8 +311,8 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
case HCI_EVENT_LE_META:
|
case HCI_EVENT_LE_META:
|
||||||
if (hci_event_le_meta_get_subevent_code(packet) != HCI_SUBEVENT_LE_CONNECTION_COMPLETE) break;
|
if (hci_event_le_meta_get_subevent_code(packet) != HCI_SUBEVENT_LE_CONNECTION_COMPLETE) break;
|
||||||
// disable PB_GATT
|
// disable PB_GATT
|
||||||
printf("Connected, stop advertising gatt service\n");
|
printf("Connected, stop advertising GATT service\n");
|
||||||
adv_bearer_advertisements_remove_item(&connectable_advertisement_item);
|
mesh_proxy_stop_advertising_unprovisioned_device();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -701,10 +691,7 @@ static void stdin_process(char cmd){
|
|||||||
case '8':
|
case '8':
|
||||||
mesh_node_reset();
|
mesh_node_reset();
|
||||||
printf("Mesh Node Reset!\n");
|
printf("Mesh Node Reset!\n");
|
||||||
mesh_proxy_setup_advertising_unprovisioned(&connectable_advertisement_item, test_device_uuid);
|
mesh_proxy_start_advertising_unprovisioned_device(test_device_uuid);
|
||||||
// setup advertisements
|
|
||||||
adv_bearer_advertisements_add_item(&connectable_advertisement_item);
|
|
||||||
adv_bearer_advertisements_enable(1);
|
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
printf("+ Public Key OOB Enabled\n");
|
printf("+ Public Key OOB Enabled\n");
|
||||||
|
@ -73,7 +73,7 @@ static uint8_t mesh_proxy_node_id_rando
|
|||||||
static uint16_t primary_element_address;
|
static uint16_t primary_element_address;
|
||||||
|
|
||||||
// Mesh Proxy, advertise with node id
|
// Mesh Proxy, advertise with node id
|
||||||
static adv_bearer_connectable_advertisement_data_item_t connectable_advertisement_with_node_id;
|
static adv_bearer_connectable_advertisement_data_item_t connectable_advertisement;
|
||||||
|
|
||||||
static const uint8_t adv_data_with_node_identity_template[] = {
|
static const uint8_t adv_data_with_node_identity_template[] = {
|
||||||
// Flags general discoverable, BR/EDR not supported
|
// Flags general discoverable, BR/EDR not supported
|
||||||
@ -114,7 +114,7 @@ static const uint8_t adv_data_unprovisioned_template[] = {
|
|||||||
};
|
};
|
||||||
const uint8_t adv_data_unprovisioned_template_len = sizeof(adv_data_unprovisioned_template);
|
const uint8_t adv_data_unprovisioned_template_len = sizeof(adv_data_unprovisioned_template);
|
||||||
|
|
||||||
void mesh_proxy_setup_advertising_unprovisioned(adv_bearer_connectable_advertisement_data_item_t * advertisement_item, const uint8_t * device_uuid) {
|
static void mesh_proxy_setup_advertising_unprovisioned(adv_bearer_connectable_advertisement_data_item_t * advertisement_item, const uint8_t * device_uuid) {
|
||||||
// store in advertisement item
|
// store in advertisement item
|
||||||
memset(advertisement_item, 0, sizeof(adv_bearer_connectable_advertisement_data_item_t));
|
memset(advertisement_item, 0, sizeof(adv_bearer_connectable_advertisement_data_item_t));
|
||||||
advertisement_item->adv_length = adv_data_unprovisioned_template_len + 18;
|
advertisement_item->adv_length = adv_data_unprovisioned_template_len + 18;
|
||||||
@ -123,6 +123,22 @@ void mesh_proxy_setup_advertising_unprovisioned(adv_bearer_connectable_advertise
|
|||||||
memcpy(&advertisement_item->adv_data[11], device_uuid, 16);
|
memcpy(&advertisement_item->adv_data[11], device_uuid, 16);
|
||||||
little_endian_store_16(advertisement_item->adv_data, 27, 0);
|
little_endian_store_16(advertisement_item->adv_data, 27, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mesh_proxy_start_advertising_unprovisioned_device(const uint8_t * device_uuid){
|
||||||
|
mesh_proxy_setup_advertising_unprovisioned(&connectable_advertisement, device_uuid);
|
||||||
|
// setup advertisements
|
||||||
|
adv_bearer_advertisements_add_item(&connectable_advertisement);
|
||||||
|
adv_bearer_advertisements_enable(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Start Advertising Unprovisioned Device with Device ID
|
||||||
|
* @param device_uuid
|
||||||
|
*/
|
||||||
|
void mesh_proxy_stop_advertising_unprovisioned_device(void){
|
||||||
|
adv_bearer_advertisements_remove_item(&connectable_advertisement);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t mesh_proxy_setup_advertising_with_network_id(uint8_t * buffer, uint8_t * network_id){
|
static uint8_t mesh_proxy_setup_advertising_with_network_id(uint8_t * buffer, uint8_t * network_id){
|
||||||
@ -132,7 +148,7 @@ static uint8_t mesh_proxy_setup_advertising_with_network_id(uint8_t * buffer, ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void mesh_proxy_stop_all_advertising_with_node_id(void){
|
static void mesh_proxy_stop_all_advertising_with_node_id(void){
|
||||||
adv_bearer_advertisements_remove_item(&connectable_advertisement_with_node_id);
|
adv_bearer_advertisements_remove_item(&connectable_advertisement);
|
||||||
mesh_subnet_iterator_t it;
|
mesh_subnet_iterator_t it;
|
||||||
mesh_subnet_iterator_init(&it);
|
mesh_subnet_iterator_init(&it);
|
||||||
while (mesh_subnet_iterator_has_more(&it)){
|
while (mesh_subnet_iterator_has_more(&it)){
|
||||||
@ -152,13 +168,13 @@ static void mesh_proxy_node_id_timeout_handler(btstack_timer_source_t * ts){
|
|||||||
static void mesh_proxy_node_id_handle_get_aes128(void * arg){
|
static void mesh_proxy_node_id_handle_get_aes128(void * arg){
|
||||||
mesh_subnet_t * network_key = (mesh_subnet_t *) arg;
|
mesh_subnet_t * network_key = (mesh_subnet_t *) arg;
|
||||||
|
|
||||||
memcpy(connectable_advertisement_with_node_id.adv_data, adv_data_with_node_identity_template, 12);
|
memcpy(connectable_advertisement.adv_data, adv_data_with_node_identity_template, 12);
|
||||||
memcpy(&connectable_advertisement_with_node_id.adv_data[12], &mesh_proxy_node_id_hash[8], 8);
|
memcpy(&connectable_advertisement.adv_data[12], &mesh_proxy_node_id_hash[8], 8);
|
||||||
memcpy(&connectable_advertisement_with_node_id.adv_data[20], mesh_proxy_node_id_random_value, 8);
|
memcpy(&connectable_advertisement.adv_data[20], mesh_proxy_node_id_random_value, 8);
|
||||||
connectable_advertisement_with_node_id.adv_length = 28;
|
connectable_advertisement.adv_length = 28;
|
||||||
|
|
||||||
// setup advertisements
|
// setup advertisements
|
||||||
adv_bearer_advertisements_add_item(&connectable_advertisement_with_node_id);
|
adv_bearer_advertisements_add_item(&connectable_advertisement);
|
||||||
adv_bearer_advertisements_enable(1);
|
adv_bearer_advertisements_enable(1);
|
||||||
|
|
||||||
// set timer
|
// set timer
|
||||||
|
@ -59,9 +59,16 @@ typedef enum {
|
|||||||
void mesh_proxy_init(uint16_t primary_unicast_address);
|
void mesh_proxy_init(uint16_t primary_unicast_address);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @brief Start Advertising Unprovisioned Device with Device ID
|
||||||
|
* @param device_uuid
|
||||||
*/
|
*/
|
||||||
|
void mesh_proxy_start_advertising_unprovisioned_device(const uint8_t * device_uuid);
|
||||||
|
|
||||||
void mesh_proxy_setup_advertising_unprovisioned(adv_bearer_connectable_advertisement_data_item_t * advertisement_item, const uint8_t * device_uuid);
|
/**
|
||||||
|
* @brief Start Advertising Unprovisioned Device with Device ID
|
||||||
|
* @param device_uuid
|
||||||
|
*/
|
||||||
|
void mesh_proxy_stop_advertising_unprovisioned_device(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set Advertising with Node ID on given subnet
|
* @brief Set Advertising with Node ID on given subnet
|
||||||
|
Loading…
x
Reference in New Issue
Block a user