Skip to main content

Returns comprehensive imp network details


Device (from impOS™ 34)


Table containing the network configuration information (see below)


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 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 { ... }

The top-level ipv4 table, where present (it is not included in the impC001, for example), contains the following keys:

ipv4 Key Type Notes
dhcpserver String The DHCP server’s IP address. Absent if the imp has a static IP address
address String The imp’s IP address, eg. ""
netmask String The network’s mask eg. ""
broadcast String The network router’s broadcast IP address eg. ""
gateway String The network’s gateway IP address eg. ""
dnsserver Array One or two DNS server addresses each in "" form
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)

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. ""
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) or RETURN_ON_ERROR (1)
tcpwaitfor Integer WAIT_TIL_SENT (0) or WAIT_FOR_ACK (1)
tcptimeout Float Timeout in seconds
tcpsendwindow Integer TCP window size in bytes

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 (from impOS™ 36)
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

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

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
swver String Modem software revision, eg. "REVISION 01.000"

IMPORTANT Prior to impOS 40, the cellular-specific interface table also contains the following state-specific keys:

Key Type imp State When Data Available Notes
voltage Integer Connecting, Connected Modem voltage in mV, eg. 3807
rssi Integer Connected The signal strength, eg. -78
cellinfo String Connected Cellular connection information, eg. "4G,6300,20,10,10,FDD,262,02,BF75,0345103,350,90,-94,-7,CONN"

From impOS 40, these three keys are no longer included in the table and attempts to read them will cause an exception to be thrown. The connection state information is instead made available by other means, specifically the new imp API method, which asynchronously returns the cellinfo string and data that can be used to determine RSSI.

Known Issue

Under impOS 36, the Ethernet interface is not present in output when the Ethernet is not powered up. Ethernet is not powered up when the imp005 is disconnected.

Expected Fix This issue is scheduled to be addressed in a future impOS release.

Example Code

The following example shows a simple use of to log what network interfaces an imp has available and which one, if any, it is connected to.