Skip to content

Commit 89826ce

Browse files
author
Jarkko Paso
authored
Iotthd 4224 (ARMmbed#2403)
* FHSS WS: use large retry backoff when broadcast schedule unknown * FHSS WS: Use large randomized retry backoff when TX/RX slots unknown
1 parent 3fc1ae2 commit 89826ce

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
295295
// stop broadcast schedule
296296
fhss_structure->ws->is_on_bc_channel = false;
297297
fhss_structure->ws->synchronization_time = 0;
298+
fhss_structure->ws->broadcast_timer_running = false;
298299
return;
299300
}
300301
if (fhss_structure->ws->is_on_bc_channel == false) {
@@ -479,6 +480,7 @@ static int16_t fhss_ws_synch_state_set_callback(const fhss_api_t *api, fhss_stat
479480
// Start broadcast schedule when BC intervals are known
480481
if (fhss_broadcast_interval && fhss_bc_dwell_interval) {
481482
fhss_broadcast_handler(fhss_structure->fhss_api, 0);
483+
fhss_structure->ws->broadcast_timer_running = true;
482484
}
483485
// Start unicast schedule
484486
if ((fhss_structure->ws->fhss_configuration.ws_uc_channel_function != WS_FIXED_CHANNEL)) {
@@ -491,6 +493,7 @@ static int16_t fhss_ws_synch_state_set_callback(const fhss_api_t *api, fhss_stat
491493
eventOS_callback_timer_stop(fhss_structure->fhss_event_timer);
492494
fhss_stop_timer(fhss_structure, fhss_unicast_handler);
493495
fhss_stop_timer(fhss_structure, fhss_broadcast_handler);
496+
fhss_structure->ws->broadcast_timer_running = false;
494497
}
495498

496499
fhss_structure->fhss_state = fhss_state;
@@ -853,8 +856,13 @@ static uint32_t fhss_ws_get_retry_period_callback(const fhss_api_t *api, uint8_t
853856
if (!fhss_structure) {
854857
return return_value;
855858
}
859+
// We don't know the broadcast schedule, use large backoff with MAC retries
860+
if (fhss_structure->ws->broadcast_timer_running == false) {
861+
return 100000;
862+
}
863+
// We don't know the TX/RX slots, use randomised large backoff with MAC retries
856864
if (fhss_structure->own_hop == 0xff) {
857-
return return_value;
865+
return ((uint32_t) randLIB_get_random_in_range(50, 150) * 1000);
858866
}
859867
if (fhss_structure->ws->is_on_bc_channel == true) {
860868
return return_value;
@@ -955,6 +963,7 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8],
955963
timeout -= MS_TO_US(bc_timing_info->broadcast_interval - bc_timing_info->broadcast_dwell_interval);
956964
}
957965
fhss_ws_start_timer(fhss_structure, timeout, fhss_broadcast_handler);
966+
fhss_structure->ws->broadcast_timer_running = true;
958967
uint16_t slots_since_reception = (bc_timing_info->broadcast_interval_offset + time_from_reception_ms) / bc_timing_info->broadcast_interval;
959968
// TODO: Calculate drift error
960969
fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval = bc_timing_info->broadcast_dwell_interval;

source/Service_Libs/fhss/fhss_ws.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct fhss_ws {
4141
int16_t *tr51_channel_table;
4242
uint8_t *tr51_output_table;
4343
bool unicast_timer_running;
44+
bool broadcast_timer_running;
4445
bool is_on_bc_channel;
4546
struct fhss_ws_configuration fhss_configuration;
4647
const struct broadcast_timing_info *parent_bc_info;

0 commit comments

Comments
 (0)