Skip to content

Commit 3d1c8a0

Browse files
author
Jarkko Paso
committed
FHSS: Stop unicast schedule when fixed channel or no dwell interval
1 parent 62ffba3 commit 3d1c8a0

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

source/Service_Libs/fhss/fhss_common.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ void fhss_start_timer(fhss_structure_t *fhss_structure, uint32_t time, void (*ca
130130
}
131131
}
132132

133+
void fhss_stop_timer(fhss_structure_t *fhss_structure, void (*callback)(const fhss_api_t *fhss_api, uint16_t))
134+
{
135+
if (callback){
136+
fhss_structure->platform_functions.fhss_timer_stop(callback, fhss_structure->fhss_api);
137+
}
138+
}
139+
133140
int fhss_timeout_start(fhss_structure_t *fhss_structure, uint32_t time)
134141
{
135142
if (!fhss_structure) {

source/Service_Libs/fhss/fhss_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ fhss_structure_t *fhss_get_object_with_api(const fhss_api_t *fhss_api);
6262
void fhss_clear_active_event(fhss_structure_t *fhss_structure, uint8_t event_type);
6363
int8_t fhss_disable(fhss_structure_t *fhss_structure);
6464
void fhss_start_timer(fhss_structure_t *fhss_structure, uint32_t time, void (*callback)(const fhss_api_t *fhss_api, uint16_t));
65+
void fhss_stop_timer(fhss_structure_t *fhss_structure, void (*callback)(const fhss_api_t *fhss_api, uint16_t));
6566
int fhss_timeout_start(fhss_structure_t *fhss_structure, uint32_t time);
6667
int fhss_timeout_stop(fhss_structure_t *fhss_structure);
6768
int fhss_update_synch_parent_address(fhss_structure_t *fhss_structure);

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ static int16_t fhss_ws_synch_state_set_callback(const fhss_api_t *api, fhss_stat
302302
if ((fhss_structure->ws->fhss_configuration.ws_uc_channel_function != WS_FIXED_CHANNEL)) {
303303
fhss_ws_update_uc_channel_callback(fhss_structure);
304304
fhss_start_timer(fhss_structure, fhss_structure->ws->fhss_configuration.fhss_uc_dwell_interval*1000, fhss_unicast_handler);
305+
fhss_structure->ws->unicast_timer_running = true;
305306
}
306307
}
307308

@@ -622,7 +623,13 @@ static void fhss_unicast_handler(const fhss_api_t *fhss_api, uint16_t delay)
622623
return;
623624
}
624625
timeout = fhss_ws_get_sf_timeout_callback(fhss_structure);
626+
if (!timeout) {
627+
fhss_stop_timer(fhss_structure, fhss_unicast_handler);
628+
fhss_structure->ws->unicast_timer_running = false;
629+
return;
630+
}
625631
fhss_start_timer(fhss_structure, timeout - (delay * fhss_structure->platform_functions.fhss_resolution_divider), fhss_unicast_handler);
632+
fhss_structure->ws->unicast_timer_running = true;
626633
fhss_ws_update_uc_channel_callback(fhss_structure);
627634
// Unless we have broadcast schedule, we have to poll unicast queue when changing channel. This is randomized by the unicast schedule.
628635
if (!fhss_structure->ws->fhss_configuration.fhss_broadcast_interval || !fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval) {
@@ -660,7 +667,7 @@ int fhss_ws_set_parent(fhss_structure_t *fhss_structure, const uint8_t eui64[8],
660667
return -1;
661668
}
662669
platform_enter_critical();
663-
fhss_structure->platform_functions.fhss_timer_stop(fhss_broadcast_handler, fhss_structure->fhss_api);
670+
fhss_stop_timer(fhss_structure, fhss_broadcast_handler);
664671
uint32_t time_from_reception_ms = (fhss_structure->callbacks.read_timestamp(fhss_structure->fhss_api) - bc_timing_info->bt_rx_timestamp)/1000;
665672
uint32_t true_bc_interval_offset = (bc_timing_info->broadcast_interval_offset + time_from_reception_ms) % bc_timing_info->broadcast_interval;
666673
uint32_t timeout = ((bc_timing_info->broadcast_interval-true_bc_interval_offset)*1000);
@@ -697,9 +704,13 @@ int fhss_ws_configuration_set(fhss_structure_t *fhss_structure, const fhss_ws_co
697704
if (channel_count <= 0) {
698705
return -1;
699706
}
700-
if ((fhss_structure->ws->fhss_configuration.ws_uc_channel_function == WS_FIXED_CHANNEL) && (fhss_configuration->ws_uc_channel_function != WS_FIXED_CHANNEL)) {
701-
// Start unicast schedule if channel function changed from fixed channel
707+
if (fhss_configuration->ws_uc_channel_function == WS_FIXED_CHANNEL || fhss_configuration->fhss_uc_dwell_interval == 0) {
708+
fhss_stop_timer(fhss_structure, fhss_unicast_handler);
709+
fhss_structure->ws->unicast_timer_running = false;
710+
}
711+
if ((fhss_structure->ws->unicast_timer_running == false) && (fhss_configuration->ws_uc_channel_function != WS_FIXED_CHANNEL) && fhss_configuration->fhss_uc_dwell_interval) {
702712
fhss_start_timer(fhss_structure, fhss_configuration->fhss_uc_dwell_interval*1000, fhss_unicast_handler);
713+
fhss_structure->ws->unicast_timer_running = true;
703714
}
704715
fhss_structure->ws->fhss_configuration = *fhss_configuration;
705716
fhss_structure->number_of_channels = channel_count;

source/Service_Libs/fhss/fhss_ws.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct fhss_ws
3131
uint16_t uc_slot;
3232
uint16_t bc_slot;
3333
uint32_t txrx_slot_length_ms;
34+
bool unicast_timer_running;
3435
bool is_on_bc_channel;
3536
struct fhss_ws_configuration fhss_configuration;
3637
const struct broadcast_timing_info *parent_bc_info;

test/nanostack/unittest/stub/fhss_common_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ void fhss_start_timer(fhss_structure_t *fhss_structure, uint32_t time, void (*ca
8787
}
8888
}
8989

90+
void fhss_stop_timer(fhss_structure_t *fhss_structure, void (*callback)(const fhss_api_t *fhss_api, uint16_t))
91+
{
92+
93+
}
94+
9095
int fhss_timeout_start(fhss_structure_t *fhss_structure, uint32_t time)
9196
{
9297
return 0;

0 commit comments

Comments
 (0)