@@ -45,6 +45,7 @@ static int8_t fhss_beacon_create_tasklet(fhss_structure_t *fhss_structure);
45
45
static void fhss_beacon_tasklet_func (arm_event_s * event );
46
46
static int fhss_beacon_periodic_start (fhss_structure_t * fhss_structure , uint32_t time_to_first_beacon );
47
47
static void fhss_beacon_periodic_stop (fhss_structure_t * fhss_structure );
48
+ static int fhss_reset_synch_monitor (fhss_synch_monitor_s * synch_monitor );
48
49
49
50
fhss_structure_t * fhss_enable (fhss_api_t * fhss_api , const fhss_configuration_t * fhss_configuration , const fhss_timer_t * fhss_timer , fhss_statistics_t * fhss_statistics )
50
51
{
@@ -80,6 +81,7 @@ fhss_structure_t *fhss_enable(fhss_api_t *fhss_api, const fhss_configuration_t *
80
81
if (!fhss_struct -> bs -> fhss_configuration .fhss_max_synch_interval ) {
81
82
fhss_struct -> bs -> fhss_configuration .fhss_max_synch_interval = 240 ;
82
83
}
84
+ fhss_reset_synch_monitor (& fhss_struct -> bs -> synch_monitor );
83
85
ns_list_init (& fhss_struct -> fhss_failed_tx_list );
84
86
fhss_struct -> own_hop = 0xff ;
85
87
fhss_reset (fhss_struct );
@@ -1059,7 +1061,7 @@ static uint8_t *fhss_beacon_encode_raw(uint8_t *buffer, const fhss_synchronizati
1059
1061
return buffer ;
1060
1062
}
1061
1063
1062
- static void fhss_beacon_build (fhss_structure_t * fhss_structure , uint8_t * dest )
1064
+ static void fhss_beacon_build (fhss_structure_t * fhss_structure , uint8_t * dest , uint32_t tx_time )
1063
1065
{
1064
1066
fhss_synchronization_beacon_payload_s temp_payload ;
1065
1067
platform_enter_critical ();
@@ -1075,8 +1077,12 @@ static void fhss_beacon_build(fhss_structure_t *fhss_structure, uint8_t *dest)
1075
1077
temp_payload .number_of_broadcast_channels = config -> fhss_number_of_bc_channels ;
1076
1078
temp_payload .number_of_tx_slots = config -> fhss_number_of_tx_slots ;
1077
1079
temp_payload .time_since_last_beacon = 0 ; // XXX not available yet
1078
- uint32_t tx_time = fhss_get_tx_time (fhss_structure , 71 , 0 , 0 );
1079
- temp_payload .processing_delay = fhss_structure -> bs -> fhss_configuration .fhss_tuning_parameters .tx_processing_delay + tx_time ;
1080
+ uint32_t time_to_tx = 0 ;
1081
+ uint32_t cur_time = fhss_structure -> callbacks .read_timestamp (fhss_structure -> fhss_api );
1082
+ if (cur_time < tx_time ) {
1083
+ time_to_tx = tx_time - cur_time ;
1084
+ }
1085
+ temp_payload .processing_delay = fhss_structure -> bs -> fhss_configuration .fhss_tuning_parameters .tx_processing_delay + time_to_tx ;
1080
1086
temp_payload .superframe_length = config -> fhss_superframe_length ;
1081
1087
temp_payload .number_of_superframes_per_channel = config -> fhss_number_of_superframes ;
1082
1088
platform_exit_critical ();
@@ -1091,7 +1097,7 @@ static int16_t fhss_write_synch_info_callback(const fhss_api_t *api, uint8_t *pt
1091
1097
if (!fhss_structure || !ptr || (frame_type != FHSS_SYNCH_FRAME )) {
1092
1098
return -1 ;
1093
1099
}
1094
- fhss_beacon_build (fhss_structure , ptr );
1100
+ fhss_beacon_build (fhss_structure , ptr , tx_time );
1095
1101
return FHSS_SYNCH_INFO_LENGTH ;
1096
1102
}
1097
1103
0 commit comments