Skip to content

Commit 53a82fa

Browse files
Prevent double attempt to connect mesh api
Socket network interface tests were failing due to DICONNECTED event being advertised, where GLOBAL_UP was expected. It turned out that nanostack receives two events: APPL_EVENT_CONNECT and APPL_BACKHAUL_INTERFACE_PHY_UP. The second attempt to connect obviously returns errors, but it also causes events to be sent out to the application. The second attempt should not take place in case the bootstrap is already started. I also fixed two reports being sent with DISCONNECT status, while they are actually something else.
1 parent a4ed473 commit 53a82fa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

features/nanostack/mbed-mesh-api/source/ethernet_tasklet.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ void enet_tasklet_main(arm_event_s *event)
120120
case APPLICATION_EVENT:
121121
if (event->event_id == APPL_EVENT_CONNECT) {
122122
enet_tasklet_configure_and_connect_to_network();
123-
} else if (event->event_id == APPL_BACKHAUL_INTERFACE_PHY_UP) {
123+
} else if (event->event_id == APPL_BACKHAUL_INTERFACE_PHY_UP
124+
&& tasklet_data_ptr->tasklet_state != TASKLET_STATE_BOOTSTRAP_STARTED) {
124125
// Ethernet cable has been plugged in
125126
arm_nwk_interface_configure_ipv6_bootstrap_set(
126127
tasklet_data_ptr->network_interface_id, NET_IPV6_BOOTSTRAP_AUTONOMOUS, NULL);
@@ -175,13 +176,13 @@ void enet_tasklet_parse_network_event(arm_event_s *event)
175176
/* No ND Router at current Channel Stack is Already at Idle state */
176177
tr_info("Bootstrap fail");
177178
tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_FAILED;
178-
enet_tasklet_network_state_changed(MESH_DISCONNECTED);
179+
enet_tasklet_network_state_changed(MESH_BOOTSTRAP_FAILED);
179180
break;
180181
case ARM_NWK_NWK_CONNECTION_DOWN:
181182
/* Connection to Access point is lost wait for Scan Result */
182183
tr_info("Connection lost");
183184
tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_FAILED;
184-
enet_tasklet_network_state_changed(MESH_DISCONNECTED);
185+
enet_tasklet_network_state_changed(MESH_BOOTSTRAP_FAILED);
185186
break;
186187
default:
187188
tr_warn("Unknown event %d", status);

0 commit comments

Comments
 (0)