Skip to content

Commit 59397d1

Browse files
author
Mika Tervonen
committed
Fixed Wi-SUN border router restart after settings change
Moved RF configuration function to separate calls from setting change called configurations from bootstrap Added cleanup functions to restart
1 parent 8295a43 commit 59397d1

File tree

3 files changed

+34
-21
lines changed

3 files changed

+34
-21
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,19 @@ int ws_bootstrap_aro_failure(protocol_interface_info_entry_t *cur, const uint8_t
20522052
return 0;
20532053
}
20542054

2055+
static int ws_bootstrap_set_domain_rf_config(protocol_interface_info_entry_t *cur)
2056+
{
2057+
phy_rf_channel_configuration_s rf_configs;
2058+
rf_configs.channel_0_center_frequency = (uint32_t)cur->ws_info->hopping_schdule.ch0_freq * 100000;
2059+
rf_configs.channel_spacing = ws_decode_channel_spacing(cur->ws_info->hopping_schdule.channel_spacing);
2060+
rf_configs.datarate = ws_get_datarate_using_operating_mode(cur->ws_info->hopping_schdule.operating_mode);
2061+
rf_configs.modulation_index = ws_get_modulation_index_using_operating_mode(cur->ws_info->hopping_schdule.operating_mode);
2062+
rf_configs.modulation = M_2FSK;
2063+
rf_configs.number_of_channels = cur->ws_info->hopping_schdule.number_of_channels;
2064+
ws_bootstrap_set_rf_config(cur, rf_configs);
2065+
return 0;
2066+
}
2067+
20552068
static void ws_bootstrap_mac_activate(protocol_interface_info_entry_t *cur, uint16_t channel, uint16_t panid, bool coordinator)
20562069
{
20572070
mlme_start_t start_req;
@@ -2484,6 +2497,7 @@ static void ws_bootstrap_network_discovery_configure(protocol_interface_info_ent
24842497
cur->ws_info->network_pan_id = 0xffff;
24852498

24862499
ws_common_regulatory_domain_config(cur, &cur->ws_info->hopping_schdule);
2500+
ws_bootstrap_set_domain_rf_config(cur);
24872501
ws_fhss_configure(cur, true);
24882502

24892503
//Set Network names, Pan information configure, hopping schedule & GTKHash
@@ -2909,12 +2923,18 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
29092923
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
29102924
tr_info("Border router start network");
29112925

2926+
29122927
if (!ws_bbr_ready_to_start(cur)) {
29132928
// Wi-SUN not started yet we wait for Border router permission
29142929
ws_bootstrap_state_change(cur, ER_WAIT_RESTART);
29152930
cur->nwk_nd_re_scan_count = randLIB_get_random_in_range(40, 100);
29162931
return;
29172932
}
2933+
// Clear Old information from stack
2934+
2935+
ws_nud_table_reset(cur);
2936+
ws_bootstrap_neighbor_list_clean(cur);
2937+
ws_bootstrap_ip_stack_reset(cur);
29182938
ws_pae_controller_auth_init(cur);
29192939

29202940
// Randomize fixed channels. Only used if channel plan is fixed.
@@ -2937,9 +2957,10 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
29372957
ws_bbr_pan_version_increase(cur);
29382958

29392959
// Set default parameters for FHSS when starting a discovery
2960+
ws_common_regulatory_domain_config(cur, &cur->ws_info->hopping_schdule);
29402961
ws_fhss_border_router_configure(cur);
2962+
ws_bootstrap_set_domain_rf_config(cur);
29412963
ws_bootstrap_fhss_activate(cur);
2942-
ws_bootstrap_event_operation_start(cur);
29432964

29442965
uint8_t ll_addr[16];
29452966
addr_interface_get_ll_address(cur, ll_addr, 1);
@@ -2958,6 +2979,8 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
29582979

29592980
// Set PAE port to 10254 and authenticator relay to 10253 (and to own ll address)
29602981
ws_pae_controller_authenticator_start(cur, PAE_AUTH_SOCKET_PORT, ll_addr, EAPOL_RELAY_SOCKET_PORT);
2982+
2983+
ws_bootstrap_event_operation_start(cur);
29612984
break;
29622985
}
29632986
ws_pae_controller_supp_init(cur);

source/6LoWPAN/ws/ws_common.c

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int8_t ws_generate_channel_list(uint32_t *channel_mask, uint16_t number_of_chann
5959
return 0;
6060
}
6161

62-
static uint32_t ws_decode_channel_spacing(uint8_t channel_spacing)
62+
uint32_t ws_decode_channel_spacing(uint8_t channel_spacing)
6363
{
6464
if (CHANNEL_SPACING_100 == channel_spacing) {
6565
return 100000;
@@ -75,7 +75,7 @@ static uint32_t ws_decode_channel_spacing(uint8_t channel_spacing)
7575
return 0;
7676
}
7777

78-
static uint32_t ws_get_datarate_using_operating_mode(uint8_t operating_mode)
78+
uint32_t ws_get_datarate_using_operating_mode(uint8_t operating_mode)
7979
{
8080
if ((OPERATING_MODE_1a == operating_mode) || (OPERATING_MODE_1b == operating_mode)) {
8181
return 50000;
@@ -91,7 +91,7 @@ static uint32_t ws_get_datarate_using_operating_mode(uint8_t operating_mode)
9191
return 0;
9292
}
9393

94-
static phy_modulation_index_e ws_get_modulation_index_using_operating_mode(uint8_t operating_mode)
94+
phy_modulation_index_e ws_get_modulation_index_using_operating_mode(uint8_t operating_mode)
9595
{
9696
if ((OPERATING_MODE_1b == operating_mode) || (OPERATING_MODE_2b == operating_mode) || (OPERATING_MODE_4b == operating_mode)) {
9797
return MODULATION_INDEX_1_0;
@@ -100,21 +100,9 @@ static phy_modulation_index_e ws_get_modulation_index_using_operating_mode(uint8
100100
}
101101
}
102102

103-
static int ws_set_domain_rf_config(protocol_interface_info_entry_t *cur)
104-
{
105-
phy_rf_channel_configuration_s rf_configs;
106-
rf_configs.channel_0_center_frequency = (uint32_t)cur->ws_info->hopping_schdule.ch0_freq * 100000;
107-
rf_configs.channel_spacing = ws_decode_channel_spacing(cur->ws_info->hopping_schdule.channel_spacing);
108-
rf_configs.datarate = ws_get_datarate_using_operating_mode(cur->ws_info->hopping_schdule.operating_mode);
109-
rf_configs.modulation_index = ws_get_modulation_index_using_operating_mode(cur->ws_info->hopping_schdule.operating_mode);
110-
rf_configs.modulation = M_2FSK;
111-
rf_configs.number_of_channels = cur->ws_info->hopping_schdule.number_of_channels;
112-
ws_bootstrap_set_rf_config(cur, rf_configs);
113-
return 0;
114-
}
115-
116103
int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur, ws_hopping_schedule_t *hopping_schdule)
117104
{
105+
(void)cur;
118106
if (ws_get_datarate_using_operating_mode(hopping_schdule->operating_mode) == 0) {
119107
//Unsupported operation mode
120108
return -1;
@@ -201,10 +189,6 @@ int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur,
201189
if (!hopping_schdule->number_of_channels) {
202190
return -1;
203191
}
204-
205-
if (cur) {
206-
ws_set_domain_rf_config(cur);
207-
}
208192
return 0;
209193
}
210194

source/6LoWPAN/ws/ws_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ typedef struct ws_info_s {
114114

115115
int8_t ws_generate_channel_list(uint32_t *channel_mask, uint16_t number_of_channels, uint8_t regulatory_domain);
116116

117+
uint32_t ws_decode_channel_spacing(uint8_t channel_spacing);
118+
119+
uint32_t ws_get_datarate_using_operating_mode(uint8_t operating_mode);
120+
121+
phy_modulation_index_e ws_get_modulation_index_using_operating_mode(uint8_t operating_mode);
122+
117123
int8_t ws_common_regulatory_domain_config(protocol_interface_info_entry_t *cur, ws_hopping_schedule_t *hopping_schdule);
118124

119125
uint16_t ws_common_channel_number_calc(uint8_t regulatory_domain, uint8_t operating_class);

0 commit comments

Comments
 (0)