Skip to content

Commit 8f194f8

Browse files
author
Jarkko Paso
committed
FHSS: Implemented TX slot calculation
1 parent b06b58a commit 8f194f8

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,29 @@ static bool fhss_check_bad_channel(fhss_structure_t *fhss_structure, uint8_t han
309309

310310
static bool fhss_ws_check_tx_allowed(fhss_structure_t *fhss_structure)
311311
{
312-
return true;
312+
// Ignore TX/RX slots
313+
if (fhss_structure->own_hop == 0xff) {
314+
return true;
315+
}
316+
// Currently on broadcast channel
317+
if (fhss_structure->ws->is_on_bc_channel == true) {
318+
return true;
319+
}
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);
321+
uint32_t remaining_time_ms = fhss_structure->platform_functions.fhss_get_remaining_slots(fhss_broadcast_handler, fhss_structure->fhss_api) / 1000;
322+
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));
323+
uint32_t rx_slot_begin = tx_slot_begin - slot_len_ms;
324+
uint8_t n_o_tx_slots = WS_NUMBER_OF_TX_SLOTS;
325+
326+
while (n_o_tx_slots--) {
327+
if ((remaining_time_ms <= tx_slot_begin) && (remaining_time_ms > rx_slot_begin)) {
328+
return true;
329+
}
330+
tx_slot_begin -= (2*slot_len_ms);
331+
rx_slot_begin = tx_slot_begin - slot_len_ms;
332+
}
333+
334+
return false;
313335
}
314336

315337
static bool fhss_ws_check_tx_conditions_callback(const fhss_api_t *api, bool is_broadcast_addr, uint8_t handle, int frame_type, uint16_t frame_length, uint8_t phy_header_length, uint8_t phy_tail_length)

source/Service_Libs/fhss/fhss_ws.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +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
2426
typedef struct fhss_ws fhss_ws_t;
2527

2628
struct fhss_ws

0 commit comments

Comments
 (0)