Skip to content

Commit ef38363

Browse files
author
Jarkko Paso
committed
FHSS: Traces in set parent
1 parent 296e455 commit ef38363

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,10 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8],
730730
if ((S_TO_US(fhss_structure->ws->min_synch_interval) > (fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api) - fhss_structure->ws->synchronization_time)) && !force_synch) {
731731
return 0;
732732
}
733-
fhss_structure->ws->synchronization_time = fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api);
734733
platform_enter_critical();
734+
uint32_t prev_synchronization_time = fhss_structure->ws->synchronization_time;
735+
fhss_structure->ws->synchronization_time = fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api);
736+
uint32_t own_bc_interval_offset = fhss_ws_calculate_broadcast_interval_offset(fhss_structure, fhss_structure->ws->synchronization_time);
735737
fhss_stop_timer(fhss_structure, fhss_broadcast_handler);
736738
uint32_t time_from_reception_ms = US_TO_MS(fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api) - bc_timing_info->bt_rx_timestamp);
737739
uint32_t true_bc_interval_offset = (bc_timing_info->broadcast_interval_offset + time_from_reception_ms) % bc_timing_info->broadcast_interval;
@@ -756,6 +758,9 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8],
756758
platform_exit_critical();
757759
//TODO: support multiple parents
758760
fhss_structure->ws->parent_bc_info = bc_timing_info;
761+
if (prev_synchronization_time) {
762+
tr_debug("synch to parent: %s, drift: %ims in %u seconds", trace_array(eui64, 8), true_bc_interval_offset-own_bc_interval_offset, US_TO_S(fhss_structure->ws->synchronization_time-prev_synchronization_time));
763+
}
759764
return 0;
760765
}
761766

0 commit comments

Comments
 (0)