Skip to main content

server.expectonlinein(sleepTime)

Informs the server that the device will be disconnecting and that it will reconnect after a specified time

Availability

Device
DEPRECATED METHOD — DO NOT USE IN NEW CODE

Parameters

Name Type Description
sleepTime Integer The deep sleep duration in seconds (0—2,419,198)

Returns

Integer — 0 on success, or a Send Error Code on failure

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. Please use server.sleepfor() or server.sleepuntil() instead.

This method informs the server that the imp will now disconnect but will re-connect in a specified number of seconds. Without this information, the server may end up assuming that the imp is offline when in fact the imp is just asleep.

The maximum sleep time is 2,419,198 seconds (28 days minus two seconds).

This method should be called when using the method imp.deepsleepfor(). The server.sleepfor() call combines the effects of server.expectonlinein() and imp.deepsleepfor(), but there are circumstances when the two calls should not be combined and instead run separately: for example, in order to perform operations before the imp is put into deep sleep.

Because this is only useful for imps that are about to disconnect from the server, server.expectonlinein() includes an implicit server.disconnect() after informing the server of the impending sleep.