Skip to content

Commit 00bbd02

Browse files
author
Jarkko Paso
authored
Don't allow TX slot length go below allowed minimum (ARMmbed#2528)
1 parent 8333faa commit 00bbd02

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void fhss_set_txrx_slot_length(fhss_structure_t *fhss_structure)
195195
if (fhss_structure->ws->fhss_configuration.fhss_broadcast_interval == 0 || fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval == 0) {
196196
return;
197197
}
198-
uint32_t txrx_slot_length_ms_tmp = WS_TXRX_SLOT_LEN_MS;
198+
uint32_t txrx_slot_length_ms_tmp = WS_TXRX_SLOT_LEN_MS_MAX;
199199
if (fhss_structure->callbacks.read_datarate) {
200200
/* Calculate minimum TX slot length which can fit optimal packet length twice.
201201
* Twice, because 0, 1, 4, 5... hop starts transmission at the beginning of TX slot and 2, 3, 6, 7... hop at the middle of TX slot
@@ -217,9 +217,14 @@ void fhss_set_txrx_slot_length(fhss_structure_t *fhss_structure)
217217
if (datarate) {
218218
txrx_slot_length_ms_tmp = ((fhss_structure->optimal_packet_length * 2) * (8000000 / datarate)) / 1000;
219219
// Do not allow using too high TX slot length.
220-
if (txrx_slot_length_ms_tmp > WS_TXRX_SLOT_LEN_MS) {
221-
tr_debug("TX slot length setting too high %"PRIu32"ms, using %"PRIu32"ms", txrx_slot_length_ms_tmp, (uint32_t)WS_TXRX_SLOT_LEN_MS);
222-
txrx_slot_length_ms_tmp = WS_TXRX_SLOT_LEN_MS;
220+
if (txrx_slot_length_ms_tmp > WS_TXRX_SLOT_LEN_MS_MAX) {
221+
tr_debug("TX slot length setting too high %"PRIu32"ms, using %"PRIu32"ms", txrx_slot_length_ms_tmp, (uint32_t)WS_TXRX_SLOT_LEN_MS_MAX);
222+
txrx_slot_length_ms_tmp = WS_TXRX_SLOT_LEN_MS_MAX;
223+
}
224+
// Do not allow using too low TX slot length.
225+
if (txrx_slot_length_ms_tmp < WS_TXRX_SLOT_LEN_MS_MIN) {
226+
tr_debug("TX slot length setting too low %"PRIu32"ms, using %"PRIu32"ms", txrx_slot_length_ms_tmp, (uint32_t)WS_TXRX_SLOT_LEN_MS_MIN);
227+
txrx_slot_length_ms_tmp = WS_TXRX_SLOT_LEN_MS_MIN;
223228
}
224229
}
225230
}

source/Service_Libs/fhss/fhss_ws.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919

2020
// TX slot length is optimised to this packet length
2121
#define OPTIMAL_PACKET_LENGTH 500
22-
// Default TX/RX slot length in milliseconds. Is used when datarate is not given by PHY.
23-
#define WS_TXRX_SLOT_LEN_MS 100
22+
// Max TX/RX slot length in milliseconds. Is used when datarate is not given by PHY or calculated slot length exceeds maximum allowed.
23+
#define WS_TXRX_SLOT_LEN_MS_MAX 100
24+
// Min TX/RX slot length in milliseconds. Is used when calculated slot length is under minimum allowed.
25+
#define WS_TXRX_SLOT_LEN_MS_MIN 10
2426
// Default minimum broadcast synchronization interval in seconds
2527
#define DEFAULT_MIN_SYNCH_INTERVAL 60
2628
// Drift compensation allowed if at least SYNCH_COMPENSATION_MIN_INTERVAL (seconds) since last synchronization

0 commit comments

Comments
 (0)