Skip to content

Commit 4096c1a

Browse files
author
Juha Heiuskanen
committed
Wi-SUN bootstrap support RPL poison from Connected state to Discovery
From Connected State to discovery will now do Soft RPL down by new state. State is started by trigger RPL poison and wait event from RPL before trigger discovery state.
1 parent 66378d1 commit 4096c1a

File tree

3 files changed

+61
-4
lines changed

3 files changed

+61
-4
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,32 @@ static int8_t ws_bootstrap_up(protocol_interface_info_entry_t *cur)
10861086
return ret_val;
10871087
}
10881088

1089+
void ws_bootstrap_disconnect(protocol_interface_info_entry_t *cur, ws_bootsrap_event_type_e event_type)
1090+
{
1091+
if (cur->nwk_bootstrap_state == ER_RPL_NETWORK_LEAVING) {
1092+
//Already moved to leaving state.
1093+
return;
1094+
}
1095+
1096+
if (cur->rpl_domain && cur->nwk_bootstrap_state == ER_BOOTSRAP_DONE) {
1097+
//Stop Asych Timer
1098+
ws_bootstrap_asynch_trickle_stop(cur);
1099+
tr_debug("Start Network soft leaving");
1100+
if (event_type == WS_FAST_DISCONNECT) {
1101+
rpl_control_instant_poison(cur, cur->rpl_domain);
1102+
cur->bootsrap_state_machine_cnt = 80; //Give 8 seconds time to send Poison
1103+
} else {
1104+
rpl_control_poison(cur->rpl_domain, 1);
1105+
cur->bootsrap_state_machine_cnt = 6000; //Give 10 minutes time for poison if RPL is not report
1106+
}
1107+
1108+
} else {
1109+
ws_bootstrap_event_discovery_start(cur);
1110+
}
1111+
cur->nwk_bootstrap_state = ER_RPL_NETWORK_LEAVING;
1112+
}
1113+
1114+
10891115
static void ws_bootstrap_asynch_trickle_stop(protocol_interface_info_entry_t *cur)
10901116
{
10911117
cur->ws_info->trickle_pas_running = false;
@@ -1638,7 +1664,7 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
16381664
tr_debug("NEW Brodcast Schedule %u...BR rebooted", ws_bs_ie.broadcast_schedule_identifier);
16391665
cur->ws_info->ws_bsi_block.block_time = cur->ws_info->cfg->timing.pan_timeout;
16401666
cur->ws_info->ws_bsi_block.old_bsi = cur->ws_info->hopping_schdule.fhss_bsi;
1641-
ws_bootstrap_event_discovery_start(cur);
1667+
ws_bootstrap_event_disconnect(cur, WS_NORMAL_DISCONNECT);
16421668
}
16431669
return;
16441670
}
@@ -2553,6 +2579,15 @@ static void ws_bootstrap_rpl_callback(rpl_event_t event, void *handle)
25532579
if (!cur->rpl_domain || cur->interface_mode != INTERFACE_UP) {
25542580
return;
25552581
}
2582+
2583+
if (event == RPL_EVENT_POISON_FINISHED) {
2584+
//If we are waiting poison we will trig Discovery after couple seconds
2585+
if (cur->nwk_bootstrap_state == ER_RPL_NETWORK_LEAVING) {
2586+
cur->bootsrap_state_machine_cnt = 80; //Give 8 seconds time to send Poison
2587+
}
2588+
return;
2589+
}
2590+
25562591
// if waiting for RPL and
25572592
if (event == RPL_EVENT_DAO_DONE) {
25582593
// Trigger statemachine check
@@ -3132,6 +3167,12 @@ void ws_bootstrap_event_routing_ready(protocol_interface_info_entry_t *cur)
31323167
{
31333168
ws_bootsrap_event_trig(WS_ROUTING_READY, cur->bootStrapId, ARM_LIB_LOW_PRIORITY_EVENT, NULL);
31343169
}
3170+
3171+
void ws_bootstrap_event_disconnect(protocol_interface_info_entry_t *cur, ws_bootsrap_event_type_e event_type)
3172+
{
3173+
ws_bootsrap_event_trig(event_type, cur->bootStrapId, ARM_LIB_LOW_PRIORITY_EVENT, NULL);
3174+
}
3175+
31353176
void ws_bootstrap_configuration_trickle_reset(protocol_interface_info_entry_t *cur)
31363177
{
31373178
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config, &cur->ws_info->trickle_params_pan_discovery);
@@ -3315,6 +3356,7 @@ static int8_t ws_bootstrap_backbone_ip_addr_get(protocol_interface_info_entry_t
33153356
return -1;
33163357
}
33173358

3359+
33183360
static void ws_bootstrap_event_handler(arm_event_s *event)
33193361
{
33203362
ws_bootsrap_event_type_e event_type;
@@ -3331,7 +3373,6 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
33313373
break;
33323374
case WS_DISCOVERY_START:
33333375
tr_info("Discovery start");
3334-
33353376
protocol_mac_reset(cur);
33363377
ws_llc_reset(cur);
33373378
lowpan_adaptation_interface_reset(cur->id);
@@ -3467,6 +3508,12 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
34673508
ws_bootstrap_advertise_start(cur);
34683509
ws_bootstrap_state_change(cur, ER_BOOTSRAP_DONE);
34693510
break;
3511+
case WS_FAST_DISCONNECT:
3512+
ws_bootstrap_disconnect(cur, WS_FAST_DISCONNECT);
3513+
break;
3514+
case WS_NORMAL_DISCONNECT:
3515+
ws_bootstrap_disconnect(cur, WS_NORMAL_DISCONNECT);
3516+
break;
34703517

34713518
default:
34723519
tr_err("Invalid event received");
@@ -3658,6 +3705,10 @@ void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur)
36583705
// Bootstrap_done event to application
36593706
nwk_bootsrap_state_update(ARM_NWK_BOOTSTRAP_READY, cur);
36603707
break;
3708+
case ER_RPL_NETWORK_LEAVING:
3709+
tr_debug("WS SM:RPL Leaving ready trigger discovery");
3710+
ws_bootstrap_event_discovery_start(cur);
3711+
break;
36613712
default:
36623713
tr_warn("WS SM:Invalid state %d", cur->nwk_bootstrap_state);
36633714
}
@@ -3743,9 +3794,10 @@ void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t s
37433794
}
37443795
} else {
37453796
// Border router has timed out
3797+
//Clear Timeout timer
37463798
cur->ws_info->pan_timeout_timer = 0;
37473799
tr_warn("Border router has timed out");
3748-
ws_bootstrap_event_discovery_start(cur);
3800+
ws_bootstrap_event_disconnect(cur, WS_FAST_DISCONNECT);
37493801
}
37503802
}
37513803
if (cur->ws_info->aro_registration_timer) {

source/6LoWPAN/ws/ws_bootstrap.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ typedef enum {
2424
WS_DISCOVERY_START, /**< discovery start*/
2525
WS_CONFIGURATION_START, /**< configuration learn start*/
2626
WS_OPERATION_START, /**< active operation start*/
27-
WS_ROUTING_READY /**< RPL routing connected to BR*/
27+
WS_ROUTING_READY, /**< RPL routing connected to BR*/
28+
WS_FAST_DISCONNECT, /**< Do fast timeout after Border router timeout*/
29+
WS_NORMAL_DISCONNECT /**< Border have been rebooted so Slow poison Process*/
2830
} ws_bootsrap_event_type_e;
2931

3032
#ifdef HAVE_WS
@@ -60,6 +62,8 @@ void ws_bootstrap_event_operation_start(protocol_interface_info_entry_t *cur);
6062

6163
void ws_bootstrap_event_routing_ready(protocol_interface_info_entry_t *cur);
6264

65+
void ws_bootstrap_event_disconnect(protocol_interface_info_entry_t *cur, ws_bootsrap_event_type_e event_type);
66+
6367
void ws_bootstrap_configuration_trickle_reset(protocol_interface_info_entry_t *cur);
6468

6569
void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds);

source/NWK_INTERFACE/Include/protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ typedef enum icmp_state {
124124
ER_BOOTSTRAP_NEW_FRAGMENT_START,
125125
ER_WAIT_RESTART,
126126
ER_RPL_LOCAL_REPAIR,
127+
ER_RPL_NETWORK_LEAVING,
127128
} icmp_state_t;
128129

129130
typedef enum {

0 commit comments

Comments
 (0)