KallistoManager¶
-
public abstract class
KallistoManager¶ KallistoManager provides the interactions related to the
Kallisto Devices. This class is used as base for the other managers.Allows the developer to
getKallisto devices,create bonds,registerforsystem events,registerforbattery eventsandto updatethe device firmware.
Fields¶
ACTUATOR_SERVICE_CONNECTED¶
-
public static final String
ACTUATOR_SERVICE_CONNECTED¶ A broadcast action used to signalize when the
Actuator Managerconnects to the remote service and is ready to receive requests.
SENSOR_SERVICE_CONNECTED¶
-
public static final String
SENSOR_SERVICE_CONNECTED¶ A broadcast action used to signalize when the
Sensor Managerconnects to the remote service and is ready to receive requests.
SERVICE_DISCONNECTED¶
-
public static final String
SERVICE_DISCONNECTED¶ A broadcast action used to signalize when the remote service exits. No new request are accepted and the ongoing request will fail.
This broadcast is sent when
disconnect()is called and the remote service finished cleaning resources or when the Android system decides to kill the service. Refer to the Android documentation for more information of the second case.
SERVICE_FAILED¶
-
public static final String
SERVICE_FAILED¶ A broadcast action used to signalize a failure in starting the remote service. This can happen for some reasons:
pt.fraunhofer.kallisto.service.KallistoServiceorpt.fraunhofer.kallisto.service.KallistoDfuServicenot declared in manifest;Bluetooth LE not available on the smartphone;
Service binding fails
Constructors¶
KallistoManager¶
-
protected
KallistoManager(Context context, BleDeviceManagerConfiguration bleConfiguration, LoggerConfiguration loggerConfiguration)¶ KallistoManager constructor.
- Parameters
context – A valid context.
bleConfiguration – The BLE configuration. Can be
null, the default will be used.loggerConfiguration – The logger configuration. Can be
null, the default will be used.
Methods¶
createBond¶
-
public boolean
createBond(Kallisto Kallisto)¶ Creates a bond with the passed
Kallistodevice.For now, only Just Works pairing is supported.
Once connected to a bonded device, the device will stay connected even if not in use.
Requires Android API > 19.
Blocking function.
- Parameters
Kallisto – The
Kallistodevice to create a bond with.
- Returns
trueif everything went ok.
disableServiceNotification¶
-
public boolean
disableServiceNotification()¶ Disables remote service persistent notification.
- Returns
true if all went ok
disconnect¶
-
public abstract void
disconnect()¶ Disconnects from the remote service. Will trigger all cleanup routines in the service.
Always call it when done with the service.
doNotStayConnected¶
-
public boolean
doNotStayConnected(Kallisto Kallisto)¶ Resets the stay connected flag of the desired
Kallistodevice.Disables the behaviour described in
stayConnected(Kallisto).Calling this function will trigger a disconnection, if the device is not being used.
Blocking function if the device is connected but not in use.
This is the default behaviour.
- Parameters
Kallisto – The
Kallistodevice to set the stay connected flag.
- Returns
trueif everything went ok.
enableServiceNotification¶
getKallisto¶
getKallisto¶
-
public Kallisto
getKallisto(KallistoSensor sensor)¶ Get the
Kallistodevice that contains the passedKallistoSensor.- Parameters
sensor – The
KallistoSensorcontained by the desiredKallistodevice.
- Returns
The desired
Kallistodevice ornullif not found.
getKallistoList¶
getRegisteredKallistos¶
-
public List<Kallisto>
getRegisteredKallistos(BatteryEventListener listener)¶ Returns a list of
Kallistodevices whose the passedlisteneris registered to.- Parameters
listener – The
listenerused inKallistoManager.registerBatteryListener(BatteryEventListener,Kallisto)call.
- Returns
A list of
Kallistodevices the passedlisteneris registered to.
getRssi¶
getScannerConfiguration¶
-
public ScannerConfiguration
getScannerConfiguration()¶ Gets the current scanner configuration.
- Returns
The scanner configuration.
getScannerFilter¶
-
public ScannerFilter
getScannerFilter()¶ Gets the current scanner filter.
- Returns
The scanner filter.
isBonded¶
isBound¶
-
public boolean
isBound()¶ Checks if the manager is bound to the remote service.
- Returns
trueif service is bound
reboot¶
-
public boolean
reboot(Kallisto Kallisto)¶ Reboots the passed
Kallistodevice.Not every type device supports rebooting, use
Kallisto.getModeChangeSupport()to check if is available.Rebooting will trigger a disconnection (if connected), even if the device is being used or the
stayConnected(Kallisto)flag is enabled triggering aSystemEventType.LINK_LOSSsystem event.Blocking function.
- Parameters
Kallisto – The
Kallistodevice to reboot.
- Returns
trueif device rebooted.
refreshCache¶
-
public void
refreshCache()¶ Updates the
Kallistodevice list.This will clear the remote service device list and start a
de.sensry.kallisto.bluetooth.scanner.ScannerConfiguration.ScanConfiguration.ONE_SHOT,ScannerConfiguration.MEDIUM_SCANin order to get a fresh device list.Triggers a
SystemEventType.CACHE_CLEAREDsystem event.
registerBatteryListener¶
-
public boolean
registerBatteryListener(BatteryEventListener listener, Kallisto Kallisto)¶ Register a new
listenerfor the passedKallistodevice.Blocking function.
- Parameters
listener – The
listenerto receivebattery events.Kallisto – The
Kallistodevice from which the battery will be monitored.
- Returns
trueif the battery monitoring was started successfully.
registerSystemListener¶
-
public boolean
registerSystemListener(SystemEventListener listener, int eventLevel)¶ Registers a
SystemEventListenerforsystem eventsof the passed levels. The available levels areSystemEventType.TYPE_ERRORandSystemEventType.TYPE_INFO.A listener registered for
SystemEventType.TYPE_INFOevents will receiveSystemEventType.TYPE_ERRORevents too.- Parameters
listener – A
SystemEventListenerto receivesystem events.eventLevel – The desired event level.
SystemEventType.TYPE_INFOandSystemEventType.TYPE_ERRORare available.
- Returns
trueif everything went ok.
removeBond¶
-
public boolean
removeBond(Kallisto Kallisto)¶ Removes the bond with the passed
Kallistodevice.Removing a bond will trigger a disconnection (if connected), even if the device is being used or the
stayConnected(Kallisto)flag is enabled triggering aSystemEventType.LINK_LOSSsystem event.Requires Android API > 19.
- Parameters
Kallisto – The
Kallistodevice to remove the bond.
- Returns
trueif everything went ok.
shipMode¶
-
public boolean
shipMode(Kallisto Kallisto)¶ Puts the passed
Kallistodevice in ship mode (see datasheet).Not every type device supports this mode, use
Kallisto.getModeChangeSupport()to check if is available.Putting the device in ship mode is only possible if the device is not being used.
Blocking function.
- Parameters
Kallisto – The
Kallistodevice to enter ship mode.
- Returns
trueif device entered ship mode.
startDfu¶
-
public boolean
startDfu(String filePath, DfuEventListener listener, Kallisto Kallisto)¶ Starts the Device Firmware Update (DFU) procedure for the passed
Kallistodevice.Refer to the firmware documentation for instructions how to build a compatible update package.
Only one
Kallistodevice can be under update process at any given time.Blocking function.
- Parameters
filePath – Absolute filepath of the update package to be flashed onto the device.
listener – The
listenerto receiveDFU events.Kallisto – The
Kallistodevice to be updated.
- Returns
trueif the update process started successfully.
startDfu¶
-
public boolean
startDfu(int resId, DfuEventListener listener, Kallisto Kallisto)¶ Starts the Device Firmware Update (DFU) procedure for the passed
Kallistodevice.Refer to the firmware documentation for instructions how to build a compatible update package.
Only one
Kallistodevice can be under update process at any given time.Blocking function.
- Parameters
resId – Resource id of the .zip to be flashed onto the device. The file should be in /res/raw.
listener – The
listenerto receiveDFU events.Kallisto – The
Kallistodevice to be updated.
- Returns
trueif the update process started successfully.
stayConnected¶
-
public boolean
stayConnected(Kallisto Kallisto)¶ Sets the stay connected flag of the desired
Kallistodevice.Since all connections are opportunistic and are killed when the device is not in use, this signals the remote service that the device should stay connected even when not in use.
Calling this function will trigger a connection, if not connected, and start device discovery.
Blocking function if the device is disconnected.
- Parameters
Kallisto – The
Kallistodevice to set the stay connected flag.
- Returns
trueif everything went ok.
stopDfu¶
-
public boolean
stopDfu(Kallisto Kallisto)¶ Stops the current Device Firmware Update (DFU) procedure of the passed
Kallistodevice.The device will rollback to the previous firmware or, if only contains bootloader, will stay in DFU mode waiting for a valid package.
- Parameters
Kallisto – The
Kallistodevice to stop the DFU process.
- Returns
trueif the update process stopped successfully.
unregisterBatteryListener¶
-
public boolean
unregisterBatteryListener(BatteryEventListener listener, Kallisto Kallisto)¶ Unregisters the
listenerfor the passedKallistodevice.Blocking function if the device is no longer in use.
- Parameters
listener – The
listenerused inKallistoManager.registerBatteryListener(BatteryEventListener,Kallisto)call.Kallisto – The
Kallistodevice used inKallistoManager.registerBatteryListener(BatteryEventListener,Kallisto)call.
- Returns
trueif everything went ok.
unregisterBatteryListener¶
-
public boolean
unregisterBatteryListener(BatteryEventListener listener)¶ Unregisters a
listenerfor allKallistodevice.Blocking function if the device is no longer in use.
- Parameters
listener – The
listenerused inKallistoManager.registerBatteryListener(BatteryEventListener,Kallisto)call.
- Returns
trueif everything went ok.
unregisterSystemListener¶
-
public void
unregisterSystemListener(SystemEventListener listener)¶ Unregisters the
listener.- Parameters
listener – The
listenerused inregisterSystemListener(SystemEventListener,int)call.
updateScannerConfiguration¶
-
public void
updateScannerConfiguration(ScannerConfiguration configuration)¶ Sets the scan parameters for the KallistoService Scanner thread.
Calling this function will stop any on-going scan in order to update it to the new desired configuration.
Triggers a
SystemEventType.SCAN_CHANGEDsystem event.- Parameters
configuration – The desired scanner configuration. If
nullis passed, the default configuration will be used.
updateScannerFilter¶
-
public void
updateScannerFilter(ScannerFilter filter)¶ Sets the scanner filter.
The current
Kallistolist will be filtered to reflect the new filter. For each device filtered according to the new filter, aSystemEventType.LINK_REMOVEDsystem event will be triggered.Triggers a
SystemEventType.SCAN_CHANGEDsystem event.- Parameters
filter – The desired scan filter. If
nullis passed, the default filter will be used.