@@ -197,7 +197,7 @@ static int32_t fhss_ws_calc_bc_channel(fhss_structure_t *fhss_structure)
197
197
}
198
198
}
199
199
#ifdef FHSS_CHANNEL_DEBUG
200
- tr_info ("%" PRIu32 " BC %u %u" , fhss_structure -> callbacks .read_timestamp (fhss_structure -> fhss_api ), next_channel , fhss_structure -> ws -> bc_slot );
200
+ tr_info ("%" PRIu32 " BC %u %u %u " , fhss_structure -> callbacks .read_timestamp (fhss_structure -> fhss_api ), next_channel , fhss_structure -> ws -> bc_slot , fhss_structure -> ws -> fhss_configuration . bsi );
201
201
#endif /*FHSS_CHANNEL_DEBUG*/
202
202
return next_channel ;
203
203
}
@@ -486,7 +486,7 @@ static int fhss_ws_tx_handle_callback(const fhss_api_t *api, bool is_broadcast_a
486
486
}
487
487
}
488
488
#ifdef FHSS_CHANNEL_DEBUG
489
- tr_debug ("TX channel: %u %u" , tx_channel , destination_slot + 1 );
489
+ tr_debug ("TX channel: %u %u %s " , tx_channel , destination_slot + 1 , trace_array ( destination_address , 8 ) );
490
490
#endif /*FHSS_CHANNEL_DEBUG*/
491
491
fhss_structure -> callbacks .change_channel (fhss_structure -> fhss_api , tx_channel );
492
492
}
@@ -772,6 +772,7 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8],
772
772
return 0 ;
773
773
}
774
774
platform_enter_critical ();
775
+ uint16_t own_bc_slot = fhss_structure -> ws -> bc_slot ;
775
776
uint32_t prev_synchronization_time = fhss_structure -> ws -> synchronization_time ;
776
777
fhss_structure -> ws -> synchronization_time = fhss_structure -> callbacks .read_timestamp (fhss_structure -> fhss_api );
777
778
uint32_t time_since_last_synch_us = fhss_structure -> ws -> synchronization_time - prev_synchronization_time ;
@@ -803,9 +804,9 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8],
803
804
if (prev_synchronization_time ) {
804
805
if (SYNCH_COMPENSATION_MIN_INTERVAL <= US_TO_S (time_since_last_synch_us )) {
805
806
// Update clock drift
806
- fhss_structure -> ws -> drift_per_millisecond_ns += divide_integer (MS_TO_NS (true_bc_interval_offset - own_bc_interval_offset ), US_TO_MS (time_since_last_synch_us ));
807
+ fhss_structure -> ws -> drift_per_millisecond_ns += divide_integer (MS_TO_NS (( true_bc_interval_offset - own_bc_interval_offset ) + (( int32_t )( fhss_structure -> ws -> bc_slot - own_bc_slot ) * bc_timing_info -> broadcast_interval ) ), US_TO_MS (time_since_last_synch_us ));
807
808
}
808
- tr_debug ("synch to parent: %s, drift: %" PRIi32 "ms in %" PRIu32 " seconds, compensation: %" PRIi32 "ns per ms" , trace_array (eui64 , 8 ), true_bc_interval_offset - own_bc_interval_offset , US_TO_S (time_since_last_synch_us ), fhss_structure -> ws -> drift_per_millisecond_ns );
809
+ tr_debug ("synch to parent: %s, drift: %" PRIi32 "ms in %" PRIu32 " seconds, compensation: %" PRIi32 "ns per ms" , trace_array (eui64 , 8 ), true_bc_interval_offset - own_bc_interval_offset + (( int32_t )( fhss_structure -> ws -> bc_slot - own_bc_slot ) * bc_timing_info -> broadcast_interval ) , US_TO_S (time_since_last_synch_us ), fhss_structure -> ws -> drift_per_millisecond_ns );
809
810
}
810
811
return 0 ;
811
812
}
@@ -859,5 +860,4 @@ int fhss_ws_set_hop_count(fhss_structure_t *fhss_structure, const uint8_t hop_co
859
860
fhss_structure -> own_hop = hop_count ;
860
861
return 0 ;
861
862
}
862
-
863
863
#endif // HAVE_WS
0 commit comments