Skip to main content

Squirrel Debugging API in Electric Imp Application Code

APIs that enhances debugging when integrated into your code

To effectively identify and resolve performance or connectivity issues in your Electric Imp applications, it's essential to leverage specific Squirrel APIs designed for debugging. Proper integration of these APIs into your application code enables precise root cause analysis, facilitating timely and efficient troubleshooting. The table below outlines the Squirrel APIs available for debugging purposes:

Type API Description Usage
Hardware details imp.getbootromversion() Returns the current version of the imp’s BootROM Helps verify if the boot version is outdated and identify any issues arising from using an older version
Hardware details imp.getsoftwareversion() Returns the imp or agent’s firmware version as a string This helps determine if the devices are running the latest software version
Hardware details imp.getmemoryfree() Returns the amount of currently unused memory in the imp Helps to detect out-of-memory issues
Hardware details hardware.getdeviceid() Returns the device id Helps distinguish logs from the device when multiple devices are involved.
Hardware details hardware.voltage() Returns the imp’s power supply voltage Helps diagnose issues such as brownouts and device restarts caused by power instability, especially in battery-operated systems
Hardware details hardware.vbat() Returns the true battery voltage of devices based on certain imps Developers can use hardware.vbat() to monitor the cell voltage, the better to track battery life
Wake reason hardware.wakereason() Returns a constant indicating the reason why the imp was woken Helps to identify the wakeup cause, such as a firmware update, timer, software reset, or wakeup pin.
cm state cm.isConnected() Helps to know imp is connected or not when using connection manager
cm state cm.onDisconnect() Helps to track ConnectionManager’s connection state changes from online to offline
cm state cm.onConnect() Can be used to notify when a connection is established
Error policy imp.net.info() net.info() has a table to know error policy
Wifi imp.getcountry() Wifi country code
Wifi imp.getpowersave() Gives imp’s current WiFi power-save setting
Wifi imp.net.counters() Retrieves a snapshot of WiFi counters. Currently, the table includes just one key, wwd_wifi Helps to know advanced wireless connection information
Wifi imp.net.info() Returns comprehensive imp network details. Using the interface table of wifi, we can get information like macaddress, bands, country, powersave, channel, rssi, ssid, connectedssid, bssid, encryption, powered Helps in troubleshooting issues related to low RSSI values and identifying the DNS servers in use.
Cell imp.net.info() Using the interface table of cellular, we can get information like manufacture, model, imei, imsi, iccid, swver, powered, connectedtoimpserver, name
Cell imp.net.getcellinfo() Retrieve cellular connection state information Aids in cellular troubleshooting by providing information such as MCC, MNC, and signal strength.
Ethernet imp.net.info() Using the interface table of ethernet, we can get informations like macaddress,link, duplex, powered, connectedtoimpserver, name
Other debugging API imp.onunhandledexception() This method registers a global error handling function that is able to trap any Squirrel exception which takes place outside of Squirrel’s own try… catch structure
Network related BlinkupLed_error_codes This helps identify connectivity issues with cellular, Wi-Fi, or Ethernet by analyzing the LED blinking pattern
Network related server.connect() A timeout policy can be set to RETURN_ON_ERROR or RETURN_ON_ERROR_NO_DISCONNECT. The function provided in the callback parameter of server.connect will execute upon connection completion or in case of an error. The constant passed to this function can be evaluated to determine the reason for the connection failure, such as NO_WIFI, NO_LINK, etc
Network related server.onunexpecteddisconnect() This method nominates a function to be called if the device is unexpectedly disconnected from the server, but only if the imp has been set to a timeout policy of RETURN_ON_ERROR.