From 9d79ca91e7d430028c574a1991f33c22453752c7 Mon Sep 17 00:00:00 2001 From: Jarkko Paso Date: Thu, 27 Sep 2018 14:01:12 +0300 Subject: [PATCH] FHSS: Added minimum synch interval --- source/Service_Libs/fhss/fhss_ws.c | 5 +++++ source/Service_Libs/fhss/fhss_ws.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/source/Service_Libs/fhss/fhss_ws.c b/source/Service_Libs/fhss/fhss_ws.c index 66b17c20b6e..0e5174065ad 100644 --- a/source/Service_Libs/fhss/fhss_ws.c +++ b/source/Service_Libs/fhss/fhss_ws.c @@ -91,6 +91,7 @@ fhss_structure_t *fhss_ws_enable(fhss_api_t *fhss_api, const fhss_ws_configurati fhss_struct->number_of_channels = channel_count; fhss_struct->own_hop = 0xff; fhss_struct->rx_channel = fhss_configuration->unicast_fixed_channel; + fhss_struct->ws->min_synch_interval = DEFAULT_MIN_SYNCH_INTERVAL; fhss_set_txrx_slot_length(fhss_struct); ns_list_init(&fhss_struct->fhss_failed_tx_list); return fhss_struct; @@ -666,6 +667,10 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8], if (!bc_timing_info->broadcast_interval || !bc_timing_info->broadcast_dwell_interval) { return -1; } + if (((uint32_t)fhss_structure->ws->min_synch_interval*1000000) > (fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api) - fhss_structure->ws->synchronization_time)) { + return 0; + } + fhss_structure->ws->synchronization_time = fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api); platform_enter_critical(); fhss_stop_timer(fhss_structure, fhss_broadcast_handler); uint32_t time_from_reception_ms = (fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api) - bc_timing_info->bt_rx_timestamp)/1000; diff --git a/source/Service_Libs/fhss/fhss_ws.h b/source/Service_Libs/fhss/fhss_ws.h index ff8f30de11e..6b1c59ee873 100644 --- a/source/Service_Libs/fhss/fhss_ws.h +++ b/source/Service_Libs/fhss/fhss_ws.h @@ -23,6 +23,8 @@ #define WS_NUMBER_OF_CHANNEL_RETRIES 4 //TX/RX slot length in milliseconds #define WS_MAX_TXRX_SLOT_LEN_MS 100 +// Default minimum broadcast synchronization interval in seconds +#define DEFAULT_MIN_SYNCH_INTERVAL 60 typedef struct fhss_ws fhss_ws_t; struct fhss_ws @@ -30,7 +32,9 @@ struct fhss_ws uint8_t bc_channel; uint16_t uc_slot; uint16_t bc_slot; + uint16_t min_synch_interval; uint32_t txrx_slot_length_ms; + uint32_t synchronization_time; bool unicast_timer_running; bool is_on_bc_channel; struct fhss_ws_configuration fhss_configuration;