KallistoSensor¶
-
public abstract class
KallistoSensor
extends Sensor¶ Class representing an sensor contained in a Kallisto device.
This is an extension to the
android.hardware.Sensor
from the Android OS.Since we allow multiple instances of each sensor type in a
Kallisto
device, an identifier was added to ensure correct usage of each device. Get the identifier usingSensor.getIdentifier()
.A developer can add his own sensors by implementing this class and providing his sensor with a
de.sensry.kallisto.hardware.hal.sensors.SensorProvider
interface.
Fields¶
KEY_DELAY¶
TYPE_ANALOG_FRONTEND¶
-
public static final int
TYPE_ANALOG_FRONTEND
¶ A constant describing a Analog Front-End sensor.
See
de.sensry.kallisto.hardware.listeners.events.SensorEvent.values
for more details.
TYPE_BUTTON¶
-
public static final int
TYPE_BUTTON
¶ A constant describing a Button sensor.
See
de.sensry.kallisto.hardware.listeners.events.SensorEvent.values
for more details.
TYPE_CO2¶
-
public static final int
TYPE_CO2
¶ A constant describing a CO2 sensor.
See
de.sensry.kallisto.hardware.listeners.events.SensorEvent.values
for more details.
TYPE_FALL_DETECTOR¶
-
public static final int
TYPE_FALL_DETECTOR
¶ A constant describing a Fall Detector sensor.
See
de.sensry.kallisto.hardware.listeners.events.SensorEvent.values
for more details.
TYPE_FUEL_GAUGE¶
-
public static final int
TYPE_FUEL_GAUGE
¶ A constant describing a Fuel Gauge sensor. Reports Battery values.
Note that this type of sensors can’t be subscribed using
KallistoSensorManager.registerListener(SensorEventListener,KallistoSensor,int)
, theKallistoManager.registerBatteryListener(BatteryEventListener,Kallisto)
must be used.
TYPE_TVOC¶
-
public static final int
TYPE_TVOC
¶ A constant describing a Total Volatile Organic Compound sensor.
See
de.sensry.kallisto.hardware.listeners.events.SensorEvent.values
for more details.
Constructors¶
KallistoSensor¶
-
protected
KallistoSensor
(String name, String vendor, int version, int type, String stringType, int identifier, float maxRange, float resolution, float power, int minDelay, int maxDelay, String hardwareAddress)¶ KallistoSensor constructor.
- Parameters
name – This sensor name.
vendor – This sensor vendor.
version – This sensor version.
type – This sensor type.
stringType – A string describing the sensor type.
identifier – An identifier for this sensor instance. Can be used to uniquely identify a sensor in a case where more than one instance of the same sensor 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.maxRange – Maximum range of the sensor in the sensor units.
resolution – Minimum value difference that can be read by the sensor in the sensor units.
power – Standard power consumption. Should report how much power the sensor consumes, in mA, if it is enabled in a standard use-case.
minDelay – Minimum delay between samples, in microseconds.
maxDelay – Maximum delay between samples, in microseconds.
hardwareAddress – The MAC address of the
Kallisto
device that contains this sensor.
Methods¶
close¶
deleteCalibration¶
-
protected abstract boolean
deleteCalibration
()¶ Called when the sensor should delete a sensor calibration.
- Throws
BleException – If something went wrong with the BLE communication.
- Returns
true
if everything went ok.
disable¶
-
protected abstract boolean
disable
()¶ Called when the sensor should be disabled and start reporting data.
- Throws
BleException – If something went wrong with the BLE communication.
- Returns
true
if everything went ok.
enable¶
-
protected abstract boolean
enable
(Map<String, Object> parameters)¶ Called when the sensor should be enabled and start reporting data.
The available parameters are:
KEY_DELAY
- the object should be parsed as an integer where the sensor delay is passed in microseconds;
- 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.
getAddress¶
getCharacteristics¶
getIdentifyingHash¶
-
public final long
getIdentifyingHash
()¶ Retrieve a 64-bit hash that identifies the sensor according to its hardware address, sensor type and identifier.
- Returns
The identifying hash
isCalibrating¶
-
public final boolean
isCalibrating
()¶ Checks if sensor is calibrating.
- Returns
true
if this sensor is calibrating.
isEnabled¶
-
public final boolean
isEnabled
()¶ Checks if this sensor is enabled.
- Returns
true
if this sensor is enabled.
onLinkLoss¶
-
protected abstract void
onLinkLoss
()¶ Called when the
Kallisto
device that contains this sensor enters in Link Loss mode.The sensor should save the current state.
If there is an on-going calibration, it should send a
de.sensry.kallisto.hardware.listeners.events.CalibrationEventType.CALIBRATION_FAILED
event.
onLinkRecovered¶
-
protected abstract void
onLinkRecovered
()¶ Called when the
Kallisto
device that contains this sensor recovers from Link Loss mode.The sensor should restore the state saved in
onLinkLoss()
. For example, if it was enabled, it should start reporting data at the rate previously configured.
startCalibration¶
-
protected abstract boolean
startCalibration
(Map<String, Object> parameters)¶ Called when the sensor should start a calibration procedure.
The sensor should send
calibration events
to report the calibration result.- Parameters
parameters – Map of abstract parameters. Right now, no parameter is supported.
- Throws
BleException – If something went wrong with the BLE communication.
- Returns
true
if everything went ok.
stopCalibration¶
-
protected abstract boolean
stopCalibration
()¶ Called when the sensor should stop a on-going calibration procedure.
The sensor should send a
de.sensry.kallisto.hardware.listeners.events.CalibrationEventType.CALIBRATION_STOPPED
when it is stopped successfully or an error type otherwise.- Throws
BleException – If something went wrong with the BLE communication.
- Returns
true
if everything went ok.
supportsCalibration¶
-
public abstract boolean
supportsCalibration
()¶ Get if this sensor supports calibration.
- Returns
true
if calibration is supported.
supportsSynchronization¶
-
protected abstract boolean
supportsSynchronization
()¶ Called to check if the sensor supports time synchronization.
We will try to match the timestamp 0 with the phone time but, in some cases, this doesn’t make sense. This should report
false
in these cases.- Returns
true
If the events of this sensor should be synchronized.
update¶
-
protected abstract boolean
update
(Map<String, Object> parameters)¶ Called when when the sensor is already enabled and should update its’ configurations.
This call is used to request the sensor to update its’ rate, for example.
The available parameters are:
KEY_DELAY
- the object should be parsed as an integer where the sensor delay is passed in microseconds;
- 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.