@@ -173,7 +173,11 @@ static uint32_t fhss_ws_calculate_ufsi(fhss_structure_t *fhss_structure, uint32_
173173 }
174174 cur_slot -- ;
175175 uint32_t remaining_time = (fhss_structure -> platform_functions .fhss_get_remaining_slots (fhss_unicast_handler , fhss_structure -> fhss_api ) / 1000 );
176- uint32_t time_to_tx = (tx_time - fhss_structure -> callbacks .read_timestamp (fhss_structure -> fhss_api )) / 1000 ;
176+ uint32_t time_to_tx = 0 ;
177+ uint32_t cur_time = fhss_structure -> callbacks .read_timestamp (fhss_structure -> fhss_api );
178+ if (cur_time < tx_time ) {
179+ time_to_tx = (tx_time - cur_time ) / 1000 ;
180+ }
177181 uint64_t ms_since_seq_start = (cur_slot * dwell_time ) + (dwell_time - remaining_time ) + time_to_tx ;
178182 uint32_t seq_length = 0x10000 ;
179183 if (fhss_structure -> ws -> fhss_configuration .ws_channel_function == WS_TR51CF ) {
@@ -205,7 +209,7 @@ static uint16_t fhss_ws_calculate_destination_slot(fhss_ws_neighbor_timing_info_
205209 if (neighbor_timing_info -> uc_timing_info .unicast_channel_function == WS_TR51CF ) {
206210 seq_length = neighbor_timing_info -> uc_timing_info .unicast_number_of_channels ;
207211 }
208- uint32_t dest_ms_since_seq_start = own_ceil ((float )(ufsi * seq_length * dwell_time ) / DEF_2E24 );
212+ uint32_t dest_ms_since_seq_start = own_ceil ((float )(( uint64_t ) ufsi * seq_length * dwell_time ) / DEF_2E24 );
209213 return (own_floor (((float )((tx_time - ufsi_timestamp )/1000 + dest_ms_since_seq_start ) / dwell_time )) % seq_length );
210214}
211215
@@ -241,7 +245,7 @@ static void fhss_ws_synch_state_set_callback(const fhss_api_t *api, fhss_states
241245static void fhss_ws_update_uc_channel_callback (fhss_structure_t * fhss_structure )
242246{
243247 uint8_t mac_address [8 ];
244- int32_t next_channel ;
248+ int32_t next_channel = fhss_structure -> rx_channel ;
245249 fhss_structure -> callbacks .read_mac_address (fhss_structure -> fhss_api , mac_address );
246250 if (fhss_structure -> ws -> fhss_configuration .ws_channel_function == WS_FIXED_CHANNEL ) {
247251 return ;
0 commit comments