From 2695601c7c9e52ef0fc76b0d39f86312e017aba8 Mon Sep 17 00:00:00 2001 From: Juha Heiskanen Date: Wed, 5 Sep 2018 13:31:22 +0300 Subject: [PATCH] FHSS parent synch fix. Parent broadcast set never stop old shedule which cause that nodes start advertisment Broadast shedule wrongly. --- source/Service_Libs/fhss/fhss_ws.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/Service_Libs/fhss/fhss_ws.c b/source/Service_Libs/fhss/fhss_ws.c index 37b16585466..c7ac2c44a02 100644 --- a/source/Service_Libs/fhss/fhss_ws.c +++ b/source/Service_Libs/fhss/fhss_ws.c @@ -664,10 +664,14 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8], return -1; } platform_enter_critical(); + fhss_structure->platform_functions.fhss_timer_stop(fhss_broadcast_handler, fhss_structure->fhss_api); uint32_t time_from_reception_ms = (fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api) - bc_timing_info->bt_rx_timestamp)/1000; uint32_t true_bc_interval_offset = (bc_timing_info->broadcast_interval_offset + time_from_reception_ms) % bc_timing_info->broadcast_interval; uint32_t timeout = ((bc_timing_info->broadcast_interval-true_bc_interval_offset)*1000); - fhss_structure->ws->is_on_bc_channel = false; + + if (fhss_structure->ws->is_on_bc_channel) { + timeout -= ((bc_timing_info->broadcast_interval - bc_timing_info->broadcast_dwell_interval) *1000); + } fhss_start_timer(fhss_structure, timeout, fhss_broadcast_handler); uint16_t slots_since_reception = (bc_timing_info->broadcast_interval_offset + time_from_reception_ms) / bc_timing_info->broadcast_interval; // TODO: Calculate drift error