@@ -76,6 +76,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event);
76
76
static void ws_bootstrap_state_change (protocol_interface_info_entry_t * cur , icmp_state_t nwk_bootstrap_state );
77
77
static bool ws_bootstrap_state_active (struct protocol_interface_info_entry * cur );
78
78
static bool ws_bootstrap_state_discovery (struct protocol_interface_info_entry * cur );
79
+ static bool ws_bootstrap_state_wait_rpl (struct protocol_interface_info_entry * cur );
79
80
80
81
static mac_neighbor_table_entry_t * ws_bootstrap_add_neighbor (struct protocol_interface_info_entry * interface , const uint8_t * src64 )
81
82
{
@@ -838,7 +839,17 @@ static void ws_bootstrap_rpl_callback(rpl_event_t event, void *handle)
838
839
if (!cur -> rpl_domain || cur -> interface_mode != INTERFACE_UP ) {
839
840
return ;
840
841
}
841
- tr_warn ("RPL callback event %d" , event );
842
+ // if waiting for RPL and
843
+ if (event == RPL_EVENT_DAO_DONE ) {
844
+ // Trigger statemachine check
845
+ cur -> bootsrap_state_machine_cnt = 1 ;
846
+ } else if (event == RPL_EVENT_LOCAL_REPAIR_NO_MORE_DIS ) {
847
+ // RPL gave up so we need to re-trigger network scan.
848
+ // TODO is this correct?
849
+ ws_bootstrap_event_configuration_start (cur );
850
+ }
851
+ cur -> ws_info -> rpl_state = event ;
852
+ tr_info ("RPL event %d" , event );
842
853
}
843
854
844
855
static void ws_bootstrap_rpl_activate (protocol_interface_info_entry_t * cur )
@@ -853,6 +864,7 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
853
864
// If i am router I Do this
854
865
rpl_control_force_leaf (protocol_6lowpan_rpl_domain , leaf );
855
866
867
+ cur -> ws_info -> rpl_state = 0xff ; // Set invalid state and learn from event
856
868
if (cur -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_ROUTER ) {
857
869
rpl_control_transmit_dis (cur -> rpl_domain , cur , 0 , 0 , NULL , 0 , ADDR_LINK_LOCAL_ALL_ROUTERS );
858
870
}
@@ -1061,7 +1073,13 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
1061
1073
ws_bootstrap_rpl_activate (cur );
1062
1074
ws_bootstrap_network_start (cur );
1063
1075
ws_bootstrap_advertise_start (cur );
1064
- ws_bootstrap_event_routing_ready (cur );
1076
+ // Wait for RPL start
1077
+ if (cur -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER ) {
1078
+ ws_bootstrap_event_routing_ready (cur );
1079
+ } else {
1080
+ // routers wait until RPL root is contacted
1081
+ ws_bootstrap_state_change (cur , ER_RPL_SCAN );
1082
+ }
1065
1083
break ;
1066
1084
case WS_ROUTING_READY :
1067
1085
tr_info ("Routing ready" );
@@ -1101,6 +1119,15 @@ void ws_bootstrap_configure_process(protocol_interface_info_entry_t *cur)
1101
1119
}
1102
1120
return ;
1103
1121
}
1122
+ void ws_bootstrap_rpl_wait_process (protocol_interface_info_entry_t * cur )
1123
+ {
1124
+
1125
+ if (cur -> ws_info -> rpl_state == RPL_EVENT_DAO_DONE ) {
1126
+ // Trigger statemachine check
1127
+ ws_bootstrap_event_routing_ready (cur );
1128
+ }
1129
+ return ;
1130
+ }
1104
1131
1105
1132
static bool ws_bootstrap_state_active (struct protocol_interface_info_entry * cur )
1106
1133
{
@@ -1119,6 +1146,15 @@ static bool ws_bootstrap_state_configure(struct protocol_interface_info_entry *c
1119
1146
return false;
1120
1147
}
1121
1148
1149
+ static bool ws_bootstrap_state_wait_rpl (struct protocol_interface_info_entry * cur )
1150
+ {
1151
+ // Think about the state value
1152
+ if (cur -> nwk_bootstrap_state == ER_RPL_SCAN ) {
1153
+ return true;
1154
+ }
1155
+ return false;
1156
+ }
1157
+
1122
1158
static bool ws_bootstrap_state_discovery (struct protocol_interface_info_entry * cur )
1123
1159
{
1124
1160
if (cur -> nwk_bootstrap_state == ER_ACTIVE_SCAN ) {
@@ -1144,6 +1180,10 @@ void ws_bootstrap_state_machine(protocol_interface_info_entry_t *cur)
1144
1180
tr_debug ("WS SM:configuration Scan" );
1145
1181
ws_bootstrap_configure_process (cur );
1146
1182
break ;
1183
+ case ER_RPL_SCAN :
1184
+ tr_debug ("WS SM:Wait RPL to contact DODAG root" );
1185
+ ws_bootstrap_rpl_wait_process (cur );
1186
+ break ;
1147
1187
case ER_BOOTSRAP_DONE :
1148
1188
tr_debug ("WS SM:Bootstrap Done" );
1149
1189
// Bootstrap_done event to application
0 commit comments