@@ -230,29 +230,34 @@ static int8_t ws_fhss_initialize(protocol_interface_info_entry_t *cur)
230
230
}
231
231
return 0 ;
232
232
}
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 )
234
248
{
235
249
// Read configuration of existing FHSS and start using the default values for any network
236
250
fhss_ws_configuration_t fhss_configuration = {0 };
237
251
if (ns_fhss_ws_configuration_get (cur -> ws_info -> fhss_api )) {
238
252
memcpy (& fhss_configuration , ns_fhss_ws_configuration_get (cur -> ws_info -> fhss_api ), sizeof (fhss_ws_configuration_t ));
239
253
}
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 );
252
255
ns_fhss_ws_configuration_set (cur -> ws_info -> fhss_api ,& fhss_configuration );
256
+ ws_bootstrap_llc_hopping_update (cur ,& fhss_configuration );
253
257
254
258
return 0 ;
255
259
}
260
+
256
261
static int8_t ws_fhss_discovery_configure (protocol_interface_info_entry_t * cur )
257
262
{
258
263
// 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
304
309
fhss_ws_configuration_t fhss_configuration ;
305
310
memcpy (& fhss_configuration , ns_fhss_ws_configuration_get (cur -> ws_info -> fhss_api ), sizeof (fhss_ws_configuration_t ));
306
311
312
+ ws_fhss_set_defaults (cur , & fhss_configuration );
313
+
314
+ // Learning unicast network configuration
307
315
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
+ }
309
319
/* Learning different unicast is not working currently at fhss network follows border router
310
320
*/
311
321
// Learn broadcast information from selected parent
@@ -704,16 +714,21 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
704
714
ws_neighbor_class_neighbor_broadcast_schedule_set (neighbor_info .ws_neighbor , & ws_bs_ie );
705
715
neighbor_info .neighbor -> trusted_device = true;
706
716
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 ) {
709
718
// 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
+ }
713
730
}
714
- return ;
715
731
}
716
- trickle_consistent_heard (& cur -> ws_info -> trickle_pan_config );
717
732
718
733
if (cur -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER ) {
719
734
//Border router does not learn network information
@@ -741,14 +756,11 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
741
756
// return to state machine after 1-2 s
742
757
cur -> bootsrap_state_machine_cnt = randLIB_get_random_in_range (10 ,20 );
743
758
// enable frequency hopping for unicast channel and start listening first neighbour
744
- ws_fhss_set_defaults (cur );
745
759
ws_bootstrap_primary_parent_set (cur , & neighbor_info );
746
760
} else if (neighbor_info .neighbor -> link_role == PRIORITY_PARENT_NEIGHBOUR ) {
747
761
// RPL priority parent configuration we must update FHSS data
748
762
ws_bootstrap_primary_parent_set (cur , & neighbor_info );
749
763
}
750
-
751
-
752
764
}
753
765
754
766
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
1343
1355
async_req .wh_requested_ie_list .utt_ie = true;
1344
1356
async_req .wp_requested_nested_ie_list .us_ie = true;
1345
1357
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
+
1349
1361
async_req .channel_list .channel_page = CHANNEL_PAGE_10 ;
1350
1362
async_req .security .SecurityLevel = 0 ;
1351
1363
@@ -1361,9 +1373,9 @@ static void ws_bootstrap_pan_config_solicit(protocol_interface_info_entry_t *cur
1361
1373
async_req .wh_requested_ie_list .utt_ie = true;
1362
1374
async_req .wp_requested_nested_ie_list .us_ie = true;
1363
1375
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
+
1367
1379
async_req .channel_list .channel_page = CHANNEL_PAGE_10 ;
1368
1380
async_req .security .SecurityLevel = 0 ;
1369
1381
@@ -1415,9 +1427,9 @@ static void ws_bootstrap_pan_advert(protocol_interface_info_entry_t *cur)
1415
1427
async_req .wp_requested_nested_ie_list .us_ie = true;
1416
1428
async_req .wp_requested_nested_ie_list .pan_ie = true;
1417
1429
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
+
1421
1433
async_req .channel_list .channel_page = CHANNEL_PAGE_10 ;
1422
1434
async_req .security .SecurityLevel = 0 ;
1423
1435
@@ -1448,9 +1460,9 @@ static void ws_bootstrap_pan_config(protocol_interface_info_entry_t *cur)
1448
1460
async_req .wp_requested_nested_ie_list .pan_version_ie = true;
1449
1461
async_req .wp_requested_nested_ie_list .gtkhash_ie = true;
1450
1462
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
+
1454
1466
async_req .channel_list .channel_page = CHANNEL_PAGE_10 ;
1455
1467
async_req .security .SecurityLevel = mac_helper_default_security_level_get (cur );
1456
1468
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)
1501
1513
trickle_stop (& cur -> ws_info -> trickle_pan_advertisement );
1502
1514
trickle_stop (& cur -> ws_info -> trickle_pan_config );
1503
1515
1504
- // Set default parameters for FHSS when starting a discovery
1505
- ws_fhss_set_defaults (cur );
1506
-
1507
1516
if (cur -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER ) {
1508
1517
tr_debug ("Border router start network" );
1509
1518
// Randomize fixed channel. Only used if channel plan is fixed
@@ -1517,7 +1526,9 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
1517
1526
cur -> ws_info -> pan_information .version = WS_FAN_VERSION_1_0 ;
1518
1527
ws_llc_set_gtkhash (cur , cur -> ws_info -> gtkhash );
1519
1528
cur -> ws_info -> pan_version_timer = PAN_VERSION_LIFETIME ;
1529
+
1520
1530
// Set default parameters for FHSS when starting a discovery
1531
+ ws_fhss_border_router_configure (cur );
1521
1532
ws_bootstrap_fhss_activate (cur );
1522
1533
ws_bootstrap_set_test_key (cur );
1523
1534
ws_bootstrap_event_operation_start (cur );
0 commit comments