Skip to main content

imp.getethernetspeed()

Returns the rated link speed of an imp005’s Ethernet PHY

Availability

Device (from impOS™ 33)
DEPRECATED METHOD — DO NOT USE IN NEW CODE

Returns

The current Ethernet rated link speed as an integer (10 or 100), otherwise zero

Description

This method is now deprecated. However, removing it altogether would cause users’ existing code to stop working, so we currently have no plans to do so. The recommended means of gaining the information this method returns is to call imp.net.info().

This method tells you at which speed an imp005 module’s Ethernet connection is currently rated. It returns an integer of value 10 or 100, representing 10Mbps and 100Mbps, respectively. If the method returns 0, either the imp005‘s Ethernet port is disconnected or the network to which it is connected is inactive.

If the method is called on any imp module other than an imp005, it will trigger an ‘index not found’ runtime error. imp.getethernetspeed() is also unavailable on imp005-based devices which lack an Ethernet PHY.

Ethernet Hot-plug Polling

imp.getethernetspeed() may be called at any time and will return a value even if the imp005 is communicating with the server via WiFi. As such it can be used to poll the imp005 to determine whether an Ethernet cable has been hot plugged, and it provides a more efficient way to determine whether this is the case than calling imp.net.info() and parsing the nested tables of information returned by that method.

If the imp is already connected using Ethernet, polling is unnecessary and so the device code should, for example, check imp.net.info() at start-up to determine whether it is connected by Ethernet or WiFi, and only if it is using the latter does it need to poll for the ad hoc connection of an Ethernet cable.

Note This method has been removed from versions of impOS running on the impC001.