Skip to main content

device.isconnected()

Indicates whether the device is currently connected to the server or not

Availability

Agent

Returns

Bool — true if the device is connected or false if it is not

Description

This method can be used in agent code to determine whether the imp-enabled device is currently connected. This is typically done before attempting to send messages and data to the device — if the device is not connected, those messages will be lost.

Example Code

This simple code uses device.isconnected() to change the value of the variable connectedString if the imp is online, or to leave the string with its default value if the device has gone offline.