From e0276f6634fe9cce1336019cb936d9e938078e92 Mon Sep 17 00:00:00 2001 From: Jarkko Paso Date: Mon, 15 Oct 2018 15:22:27 +0300 Subject: [PATCH 1/4] FHSS: Configure in critical state --- source/Service_Libs/fhss/fhss_ws.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/Service_Libs/fhss/fhss_ws.c b/source/Service_Libs/fhss/fhss_ws.c index 18664fc1639..f49042f3a28 100644 --- a/source/Service_Libs/fhss/fhss_ws.c +++ b/source/Service_Libs/fhss/fhss_ws.c @@ -726,6 +726,7 @@ int fhss_ws_configuration_set(fhss_structure_t *fhss_structure, const fhss_ws_co if (channel_count <= 0) { return -1; } + platform_enter_critical(); if (fhss_configuration->ws_uc_channel_function == WS_FIXED_CHANNEL || fhss_configuration->fhss_uc_dwell_interval == 0) { fhss_stop_timer(fhss_structure, fhss_unicast_handler); fhss_structure->ws->unicast_timer_running = false; @@ -739,6 +740,7 @@ int fhss_ws_configuration_set(fhss_structure_t *fhss_structure, const fhss_ws_co if (fhss_configuration->ws_uc_channel_function == WS_FIXED_CHANNEL) { fhss_structure->rx_channel = fhss_configuration->unicast_fixed_channel; } + platform_exit_critical(); tr_info("fhss Configuration set, UC channel: %d, BC channel: %d, UC CF: %d, BC CF: %d, channels: %d, uc dwell: %d, bc dwell: %d, bc interval: %d, bsi:%d", fhss_structure->ws->fhss_configuration.unicast_fixed_channel, fhss_structure->ws->fhss_configuration.broadcast_fixed_channel, From bcffa5f18441e7d60651fe105359ef39876b4bbc Mon Sep 17 00:00:00 2001 From: Jarkko Paso Date: Tue, 16 Oct 2018 10:28:21 +0300 Subject: [PATCH 2/4] FHSS: Fixed setting parent synch --- source/Service_Libs/fhss/fhss_ws.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/Service_Libs/fhss/fhss_ws.c b/source/Service_Libs/fhss/fhss_ws.c index f49042f3a28..8e91a790b0e 100644 --- a/source/Service_Libs/fhss/fhss_ws.c +++ b/source/Service_Libs/fhss/fhss_ws.c @@ -689,6 +689,9 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8], fhss_stop_timer(fhss_structure, fhss_broadcast_handler); uint32_t time_from_reception_ms = divide_integer(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; + if (true_bc_interval_offset >= bc_timing_info->broadcast_dwell_interval) { + fhss_structure->ws->is_on_bc_channel = false; + } uint32_t timeout = ((bc_timing_info->broadcast_interval-true_bc_interval_offset)*1000); if (fhss_structure->ws->is_on_bc_channel) { From 6679db46ffc11cf2aa2c3e7b402dfec202fd445b Mon Sep 17 00:00:00 2001 From: Jarkko Paso Date: Fri, 19 Oct 2018 11:32:27 +0300 Subject: [PATCH 3/4] WS bootstrap: traces to hop calculation --- source/6LoWPAN/ws/ws_bootstrap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/6LoWPAN/ws/ws_bootstrap.c b/source/6LoWPAN/ws/ws_bootstrap.c index c19ce516778..5785a8cbd4a 100644 --- a/source/6LoWPAN/ws/ws_bootstrap.c +++ b/source/6LoWPAN/ws/ws_bootstrap.c @@ -1469,6 +1469,7 @@ static void ws_set_fhss_hop(protocol_interface_info_entry_t *cur) // Calculate own hop count. This method gets inaccurate when hop count increases. uint8_t own_hop = (own_rank - rank_inc) / rank_inc; ns_fhss_ws_set_hop_count(cur->ws_info->fhss_api, own_hop); + tr_debug("own hop: %u, own rank: %u, rank inc: %u", own_hop, own_rank, rank_inc); } static void ws_address_registration_update(protocol_interface_info_entry_t *interface) From 2188fd2d5f1b7cfc89fcd70fe9f3cf90b87ebceb Mon Sep 17 00:00:00 2001 From: Jarkko Paso Date: Tue, 23 Oct 2018 11:09:51 +0300 Subject: [PATCH 4/4] FHSS: Fixed negative remaining time in ufsi calculation --- source/Service_Libs/fhss/fhss_ws.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/Service_Libs/fhss/fhss_ws.c b/source/Service_Libs/fhss/fhss_ws.c index 8e91a790b0e..0118d35792d 100644 --- a/source/Service_Libs/fhss/fhss_ws.c +++ b/source/Service_Libs/fhss/fhss_ws.c @@ -241,6 +241,9 @@ static uint32_t fhss_ws_calculate_ufsi(fhss_structure_t *fhss_structure, uint32_ } cur_slot--; uint32_t remaining_time = (fhss_structure->platform_functions.fhss_get_remaining_slots(fhss_unicast_handler, fhss_structure->fhss_api) / 1000); + if (remaining_time > dwell_time) { + remaining_time = 0; + } uint32_t time_to_tx = 0; uint32_t cur_time = fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api); if (cur_time < tx_time) {