Returns comprehensive imp network details
Device
Table — the network configuration information
This method returns a table populated with the imp’s stored network information. The table contains a number of keys some of whose values are themselves tables of data. Only relevant tables are returned. For example, if the method is called on an imp001, imp002, imp003, imp004m, imp006 or impC001, it will not contain an interface record for Ethernet — only the imp005 currently provides Ethernet support.
These are the top-level keys:
Key | Type | Notes |
---|---|---|
interface | Array of tables | One table per available interface, see below |
active | Integer | The index in the interface array of the current active (connected to the server) interface. If the active key is not present, no interface is active |
ipv4 | Table | Network configuration data for the active connection, see below. Note This entry is not present on the impC001 |
lasterror | Integer | The last network error code, see server.connect(). Not present if there was no error, ie. server is connected |
Do not assume that the tables contained in the array interface will be ordered in any specific way. It is not guaranteed that, for example, the first entry in the array will always be the WiFi interface.
Note The presence of the active key in the table can be used as a proxy for server.isconnected(), ie. the following two snippets are functionally equivalent:
if (server.isconnected()) { ... }
if ("active" in imp.net.info()) { ... }
The top-level ipv4 table, where present (it is not included in the impC001, for example), contains the following keys:
ipv4 Key | Type | Notes |
---|---|---|
address | String | The imp’s IP address, eg. "192.168.0.3" |
broadcast | String | The network router’s broadcast IP address eg. "192.168.0.255" |
dhcpserver | String | The DHCP server’s IP address. Absent if the imp has a static IP address |
dnsserver | Array | One or two DNS server addresses each in "www.xxx.yyy.zzz" form |
gateway | String | The network’s gateway IP address eg. "192.168.0.1" |
netmask | String | The network’s mask eg. "255.255.255.0" |
proxy | Table | A proxy server’s details (see below). Absent if a proxy has never been set with imp.setproxy() |
server | Table | The imp server’s connection details (see below) |
Note The address field in this ipv4 table is optional in as much as it will not be included in the table if the determined IP address is 0.0.0.0
. You should always test for the presence of the key address in the ipv4 table (if ("address" in imp.net.info().ipv4) {...}
) or embed your address lookup code in a try...catch
structure.
The ipv4 table’s proxy key’s value is a table with the following keys:
proxy Key | Type | Notes |
---|---|---|
type | Integer | The proxy type (see imp.setproxy()) |
address | String | The proxy’s IP address, eg. "192.168.0.2" |
port | Integer | The proxy’s port, eg. 80 |
user | String | The proxy username, when configured |
The ipv4 table’s server key’s value is a table with the following keys:
server Key | Type | Notes |
---|---|---|
port | Integer | The server’s port, eg. 31314 |
errorpolicy | Integer | SUSPEND_ON_ERROR (0), RETURN_ON_ERROR (1) or RETURN_ON_ERROR_NO_DISCONNECT (2) |
tcpsendfree | Integer | Current free space in the TCP send buffer |
tcpsendwindow | Integer | TCP window size in bytes |
tcptimeout | Float | Timeout in seconds |
tcpwaitfor | Integer | WAIT_TIL_SENT (0) or WAIT_FOR_ACK (1) |
The top-level interface array (above) contains type-specific tables. For WiFi interfaces:
interface Key | Type | Notes |
---|---|---|
type | String | "wifi" |
macaddress | String | The imp’s WiFi MAC address |
bands | String | The imp’s supported WiFi bands, ie. "2.4G" , "5G" or "2.4G,5G" . For multi-band imps, this is not the band actually in use |
country | String | The regulatory region code (see imp.getcountry()) |
powersave | Bool | Whether Powersave mode is active (see imp.getpowersave()) |
channel | Integer | The WiFi channel in use |
rssi | Integer | The signal strength at the time of the request. Only present when WiFi is up |
ssid | String | The network SSID recorded in the imp’s Flash (see imp.setwificonfiguration()) |
connectedssid | String | The SSID of the network to which the imp is actually connected. Only present when WiFi is up |
bssid | String | The router’s BSSID. Only present when WiFi is up |
encryption | String | The encryption type, eg. "WPA2-PSK (AES)" . Only present after first association. This parameter does not provide the network password |
powered | Boolean | Is the interface currently powered? |
connectedtoimpserver | Boolean | Is the interface currently being used to maintain the imp’s connection to the impCloud? |
name | String | The specific network interface, eg. "wl0" |
For Ethernet interfaces (Ethernet-supporting imps only):
interface Key | Type | Notes |
---|---|---|
type | String | "ethernet" |
macaddress | String | The imp’s Ethernet MAC address |
link | String | "10M" or "100M" . Only present when link detected |
duplex | String | "half" or "full" . Only present when link detected |
powered | Boolean | Is the interface currently powered? |
connectedtoimpserver | Boolean | Is the interface currently being used to maintain the imp’s connection to the impCloud? |
name | String | The specific network interface, eg. "eth0" |
For cellular interfaces (cellular-supporting imps only):
Key | Type | Notes |
---|---|---|
type | String | "cell" |
manufacturer | String | The modem manufacturer, eg. "Cinterion" |
model | String | The modem model number, eg. "ELS61-E" |
imei | String | The imp’s International Mobile Equipment Identity number |
imsi | String | The imp’s International Mobile Subscriber Identity number |
iccid | String | The Integrated Circuit Card Identifier: the unique serial number of the imp’s SIM |
swver | String | Modem software revision, eg. "REVISION 01.000" |
powered | Boolean | Is the interface currently powered? |
connectedtoimpserver | Boolean | Is the interface currently being used to maintain the imp’s connection to the impCloud? |
name | String | The specific network interface, eg. "cell0" |
Extra cellular connection state information is made available by the imp API method imp.net.getcellinfo().
IMPORTANT Prior to impOS 40, also contains the following state-specific keys:
impOS 42 adds a number of keys to each interface table for the various connectivity modes: WiFi, Ethernet and cellular.
Removes the following keys from the cellular-specific interface table:
Connection state information is instead made available by other means, specifically the imp API method imp.net.getcellinfo(), which asynchronously returns the cellinfo string and data that can be used to determine RSSI.
The following example shows a simple use of net.info(): to log what network interfaces an imp has available and which one, if any, it is connected to.