Skip to content

Commit

Permalink
FHSS parent synch fix.
Browse files Browse the repository at this point in the history
Parent broadcast set never stop old shedule which cause that nodes start
advertisment Broadast shedule wrongly.
  • Loading branch information
Juha Heiskanen committed Sep 11, 2018
1 parent b50abb0 commit 2695601
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/Service_Libs/fhss/fhss_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2695601

Please sign in to comment.