Skip to content

Commit ee7f218

Browse files
author
Mika Tervonen
committed
Modify discovery start timing
Discovery trickle reseted only when comming from state 2 or 3 wait results for advertisements own trickle interval + imin removed unneeded boolean
1 parent 1ba806d commit ee7f218

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -699,8 +699,6 @@ static int8_t ws_bootstrap_up(protocol_interface_info_entry_t *cur)
699699
return -3;
700700
}
701701

702-
//Enable Power bootup timer setup
703-
cur->ws_info->power_up_setup = true;
704702
// Save FHSS api
705703
cur->ws_info->fhss_api = ns_sw_mac_get_fhss_api(cur->mac_api);
706704

@@ -1967,25 +1965,31 @@ static void ws_bootstrap_start_discovery(protocol_interface_info_entry_t *cur)
19671965
// New network scan started old addresses not assumed valid anymore
19681966
ws_bootstrap_ip_stack_addr_clear(cur);
19691967

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-
19801968
if ((cur->lowpan_info & INTERFACE_NWK_BOOTSRAP_ACTIVE) != INTERFACE_NWK_BOOTSRAP_ACTIVE) {
19811969
// we have sent bootstrap ready event and now
19821970
// restarted discovery so bootstrap down event is sent
19831971
cur->lowpan_info |= INTERFACE_NWK_BOOTSRAP_ACTIVE;
19841972
ws_nwk_event_post(cur, ARM_NWK_NWK_CONNECTION_DOWN);
19851973
}
19861974

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;
19891993
}
19901994

19911995
// Start authentication
@@ -2039,6 +2043,8 @@ static void ws_bootstrap_authentication_completed(protocol_interface_info_entry_
20392043
} else {
20402044
tr_debug("authentication failed");
20412045
// 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);
20422048
ws_bootstrap_event_discovery_start(cur);
20432049
}
20442050
}
@@ -2522,9 +2528,6 @@ void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur)
25222528
break;
25232529
case ER_PANA_AUTH:
25242530
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
25282531
// Advertisements stopped during the EAPOL
25292532
cur->ws_info->trickle_pa_running = false;
25302533
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
25642567
// Remove network keys from MAC
25652568
ws_pae_controller_nw_keys_remove(cur);
25662569

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);
25672572
ws_bootstrap_event_discovery_start(cur);
25682573
return;
25692574
}

source/6LoWPAN/ws/ws_common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ typedef struct ws_info_s {
7979
bool trickle_pa_running: 1;
8080
bool trickle_pcs_running: 1;
8181
bool trickle_pc_running: 1;
82-
bool power_up_setup: 1;
8382
// default fhss parameters for this device
8483
uint8_t fhss_uc_dwell_interval;
8584
uint8_t fhss_bc_dwell_interval;

0 commit comments

Comments
 (0)