Skip to content

Commit

Permalink
FHSS: Calculate number of TX slots using defined slot length
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarkko Paso committed May 11, 2018
1 parent ba98835 commit ddd7e92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions source/Service_Libs/fhss/fhss_ws.c
Expand Up @@ -317,11 +317,16 @@ static bool fhss_ws_check_tx_allowed(fhss_structure_t *fhss_structure)
if (fhss_structure->ws->is_on_bc_channel == true) {
return true;
}
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);
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;
// Allow transmission when broadcast interval is very short comparing to MAX slot length
if (!number_of_tx_slots) {
return true;
}
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);
uint32_t remaining_time_ms = fhss_structure->platform_functions.fhss_get_remaining_slots(fhss_broadcast_handler, fhss_structure->fhss_api) / 1000;
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));
uint32_t rx_slot_begin = tx_slot_begin - slot_len_ms;
uint8_t n_o_tx_slots = WS_NUMBER_OF_TX_SLOTS;
uint8_t n_o_tx_slots = number_of_tx_slots;

while (n_o_tx_slots--) {
if ((remaining_time_ms <= tx_slot_begin) && (remaining_time_ms > rx_slot_begin)) {
Expand Down
4 changes: 2 additions & 2 deletions source/Service_Libs/fhss/fhss_ws.h
Expand Up @@ -21,8 +21,8 @@
* At least 4 channel retries must be used: (Initial channel + WS_NUMBER_OF_CHANNEL_RETRIES) * MAC attempts = (1+4)*4=20 attempts
*/
#define WS_NUMBER_OF_CHANNEL_RETRIES 4
//TODO: Make this configurable
#define WS_NUMBER_OF_TX_SLOTS 2
//TX/RX slot length in milliseconds
#define WS_MAX_TXRX_SLOT_LEN_MS 100
typedef struct fhss_ws fhss_ws_t;

struct fhss_ws
Expand Down

0 comments on commit ddd7e92

Please sign in to comment.