@@ -302,6 +302,7 @@ static int16_t fhss_ws_synch_state_set_callback(const fhss_api_t *api, fhss_stat
302
302
if ((fhss_structure -> ws -> fhss_configuration .ws_uc_channel_function != WS_FIXED_CHANNEL )) {
303
303
fhss_ws_update_uc_channel_callback (fhss_structure );
304
304
fhss_start_timer (fhss_structure , fhss_structure -> ws -> fhss_configuration .fhss_uc_dwell_interval * 1000 , fhss_unicast_handler );
305
+ fhss_structure -> ws -> unicast_timer_running = true;
305
306
}
306
307
}
307
308
@@ -622,7 +623,13 @@ static void fhss_unicast_handler(const fhss_api_t *fhss_api, uint16_t delay)
622
623
return ;
623
624
}
624
625
timeout = fhss_ws_get_sf_timeout_callback (fhss_structure );
626
+ if (!timeout ) {
627
+ fhss_stop_timer (fhss_structure , fhss_unicast_handler );
628
+ fhss_structure -> ws -> unicast_timer_running = false;
629
+ return ;
630
+ }
625
631
fhss_start_timer (fhss_structure , timeout - (delay * fhss_structure -> platform_functions .fhss_resolution_divider ), fhss_unicast_handler );
632
+ fhss_structure -> ws -> unicast_timer_running = true;
626
633
fhss_ws_update_uc_channel_callback (fhss_structure );
627
634
// Unless we have broadcast schedule, we have to poll unicast queue when changing channel. This is randomized by the unicast schedule.
628
635
if (!fhss_structure -> ws -> fhss_configuration .fhss_broadcast_interval || !fhss_structure -> ws -> fhss_configuration .fhss_bc_dwell_interval ) {
@@ -660,7 +667,7 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8],
660
667
return -1 ;
661
668
}
662
669
platform_enter_critical ();
663
- fhss_structure -> platform_functions . fhss_timer_stop ( fhss_broadcast_handler , fhss_structure -> fhss_api );
670
+ fhss_stop_timer ( fhss_structure , fhss_broadcast_handler );
664
671
uint32_t time_from_reception_ms = (fhss_structure -> callbacks .read_timestamp (fhss_structure -> fhss_api ) - bc_timing_info -> bt_rx_timestamp )/1000 ;
665
672
uint32_t true_bc_interval_offset = (bc_timing_info -> broadcast_interval_offset + time_from_reception_ms ) % bc_timing_info -> broadcast_interval ;
666
673
uint32_t timeout = ((bc_timing_info -> broadcast_interval - true_bc_interval_offset )* 1000 );
@@ -697,9 +704,13 @@ int fhss_ws_configuration_set(fhss_structure_t *fhss_structure, const fhss_ws_co
697
704
if (channel_count <= 0 ) {
698
705
return -1 ;
699
706
}
700
- if ((fhss_structure -> ws -> fhss_configuration .ws_uc_channel_function == WS_FIXED_CHANNEL ) && (fhss_configuration -> ws_uc_channel_function != WS_FIXED_CHANNEL )) {
701
- // Start unicast schedule if channel function changed from fixed channel
707
+ if (fhss_configuration -> ws_uc_channel_function == WS_FIXED_CHANNEL || fhss_configuration -> fhss_uc_dwell_interval == 0 ) {
708
+ fhss_stop_timer (fhss_structure , fhss_unicast_handler );
709
+ fhss_structure -> ws -> unicast_timer_running = false;
710
+ }
711
+ if ((fhss_structure -> ws -> unicast_timer_running == false) && (fhss_configuration -> ws_uc_channel_function != WS_FIXED_CHANNEL ) && fhss_configuration -> fhss_uc_dwell_interval ) {
702
712
fhss_start_timer (fhss_structure , fhss_configuration -> fhss_uc_dwell_interval * 1000 , fhss_unicast_handler );
713
+ fhss_structure -> ws -> unicast_timer_running = true;
703
714
}
704
715
fhss_structure -> ws -> fhss_configuration = * fhss_configuration ;
705
716
fhss_structure -> number_of_channels = channel_count ;
0 commit comments