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
get
Kallisto devices,create bonds
,register
forsystem events
,register
forbattery events
andto update
the device firmware.
Fields¶
ACTUATOR_SERVICE_CONNECTED¶
-
public static final String
ACTUATOR_SERVICE_CONNECTED
¶ A broadcast action used to signalize when the
Actuator Manager
connects 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 Manager
connects 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.KallistoService
orpt.fraunhofer.kallisto.service.KallistoDfuService
not 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
Kallisto
device.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
Kallisto
device to create a bond with.
- Returns
true
if 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
Kallisto
device.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
Kallisto
device to set the stay connected flag.
- Returns
true
if everything went ok.
enableServiceNotification¶
getKallisto¶
getKallisto¶
-
public Kallisto
getKallisto
(KallistoSensor sensor)¶ Get the
Kallisto
device that contains the passedKallistoSensor
.- Parameters
sensor – The
KallistoSensor
contained by the desiredKallisto
device.
- Returns
The desired
Kallisto
device ornull
if not found.
getKallistoList¶
getRegisteredKallistos¶
-
public List<Kallisto>
getRegisteredKallistos
(BatteryEventListener listener)¶ Returns a list of
Kallisto
devices whose the passedlistener
is registered to.- Parameters
listener – The
listener
used inKallistoManager.registerBatteryListener(BatteryEventListener,Kallisto)
call.
- Returns
A list of
Kallisto
devices the passedlistener
is 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
true
if service is bound
reboot¶
-
public boolean
reboot
(Kallisto Kallisto)¶ Reboots the passed
Kallisto
device.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_LOSS
system event.Blocking function.
- Parameters
Kallisto – The
Kallisto
device to reboot.
- Returns
true
if device rebooted.
refreshCache¶
-
public void
refreshCache
()¶ Updates the
Kallisto
device list.This will clear the remote service device list and start a
de.sensry.kallisto.bluetooth.scanner.ScannerConfiguration.ScanConfiguration.ONE_SHOT
,ScannerConfiguration.MEDIUM_SCAN
in order to get a fresh device list.Triggers a
SystemEventType.CACHE_CLEARED
system event.
registerBatteryListener¶
-
public boolean
registerBatteryListener
(BatteryEventListener listener, Kallisto Kallisto)¶ Register a new
listener
for the passedKallisto
device.Blocking function.
- Parameters
listener – The
listener
to receivebattery events
.Kallisto – The
Kallisto
device from which the battery will be monitored.
- Returns
true
if the battery monitoring was started successfully.
registerSystemListener¶
-
public boolean
registerSystemListener
(SystemEventListener listener, int eventLevel)¶ Registers a
SystemEventListener
forsystem events
of the passed levels. The available levels areSystemEventType.TYPE_ERROR
andSystemEventType.TYPE_INFO
.A listener registered for
SystemEventType.TYPE_INFO
events will receiveSystemEventType.TYPE_ERROR
events too.- Parameters
listener – A
SystemEventListener
to receivesystem events
.eventLevel – The desired event level.
SystemEventType.TYPE_INFO
andSystemEventType.TYPE_ERROR
are available.
- Returns
true
if everything went ok.
removeBond¶
-
public boolean
removeBond
(Kallisto Kallisto)¶ Removes the bond with the passed
Kallisto
device.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_LOSS
system event.Requires Android API > 19.
- Parameters
Kallisto – The
Kallisto
device to remove the bond.
- Returns
true
if everything went ok.
shipMode¶
-
public boolean
shipMode
(Kallisto Kallisto)¶ Puts the passed
Kallisto
device 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
Kallisto
device to enter ship mode.
- Returns
true
if device entered ship mode.
startDfu¶
-
public boolean
startDfu
(String filePath, DfuEventListener listener, Kallisto Kallisto)¶ Starts the Device Firmware Update (DFU) procedure for the passed
Kallisto
device.Refer to the firmware documentation for instructions how to build a compatible update package.
Only one
Kallisto
device 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
listener
to receiveDFU events
.Kallisto – The
Kallisto
device to be updated.
- Returns
true
if 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
Kallisto
device.Refer to the firmware documentation for instructions how to build a compatible update package.
Only one
Kallisto
device 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
listener
to receiveDFU events
.Kallisto – The
Kallisto
device to be updated.
- Returns
true
if the update process started successfully.
stayConnected¶
-
public boolean
stayConnected
(Kallisto Kallisto)¶ Sets the stay connected flag of the desired
Kallisto
device.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
Kallisto
device to set the stay connected flag.
- Returns
true
if everything went ok.
stopDfu¶
-
public boolean
stopDfu
(Kallisto Kallisto)¶ Stops the current Device Firmware Update (DFU) procedure of the passed
Kallisto
device.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
Kallisto
device to stop the DFU process.
- Returns
true
if the update process stopped successfully.
unregisterBatteryListener¶
-
public boolean
unregisterBatteryListener
(BatteryEventListener listener, Kallisto Kallisto)¶ Unregisters the
listener
for the passedKallisto
device.Blocking function if the device is no longer in use.
- Parameters
listener – The
listener
used inKallistoManager.registerBatteryListener(BatteryEventListener,Kallisto)
call.Kallisto – The
Kallisto
device used inKallistoManager.registerBatteryListener(BatteryEventListener,Kallisto)
call.
- Returns
true
if everything went ok.
unregisterBatteryListener¶
-
public boolean
unregisterBatteryListener
(BatteryEventListener listener)¶ Unregisters a
listener
for allKallisto
device.Blocking function if the device is no longer in use.
- Parameters
listener – The
listener
used inKallistoManager.registerBatteryListener(BatteryEventListener,Kallisto)
call.
- Returns
true
if everything went ok.
unregisterSystemListener¶
-
public void
unregisterSystemListener
(SystemEventListener listener)¶ Unregisters the
listener
.- Parameters
listener – The
listener
used 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_CHANGED
system event.- Parameters
configuration – The desired scanner configuration. If
null
is passed, the default configuration will be used.
updateScannerFilter¶
-
public void
updateScannerFilter
(ScannerFilter filter)¶ Sets the scanner filter.
The current
Kallisto
list will be filtered to reflect the new filter. For each device filtered according to the new filter, aSystemEventType.LINK_REMOVED
system event will be triggered.Triggers a
SystemEventType.SCAN_CHANGED
system event.- Parameters
filter – The desired scan filter. If
null
is passed, the default filter will be used.