Disconnects the imp from the server and turns the network interface off
Device
Nothing
This method disconnects the device from the server and turns off the imp’s current network interface, whether it is WiFi, Ethernet or cellular. The imp will try to reconnect based on its current reconnection policy:
If the SUSPEND_ON_ERROR policy is in effect, the imp will try to reconnect when any call is made that talks to the server, such as server.log().
If the RETURN_ON_ERROR policy is in effect, the imp will try to reconnect only when server.connect() is explicitly called by the device code.
The imp will always try to reconnect on a cold boot, irrespective of any policy set so far.
Important You must allow impOS an opportunity to perform any necessary housekeeping — listen for an impOS and/or Squirrel update, server redirect, or any application messages to the device — before disconnection takes place. The best — and strongly recommended — way to achieve this is to embed the call in a function that will executed when the imp next goes idle, which happens when there is no further Squirrel code in queue and impOS has performed all the tasks it needs to perform. Register this function using imp.onidle(). This is demonstrated in the example code, below.
Disconnecting an imp from its current network interface frees a small amount of memory — about 3KB; the TCP send buffer — which re-connecting then re-uses. If the code disconnects, uses up nearly all the of the imp’s free memory and attempts to connect again, then there is a risk of it restarting with an out-of-memory error.
This example demonstrates how you can disconnect an imp001 from WiFi and continue running code — in this case, blinking an LED spanning Pin 1 and GND. After two minutes, the imp will attempt to reconnect; when it does, the LED stops flashing.