Skip to content

Commit 75cce02

Browse files
author
Mika Tervonen
committed
Add bootstrap Down event when re-starting network discovery
When bootstrap is restarted bootstrap down event is sent keep status if we have set bootstrap ready before sending the event
1 parent 3d93f64 commit 75cce02

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,21 @@ static int ws_bootstrap_tasklet_init(protocol_interface_info_entry_t *cur)
183183

184184
return 0;
185185
}
186+
static void ws_nwk_event_post(protocol_interface_info_entry_t *cur, arm_nwk_interface_status_type_e posted_event)
187+
{
188+
arm_event_s event = {
189+
.receiver = cur->net_start_tasklet,
190+
.sender = protocol_read_tasklet_id(), /**< Event sender Tasklet ID */
191+
.event_type = ARM_LIB_NWK_INTERFACE_EVENT,
192+
.event_data = posted_event,
193+
.event_id = (int8_t) cur->id,
194+
.data_ptr = NULL,
195+
.priority = ARM_LIB_LOW_PRIORITY_EVENT,
196+
};
197+
if (eventOS_event_send(&event) != 0) {
198+
tr_error("nwk_net_event_post(): event send failed");
199+
}
200+
}
186201

187202
static int8_t ws_bootsrap_event_trig(ws_bootsrap_event_type_e event_type, int8_t interface_id, arm_library_event_priority_e priority, void *event_data)
188203
{
@@ -1966,6 +1981,13 @@ static void ws_bootstrap_start_discovery(protocol_interface_info_entry_t *cur)
19661981
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_advertisement_solicit, &cur->ws_info->trickle_params_pan_discovery);
19671982
}
19681983

1984+
if ((cur->lowpan_info & INTERFACE_NWK_BOOTSRAP_ACTIVE) != INTERFACE_NWK_BOOTSRAP_ACTIVE) {
1985+
// we have sent bootstrap ready event and now
1986+
// restarted discovery so bootstrap down event is sent
1987+
cur->lowpan_info |= INTERFACE_NWK_BOOTSRAP_ACTIVE;
1988+
ws_nwk_event_post(cur, ARM_NWK_NWK_CONNECTION_DOWN);
1989+
}
1990+
19691991
// Discovery statemachine is checkked after two trickle interval
19701992
cur->bootsrap_state_machine_cnt = 2 * cur->ws_info->trickle_params_pan_discovery.Imin + randLIB_get_8bit() % 50;
19711993
}

0 commit comments

Comments
 (0)