Skip to content

Commit ec1c41d

Browse files
author
Jarkko Paso
committed
FHSS: Use given TX time in synch calculation
1 parent f0c0f66 commit ec1c41d

File tree

1 file changed

+10
-4
lines changed
  • source/Service_Libs/fhss

1 file changed

+10
-4
lines changed

source/Service_Libs/fhss/fhss.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static int8_t fhss_beacon_create_tasklet(fhss_structure_t *fhss_structure);
4545
static void fhss_beacon_tasklet_func(arm_event_s *event);
4646
static int fhss_beacon_periodic_start(fhss_structure_t *fhss_structure, uint32_t time_to_first_beacon);
4747
static void fhss_beacon_periodic_stop(fhss_structure_t *fhss_structure);
48+
static int fhss_reset_synch_monitor(fhss_synch_monitor_s *synch_monitor);
4849

4950
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)
5051
{
@@ -80,6 +81,7 @@ fhss_structure_t *fhss_enable(fhss_api_t *fhss_api, const fhss_configuration_t *
8081
if (!fhss_struct->bs->fhss_configuration.fhss_max_synch_interval) {
8182
fhss_struct->bs->fhss_configuration.fhss_max_synch_interval = 240;
8283
}
84+
fhss_reset_synch_monitor(&fhss_struct->bs->synch_monitor);
8385
ns_list_init(&fhss_struct->fhss_failed_tx_list);
8486
fhss_struct->own_hop = 0xff;
8587
fhss_reset(fhss_struct);
@@ -1059,7 +1061,7 @@ static uint8_t *fhss_beacon_encode_raw(uint8_t *buffer, const fhss_synchronizati
10591061
return buffer;
10601062
}
10611063

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)
10631065
{
10641066
fhss_synchronization_beacon_payload_s temp_payload;
10651067
platform_enter_critical();
@@ -1075,8 +1077,12 @@ static void fhss_beacon_build(fhss_structure_t *fhss_structure, uint8_t *dest)
10751077
temp_payload.number_of_broadcast_channels = config->fhss_number_of_bc_channels;
10761078
temp_payload.number_of_tx_slots = config->fhss_number_of_tx_slots;
10771079
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;
10801086
temp_payload.superframe_length = config->fhss_superframe_length;
10811087
temp_payload.number_of_superframes_per_channel = config->fhss_number_of_superframes;
10821088
platform_exit_critical();
@@ -1091,7 +1097,7 @@ static int16_t fhss_write_synch_info_callback(const fhss_api_t *api, uint8_t *pt
10911097
if (!fhss_structure || !ptr || (frame_type != FHSS_SYNCH_FRAME)) {
10921098
return -1;
10931099
}
1094-
fhss_beacon_build(fhss_structure, ptr);
1100+
fhss_beacon_build(fhss_structure, ptr, tx_time);
10951101
return FHSS_SYNCH_INFO_LENGTH;
10961102
}
10971103

0 commit comments

Comments
 (0)