Skip to content

Commit

Permalink
FHSS WS: Check if BC schedule is stopped before computing timeout del…
Browse files Browse the repository at this point in the history
…ay (ARMmbed#2469)
  • Loading branch information
Jarkko Paso committed Oct 6, 2020
1 parent a0b112a commit 86f64c5
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions source/Service_Libs/fhss/fhss_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,15 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
if (!fhss_structure) {
return;
}

if (fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval == 0 || fhss_structure->ws->fhss_configuration.fhss_broadcast_interval == 0) {
// stop broadcast schedule
fhss_structure->ws->is_on_bc_channel = false;
fhss_structure->ws->synchronization_time = 0;
fhss_structure->ws->broadcast_timer_running = false;
return;
}

int32_t delay_us = fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api) - fhss_structure->ws->next_bc_timeout;
// Assume this was initial call for this function without timer
if (!fhss_structure->ws->bc_slot && !fhss_structure->ws->next_bc_timeout) {
Expand Down Expand Up @@ -332,14 +341,6 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
fhss_structure->ws->bc_slot %= fhss_structure->number_of_channels;
}


if (fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval == 0 || fhss_structure->ws->fhss_configuration.fhss_broadcast_interval == 0) {
// stop broadcast schedule
fhss_structure->ws->is_on_bc_channel = false;
fhss_structure->ws->synchronization_time = 0;
fhss_structure->ws->broadcast_timer_running = false;
return;
}
if (fhss_structure->ws->is_on_bc_channel == false) {
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);
fhss_structure->ws->is_on_bc_channel = true;
Expand Down

0 comments on commit 86f64c5

Please sign in to comment.