Skip to content

Commit 501a612

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
Wi-sun trigle timer update:
Added more resolution to trigle. Change-Id: Icc0841d30fdb3f2242cbe4b7988c5c9bfee93207
1 parent 47619c4 commit 501a612

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@
6363

6464
#ifdef HAVE_WS
6565

66+
#define TRIGLE_IMIN_60_SECS (60 * 10) //
67+
6668
static const trickle_params_t trickle_params_pan_discovery = {
67-
.Imin = 60, /* 60 second; ticks are 1s */
68-
.Imax = 60 << 4, /* 960 seconds 16 min*/
69+
.Imin = TRIGLE_IMIN_60_SECS, /* 60 second; ticks are 1s */
70+
.Imax = TRIGLE_IMIN_60_SECS << 4, /* 960 seconds 16 min*/
6971
.k = 1, /* 1 */
7072
.TimerExpirations = TRICKLE_EXPIRATIONS_INFINITE
7173
};
@@ -425,7 +427,7 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
425427

426428
if(ws_neighbor_class_rssi_from_dbm_calculate(data->signal_dbm) < (CAND_PARENT_THRESHOLD + CAND_PARENT_HYSTERISIS)) {
427429
// First neighbor is too low we need to wait one extra trickle
428-
cur->bootsrap_state_machine_cnt += trickle_params_pan_discovery.Imin*10 + randLIB_get_8bit() % 50;
430+
cur->bootsrap_state_machine_cnt += trickle_params_pan_discovery.Imin + randLIB_get_8bit() % 50;
429431
}
430432
}
431433

@@ -1120,7 +1122,7 @@ static void ws_bootstrap_start_discovery(protocol_interface_info_entry_t *cur)
11201122
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement_solicit, &trickle_params_pan_discovery);
11211123

11221124
// Discovery statemachine is checkked after two trickle interval
1123-
cur->bootsrap_state_machine_cnt = 2*trickle_params_pan_discovery.Imin*10 + randLIB_get_8bit() % 50;
1125+
cur->bootsrap_state_machine_cnt = 2*trickle_params_pan_discovery.Imin + randLIB_get_8bit() % 50;
11241126
}
11251127
// Start configuration learning
11261128
static void ws_bootstrap_start_configuration_learn(protocol_interface_info_entry_t *cur)
@@ -1418,7 +1420,7 @@ void ws_bootstrap_network_scan_process(protocol_interface_info_entry_t *cur)
14181420

14191421
if (!ws_bootstrap_network_found(cur)) {
14201422
// Next check will be after one trickle
1421-
cur->bootsrap_state_machine_cnt += trickle_params_pan_discovery.Imin*10 + randLIB_get_8bit() % 50;
1423+
cur->bootsrap_state_machine_cnt += trickle_params_pan_discovery.Imin + randLIB_get_8bit() % 50;
14221424
return;
14231425
}
14241426
tr_info("select network");
@@ -1524,34 +1526,41 @@ void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur)
15241526

15251527
}
15261528
}
1527-
void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds)
1529+
1530+
void ws_bootstrap_trigle_timer(protocol_interface_info_entry_t *cur, uint16_t ticks)
15281531
{
1529-
if(trickle_timer(&cur->ws_info->trickle_pan_advertisement_solicit, &trickle_params_pan_discovery, seconds)) {
1532+
if(trickle_timer(&cur->ws_info->trickle_pan_advertisement_solicit, &trickle_params_pan_discovery, ticks)) {
15301533
// send PAN advertisement solicit
15311534
tr_info("Send PAN advertisement Solicit");
15321535
ws_bootstrap_pan_advert_solicit(cur);
15331536
}
1534-
if(trickle_timer(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery, seconds)) {
1537+
if(trickle_timer(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery, ticks)) {
15351538
// send PAN Configuration solicit
15361539
if (cur->ws_info->pas_requests > PCS_MAX) {
15371540
// if MAX PCS sent restart discovery
1541+
tr_debug("Restart???");
15381542
ws_bootstrap_event_discovery_start(cur);
15391543
return;
15401544
}
15411545
tr_info("Send PAN configuration Solicit");
15421546
cur->ws_info->pas_requests++;
15431547
ws_bootstrap_pan_config_solicit(cur);
15441548
}
1545-
if(trickle_timer(&cur->ws_info->trickle_pan_advertisement, &trickle_params_pan_discovery, seconds)) {
1549+
if(trickle_timer(&cur->ws_info->trickle_pan_advertisement, &trickle_params_pan_discovery, ticks)) {
15461550
// send PAN advertisement
15471551
tr_info("Send PAN advertisement");
15481552
ws_bootstrap_pan_advert(cur);
15491553
}
1550-
if(trickle_timer(&cur->ws_info->trickle_pan_config, &trickle_params_pan_discovery, seconds)) {
1554+
if(trickle_timer(&cur->ws_info->trickle_pan_config, &trickle_params_pan_discovery, ticks)) {
15511555
// send PAN Configuration
15521556
tr_info("Send PAN configuration");
15531557
ws_bootstrap_pan_config(cur);
15541558
}
1559+
}
1560+
1561+
1562+
void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds)
1563+
{
15551564
if (cur->ws_info->pan_version_timeout_timer){
15561565
// PAN version timer running
15571566
if (cur->ws_info->pan_version_timeout_timer > seconds ) {

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ void ws_bootstrap_configuration_trickle_reset(protocol_interface_info_entry_t *c
5050

5151
void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds);
5252

53+
void ws_bootstrap_trigle_timer(protocol_interface_info_entry_t *cur, uint16_t ticks);
54+
5355
#else
5456

5557
#define ws_bootstrap_init(interface_id, bootstrap_mode) (-1)

source/6LoWPAN/ws/ws_common.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ void ws_common_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seco
165165
ws_bootstrap_seconds_timer(cur, seconds);
166166
}
167167

168+
void ws_common_fast_timer(protocol_interface_info_entry_t *cur, uint16_t ticks)
169+
{
170+
ws_bootstrap_trigle_timer(cur, ticks);
171+
}
172+
173+
168174
void ws_common_neighbor_update(protocol_interface_info_entry_t *cur, const uint8_t *ll_address)
169175
{
170176
//Neighbor connectected update

source/6LoWPAN/ws/ws_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,16 @@ int8_t ws_common_allocate_and_init(protocol_interface_info_entry_t *cur);
7070

7171
void ws_common_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds);
7272

73+
void ws_common_fast_timer(protocol_interface_info_entry_t *cur, uint16_t ticks);
74+
7375
void ws_common_neighbor_update(protocol_interface_info_entry_t *cur, const uint8_t *ll_address);
7476

7577
#define ws_info(cur) ((cur)->ws_info)
7678
#else
7779
#define ws_info(cur) ((ws_info_t *) NULL)
7880
#define ws_common_seconds_timer(cur, seconds)
7981
#define ws_common_neighbor_update(cur, ll_address) ((void) 0)
82+
#define ws_common_fast_timer(cur, ticks) ((void) 0)
8083

8184

8285
#endif //HAVE_WS

source/NWK_INTERFACE/protocol_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ void core_timer_event_handle(uint16_t ticksUpdate)
312312
nd_object_timer(cur,ticksUpdate);
313313
if (thread_info(cur)) {
314314
thread_timer(cur, ticksUpdate);
315+
} else if (ws_info(cur)) {
316+
ws_common_fast_timer(cur, ticksUpdate);
315317
}
316318
lowpan_context_timer(&cur->lowpan_contexts, ticksUpdate);
317319
}

0 commit comments

Comments
 (0)