DeviceClient

public final class DeviceClient

Fields

NONE

public static final DeviceClient NONE

Constructors

DeviceClient

public DeviceClient(DiscoveredDevice discoveredDevice, RpcClient rpcClient, DeviceClient.StateListener listener)

DeviceClient

public DeviceClient(Device device, RpcClient rpcClient, DeviceClient.StateListener listener)

Methods

acceptData

public void acceptData()

Sends the user feedback that the data received has been accepted.

Beeps, flashes and/or rumbles the device to indicate success.

close

public void close()

disableDataSource

public void disableDataSource(int dataSourceId, PropertyCallback callback)
Parameters:
  • dataSourceId – data source to enable as defined in DataSource.ID_*
  • callback – receives an error if disabling the data source failed

disableLocalAcknowledgment

public void disableLocalAcknowledgment(PropertyCallback callback)

dispatch

void dispatch(Event event)

enableDataSource

public void enableDataSource(int dataSourceId, PropertyCallback callback)
Parameters:
  • dataSourceId – data source to enable as defined in DataSource.ID_*
  • callback – receives an error if enabling the data source failed

enableLocalAcknowledgment

public void enableLocalAcknowledgment(PropertyCallback callback)

getBatteryLevel

public void getBatteryLevel(PropertyCallback callback)

Queries the battery level of the device

Result is an integer where the four bytes represent

  • Byte 0 - reserved/empty
  • Byte 1 - current level
  • Byte 2 - minimum
  • Byte 3 - maximum

To calculate the level as a percentage

// Java
int value = property.getInt();
int current = value >>> 8 & 0xFF
int min = value >>> 16 & 0xFF
int max = value >>> 24 & 0xFF
Double batteryPercent = current * 100.0 / (max - min)

// Kotlin
val current = property.int ushr 8 and 0xff
val min = property.int ushr 16 and 0xff
val max = property.int ushr 24 and 0xff
val percentage = current * 100.0 / (max - min)
Parameters:
  • callback – Receives the result of the query

getDataSourceStatus

public void getDataSourceStatus(int dataSourceId, PropertyCallback callback)
Parameters:
  • dataSourceId – data source id as defined in DataSource.ID_*
  • callback – receives a property with status of the data source

getDeviceGuid

public String getDeviceGuid()

getDeviceName

public String getDeviceName()

getDeviceType

public int getDeviceType()

getDiscoveredDevice

public DiscoveredDevice getDiscoveredDevice()

getFirmwareVersion

public void getFirmwareVersion(PropertyCallback callback)

getHandle

int getHandle()

getPowerState

public void getPowerState(PropertyCallback callback)

Queries the power state of the device

Result is the power state as one of the following distinct values

  • Unknown (0x00) - The device most likely does not support this feature
  • Battery (0x01) - Discharging, on battery power
  • Cradle (0x02) - Charging (if battery is present), power supplied through pogo pins
  • AC (0x04) - Charging (if battery is present), power supplied through barrel connector or USB
Parameters:
  • callback – Receives the result of the query

getProperty

public void getProperty(Property property, PropertyCallback callback)

gone

void gone()

open

public void open()

rejectData

public void rejectData()

Sends the user feedback that the data received has been rejected

Beeps, flashes and/or rumbles the device to indicate failure.

sendSpecificCommand

public void sendSpecificCommand(byte[] command, PropertyCallback callback)

setHandle

void setHandle(int handle)

setProperty

public void setProperty(Property property, PropertyCallback callback)

subscribe

public void subscribe(EventListener listener)

trigger

public void trigger(PropertyCallback callback)

Starts a scan

triggerFeedback

public void triggerFeedback(int flags)

Send the user feedback

Do not mix positive and negative feedback flags.

Parameters:
  • flags – Some combination of Confirmation.ACTION_BEEP_*, Confirmation.ACTION_FLASH_*, and Confirmation.ACTION_RUMBLE_*.

updateDeviceDiscovered

void updateDeviceDiscovered()

updateDeviceManagerArrival

void updateDeviceManagerArrival()

updateOwnership

void updateOwnership(String guid)