Module network
Data Types
ap_config()
ap_config() = {ap, [ap_config_property()]}
ap_config_property()
ap_config_property() = ssid_config() | psk_config() | ap_ssid_hidden_config() | ap_max_connections_config() | ap_started_config() | ap_sta_connected_config() | ap_sta_disconnected_config() | ap_sta_ip_assigned_config()
ap_max_connections_config()
ap_max_connections_config() = {ap_max_connections, non_neg_integer()}
ap_sta_connected_config()
ap_sta_connected_config() = {sta_connected, fun((mac()) -> term())}
ap_sta_disconnected_config()
ap_sta_disconnected_config() = {sta_disconnected, fun((mac()) -> term())}
ap_sta_ip_assigned_config()
ap_sta_ip_assigned_config() = {sta_ip_assigned, fun((ipv4_address()) -> term())}
ap_started_config()
ap_started_config() = {ap_started, fun(() -> term())}
db()
db() = integer()
dhcp_hostname_config()
dhcp_hostname_config() = {dhcp_hostname, string() | binary()}
ip_info()
ip_info() = ipv4_info()
ipv4_address()
ipv4_address() = {octet(), octet(), octet(), octet()}
ipv4_info()
ipv4_info() = {IPAddress::ipv4_address(), NetMask::ipv4_address(), Gateway::ipv4_address()}
mac()
mac() = binary()
network_config()
network_config() = [sta_config() | ap_config() | sntp_config()]
octet()
octet() = 0..255
psk_config()
psk_config() = {psk, string() | binary()}
sntp_config()
sntp_config() = {sntp, [sntp_config_property()]}
sntp_config_property()
sntp_config_property() = sntp_host_config() | sntp_synchronized_config()
sntp_host_config()
sntp_host_config() = {host, string() | binary()}
sntp_synchronized_config()
sntp_synchronized_config() = {synchronized, fun(({non_neg_integer(), non_neg_integer()}) -> term())}
ssid_config()
ssid_config() = {ssid, string() | binary()}
sta_config()
sta_config() = {sta, [sta_config_property()]}
sta_config_property()
sta_config_property() = ssid_config() | psk_config() | dhcp_hostname_config() | sta_connected_config() | sta_disconnected_config() | sta_got_ip_config()
sta_connected_config()
sta_connected_config() = {connected, fun(() -> term())}
sta_disconnected_config()
sta_disconnected_config() = {disconnected, fun(() -> term())}
sta_got_ip_config()
sta_got_ip_config() = {got_ip, fun((ip_info()) -> term())}
Function Index
sta_rssi/0 | Get the rssi information of AP to which the device is associated with. |
start/1 | Start a network interface. |
start_link/1 | |
stop/0 | Stop a network interface. |
wait_for_ap/0 | Equivalent to wait_for_ap(15000). |
wait_for_ap/1 | Equivalent to wait_for_ap([], Timeout) or wait_for_ap(StaConfig, 15000). |
wait_for_ap/2 | Start a network interface in access point mode and wait the AP to be up and running. |
wait_for_sta/0 | Equivalent to wait_for_sta(15000). |
wait_for_sta/1 | Equivalent to wait_for_sta([], Timeout) or wait_for_sta(StaConfig, 15000). |
wait_for_sta/2 | Start a network interface in station mode and wait for a connection to be established. |
Function Details
sta_rssi/0
sta_rssi() -> {ok, Rssi::db()} | {error, Reason::term()}
returns: {ok, Rssi} in decibels, or {error, Reason}.
Get the rssi information of AP to which the device is associated with.
start/1
start(Config::network_config()) -> {ok, pid()} | {error, Reason::term()}
Config
: The network configuration
returns: ok, if the network interface was started, or {error, Reason} if a failure occurred (e.g., due to malformed network configuration).
Start a network interface.
This function will start a network interface, which will attempt to connect to an AP endpoint in the background. Specify callback functions to receive definitive information that the connection succeeded. See the AtomVM Network FSM Programming Manual for more information.
start_link/1
start_link(Config::network_config()) -> {ok, pid()} | {error, Reason::term()}
stop/0
stop() -> ok | {error, Reason::term()}
returns: ok, if the network interface was stopped, or {error, Reason} if a failure occurred.
Stop a network interface.
wait_for_ap/0
wait_for_ap() -> ok | {error, Reason::term()}
Equivalent to wait_for_ap(15000).
wait_for_ap/1
wait_for_ap(TimeoutOrApConfig::non_neg_integer() | [ap_config_property()]) -> ok | {error, Reason::term()}
TimeoutOrApConfig
: The AP network configuration or timeout in ms.
Equivalent to wait_for_ap([], Timeout) or wait_for_ap(StaConfig, 15000).
wait_for_ap/2
wait_for_ap(ApConfig::[ap_config_property()], Timeout::non_neg_integer()) -> ok | {error, Reason::term()}
ApConfig
: The AP network configurationTimeout
: amount of time in milliseconds to wait for a connection
returns: ok, when the network has started the AP, or {error, Reason} if a failure occurred (e.g., due to malformed network configuration).
Start a network interface in access point mode and wait the AP to be up and running
This function will start a network interface in AP mode, and will wait until the network is up and ready to be connected. This is a convenience function, for applications that do not need to be notified of connectivity changes in the network.
wait_for_sta/0
wait_for_sta() -> {ok, ip_info()} | {error, Reason::term()}
Equivalent to wait_for_sta(15000).
wait_for_sta/1
wait_for_sta(TimeoutOrStaConfig::non_neg_integer() | [sta_config_property()]) -> {ok, ip_info()} | {error, Reason::term()}
TimeoutOrStaConfig
: The STA network configuration or timeout in ms.
Equivalent to wait_for_sta([], Timeout) or wait_for_sta(StaConfig, 15000).
wait_for_sta/2
wait_for_sta(StaConfig::[sta_config_property()], Timeout::non_neg_integer()) -> {ok, ip_info()} | {error, Reason::term()}
StaConfig
: The STA network configurationTimeout
: amount of time in milliseconds to wait for a connection
returns: {ok, IpInfo}, if the network interface was started, or {error, Reason} if a failure occurred (e.g., due to malformed network configuration).
Start a network interface in station mode and wait for a connection to be established
This function will start a network interface in station mode, and will wait for a connection to be established. This is a convenience function, for applications that do not need to be notified of connectivity changes in the network.