Skip to content

Commit b162d7b

Browse files
author
Mika Tervonen
committed
added support for modifying fhss configuration after initial startup
Refactored default configuration set so that configuration is only called onse Separated border router configuration Save fixed channel only when updating to fixed channel Fixed Configuration inconsistency/consistency rules modify ASYNC message sending to use full channel mask and not follow the configured channel mask
1 parent 88e239d commit b162d7b

File tree

2 files changed

+55
-39
lines changed

2 files changed

+55
-39
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -230,29 +230,34 @@ static int8_t ws_fhss_initialize(protocol_interface_info_entry_t *cur)
230230
}
231231
return 0;
232232
}
233-
static int8_t ws_fhss_set_defaults(protocol_interface_info_entry_t *cur)
233+
static int8_t ws_fhss_set_defaults(protocol_interface_info_entry_t *cur, fhss_ws_configuration_t *fhss_configuration)
234+
{
235+
fhss_configuration->fhss_uc_dwell_interval = cur->ws_info->fhss_uc_dwell_interval;
236+
fhss_configuration->ws_channel_function = cur->ws_info->fhss_channel_function;
237+
fhss_configuration->fhss_bc_dwell_interval = cur->ws_info->fhss_bc_dwell_interval;
238+
fhss_configuration->fhss_broadcast_interval = cur->ws_info->fhss_bc_interval;
239+
ws_generate_channel_list(fhss_configuration->channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);
240+
241+
// using bitwise AND operation for user set channel mask to remove channels not allowed in this device
242+
for (uint8_t n = 0;n < 8;n++) {
243+
fhss_configuration->channel_mask[n] &= cur->ws_info->fhss_channel_mask[n];
244+
}
245+
return 0;
246+
}
247+
static int8_t ws_fhss_border_router_configure(protocol_interface_info_entry_t *cur)
234248
{
235249
// Read configuration of existing FHSS and start using the default values for any network
236250
fhss_ws_configuration_t fhss_configuration = {0};
237251
if (ns_fhss_ws_configuration_get(cur->ws_info->fhss_api)) {
238252
memcpy(&fhss_configuration, ns_fhss_ws_configuration_get(cur->ws_info->fhss_api), sizeof(fhss_ws_configuration_t));
239253
}
240-
241-
fhss_configuration.fhss_uc_dwell_interval = cur->ws_info->fhss_uc_dwell_interval;
242-
fhss_configuration.ws_channel_function = cur->ws_info->fhss_channel_function;
243-
fhss_configuration.fhss_bc_dwell_interval = cur->ws_info->fhss_bc_dwell_interval;
244-
fhss_configuration.fhss_broadcast_interval = cur->ws_info->fhss_bc_interval;
245-
ws_generate_channel_list(fhss_configuration.channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);
246-
247-
// using bitwise AND operation for user set channel mask to remove channels not allowed in this device
248-
for (uint8_t n = 0;n < 8;n++) {
249-
fhss_configuration.channel_mask[n] &= cur->ws_info->fhss_channel_mask[n];
250-
}
251-
254+
ws_fhss_set_defaults(cur, &fhss_configuration);
252255
ns_fhss_ws_configuration_set(cur->ws_info->fhss_api,&fhss_configuration);
256+
ws_bootstrap_llc_hopping_update(cur,&fhss_configuration);
253257

254258
return 0;
255259
}
260+
256261
static int8_t ws_fhss_discovery_configure(protocol_interface_info_entry_t *cur)
257262
{
258263
// Read configuration of existing FHSS and start using the default values for any network
@@ -304,8 +309,13 @@ static void ws_bootstrap_primary_parent_set(struct protocol_interface_info_entry
304309
fhss_ws_configuration_t fhss_configuration;
305310
memcpy(&fhss_configuration, ns_fhss_ws_configuration_get(cur->ws_info->fhss_api), sizeof(fhss_ws_configuration_t));
306311

312+
ws_fhss_set_defaults(cur, &fhss_configuration);
313+
314+
// Learning unicast network configuration
307315
fhss_configuration.ws_channel_function = neighbor_info->ws_neighbor->fhss_data.uc_timing_info.unicast_channel_function;
308-
cur->ws_info->hopping_schdule.fixed_channel = neighbor_info->ws_neighbor->fhss_data.uc_timing_info.fixed_channel;
316+
if (fhss_configuration.ws_channel_function == WS_FIXED_CHANNEL) {
317+
cur->ws_info->hopping_schdule.fixed_channel = neighbor_info->ws_neighbor->fhss_data.uc_timing_info.fixed_channel;
318+
}
309319
/* Learning different unicast is not working currently at fhss network follows border router
310320
*/
311321
// Learn broadcast information from selected parent
@@ -704,16 +714,21 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
704714
ws_neighbor_class_neighbor_broadcast_schedule_set(neighbor_info.ws_neighbor, &ws_bs_ie);
705715
neighbor_info.neighbor->trusted_device = true;
706716

707-
if (cur->ws_info->configuration_learned &&
708-
common_serial_number_greater_16(cur->ws_info->pan_information.pan_version, pan_version)) {
717+
if (cur->ws_info->configuration_learned) {
709718
// received version is lower se we need to reset the trickle
710-
tr_info("older pan version heard");
711-
if (trickle_running(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery)) {
712-
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery);
719+
if (cur->ws_info->pan_information.pan_version == pan_version) {
720+
trickle_consistent_heard(&cur->ws_info->trickle_pan_config);
721+
} else {
722+
tr_info("different pan version heard");
723+
if (trickle_running(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery)) {
724+
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config,&trickle_params_pan_discovery);
725+
}
726+
if (common_serial_number_greater_16(cur->ws_info->pan_information.pan_version, pan_version)) {
727+
// older version heard ignoring the message
728+
return;
729+
}
713730
}
714-
return;
715731
}
716-
trickle_consistent_heard(&cur->ws_info->trickle_pan_config);
717732

718733
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
719734
//Border router does not learn network information
@@ -741,14 +756,11 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
741756
// return to state machine after 1-2 s
742757
cur->bootsrap_state_machine_cnt = randLIB_get_random_in_range(10 ,20);
743758
// enable frequency hopping for unicast channel and start listening first neighbour
744-
ws_fhss_set_defaults(cur);
745759
ws_bootstrap_primary_parent_set(cur, &neighbor_info);
746760
} else if (neighbor_info.neighbor->link_role == PRIORITY_PARENT_NEIGHBOUR) {
747761
// RPL priority parent configuration we must update FHSS data
748762
ws_bootstrap_primary_parent_set(cur, &neighbor_info);
749763
}
750-
751-
752764
}
753765

