public class ESenseManager
extends java.lang.Object
connect(int)
, disconnect from eSense with disconnect()
, register an event listener with registerEventListener(ESenseEventListener)
, etc.
See also ESenseScanner
, ESenseConnectionListener
, ESenseEventListener
Constructor and Description |
---|
ESenseManager(java.lang.String deviceName,
android.content.Context context)
Constructs an eSense manager for a given device
|
ESenseManager(java.lang.String deviceName,
android.content.Context context,
ESenseConnectionListener listener)
Constructs an eSense manager for a given device with the connection listener
|
Modifier and Type | Method and Description |
---|---|
boolean |
connect(int timeout)
Initiates a connection procedure.
|
boolean |
disconnect()
Disconnects device.
|
boolean |
getAccelerometerOffset()
Requests a read of the factory accelerometer offset values on the connected device.
|
boolean |
getAdvertisementAndConnectionInterval()
Requests a read of the parameter values of advertisement and connection interval on the connected device
The event
ESenseEventListener.onAdvertisementAndConnectionIntervalRead(int, int, int, int) is fired when the parameter values have been read from the connected device. |
boolean |
getBatteryVoltage()
Requests a read of the battery voltage of the connected device.
|
boolean |
getDeviceName()
Requests a read of the device name.
|
boolean |
getSensorConfig()
Requests a read of the sensor configuration on the connected device.
|
boolean |
isConnected()
Checks if the device is connected or not
|
boolean |
registerEventListener(ESenseEventListener listener)
Registers an event listener and enables notifications on button events.
|
io.esense.esenselib.SamplingStatus |
registerSensorListener(ESenseSensorListener listener,
int samplingRate)
Registers a sensor listener and starts sensor sampling on the connected device.
|
boolean |
setAdvertisementAndConnectiontInterval(int advMinInterval,
int advMaxInterval,
int connMinInterval,
int connMaxInterval)
Requests a change of the advertisement and connection intervals.
|
boolean |
setDeviceName(java.lang.String deviceName)
Requests a change of the device name.
|
boolean |
setSensorConfig(ESenseConfig config)
Requests a change of the sensor configuration on the connected device.
|
void |
unregisterEventListener()
Unregisters a sensor listener and stops notifications on button events
|
void |
unregisterSensorListener()
Unregisters a sensor listener and stops sensor sampling on the connected device
|
public ESenseManager(java.lang.String deviceName, android.content.Context context)
deviceName
- name of the eSense device to look for during a scancontext
- application environment to access Bluetooth/BLE interfacepublic ESenseManager(java.lang.String deviceName, android.content.Context context, ESenseConnectionListener listener)
deviceName
- name of the eSense device to look for during a scancontext
- application environment to access Bluetooth interfacelistener
- connection listenerpublic boolean getDeviceName()
ESenseEventListener.onDeviceNameRead(String)
is fired when the name has been read from the connected device.true
if the request was successfully made,
false
otherwisepublic boolean setDeviceName(java.lang.String deviceName)
deviceName
- new name for the device (maximum size is 22 characters)true
if the request was successfully made,
false
otherwisepublic boolean getAccelerometerOffset()
ESenseEventListener.onAccelerometerOffsetRead(int, int, int)
is fired when the values have been read from the connected device.true
if the request was successfully made,
false
otherwisepublic boolean getSensorConfig()
ESenseEventListener.onSensorConfigRead(ESenseConfig)
is fired when the configuration has been read from the connected device.true
if the request was successfully made,
false
otherwisepublic boolean setSensorConfig(ESenseConfig config)
config
- new configuration to be written on the devicetrue
if the request was successfully made,
false
otherwisepublic boolean getAdvertisementAndConnectionInterval()
ESenseEventListener.onAdvertisementAndConnectionIntervalRead(int, int, int, int)
is fired when the parameter values have been read from the connected device.true
if the request was successfully made,
false
otherwisepublic boolean setAdvertisementAndConnectiontInterval(int advMinInterval, int advMaxInterval, int connMinInterval, int connMaxInterval)
Condition for advertisement interval: 1) the minimum interval should be greater than or equal to 100, 2) the maximum interval should be less than or equal to 2000, 3) the maximum interval should be greater than or equal to the minimum interval.
Condition for connection interval: 1) the minimum interval should be greater than or equal to 20. 2) the maximum interval should be less than or equal to 2000, 3) the difference between the maximum and minimum intervals should be greater than or equal to 20.
advMinInterval
- minimum advertisement interval (unit: milliseconds)advMaxInterval
- maximum advertisement interval (unit: milliseconds)connMinInterval
- minimum connection interval (unit: milliseconds)connMaxInterval
- maximum connection interval (unit: mlliseconds)true
if the request was successfully made,
false
otherwisepublic boolean getBatteryVoltage()
ESenseEventListener.onBatteryRead(double)
is fired when the voltage has been read.true
if the request was successfully made,
false
otherwisepublic io.esense.esenselib.SamplingStatus registerSensorListener(ESenseSensorListener listener, int samplingRate)
ESenseSensorListener.onSensorChanged(ESenseEvent)
is fired every time a new sample is available from the connected device.listener
- sensor listenersamplingRate
- sensor sampling rate in Hz (min: 1 - max: 100)SamplingStatus.STARTED
if the sampling was started successfully,
SamplingStatus.ERROR
if the parameter is incorrect,
SamplingStatus.DEVICE_DISCONNECTED
if the device is disconnectedpublic void unregisterSensorListener()
public boolean registerEventListener(ESenseEventListener listener)
listener
- event listenertrue
if the listener was registered correctly
false
otherwisepublic void unregisterEventListener()
public boolean isConnected()
true
if device is connected
false
otherwisepublic boolean disconnect()
ESenseConnectionListener.onDisconnected(ESenseManager manager)
is fired after the disconnection has taken place.true
if the disconnection was successfully made
false
otherwisepublic boolean connect(int timeout)
ESenseConnectionListener.onDeviceFound(ESenseManager manager)
, ESenseConnectionListener.onDeviceNotFound(ESenseManager manager)
or ESenseConnectionListener.onConnected(ESenseManager manager)
are fired at different stages of the procedure.timeout
- scan timeout in milli secondstrue
if the procedure started successfully
false
otherwise