Skip to content

Correct mesh network connection status callback functionality. #8439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Nanostack::Interface : public OnboardNetworkStack::Interface, private mbed

Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb;
nsapi_connection_status_t _connect_status;
nsapi_connection_status_t _previous_connection_status;
bool _blocking;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void Nanostack::Interface::attach(
}

Nanostack::Interface::Interface(NanostackPhy &phy) : interface_phy(phy), interface_id(-1), _device_id(-1),
_connect_status(NSAPI_STATUS_DISCONNECTED), _blocking(true)
_connect_status(NSAPI_STATUS_DISCONNECTED), _blocking(true), _previous_connection_status(NSAPI_STATUS_DISCONNECTED)
{
mesh_system_init();
}
Expand Down Expand Up @@ -138,15 +138,17 @@ void Nanostack::Interface::network_handler(mesh_connection_status_t status)
_connect_status = NSAPI_STATUS_LOCAL_UP;
} else if (status == MESH_CONNECTED_GLOBAL) {
_connect_status = NSAPI_STATUS_GLOBAL_UP;
} else if (status == MESH_BOOTSTRAP_STARTED) {
} else if (status == MESH_BOOTSTRAP_STARTED || status == MESH_BOOTSTRAP_FAILED) {
_connect_status = NSAPI_STATUS_CONNECTING;
} else {
_connect_status = NSAPI_STATUS_DISCONNECTED;
}

if (_connection_status_cb) {
if (_connection_status_cb && _previous_connection_status != _connect_status) {

_connection_status_cb(NSAPI_EVENT_CONNECTION_STATUS_CHANGE, _connect_status);
}
_previous_connection_status = _connect_status;
}

nsapi_error_t Nanostack::Interface::register_phy()
Expand Down
10 changes: 5 additions & 5 deletions features/nanostack/mbed-mesh-api/source/nd_tasklet.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,28 +185,28 @@ void nd_tasklet_parse_network_event(arm_event_s *event)
/* Link Layer Active Scan Fail, Stack is Already at Idle state */
tr_debug("Link Layer Scan Fail: No Beacons");
tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_FAILED;
nd_tasklet_network_state_changed(MESH_DISCONNECTED);
nd_tasklet_network_state_changed(MESH_BOOTSTRAP_FAILED);
break;
case ARM_NWK_IP_ADDRESS_ALLOCATION_FAIL:
/* No ND Router at current Channel Stack is Already at Idle state */
tr_debug("ND Scan/ GP REG fail");
tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_FAILED;
nd_tasklet_network_state_changed(MESH_DISCONNECTED);
nd_tasklet_network_state_changed(MESH_BOOTSTRAP_FAILED);
break;
case ARM_NWK_NWK_CONNECTION_DOWN:
/* Connection to Access point is lost wait for Scan Result */
tr_debug("ND/RPL scan new network");
tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_FAILED;
nd_tasklet_network_state_changed(MESH_DISCONNECTED);
nd_tasklet_network_state_changed(MESH_BOOTSTRAP_FAILED);
break;
case ARM_NWK_NWK_PARENT_POLL_FAIL:
tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_FAILED;
nd_tasklet_network_state_changed(MESH_DISCONNECTED);
nd_tasklet_network_state_changed(MESH_BOOTSTRAP_FAILED);
break;
case ARM_NWK_AUHTENTICATION_FAIL:
tr_debug("Network authentication fail");
tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_FAILED;
nd_tasklet_network_state_changed(MESH_DISCONNECTED);
nd_tasklet_network_state_changed(MESH_BOOTSTRAP_FAILED);
break;
default:
tr_warn("Unknown event %d", status);
Expand Down
10 changes: 5 additions & 5 deletions features/nanostack/mbed-mesh-api/source/thread_tasklet.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,28 +189,28 @@ void thread_tasklet_parse_network_event(arm_event_s *event)
/* Link Layer Active Scan Fail, Stack is Already at Idle state */
tr_debug("Link Layer Scan Fail: No Beacons");
thread_tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_FAILED;
thread_tasklet_network_state_changed(MESH_DISCONNECTED);
thread_tasklet_network_state_changed(MESH_BOOTSTRAP_FAILED);
break;
case ARM_NWK_IP_ADDRESS_ALLOCATION_FAIL:
/* No ND Router at current Channel Stack is Already at Idle state */
tr_debug("ND Scan/ GP REG fail");
thread_tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_FAILED;
thread_tasklet_network_state_changed(MESH_DISCONNECTED);
thread_tasklet_network_state_changed(MESH_BOOTSTRAP_FAILED);
break;
case ARM_NWK_NWK_CONNECTION_DOWN:
/* Connection to Access point is lost wait for Scan Result */
tr_debug("ND/RPL scan new network");
thread_tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_FAILED;
thread_tasklet_network_state_changed(MESH_DISCONNECTED);
thread_tasklet_network_state_changed(MESH_BOOTSTRAP_FAILED);
break;
case ARM_NWK_NWK_PARENT_POLL_FAIL:
thread_tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_FAILED;
thread_tasklet_network_state_changed(MESH_DISCONNECTED);
thread_tasklet_network_state_changed(MESH_BOOTSTRAP_FAILED);
break;
case ARM_NWK_AUHTENTICATION_FAIL:
tr_debug("Network authentication fail");
thread_tasklet_data_ptr->tasklet_state = TASKLET_STATE_BOOTSTRAP_FAILED;
thread_tasklet_network_state_changed(MESH_DISCONNECTED);
thread_tasklet_network_state_changed(MESH_BOOTSTRAP_FAILED);
break;
default:
tr_warn("Unknown event %d", status);
Expand Down