Skip to content

Commit

Permalink
Wi-SUN bootstrap support RPL poison from Connected state to Discovery
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Juha Heiuskanen committed Jan 19, 2021
1 parent 66378d1 commit 4096c1a
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 4 deletions.
58 changes: 55 additions & 3 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,32 @@ static int8_t ws_bootstrap_up(protocol_interface_info_entry_t *cur)
return ret_val;
}

void ws_bootstrap_disconnect(protocol_interface_info_entry_t *cur, ws_bootsrap_event_type_e event_type)
{
if (cur->nwk_bootstrap_state == ER_RPL_NETWORK_LEAVING) {
//Already moved to leaving state.
return;
}

if (cur->rpl_domain && cur->nwk_bootstrap_state == ER_BOOTSRAP_DONE) {
//Stop Asych Timer
ws_bootstrap_asynch_trickle_stop(cur);
tr_debug("Start Network soft leaving");
if (event_type == WS_FAST_DISCONNECT) {
rpl_control_instant_poison(cur, cur->rpl_domain);
cur->bootsrap_state_machine_cnt = 80; //Give 8 seconds time to send Poison
} else {
rpl_control_poison(cur->rpl_domain, 1);
cur->bootsrap_state_machine_cnt = 6000; //Give 10 minutes time for poison if RPL is not report
}

} else {
ws_bootstrap_event_discovery_start(cur);
}
cur->nwk_bootstrap_state = ER_RPL_NETWORK_LEAVING;
}


static void ws_bootstrap_asynch_trickle_stop(protocol_interface_info_entry_t *cur)
{
cur->ws_info->trickle_pas_running = false;
Expand Down Expand Up @@ -1638,7 +1664,7 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
tr_debug("NEW Brodcast Schedule %u...BR rebooted", ws_bs_ie.broadcast_schedule_identifier);
cur->ws_info->ws_bsi_block.block_time = cur->ws_info->cfg->timing.pan_timeout;
cur->ws_info->ws_bsi_block.old_bsi = cur->ws_info->hopping_schdule.fhss_bsi;
ws_bootstrap_event_discovery_start(cur);
ws_bootstrap_event_disconnect(cur, WS_NORMAL_DISCONNECT);
}
return;
}
Expand Down Expand Up @@ -2553,6 +2579,15 @@ static void ws_bootstrap_rpl_callback(rpl_event_t event, void *handle)
if (!cur->rpl_domain || cur->interface_mode != INTERFACE_UP) {
return;
}

if (event == RPL_EVENT_POISON_FINISHED) {
//If we are waiting poison we will trig Discovery after couple seconds
if (cur->nwk_bootstrap_state == ER_RPL_NETWORK_LEAVING) {
cur->bootsrap_state_machine_cnt = 80; //Give 8 seconds time to send Poison
}
return;
}

// if waiting for RPL and
if (event == RPL_EVENT_DAO_DONE) {
// Trigger statemachine check
Expand Down Expand Up @@ -3132,6 +3167,12 @@ void ws_bootstrap_event_routing_ready(protocol_interface_info_entry_t *cur)
{
ws_bootsrap_event_trig(WS_ROUTING_READY, cur->bootStrapId, ARM_LIB_LOW_PRIORITY_EVENT, NULL);
}

void ws_bootstrap_event_disconnect(protocol_interface_info_entry_t *cur, ws_bootsrap_event_type_e event_type)
{
ws_bootsrap_event_trig(event_type, cur->bootStrapId, ARM_LIB_LOW_PRIORITY_EVENT, NULL);
}

void ws_bootstrap_configuration_trickle_reset(protocol_interface_info_entry_t *cur)
{
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config, &cur->ws_info->trickle_params_pan_discovery);
Expand Down Expand Up @@ -3315,6 +3356,7 @@ static int8_t ws_bootstrap_backbone_ip_addr_get(protocol_interface_info_entry_t
return -1;
}


static void ws_bootstrap_event_handler(arm_event_s *event)
{
ws_bootsrap_event_type_e event_type;
Expand All @@ -3331,7 +3373,6 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
break;
case WS_DISCOVERY_START:
tr_info("Discovery start");

protocol_mac_reset(cur);
ws_llc_reset(cur);
lowpan_adaptation_interface_reset(cur->id);
Expand Down Expand Up @@ -3467,6 +3508,12 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
ws_bootstrap_advertise_start(cur);
ws_bootstrap_state_change(cur, ER_BOOTSRAP_DONE);
break;
case WS_FAST_DISCONNECT:
ws_bootstrap_disconnect(cur, WS_FAST_DISCONNECT);
break;
case WS_NORMAL_DISCONNECT:
ws_bootstrap_disconnect(cur, WS_NORMAL_DISCONNECT);
break;

default:
tr_err("Invalid event received");
Expand Down Expand Up @@ -3658,6 +3705,10 @@ void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur)
// Bootstrap_done event to application
nwk_bootsrap_state_update(ARM_NWK_BOOTSTRAP_READY, cur);
break;
case ER_RPL_NETWORK_LEAVING:
tr_debug("WS SM:RPL Leaving ready trigger discovery");
ws_bootstrap_event_discovery_start(cur);
break;
default:
tr_warn("WS SM:Invalid state %d", cur->nwk_bootstrap_state);
}
Expand Down Expand Up @@ -3743,9 +3794,10 @@ void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t s
}
} else {
// Border router has timed out
//Clear Timeout timer
cur->ws_info->pan_timeout_timer = 0;
tr_warn("Border router has timed out");
ws_bootstrap_event_discovery_start(cur);
ws_bootstrap_event_disconnect(cur, WS_FAST_DISCONNECT);
}
}
if (cur->ws_info->aro_registration_timer) {
Expand Down
6 changes: 5 additions & 1 deletion source/6LoWPAN/ws/ws_bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ typedef enum {
WS_DISCOVERY_START, /**< discovery start*/
WS_CONFIGURATION_START, /**< configuration learn start*/
WS_OPERATION_START, /**< active operation start*/
WS_ROUTING_READY /**< RPL routing connected to BR*/
WS_ROUTING_READY, /**< RPL routing connected to BR*/
WS_FAST_DISCONNECT, /**< Do fast timeout after Border router timeout*/
WS_NORMAL_DISCONNECT /**< Border have been rebooted so Slow poison Process*/
} ws_bootsrap_event_type_e;

#ifdef HAVE_WS
Expand Down Expand Up @@ -60,6 +62,8 @@ void ws_bootstrap_event_operation_start(protocol_interface_info_entry_t *cur);

void ws_bootstrap_event_routing_ready(protocol_interface_info_entry_t *cur);

void ws_bootstrap_event_disconnect(protocol_interface_info_entry_t *cur, ws_bootsrap_event_type_e event_type);

void ws_bootstrap_configuration_trickle_reset(protocol_interface_info_entry_t *cur);

void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds);
Expand Down
1 change: 1 addition & 0 deletions source/NWK_INTERFACE/Include/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ typedef enum icmp_state {
ER_BOOTSTRAP_NEW_FRAGMENT_START,
ER_WAIT_RESTART,
ER_RPL_LOCAL_REPAIR,
ER_RPL_NETWORK_LEAVING,
} icmp_state_t;

typedef enum {
Expand Down

0 comments on commit 4096c1a

Please sign in to comment.