Skip to main content

device

Availability

Agent

Description

The device object provides the agent with a representation of its device: the imp-based hardware operating in the field. It is used to is used to pass communication from the agent to the device, and to check the imp’s connection status. As such, device is not available on the device itself — it uses the equivalent object agent.

The device object is instantiated and initialized automatically.

Member Entities

The device object has the following member methods:

  • device.info()Obtain network and connection information about an agent’s paired device
  • device.isconnected()Indicates whether the device is currently connected to the server or not
  • device.on()Registers a function to process messages sent from the device to the agent
  • device.onconnect()Registers a function that will be called when the device connects to the agent
  • device.ondisconnect()Registers a function that will be called when the device disconnects from the agent
  • device.send()Posts a message from the agent to the device