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

Commit 0ba4b9a

Browse files
author
Jarkko Paso
authored
Merge pull request ARMmbed#1700 from ARMmbed/IOTTHD-2483
FHSS: Calculate number of TX slots using defined slot length
2 parents ba98835 + 34c0df9 commit 0ba4b9a

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
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

test/nanostack/unittest/service_libs/fhss_ws/test_fhss_ws.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,12 @@ bool test_fhss_ws_check_tx_conditions_callback()
327327
fhss_common_stub.fhss_struct.own_hop = 0;
328328
fhss_common_stub.fhss_struct.ws->fhss_configuration.fhss_broadcast_interval = 800;
329329
fhss_common_stub.fhss_struct.ws->fhss_configuration.fhss_bc_dwell_interval = 200;
330-
fhss_platform_stub.remaining_slots_value = 500000;
330+
fhss_platform_stub.remaining_slots_value = 550000;
331331
if (fhss_common_stub.fhss_struct.fhss_api->check_tx_conditions(api, DEFAULT_IS_BC_DEST, DEFAULT_HANDLE, DEFAULT_FRAME_TYPE, DEFAULT_FRAME_LENGTH, DEFAULT_PHY_HEAD_LENGTH, DEFAULT_PHY_TAIL_LENGTH) != true) {
332332
return false;
333333
}
334334
// Test TX not allowed for 0 hop
335-
fhss_platform_stub.remaining_slots_value = 400000;
335+
fhss_platform_stub.remaining_slots_value = 450000;
336336
if (fhss_common_stub.fhss_struct.fhss_api->check_tx_conditions(api, DEFAULT_IS_BC_DEST, DEFAULT_HANDLE, DEFAULT_FRAME_TYPE, DEFAULT_FRAME_LENGTH, DEFAULT_PHY_HEAD_LENGTH, DEFAULT_PHY_TAIL_LENGTH) != false) {
337337
return false;
338338
}
@@ -356,7 +356,7 @@ bool test_fhss_ws_check_tx_conditions_callback()
356356
return false;
357357
}
358358
// Test TX not allowed for 2nd hop
359-
fhss_platform_stub.remaining_slots_value = 400000;
359+
fhss_platform_stub.remaining_slots_value = 100000;
360360
if (fhss_common_stub.fhss_struct.fhss_api->check_tx_conditions(api, DEFAULT_IS_BC_DEST, DEFAULT_HANDLE, DEFAULT_FRAME_TYPE, DEFAULT_FRAME_LENGTH, DEFAULT_PHY_HEAD_LENGTH, DEFAULT_PHY_TAIL_LENGTH) != false) {
361361
return false;
362362
}

0 commit comments

Comments
 (0)