From b9ccacabde1359ad6829b362661d5aca8a28c869 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 17 Jun 2019 17:21:48 +0200 Subject: [PATCH] mesh: store beacon_interval_ms in mesh_network_key_t --- src/ble/mesh/beacon.c | 17 ++++++++++++++++- src/ble/mesh/beacon.h | 7 +++++++ test/mesh/mesh_keys.h | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/ble/mesh/beacon.c b/src/ble/mesh/beacon.c index 21c48a9ea..e038c8309 100644 --- a/src/ble/mesh/beacon.c +++ b/src/ble/mesh/beacon.c @@ -39,6 +39,7 @@ #include +#include "ble/mesh/beacon.h" #include "ble/mesh/adv_bearer.h" #include "ble/core.h" #include "bluetooth.h" @@ -136,7 +137,22 @@ void beacon_unprovisioned_device_stop(void){ btstack_run_loop_remove_timer(&beacon_timer); } +// secure network beacons +// crypto context +static void beacon_secure_network_timer_handler(btstack_timer_source_t * ts){ + +} + +void beacon_secure_network_start(mesh_network_key_t * mesh_network_key){ + // start with default interval + mesh_network_key->beacon_interval_ms = 10 * 1000; // 10 seconds + // set timer for next one + + // +} + +// register handler void beacon_register_for_unprovisioned_device_beacons(btstack_packet_handler_t packet_handler){ unprovisioned_device_beacon_handler = packet_handler; } @@ -144,4 +160,3 @@ void beacon_register_for_unprovisioned_device_beacons(btstack_packet_handler_t p void beacon_register_for_secure_network_beacons(btstack_packet_handler_t packet_handler){ secure_network_beacon_handler = packet_handler; } - diff --git a/src/ble/mesh/beacon.h b/src/ble/mesh/beacon.h index 4e5ac7e3d..5f1e73c1d 100644 --- a/src/ble/mesh/beacon.h +++ b/src/ble/mesh/beacon.h @@ -41,6 +41,7 @@ #include #include "btstack_defines.h" +#include "mesh_keys.h" #if defined __cplusplus extern "C" { @@ -62,6 +63,12 @@ void beacon_unprovisioned_device_start(const uint8_t * device_uuid, uint16_t oob */ void beacon_unprovisioned_device_stop(void); +/** + * Start sending Secure Network Beacons on given subnet + * @param mesh_network_key subnet + */ +void beacon_secure_network_start(mesh_network_key_t * mesh_network_key); + /** * Register Beacon handler for unprovisioned device beacons */ diff --git a/test/mesh/mesh_keys.h b/test/mesh/mesh_keys.h index 86c444f08..7dd3dca19 100644 --- a/test/mesh/mesh_keys.h +++ b/test/mesh/mesh_keys.h @@ -92,6 +92,10 @@ typedef struct { // advertisement data for proxy adv_bearer_connectable_advertisement_data_item_t advertisement_with_network_id; + // secure network beacons + btstack_timer_source_t beacon_timer; + uint32_t beacon_interval_ms; + } mesh_network_key_t; typedef struct {