Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit ddd7e92

Browse files
author
Jarkko Paso
committed
FHSS: Calculate number of TX slots using defined slot length
1 parent ba98835 commit ddd7e92

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,16 @@ static bool fhss_ws_check_tx_allowed(fhss_structure_t *fhss_structure)
317317
if (fhss_structure->ws->is_on_bc_channel == true) {
318318
return true;
319319
}
320-
uint32_t slot_len_ms = (fhss_structure->ws->fhss_configuration.fhss_broadcast_interval - fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval) / (WS_NUMBER_OF_TX_SLOTS * 2);
320+
uint8_t number_of_tx_slots = ((fhss_structure->ws->fhss_configuration.fhss_broadcast_interval - fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval) / WS_MAX_TXRX_SLOT_LEN_MS) / 2;
321+
// Allow transmission when broadcast interval is very short comparing to MAX slot length
322+
if (!number_of_tx_slots) {
323+
return true;
324+
}
325+
uint32_t slot_len_ms = (fhss_structure->ws->fhss_configuration.fhss_broadcast_interval - fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval) / (number_of_tx_slots * 2);
321326
uint32_t remaining_time_ms = fhss_structure->platform_functions.fhss_get_remaining_slots(fhss_broadcast_handler, fhss_structure->fhss_api) / 1000;
322327
uint32_t tx_slot_begin = (fhss_structure->ws->fhss_configuration.fhss_broadcast_interval - fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval) - (slot_len_ms * (fhss_structure->own_hop & 1));
323328
uint32_t rx_slot_begin = tx_slot_begin - slot_len_ms;
324-
uint8_t n_o_tx_slots = WS_NUMBER_OF_TX_SLOTS;
329+
uint8_t n_o_tx_slots = number_of_tx_slots;
325330

326331
while (n_o_tx_slots--) {
327332
if ((remaining_time_ms <= tx_slot_begin) && (remaining_time_ms > rx_slot_begin)) {

source/Service_Libs/fhss/fhss_ws.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
* At least 4 channel retries must be used: (Initial channel + WS_NUMBER_OF_CHANNEL_RETRIES) * MAC attempts = (1+4)*4=20 attempts
2222
*/
2323
#define WS_NUMBER_OF_CHANNEL_RETRIES 4
24-
//TODO: Make this configurable
25-
#define WS_NUMBER_OF_TX_SLOTS 2
24+
//TX/RX slot length in milliseconds
25+
#define WS_MAX_TXRX_SLOT_LEN_MS 100
2626
typedef struct fhss_ws fhss_ws_t;
2727

2828
struct fhss_ws

0 commit comments

Comments
 (0)