754766
static void ws_bootstrap_pan_config_solicit_analyse(struct protocol_interface_info_entry *cur, const struct mcps_data_ind_s *data, ws_utt_ie_t *ws_utt, ws_us_ie_t *ws_us)
@@ -1343,9 +1355,9 @@ static void ws_bootstrap_pan_advert_solicit(protocol_interface_info_entry_t *cur
13431355
async_req.wh_requested_ie_list.utt_ie = true;
13441356
async_req.wp_requested_nested_ie_list.us_ie = true;
13451357
async_req.wp_requested_nested_ie_list.net_name_ie = true;
1346-
for (int i=0; i<8; i++) {
1347-
async_req.channel_list.channel_mask[i] = cur->ws_info->hopping_schdule.channel_mask[i];
1348-
}
1358+
1359+
ws_generate_channel_list(async_req.channel_list.channel_mask,cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);
1360+
13491361
async_req.channel_list.channel_page = CHANNEL_PAGE_10;
13501362
async_req.security.SecurityLevel = 0;
13511363

@@ -1361,9 +1373,9 @@ static void ws_bootstrap_pan_config_solicit(protocol_interface_info_entry_t *cur
13611373
async_req.wh_requested_ie_list.utt_ie = true;
13621374
async_req.wp_requested_nested_ie_list.us_ie = true;
13631375
async_req.wp_requested_nested_ie_list.net_name_ie = true;
1364-
for (int i=0; i<8; i++) {
1365-
async_req.channel_list.channel_mask[i] = cur->ws_info->hopping_schdule.channel_mask[i];
1366-
}
1376+
1377+
ws_generate_channel_list(async_req.channel_list.channel_mask,cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);
1378+
13671379
async_req.channel_list.channel_page = CHANNEL_PAGE_10;
13681380
async_req.security.SecurityLevel = 0;
13691381

@@ -1415,9 +1427,9 @@ static void ws_bootstrap_pan_advert(protocol_interface_info_entry_t *cur)
14151427
async_req.wp_requested_nested_ie_list.us_ie = true;
14161428
async_req.wp_requested_nested_ie_list.pan_ie = true;
14171429
async_req.wp_requested_nested_ie_list.net_name_ie = true;
1418-
for (int i=0; i<8; i++) {
1419-
async_req.channel_list.channel_mask[i] = cur->ws_info->hopping_schdule.channel_mask[i];
1420-
}
1430+
1431+
ws_generate_channel_list(async_req.channel_list.channel_mask,cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);
1432+
14211433
async_req.channel_list.channel_page = CHANNEL_PAGE_10;
14221434
async_req.security.SecurityLevel = 0;
14231435

@@ -1448,9 +1460,9 @@ static void ws_bootstrap_pan_config(protocol_interface_info_entry_t *cur)
14481460
async_req.wp_requested_nested_ie_list.pan_version_ie = true;
14491461
async_req.wp_requested_nested_ie_list.gtkhash_ie = true;
14501462
async_req.wp_requested_nested_ie_list.vp_ie = true;
1451-
for (int i=0; i<8; i++) {
1452-
async_req.channel_list.channel_mask[i] = cur->ws_info->hopping_schdule.channel_mask[i];
1453-
}
1463+
1464+
ws_generate_channel_list(async_req.channel_list.channel_mask,cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);
1465+
14541466
async_req.channel_list.channel_page = CHANNEL_PAGE_10;
14551467
async_req.security.SecurityLevel = mac_helper_default_security_level_get(cur);
14561468
async_req.security.KeyIdMode = mac_helper_default_security_key_id_mode_get(cur);
@@ -1501,9 +1513,6 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
15011513
trickle_stop(&cur->ws_info->trickle_pan_advertisement);
15021514
trickle_stop(&cur->ws_info->trickle_pan_config);
15031515

1504-
// Set default parameters for FHSS when starting a discovery
1505-
ws_fhss_set_defaults(cur);
1506-
15071516
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
15081517
tr_debug("Border router start network");
15091518
// Randomize fixed channel. Only used if channel plan is fixed
@@ -1517,7 +1526,9 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
15171526
cur->ws_info->pan_information.version = WS_FAN_VERSION_1_0;
15181527
ws_llc_set_gtkhash(cur, cur->ws_info->gtkhash);
15191528
cur->ws_info->pan_version_timer = PAN_VERSION_LIFETIME;
1529+
15201530
// Set default parameters for FHSS when starting a discovery
1531+
ws_fhss_border_router_configure(cur);
15211532
ws_bootstrap_fhss_activate(cur);
15221533
ws_bootstrap_set_test_key(cur);
15231534
ws_bootstrap_event_operation_start(cur);

source/Service_Libs/fhss/fhss_ws.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ static void fhss_broadcast_handler(const fhss_api_t *fhss_api, uint16_t delay)
115115
return;
116116
}
117117

118+
if (fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval == 0 || fhss_structure->ws->fhss_configuration.fhss_broadcast_interval == 0) {
119+
// stop broadcast schedule
120+
fhss_structure->ws->is_on_bc_channel = false;
121+
return;
122+
}
118123
if (fhss_structure->ws->is_on_bc_channel == false) {
119124
fhss_start_timer(fhss_structure, fhss_structure->ws->fhss_configuration.fhss_bc_dwell_interval*1000, fhss_broadcast_handler);
120125
fhss_structure->ws->is_on_bc_channel = true;

0 commit comments

Comments
 (0)