mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-28 16:11:24 +00:00
mesh: start unprovisioned device beacon only when unprovisioned
This commit is contained in:
parent
d6ffd4d823
commit
491309357f
@ -113,11 +113,15 @@ static void beacon_timer_handler(btstack_timer_source_t * ts){
|
|||||||
adv_bearer_request_can_send_now_for_mesh_beacon();
|
adv_bearer_request_can_send_now_for_mesh_beacon();
|
||||||
}
|
}
|
||||||
|
|
||||||
void beacon_init(const uint8_t * device_uuid, uint16_t oob_information){
|
void beacon_init(void){
|
||||||
|
|
||||||
beacon_oob_information = oob_information;
|
|
||||||
adv_bearer_register_for_mesh_beacon(&beacon_packet_handler);
|
adv_bearer_register_for_mesh_beacon(&beacon_packet_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start Unprovisioned Device Beacon
|
||||||
|
*/
|
||||||
|
void beacon_unprovisioned_device_start(const uint8_t * device_uuid, uint16_t oob_information){
|
||||||
|
beacon_oob_information = oob_information;
|
||||||
if (device_uuid){
|
if (device_uuid){
|
||||||
beacon_device_uuid = device_uuid;
|
beacon_device_uuid = device_uuid;
|
||||||
beacon_timer.process = &beacon_timer_handler;
|
beacon_timer.process = &beacon_timer_handler;
|
||||||
@ -125,6 +129,14 @@ void beacon_init(const uint8_t * device_uuid, uint16_t oob_information){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop Unprovisioned Device Beacon
|
||||||
|
*/
|
||||||
|
void beacon_unprovisioned_device_stop(void){
|
||||||
|
btstack_run_loop_remove_timer(&beacon_timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void beacon_register_for_unprovisioned_device_beacons(btstack_packet_handler_t packet_handler){
|
void beacon_register_for_unprovisioned_device_beacons(btstack_packet_handler_t packet_handler){
|
||||||
unprovisioned_device_beacon_handler = packet_handler;
|
unprovisioned_device_beacon_handler = packet_handler;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,17 @@ extern "C" {
|
|||||||
/**
|
/**
|
||||||
* Initialize Mesh Beacon
|
* Initialize Mesh Beacon
|
||||||
*/
|
*/
|
||||||
void beacon_init(const uint8_t * device_uuid, uint16_t oob_information);
|
void beacon_init(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start Unprovisioned Device Beacon
|
||||||
|
*/
|
||||||
|
void beacon_unprovisioned_device_start(const uint8_t * device_uuid, uint16_t oob_information);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop Unprovisioned Device Beacon
|
||||||
|
*/
|
||||||
|
void beacon_unprovisioned_device_stop(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register Beacon handler for unprovisioned device beacons
|
* Register Beacon handler for unprovisioned device beacons
|
||||||
|
@ -134,6 +134,7 @@ static void mesh_load_app_keys(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mesh_store_app_key(uint16_t appkey_index, uint8_t aid, const uint8_t * application_key){
|
void mesh_store_app_key(uint16_t appkey_index, uint8_t aid, const uint8_t * application_key){
|
||||||
|
printf("Store AppKey: AppKey Index 0x%06x, AID %02x: ", appkey_index, aid);
|
||||||
uint8_t data[2+1+16];
|
uint8_t data[2+1+16];
|
||||||
little_endian_store_16(data, 0, appkey_index);
|
little_endian_store_16(data, 0, appkey_index);
|
||||||
data[2] = aid;
|
data[2] = aid;
|
||||||
@ -192,6 +193,9 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
printf("Provisioning data available: %u\n", prov_len ? 1 : 0);
|
printf("Provisioning data available: %u\n", prov_len ? 1 : 0);
|
||||||
if (prov_len){
|
if (prov_len){
|
||||||
mesh_setup_from_provisioning_data(&provisioning_data);
|
mesh_setup_from_provisioning_data(&provisioning_data);
|
||||||
|
} else {
|
||||||
|
printf("Starting Unprovisioned Device Beacon\n");
|
||||||
|
beacon_unprovisioned_device_start(device_uuid, 0);
|
||||||
}
|
}
|
||||||
// load app keys
|
// load app keys
|
||||||
mesh_load_app_keys();
|
mesh_load_app_keys();
|
||||||
@ -329,7 +333,7 @@ static void load_pts_app_key(void){
|
|||||||
const char * application_key_string = "3216D1509884B533248541792B877F98";
|
const char * application_key_string = "3216D1509884B533248541792B877F98";
|
||||||
btstack_parse_hex(application_key_string, 16, application_key);
|
btstack_parse_hex(application_key_string, 16, application_key);
|
||||||
mesh_application_key_set(0, 0x38, application_key);
|
mesh_application_key_set(0, 0x38, application_key);
|
||||||
printf("PTS Application Key: ");
|
printf("PTS Application Key (AID %02x): ", 0x38);
|
||||||
printf_hexdump(application_key, 16);
|
printf_hexdump(application_key, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,6 +490,7 @@ static void show_usage(void){
|
|||||||
printf("2 - Send Segmented Access Message - Unicast\n");
|
printf("2 - Send Segmented Access Message - Unicast\n");
|
||||||
printf("3 - Send Segmented Access Message - Group D000\n");
|
printf("3 - Send Segmented Access Message - Group D000\n");
|
||||||
printf("4 - Send Segmented Access Message - Virtual 9779\n");
|
printf("4 - Send Segmented Access Message - Virtual 9779\n");
|
||||||
|
printf("7 - Load PTS App key\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,6 +523,9 @@ static void stdin_process(char cmd){
|
|||||||
case '4':
|
case '4':
|
||||||
send_pts_segmented_access_messsage_virtual();
|
send_pts_segmented_access_messsage_virtual();
|
||||||
break;
|
break;
|
||||||
|
case '7':
|
||||||
|
load_pts_app_key();
|
||||||
|
break;
|
||||||
case '8':
|
case '8':
|
||||||
printf("Creating link to device uuid: ");
|
printf("Creating link to device uuid: ");
|
||||||
printf_hexdump(pts_device_uuid, 16);
|
printf_hexdump(pts_device_uuid, 16);
|
||||||
@ -706,7 +714,7 @@ int btstack_main(void)
|
|||||||
// mesh
|
// mesh
|
||||||
adv_bearer_init();
|
adv_bearer_init();
|
||||||
|
|
||||||
beacon_init(device_uuid, 0);
|
beacon_init();
|
||||||
beacon_register_for_unprovisioned_device_beacons(&mesh_unprovisioned_beacon_handler);
|
beacon_register_for_unprovisioned_device_beacons(&mesh_unprovisioned_beacon_handler);
|
||||||
|
|
||||||
// Provisioning in device role
|
// Provisioning in device role
|
||||||
|
Loading…
x
Reference in New Issue
Block a user