1717
1818#include <string.h>
1919#include "nsconfig.h"
20+ #ifdef HAVE_WS
2021#include "ns_types.h"
2122#include "ns_trace.h"
2223#include "net_interface.h"
3839#include "RPL/rpl_protocol.h"
3940#include "RPL/rpl_control.h"
4041#include "RPL/rpl_data.h"
42+ #include "RPL/rpl_policy.h"
4143#include "Common_Protocols/icmpv6.h"
4244#include "Common_Protocols/icmpv6_radv.h"
4345#include "Common_Protocols/ipv6_constants.h"
7375
7476#define TRACE_GROUP "wsbs"
7577
76- #ifdef HAVE_WS
78+
7779
7880static void ws_bootstrap_event_handler (arm_event_s * event );
7981static void ws_bootstrap_state_change (protocol_interface_info_entry_t * cur , icmp_state_t nwk_bootstrap_state );
@@ -522,6 +524,9 @@ static int8_t ws_fhss_initialize(protocol_interface_info_entry_t *cur)
522524 return 0 ;
523525 }
524526 fhss_configuration = * fhss_configuration_copy ;
527+ //Overwrite domain channel setup this will over write a default 35 channel
528+ int num_of_channels = channel_list_count_channels (fhss_configuration_copy -> unicast_channel_mask );
529+ cur -> ws_info -> hopping_schdule .number_of_channels = (uint8_t ) num_of_channels ;
525530 memcpy (cur -> ws_info -> cfg -> fhss .fhss_channel_mask , fhss_configuration_copy -> unicast_channel_mask , sizeof (uint32_t ) * 8 );
526531 cur -> ws_info -> cfg -> fhss .fhss_uc_channel_function = fhss_configuration_copy -> ws_uc_channel_function ;
527532 cur -> ws_info -> cfg -> fhss .fhss_bc_channel_function = fhss_configuration_copy -> ws_bc_channel_function ;
@@ -2047,6 +2052,19 @@ int ws_bootstrap_aro_failure(protocol_interface_info_entry_t *cur, const uint8_t
20472052 return 0 ;
20482053}
20492054
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+
20502068static void ws_bootstrap_mac_activate (protocol_interface_info_entry_t * cur , uint16_t channel , uint16_t panid , bool coordinator )
20512069{
20522070 mlme_start_t start_req ;
@@ -2455,6 +2473,10 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
24552473 if (cur -> bootsrap_mode != ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER ) {
24562474 rpl_control_set_memory_limits (WS_NODE_RPL_SOFT_MEM_LIMIT , WS_NODE_RPL_HARD_MEM_LIMIT );
24572475 }
2476+ // Set RPL Link ETX Validation Threshold to 2.5 - 33.0
2477+ // This setup will set ETX 0x800 to report ICMP error 18% probability
2478+ // When ETX start go over 0x280 forward dropping probability start increase linear to 100% at 0x2100
2479+ rpl_policy_forward_link_etx_threshold_set (0x280 , 0x2100 );
24582480
24592481 // Set the minimum target refresh to sen DAO registrations before pan timeout
24602482 rpl_control_set_minimum_dao_target_refresh (WS_RPL_DAO_MAX_TIMOUT );
@@ -2475,6 +2497,7 @@ static void ws_bootstrap_network_discovery_configure(protocol_interface_info_ent
24752497 cur -> ws_info -> network_pan_id = 0xffff ;
24762498
24772499 ws_common_regulatory_domain_config (cur , & cur -> ws_info -> hopping_schdule );
2500+ ws_bootstrap_set_domain_rf_config (cur );
24782501 ws_fhss_configure (cur , true);
24792502
24802503 //Set Network names, Pan information configure, hopping schedule & GTKHash
@@ -2900,12 +2923,18 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
29002923 if (cur -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER ) {
29012924 tr_info ("Border router start network" );
29022925
2926+
29032927 if (!ws_bbr_ready_to_start (cur )) {
29042928 // Wi-SUN not started yet we wait for Border router permission
29052929 ws_bootstrap_state_change (cur , ER_WAIT_RESTART );
29062930 cur -> nwk_nd_re_scan_count = randLIB_get_random_in_range (40 , 100 );
29072931 return ;
29082932 }
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 );
29092938 ws_pae_controller_auth_init (cur );
29102939
29112940 // Randomize fixed channels. Only used if channel plan is fixed.
@@ -2928,9 +2957,10 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
29282957 ws_bbr_pan_version_increase (cur );
29292958
29302959 // Set default parameters for FHSS when starting a discovery
2960+ ws_common_regulatory_domain_config (cur , & cur -> ws_info -> hopping_schdule );
29312961 ws_fhss_border_router_configure (cur );
2962+ ws_bootstrap_set_domain_rf_config (cur );
29322963 ws_bootstrap_fhss_activate (cur );
2933- ws_bootstrap_event_operation_start (cur );
29342964
29352965 uint8_t ll_addr [16 ];
29362966 addr_interface_get_ll_address (cur , ll_addr , 1 );
@@ -2949,6 +2979,8 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
29492979
29502980 // Set PAE port to 10254 and authenticator relay to 10253 (and to own ll address)
29512981 ws_pae_controller_authenticator_start (cur , PAE_AUTH_SOCKET_PORT , ll_addr , EAPOL_RELAY_SOCKET_PORT );
2982+
2983+ ws_bootstrap_event_operation_start (cur );
29522984 break ;
29532985 }
29542986 ws_pae_controller_supp_init (cur );
0 commit comments