KallistoActuator

public abstract class KallistoActuator

Class representing an actuator contained in a Kallisto device.

A developer can add his own actuators by implementing this class and providing his actuator with a de.sensry.kallisto.hardware.hal.actuators.ActuatorProvider interface.

Fields

KEY_LED_MODE

public static final String KEY_LED_MODE

Used to configure LED mode. The parameter should be a LedMode value.

KEY_LED_TIME_OFF

public static final String KEY_LED_TIME_OFF

Used to configure LED on time. Only used for LedMode.LED_BLINK and LedMode.LED_FADE.

KEY_LED_TIME_ON

public static final String KEY_LED_TIME_ON

Used to configure LED on time. Only used for LedMode.LED_BLINK and LedMode.LED_FADE.

TYPE_ALL

public static final int TYPE_ALL

A constant describing all actuator types.

TYPE_LED

public static final int TYPE_LED

A constant describing a LED actuator.

Constructors

KallistoActuator

protected KallistoActuator(String name, String vendor, int version, int type, String stringType, int identifier, float power, String hardwareAddress)

KallistoActuator constructor.

Parameters
  • name – This actuator name.

  • vendor – This actuator vendor.

  • version – This actuator version.

  • type – This actuator type.

  • stringType – A string describing the actuator type.

  • identifier – An identifier for this actuator instance. Can be used to uniquely identify a actuator in a case where more than one instance of the same actuator exists in a Kallisto device. For example, if the device has two accelerometers, one in position X and another in position Y, one should have the identifier 0 and the other 1.

  • power – Standard power consumption. Should report how much power the actuator consumes, in mA, if it is enabled in a standard use-case.

  • hardwareAddress – The MAC address of the Kallisto device that contains this actuator.

Methods

close

protected abstract void close()

Called when the actuator is no longer needed and the Kallisto device is being destroyed.

Should trigger cleanup routines.

No BLE operation can be performed here and should complete as fast as possible.

get

protected abstract Object get(Map<String, Object> parameters)

Called when the actuator should report its’ state.

Parameters
  • parameters – Map of abstract parameters. It is not by any actuator of API, for now.

Throws
  • BleException – If something went wrong with the BLE communication.

Returns

A generic object or null on error. How to parse it depends of the actuator.

getAddress

public String getAddress()

Returns the Kallisto device MAC address that contains this actuator.

Returns

The MAC address. Follows the same format of android.bluetooth.BluetoothDevice.getAddress().

getCharacteristics

protected abstract List<UUID> getCharacteristics()

Should return the UUIDs of the characteristics used by this actuator.

Will be used to protect the characteristics from un-intended writes.

Returns

A list of UUIDs of the characteristics this actuator uses.

getIdentifier

public int getIdentifier()
Returns

The identifier of this actuator instance.

getIdentifyingHash

public final long getIdentifyingHash()

Retrieve a 64-bit hash that identifies the actuator according to its hardware address, actuator type and identifier.

Returns

The identifying hash

getName

public String getName()
Returns

The name string of the actuator.

getPower

public float getPower()
Returns

The power in mA used by this actuator while in use

getStringType

public String getStringType()
Returns

The type of this actuator as a string.

getType

public int getType()
Returns

The generic type of this actuator.

getVendor

public String getVendor()
Returns

The vendor string of this actuator.

getVersion

public int getVersion()
Returns

The version of the actuator’s module.

onDisconnection

protected abstract void onDisconnection()

Called when the Kallisto device that contains this actuator disconnects cleanly.

The actuator state should be reset to the initial state, for example.

onLinkLoss

protected abstract void onLinkLoss()

Called when the Kallisto device that contains this actuator enters in Link Loss mode.

The actuator should save the current state.

onLinkRecovered

protected abstract void onLinkRecovered()

Called when the Kallisto device that contains this actuator recovers from Link Loss mode.

The actuator should restore the state saved in onLinkLoss(). For example, if it was enabled, it should set the previous state.

set

protected abstract boolean set(Map<String, Object> parameters)

Called when the actuator should change state.

The available parameters are:

  • KEY_LED_MODE - the object should be parsed as a LedMode;

  • KEY_LED_TIME_OFF - the object should be parsed as an integer where the time off delay is passed in milliseconds;

  • KEY_LED_TIME_ON - the object should be parsed as an integer where the time off delay is passed in milliseconds;

Parameters
  • parameters – Map of abstract parameters. The map follows a key/value structure where the key determines how the object should be parsed.

Throws
  • BleException – If something went wrong with the BLE communication.

Returns

true If everything went ok.

toString

public String toString()
Returns

A string representation of this actuator.