Skip to content

Commit d092f83

Browse files
author
Jarkko Paso
authored
Iotthd 3995 (#2347)
* FHSS WS: Created test api for setting number of channel retries * FHSS WS: API to configure channel retries * Compiler warning if max frame retries is too low
1 parent e2ea4e4 commit d092f83

File tree

7 files changed

+67
-7
lines changed

7 files changed

+67
-7
lines changed

nanostack/fhss_config.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ typedef struct fhss_configuration {
8888
*/
8989
typedef int32_t fhss_vendor_defined_cf(const fhss_api_t *api, uint16_t slot, uint8_t eui64[8], uint16_t bsi, uint16_t number_of_channels);
9090

91+
/**
92+
* \brief Struct fhss_config_parameters defines FHSS configuration parameters.
93+
*
94+
*/
95+
typedef struct fhss_config_parameters {
96+
/** Number of channel retries defines how many consecutive channels are used when retransmitting a frame after initial transmission channel. */
97+
uint8_t number_of_channel_retries;
98+
} fhss_config_parameters_t;
99+
100+
91101
/**
92102
* \brief Struct fhss_ws_configuration defines configuration of WS FHSS.
93103
*/
@@ -125,6 +135,9 @@ typedef struct fhss_ws_configuration {
125135
/** Vendor defined channel function. */
126136
fhss_vendor_defined_cf *vendor_defined_cf;
127137

138+
/** Configuration parameters. */
139+
fhss_config_parameters_t config_parameters;
140+
128141
} fhss_ws_configuration_t;
129142

130143
/**

nanostack/fhss_test_api.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ extern "C" {
3939
*/
4040
int8_t fhss_set_optimal_packet_length(const fhss_api_t *fhss_api, uint16_t packet_length);
4141

42+
/**
43+
* \brief Set number of channel retries
44+
*
45+
* \param fhss_api FHSS instance.
46+
* \param number_of_channel_retries Number of channel retries
47+
*
48+
* \return 0 Success
49+
* \return -1 Failure
50+
*/
51+
int8_t fhss_set_number_of_channel_retries(const fhss_api_t *fhss_api, uint8_t number_of_channel_retries);
52+
4253
#ifdef __cplusplus
4354
}
4455
#endif

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ static int8_t ws_fhss_initialize(protocol_interface_info_entry_t *cur)
510510
fhss_configuration.ws_bc_channel_function = (fhss_ws_channel_functions)cur->ws_info->cfg->fhss.fhss_bc_channel_function;
511511
fhss_configuration.fhss_bc_dwell_interval = cur->ws_info->cfg->fhss.fhss_bc_dwell_interval;
512512
fhss_configuration.fhss_broadcast_interval = cur->ws_info->cfg->fhss.fhss_bc_interval;
513+
fhss_configuration.config_parameters.number_of_channel_retries = WS_NUMBER_OF_CHANNEL_RETRIES;
513514
fhss_api = ns_fhss_ws_create(&fhss_configuration, cur->ws_info->fhss_timer_ptr);
514515

515516
if (!fhss_api) {
@@ -1957,6 +1958,8 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
19571958
set_req.value_size = sizeof(bool);
19581959
cur->mac_api->mlme_req(cur->mac_api, MLME_SET, &set_req);
19591960

1961+
mac_helper_mac_mlme_max_retry_set(cur->id, WS_MAX_FRAME_RETRIES);
1962+
19601963
// Set the default parameters for MPL
19611964
cur->mpl_proactive_forwarding = true;
19621965

source/6LoWPAN/ws/ws_common_defines.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,26 @@ typedef struct ws_bs_ie {
295295
*/
296296
#define WS_TACK_MAX_MS 5
297297

298+
299+
/* WS requires at least 19 MAC retransmissions (total 1+19=20 attempts). Default 802.15.4 macMaxFrameRetries is 3 (total 1+3=4 attempts).
300+
* At least 4 channel retries must be used: (Initial channel + WS_NUMBER_OF_CHANNEL_RETRIES) * MAC attempts = (1+4)*4=20 attempts
301+
*
302+
* Valid settings could be for example:
303+
* WS_MAX_FRAME_RETRIES WS_NUMBER_OF_CHANNEL_RETRIES Total attempts
304+
* 0 19 1+0*1+19=20
305+
* 1 9 1+1*1+9=20
306+
* 2 6 1+2*1+6=21
307+
* 3 4 1+3*1+4=20
308+
*
309+
*/
310+
#define WS_MAX_FRAME_RETRIES 3
311+
#define WS_NUMBER_OF_CHANNEL_RETRIES 4
312+
313+
314+
#if (1 + WS_MAX_FRAME_RETRIES) * (1 + WS_NUMBER_OF_CHANNEL_RETRIES) < 20
315+
#warning "MAX frame retries set too low"
316+
#endif
317+
298318
/*
299319
* Config new version consistent filter period in 100ms periods
300320
*/

source/Service_Libs/fhss/fhss_test_api.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,18 @@ int8_t fhss_set_optimal_packet_length(const fhss_api_t *fhss_api, uint16_t packe
4444
#endif
4545
return 0;
4646
}
47+
48+
int8_t fhss_set_number_of_channel_retries(const fhss_api_t *fhss_api, uint8_t number_of_channel_retries)
49+
{
50+
(void) fhss_api;
51+
(void) number_of_channel_retries;
52+
#ifdef HAVE_WS
53+
fhss_structure_t *fhss_structure = fhss_get_object_with_api(fhss_api);
54+
if (!fhss_structure || !fhss_structure->ws) {
55+
return -1;
56+
}
57+
fhss_structure->ws->fhss_configuration.config_parameters.number_of_channel_retries = number_of_channel_retries;
58+
tr_debug("Setting number of channel retries to: %u", number_of_channel_retries);
59+
#endif
60+
return 0;
61+
}

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,16 +750,18 @@ static bool fhss_ws_data_tx_fail_callback(const fhss_api_t *api, uint8_t handle,
750750
if (fhss_structure->fhss_state == FHSS_UNSYNCHRONIZED) {
751751
return false;
752752
}
753-
754753
// Use channel retries only for data frames
755754
if (FHSS_DATA_FRAME != frame_type) {
756755
return false;
757756
}
758-
757+
// Channel retries are disabled
758+
if (!fhss_structure->ws->fhss_configuration.config_parameters.number_of_channel_retries) {
759+
return false;
760+
}
759761
fhss_failed_tx_t *fhss_failed_tx = fhss_failed_handle_find(fhss_structure, handle);
760762
if (fhss_failed_tx) {
761763
fhss_failed_tx->retries_done++;
762-
if (fhss_failed_tx->retries_done >= WS_NUMBER_OF_CHANNEL_RETRIES) {
764+
if (fhss_failed_tx->retries_done >= fhss_structure->ws->fhss_configuration.config_parameters.number_of_channel_retries) {
763765
// No more retries. Return false to stop retransmitting.
764766
fhss_failed_handle_remove(fhss_structure, handle);
765767
return false;

source/Service_Libs/fhss/fhss_ws.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
#ifndef FHSS_WS_H_
1818
#define FHSS_WS_H_
1919

20-
/* WS requires at least 19 MAC retransmissions (total 1+19=20 attempts). 802.15.4 macMaxFrameRetries is 3 (total 1+3=4 attempts).
21-
* At least 4 channel retries must be used: (Initial channel + WS_NUMBER_OF_CHANNEL_RETRIES) * MAC attempts = (1+4)*4=20 attempts
22-
*/
23-
#define WS_NUMBER_OF_CHANNEL_RETRIES 4
2420
// TX slot length is optimised to this packet length
2521
#define OPTIMAL_PACKET_LENGTH 500
2622
// Default TX/RX slot length in milliseconds. Is used when datarate is not given by PHY.

0 commit comments

Comments
 (0)