You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The interface handles all state changes itself between `Connecting`, `Local connectivity` and `Global route found`. Calling `NetworkInterface::connect()` might return when either local or global connectivity states are reached. This depends on the connectivity. For example, Ethernet and Wi-Fi interfaces return when global connectivity is reached. 6LoWPAN-based mesh networks depend on the standard you're using. The `LoWPANNDInterface` returns from `connect()` call when it connects to a border router that provides global connection. The `ThreadInterface` returns from `connect()` call when it joins a local mesh network. It may later get global connection when it finds a border router.
20
+
The interface handles all state changes between `Connecting`, `Local connectivity` and `Global route found`. Calling `NetworkInterface::connect()` might return when either local or global connectivity states are reached. This depends on the connectivity. For example, Ethernet and Wi-Fi interfaces return when global connectivity is reached. 6LoWPAN-based mesh networks depend on the standard you're using. The `LoWPANNDInterface` returns from `connect()` call when it connects to a border router that provides a global connection. The `ThreadInterface` returns from `connect()` call when it joins a local mesh network. It may later get a global connection when it finds a border router.
21
21
22
-
When a network or route is lost or any other cause limits the connectivity, the interface may change its state back to `Connecting`, `Local connectivity` or `Disconnected`. In the `Connecting` and `Local connectivity` states, the interface usually reconnects until the application chooses to call `NetworkInterface::disconnect()`. Depending on the network, this reconnection might have internal back off periods, and not all interfaces implement the reconnection logic at all. Refer to table below on how different interfaces behave.
22
+
When a network or route is lost or any other cause limits the connectivity, the interface may change its state back to `Connecting`, `Local connectivity` or `Disconnected`. In the `Connecting` and `Local connectivity` states, the interface usually reconnects until the application chooses to call `NetworkInterface::disconnect()`. Depending on the network, this reconnection might have internal backoff periods, and not all interfaces implement the reconnection logic at all. Please refer to table below for information on how different interfaces behave.
23
23
24
24
An application may check the connection status by calling `nsapi_connection_status_t get_connection_status()` or register a callback to monitoring status changes. The following table lists defined network states with actions that applictions should take on the state change:
25
25
@@ -30,14 +30,13 @@ An application may check the connection status by calling `nsapi_connection_stat
30
30
| Local connectivity |`NSAPI_STATUS_LOCAL_UP`| You can create sockets and communicate with local devices in the same network. |
31
31
| Global route found |`NSAPI_STATUS_GLOBAL_UP`| You can create sockets and communicate with all hosts. |
32
32
33
-
34
33
Use the following API to register status callbacks:
35
34
36
35
-[Network status](network-status.html): API for monitoring network status changes.
37
36
38
-
Error handling and reconnection logic depends on the network interface used. Use following table to determine what actions your application needs to do on each network type.
37
+
Error handling and reconnection logic depends on the network interface. Please use the following table to determine what actions your application needs to do on each network type.
39
38
40
-
|`NetworkInterface`sub class| Does it reconnect automatically? | Possible states |
39
+
|`NetworkInterface`subclass| Does it reconnect automatically? | Possible states |
|`WiFiInterface`| Yes, when onboard network stack is used.<br />For external modules, it depends on the driver.<br />See examples below. | - |
@@ -110,36 +109,36 @@ if (wifi) {
110
109
111
110
### Notes on portable applications
112
111
113
-
When application is expected to be portable between different network interfaces, following guidelines should be used:
112
+
When you expect an application to be portable between different network interfaces, please use the following guidelines:
114
113
115
114
1. Use only `NetworkInterface::get_default_instance()` for getting the interface.
116
-
2. Register network status handler and implement reconnection logic.
115
+
1. Register the network status handler, and implement reconnection logic.
117
116
118
-
See previous section [Default network interface](#default-network-interface) on how to use the portable API for network interface.
117
+
Please see the previous section,[Default network interface](#default-network-interface), on how to use the portable API for the network interface.
119
118
120
119
For network status changes, the API is specified in [Network status](network-status.html) section. Being portable means that your application only communicates after `NSAPI_STATUS_GLOBAL_UP` is received and tries to reconnect the network if `NSAPI_STATUS_DISCONNECTED` is received without calling `NetworkInterface::disconnect()`.
121
120
122
121
### Using multiple network interfaces
123
122
124
-
In Mbed OS, applications usually use just one network interface at a time, and most APIs are designed to work with such assumption.
125
-
With few limitations, applications are able to operate more than one NetworkInterface. In Mbed OS, there are two build in IP stacks and numerous external IP stacks provided by modules. Refer to [Architecture:IP networking](reference/ip-networking.html) section for explanation of how different stacks are integrated into Mbed OS.
123
+
In Mbed OS, applications usually use one network interface at a time, and most APIs are designed this way. With few limitations, applications are able to operate more than one NetworkInterface. In Mbed OS, there are two built-in IP stacks and many external IP stacks provided by modules. Please refer to the [Architecture:IP networking](reference/ip-networking.html) section for an explanation of how different stacks are integrated into Mbed OS.
124
+
125
+
When you use two network interfaces and both are operating on different IP stacks, the interfaces can work independently because there is no common data path, for example an application that uses an on-board Ethernet interface and any of the external Wi-Fi modules.
126
+
127
+
When you use two network interfaces and both use the same IP stacks, there are limitations.
126
128
127
-
When using two network interfaces where both are operating on different IP stacks, they can work independently, as there is no common data paths. Such example can be application that uses on-board Ethernet interface and any of the external WiFi modules.
129
+
We have modified the LwIP routing core to support multiple active interfaces, but when more than one active interface is active in LwIP, only one is the default. All the outgoing traffic flows through it.
128
130
129
-
When using two network interfaces where both use the same IP stacks, there are limitations. Both IP stacks, LwIP and Nanostack, are build using assumption that there is only one active interface.
130
-
For the Mbed OS 5.12, the LwIP routing core was modified to support multiple active interfaces, but it has its own limitations as well. When you have more than one active interfaces in LwIP, only one is the default, which all the outgoing traffic flows through.
131
-
If you need to force the traffic to only one of the interface, you need to use `Socket::setsockopt(NSAPI_SOCKET, NSAPI_BIND_TO_DEVICE, <interface name>, <interface name length>)` to bind the socket into one interface. Interface name can get fetched from `NetworkInterface::get_interface_name()` call.
131
+
If you need to force the traffic to only one of the interfaces, you need to use `Socket::setsockopt(NSAPI_SOCKET, NSAPI_BIND_TO_DEVICE, <interface name>, <interface name length>)` to bind the socket into one interface. You can fetch the interface name from the `NetworkInterface::get_interface_name()` call.
132
132
133
-
Another, more common, case is where only one of the interface is active at a time. In this case, there is no need for `Socket::setsockopt()` if another interface is brought down as there is only one route option. This works when LwIP is used, but not verified with Nanostack as it is used only on specific use cases. like mesh routing.
133
+
Another, more common, case is where only one of the interface is active at a time. In this case, there is no need for `Socket::setsockopt()` if another interface is brought down because there is only one route option. This works with LwIP but is not verified with Nanostack because it is used only on specific use cases, such as mesh routing.
134
134
135
135
### Asynchronous operation
136
136
137
-
`NetworkInterface::connect()` and `NetworkInterface::disconnect()` are blocking by default. When application prefers asyncronous operation
138
-
it can set the interface into non-blocking mode by calling `NetworkInterface::set_blocking(false)`. This has to be done for each interface separately.
137
+
`NetworkInterface::connect()` and `NetworkInterface::disconnect()` are blocking by default. When an application prefers asynchronous operation, it can set the interface into nonblocking mode by calling `NetworkInterface::set_blocking(false)`. This has to be done for each interface separately.
139
138
140
-
When interface is operating in asyncronous mode, the return values of `connect()` and `disconnect()` have slightly different meaning. Basically calling `connect()` starts the asyncronous operation which aims to have the device in `GLOBAL_UP` state. Calling `disconnect()`has the target state being`DISCONNECTED`. Return codes in asyncronous mode do not anymore reflect the connection status. Most common return codes in asyncronous mode is `NSAPI_ERROR_OK` which means that operation just started. Refer to Doxygen documentation of [NetworkInterface::connect()](https://os.mbed.com/docs/mbed-os/v5.11/mbed-os-api-doxy/class_network_interface.html#aaf6bf1dfffbe6a5626b7b52eaa542b6e) and [NetworkInterface::disconnect()](https://os.mbed.com/docs/mbed-os/v5.11/mbed-os-api-doxy/class_network_interface.html#afdda3f62c7d73df183ee2d352e8cd146) for return values of these functions.
139
+
When an interface operates in asynchronous mode, the return values of `connect()` and `disconnect()` have slightly different meanings. Calling `connect()` starts the asynchronous operation, which puts the device in the `GLOBAL_UP` state. Calling `disconnect()`puts the target in the`DISCONNECTED` state. Return code in asynchronous mode does not reflect the connection status. The most common return codes in asynchronous mode is `NSAPI_ERROR_OK`, which means that operation just started. Please refer to the Doxygen documentation of [NetworkInterface::connect()](https://os.mbed.com/docs/mbed-os/development/mbed-os-api-doxy/class_network_interface.html#aaf6bf1dfffbe6a5626b7b52eaa542b6e) and [NetworkInterface::disconnect()](https://os.mbed.com/docs/mbed-os/development/mbed-os-api-doxy/class_network_interface.html#afdda3f62c7d73df183ee2d352e8cd146) for return values of these functions.
141
140
142
-
For checking the whether the interface is connected, application needs to register the status callback for the interface. Refer to [Network status API](network-status.html) how to do it.
141
+
To check whether the interface is connected, the application needs to register the status callback for the interface. Please refer to the [Network status API](network-status.html)for information on how to do so.
0 commit comments