@@ -699,8 +699,6 @@ static int8_t ws_bootstrap_up(protocol_interface_info_entry_t *cur)
699
699
return -3 ;
700
700
}
701
701
702
- //Enable Power bootup timer setup
703
- cur -> ws_info -> power_up_setup = true;
704
702
// Save FHSS api
705
703
cur -> ws_info -> fhss_api = ns_sw_mac_get_fhss_api (cur -> mac_api );
706
704
@@ -1967,25 +1965,31 @@ static void ws_bootstrap_start_discovery(protocol_interface_info_entry_t *cur)
1967
1965
// New network scan started old addresses not assumed valid anymore
1968
1966
ws_bootstrap_ip_stack_addr_clear (cur );
1969
1967
1970
- // Reset advertisement solicit trickle to start discovering network
1971
- cur -> ws_info -> trickle_pas_running = true;
1972
- trickle_start (& cur -> ws_info -> trickle_pan_advertisement_solicit , & cur -> ws_info -> trickle_params_pan_discovery );
1973
- if (cur -> ws_info -> power_up_setup ) {
1974
- cur -> ws_info -> power_up_setup = false;
1975
- tr_debug ("PAS init I %u and t %u" , cur -> ws_info -> trickle_pan_advertisement_solicit .I , cur -> ws_info -> trickle_pan_advertisement_solicit .t );
1976
- } else {
1977
- trickle_inconsistent_heard (& cur -> ws_info -> trickle_pan_advertisement_solicit , & cur -> ws_info -> trickle_params_pan_discovery );
1978
- }
1979
-
1980
1968
if ((cur -> lowpan_info & INTERFACE_NWK_BOOTSRAP_ACTIVE ) != INTERFACE_NWK_BOOTSRAP_ACTIVE ) {
1981
1969
// we have sent bootstrap ready event and now
1982
1970
// restarted discovery so bootstrap down event is sent
1983
1971
cur -> lowpan_info |= INTERFACE_NWK_BOOTSRAP_ACTIVE ;
1984
1972
ws_nwk_event_post (cur , ARM_NWK_NWK_CONNECTION_DOWN );
1985
1973
}
1986
1974
1987
- // Discovery statemachine is checkked after two trickle interval
1988
- cur -> bootsrap_state_machine_cnt = 2 * cur -> ws_info -> trickle_params_pan_discovery .Imin + randLIB_get_8bit () % 50 ;
1975
+ // Start advertisement solicit trickle and calculate when we are checking the status
1976
+ cur -> ws_info -> trickle_pas_running = true;
1977
+ if (cur -> ws_info -> trickle_pan_advertisement_solicit .I != cur -> ws_info -> trickle_params_pan_discovery .Imin ) {
1978
+ // Trickle not reseted so starting a new interval
1979
+ trickle_start (& cur -> ws_info -> trickle_pan_advertisement_solicit , & cur -> ws_info -> trickle_params_pan_discovery );
1980
+ }
1981
+
1982
+ // Discovery statemachine is checkked after we have sent the Solicit
1983
+ uint16_t time_to_solicit = 0 ;
1984
+ if (cur -> ws_info -> trickle_pan_advertisement_solicit .t > cur -> ws_info -> trickle_pan_advertisement_solicit .now ) {
1985
+ time_to_solicit = cur -> ws_info -> trickle_pan_advertisement_solicit .t - cur -> ws_info -> trickle_pan_advertisement_solicit .now ;
1986
+ }
1987
+
1988
+ tr_debug ("Disc params imin %u, imax %u, expirations %u, k %u PAS Trickle I %u t %u, now %u, c %u" ,
1989
+ cur -> ws_info -> trickle_params_pan_discovery .Imin , cur -> ws_info -> trickle_params_pan_discovery .Imax , cur -> ws_info -> trickle_params_pan_discovery .TimerExpirations , cur -> ws_info -> trickle_params_pan_discovery .k ,
1990
+ cur -> ws_info -> trickle_pan_advertisement_solicit .I , cur -> ws_info -> trickle_pan_advertisement_solicit .t , cur -> ws_info -> trickle_pan_advertisement_solicit .now , cur -> ws_info -> trickle_pan_advertisement_solicit .c );
1991
+
1992
+ cur -> bootsrap_state_machine_cnt = time_to_solicit + cur -> ws_info -> trickle_params_pan_discovery .Imin + randLIB_get_8bit () % 50 ;
1989
1993
}
1990
1994
1991
1995
// Start authentication
@@ -2039,6 +2043,8 @@ static void ws_bootstrap_authentication_completed(protocol_interface_info_entry_
2039
2043
} else {
2040
2044
tr_debug ("authentication failed" );
2041
2045
// What else to do to start over again...
2046
+ // Trickle is reseted when entering to discovery from state 2
2047
+ trickle_inconsistent_heard (& cur -> ws_info -> trickle_pan_advertisement_solicit , & cur -> ws_info -> trickle_params_pan_discovery );
2042
2048
ws_bootstrap_event_discovery_start (cur );
2043
2049
}
2044
2050
}
@@ -2522,9 +2528,6 @@ void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur)
2522
2528
break ;
2523
2529
case ER_PANA_AUTH :
2524
2530
tr_info ("authentication start" );
2525
- // only advert sol stopped as we might be doing re authentication
2526
- cur -> ws_info -> trickle_pas_running = false;
2527
- //Add Test ecurity key and security level's
2528
2531
// Advertisements stopped during the EAPOL
2529
2532
cur -> ws_info -> trickle_pa_running = false;
2530
2533
cur -> ws_info -> trickle_pc_running = false;
@@ -2564,6 +2567,8 @@ void ws_bootstrap_trickle_timer(protocol_interface_info_entry_t *cur, uint16_t t
2564
2567
// Remove network keys from MAC
2565
2568
ws_pae_controller_nw_keys_remove (cur );
2566
2569
2570
+ // Trickle is reseted when entering to discovery from state 3
2571
+ trickle_inconsistent_heard (& cur -> ws_info -> trickle_pan_advertisement_solicit , & cur -> ws_info -> trickle_params_pan_discovery );
2567
2572
ws_bootstrap_event_discovery_start (cur );
2568
2573
return ;
2569
2574
}
0 commit comments