@@ -407,6 +407,15 @@ static int8_t ws_fhss_border_router_configure(protocol_interface_info_entry_t *c
407
407
return 0 ;
408
408
}
409
409
410
+ static uint16_t ws_randomize_fixed_channel (uint16_t configured_fixed_channel , uint8_t number_of_channels )
411
+ {
412
+ if (configured_fixed_channel == 0xFFFF ) {
413
+ return randLIB_get_random_in_range (0 , number_of_channels - 1 );
414
+ } else {
415
+ return configured_fixed_channel ;
416
+ }
417
+ }
418
+
410
419
static int8_t ws_fhss_discovery_configure (protocol_interface_info_entry_t * cur )
411
420
{
412
421
// Read configuration of existing FHSS and start using the default values for any network
@@ -420,12 +429,12 @@ static int8_t ws_fhss_discovery_configure(protocol_interface_info_entry_t *cur)
420
429
fhss_configuration .ws_bc_channel_function = WS_FIXED_CHANNEL ;
421
430
fhss_configuration .fhss_bc_dwell_interval = 0 ;
422
431
fhss_configuration .fhss_broadcast_interval = 0 ;
423
- cur -> ws_info -> fhss_uc_fixed_channel = randLIB_get_random_in_range ( 0 , cur -> ws_info -> hopping_schdule .number_of_channels - 1 );
424
- cur -> ws_info -> fhss_bc_fixed_channel = randLIB_get_random_in_range ( 0 , cur -> ws_info -> hopping_schdule .number_of_channels - 1 );
432
+ uint8_t tmp_uc_fixed_channel = ws_randomize_fixed_channel ( cur -> ws_info -> fhss_uc_fixed_channel , cur -> ws_info -> hopping_schdule .number_of_channels );
433
+ uint8_t tmp_bc_fixed_channel = ws_randomize_fixed_channel ( cur -> ws_info -> fhss_bc_fixed_channel , cur -> ws_info -> hopping_schdule .number_of_channels );
425
434
memset (fhss_configuration .channel_mask , 0 , sizeof (uint32_t ) * 8 );
426
- channel_list_set_channel (fhss_configuration .channel_mask , cur -> ws_info -> fhss_uc_fixed_channel , true);
427
- fhss_configuration .unicast_fixed_channel = cur -> ws_info -> fhss_uc_fixed_channel ;
428
- fhss_configuration .broadcast_fixed_channel = cur -> ws_info -> fhss_bc_fixed_channel ;
435
+ channel_list_set_channel (fhss_configuration .channel_mask , tmp_uc_fixed_channel , true);
436
+ fhss_configuration .unicast_fixed_channel = tmp_uc_fixed_channel ;
437
+ fhss_configuration .broadcast_fixed_channel = tmp_bc_fixed_channel ;
429
438
ns_fhss_ws_configuration_set (cur -> ws_info -> fhss_api ,& fhss_configuration );
430
439
ws_bootstrap_llc_hopping_update (cur ,& fhss_configuration );
431
440
@@ -473,6 +482,7 @@ static void ws_bootstrap_primary_parent_set(struct protocol_interface_info_entry
473
482
fhss_configuration .ws_bc_channel_function = neighbor_info -> ws_neighbor -> fhss_data .bc_timing_info .broadcast_channel_function ;
474
483
if (fhss_configuration .ws_bc_channel_function == WS_FIXED_CHANNEL ) {
475
484
cur -> ws_info -> hopping_schdule .bc_fixed_channel = neighbor_info -> ws_neighbor -> fhss_data .bc_timing_info .fixed_channel ;
485
+ cur -> ws_info -> fhss_bc_fixed_channel = neighbor_info -> ws_neighbor -> fhss_data .bc_timing_info .fixed_channel ;
476
486
}
477
487
fhss_configuration .bsi = neighbor_info -> ws_neighbor -> fhss_data .bc_timing_info .broadcast_schedule_id ;
478
488
fhss_configuration .fhss_bc_dwell_interval = neighbor_info -> ws_neighbor -> fhss_data .bc_timing_info .broadcast_dwell_interval ;
@@ -1776,9 +1786,9 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
1776
1786
1777
1787
if (cur -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER ) {
1778
1788
tr_debug ("Border router start network" );
1779
- // Randomize fixed channel . Only used if channel plan is fixed
1780
- cur -> ws_info -> fhss_uc_fixed_channel = randLIB_get_random_in_range ( 0 , cur -> ws_info -> hopping_schdule .number_of_channels - 1 );
1781
- cur -> ws_info -> fhss_bc_fixed_channel = randLIB_get_random_in_range ( 0 , cur -> ws_info -> hopping_schdule .number_of_channels - 1 );
1789
+ // Randomize fixed channels . Only used if channel plan is fixed.
1790
+ cur -> ws_info -> fhss_uc_fixed_channel = ws_randomize_fixed_channel ( cur -> ws_info -> fhss_uc_fixed_channel , cur -> ws_info -> hopping_schdule .number_of_channels );
1791
+ cur -> ws_info -> fhss_bc_fixed_channel = ws_randomize_fixed_channel ( cur -> ws_info -> fhss_bc_fixed_channel , cur -> ws_info -> hopping_schdule .number_of_channels );
1782
1792
cur -> ws_info -> network_pan_id = randLIB_get_random_in_range (0 ,0xfffd );
1783
1793
cur -> ws_info -> pan_information .pan_size = 0 ;
1784
1794
cur -> ws_info -> pan_information .pan_version = randLIB_get_random_in_range (0 ,0xffff );
0 commit comments