Skip to main content

imp.reset()

Reset and reboot the imp

Availability

Device

Returns

Nothing — does not return

Description

This method triggers an immediate software reset: the imp performs a true warm boot, the equivalent of a power-cycle without physically power-cycling the device. Calling this method shuts down Squirrel and places the imp in an equivalent of the ‘Cold Start’ state described in the Network State Diagram. From here, it performs the full start-up process, including connecting to the network and then to the impCloud™, receiving updated impOS™ and/or Squirrel code if either is available, and reporting the value WAKEREASON_SW_RESET via hardware.wakereason() and, for a development device, the unique Exit Code of 16 in the impCentral™ log pane.

imp.reset() may be used as an alternative to server.restart(), which simply restarts the Squirrel virtual machine in order to load any fresh Squirrel or impOS update as quickly as possible.

imp.reset() can also be used in situations for which it is not possible to use server.sleepfor(0), a common means of triggering a ‘Warm Start’ (as per the Network State Diagram) — for example, in devices with no crystal. Warm Start starts Squirrel with the imp in a disconnected state until your code attempts to access the server (SUSPEND_ON_ERROR) or calls server.connect() (RETURN_ON_ERROR).

You should guard against including imp.reset() early in your code or anywhere it is possible that the call might put the imp into an endless reset loop which will prevent it from connecting to the server and downloading Squirrel updates.