Skip to content

Commit 86f64c5

Browse files
author
Jarkko Paso
authored
FHSS WS: Check if BC schedule is stopped before computing timeout delay (ARMmbed#2469)
1 parent a0b112a commit 86f64c5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
297297
if (!fhss_structure) {
298298
return;
299299
}
300+
301+
if (fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval == 0 || fhss_structure->ws->fhss_configuration.fhss_broadcast_interval == 0) {
302+
// stop broadcast schedule
303+
fhss_structure->ws->is_on_bc_channel = false;
304+
fhss_structure->ws->synchronization_time = 0;
305+
fhss_structure->ws->broadcast_timer_running = false;
306+
return;
307+
}
308+
300309
int32_t delay_us = fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api) - fhss_structure->ws->next_bc_timeout;
301310
// Assume this was initial call for this function without timer
302311
if (!fhss_structure->ws->bc_slot && !fhss_structure->ws->next_bc_timeout) {
@@ -332,14 +341,6 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
332341
fhss_structure->ws->bc_slot %= fhss_structure->number_of_channels;
333342
}
334343

335-
336-
if (fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval == 0 || fhss_structure->ws->fhss_configuration.fhss_broadcast_interval == 0) {
337-
// stop broadcast schedule
338-
fhss_structure->ws->is_on_bc_channel = false;
339-
fhss_structure->ws->synchronization_time = 0;
340-
fhss_structure->ws->broadcast_timer_running = false;
341-
return;
342-
}
343344
if (fhss_structure->ws->is_on_bc_channel == false) {
344345
fhss_ws_start_timer(fhss_structure, MS_TO_US(fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval) - (delay_us * fhss_structure->platform_functions.fhss_resolution_divider), fhss_broadcast_handler);
345346
fhss_structure->ws->is_on_bc_channel = true;

0 commit comments

Comments
 (0)