@@ -173,7 +173,11 @@ static uint32_t fhss_ws_calculate_ufsi(fhss_structure_t *fhss_structure, uint32_
173
173
}
174
174
cur_slot -- ;
175
175
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
+ }
177
181
uint64_t ms_since_seq_start = (cur_slot * dwell_time ) + (dwell_time - remaining_time ) + time_to_tx ;
178
182
uint32_t seq_length = 0x10000 ;
179
183
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_
205
209
if (neighbor_timing_info -> uc_timing_info .unicast_channel_function == WS_TR51CF ) {
206
210
seq_length = neighbor_timing_info -> uc_timing_info .unicast_number_of_channels ;
207
211
}
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 );
209
213
return (own_floor (((float )((tx_time - ufsi_timestamp )/1000 + dest_ms_since_seq_start ) / dwell_time )) % seq_length );
210
214
}
211
215
@@ -241,7 +245,7 @@ static void fhss_ws_synch_state_set_callback(const fhss_api_t *api, fhss_states
241
245
static void fhss_ws_update_uc_channel_callback (fhss_structure_t * fhss_structure )
242
246
{
243
247
uint8_t mac_address [8 ];
244
- int32_t next_channel ;
248
+ int32_t next_channel = fhss_structure -> rx_channel ;
245
249
fhss_structure -> callbacks .read_mac_address (fhss_structure -> fhss_api , mac_address );
246
250
if (fhss_structure -> ws -> fhss_configuration .ws_channel_function == WS_FIXED_CHANNEL ) {
247
251
return ;
0 commit comments