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
Merge pull request atomvm#499 from fadushin/network_api_fix
Fixed examples and docs to reflect API changes
This PR fixes examples and documentation to reflect changes to the return value
from the `network:start` function.
The release notes have been augmented to note that the change to the network
interface is API-incompatible with previous releases of AtomVM.
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
Copy file name to clipboardExpand all lines: doc/src/network-programming-guide.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ The `<sta-properties>` property list should contain the following entries:
29
29
30
30
> Note that the station mode SSID and password _may_ be stored in non-volatile storage, in which case these parameters may be skipped. See the "NVS Credentials" section below, for more information about using non-volatile storage to store credentials that persist across device reboots.
31
31
32
-
The `network:start/1` will immediately return `ok`, if the network was properly initialized, or `{error, Reason}`, if there was an error in configuration. However, the application may want to wait for the device to connect to the target network and obtain an IP address, for example, before starting clients or services that require network access.
32
+
The `network:start/1` will immediately return `{ok, Pid}`, where `Pid` is the process ID of the network server instance, if the network was properly initialized, or `{error, Reason}`, if there was an error in configuration. However, the application may want to wait for the device to connect to the target network and obtain an IP address, for example, before starting clients or services that require network access.
33
33
34
34
Applications can specify callback functions, which get triggered as events emerge from the network layer, including connection to and disconnection from the target network, as well as IP address acquisition.
35
35
@@ -60,7 +60,7 @@ The following example illustrates initialization of the WiFi network in STA mode
60
60
{dhcp_hostname, <<"myesp32">>}
61
61
]}
62
62
],
63
-
ok = network:start(Config),
63
+
{ok, Pid} = network:start(Config),
64
64
...
65
65
66
66
The following callback functions will be called when the corresponding events occur during the lifetime of the network connection.
@@ -113,7 +113,7 @@ If the password is omitted, then an _open network_ will be created, and a warnin
113
113
114
114
> Note that the station mode SSID and password _may_ be stored in non-volatile storage, in which case these parameters may be skipped. See the "NVS Credentials" section below, for more information about using non-volatile storage to store credentials that persist across device reboots.
115
115
116
-
The `network:start/1` will immediately return `ok`, if the network was properly initialized, or `{error, Reason}`, if there was an error in configuration. However, the application may want to wait for the device to to be ready to accept connections from other devices, or to be notified when other devices connect to this AP.
116
+
The `network:start/1` will immediately return `{ok, Pid}`, where `Pid` is the process id of the network server, if the network was properly initialized, or `{error, Reason}`, if there was an error in configuration. However, the application may want to wait for the device to to be ready to accept connections from other devices, or to be notified when other devices connect to this AP.
117
117
118
118
Applications can specify callback functions, which get triggered as events emerge from the network layer, including when a station connects or disconnects from the AP, as well as when a station is assigned an IP address.
119
119
@@ -146,7 +146,7 @@ The following example illustrates initialization of the WiFi network in AP mode.
146
146
{sta_disconnected, fun sta_disconnected/1},
147
147
]}
148
148
],
149
-
ok = network:start(Config),
149
+
{ok, Pid} = network:start(Config),
150
150
...
151
151
152
152
The following callback functions will be called when the corresponding events occur during the lifetime of the network connection.
0 commit comments