public class LegoBluetoothDeviceManagerImpl extends java.lang.Object implements LegoBluetoothDeviceManager
Constructor and Description |
---|
LegoBluetoothDeviceManagerImpl(AndroidBluetoothAdapterWrapper adapter) |
Modifier and Type | Method and Description |
---|---|
java.util.List<LegoBluetoothDevice> |
allDevices()
Returns a list with all known devices regardless of their current connect state.
|
void |
cancelDeviceConnection(LegoBluetoothDevice device)
Disconnect from a LEGO Bluetooth LE Device.
|
void |
connectToDevice(android.content.Context context,
LegoBluetoothDevice device)
Connect to a @class LegoBluetoothDevice.
|
java.util.List<LegoBluetoothDevice> |
devicesInState(LegoDevice.DeviceState connectionState)
Returns a list of devices in the specified device state.
|
long |
getAdvertisingDevicesInterval() |
long |
getConnectRequestTimeoutInterval() |
boolean |
isAutomaticReconnectOnConnectionLostEnabled() |
boolean |
isBluetoothAvailable() |
boolean |
isBluetoothEnabled() |
void |
registerCallbackListener(LegoBluetoothDeviceManagerCallbackListener listener)
Add a listener to receive device discovery and connection events.
|
void |
removeConnectTimeoutTimerForDevice(LegoBluetoothDevice device) |
void |
scan(android.content.Context context)
Start scanning for LEGO BLE devices
|
void |
setAutomaticReconnectOnConnectionLostEnabled(boolean enabled) |
void |
setConnectRequestTimeoutInterval(long interval) |
void |
stopScanning()
Stop scanning for LEGO BLE devices
|
void |
unregisterCallbackListener(LegoBluetoothDeviceManagerCallbackListener listener)
Remove a listener
|
void |
updateAdvertisingDevicesInterval(long interval)
Update the Advertising interval - determines the interval in milliseconds within which devices should advertise before being ruled out
|
public LegoBluetoothDeviceManagerImpl(AndroidBluetoothAdapterWrapper adapter)
public void scan(android.content.Context context) throws java.lang.IllegalStateException
LegoBluetoothDeviceManager
scan
in interface LegoBluetoothDeviceManager
context
- the Android contextjava.lang.IllegalStateException
- when Bluetooth is not available or enabled on devicepublic void stopScanning()
LegoBluetoothDeviceManager
stopScanning
in interface LegoBluetoothDeviceManager
public void connectToDevice(android.content.Context context, LegoBluetoothDevice device)
LegoBluetoothDeviceManager
connectToDevice
in interface LegoBluetoothDeviceManager
context
- The Android contextdevice
- The device to establish a connection topublic boolean isAutomaticReconnectOnConnectionLostEnabled()
isAutomaticReconnectOnConnectionLostEnabled
in interface LegoBluetoothDeviceManager
public void setAutomaticReconnectOnConnectionLostEnabled(boolean enabled)
setAutomaticReconnectOnConnectionLostEnabled
in interface LegoBluetoothDeviceManager
enabled
- whether automatic reconnect attempts should be performed or notpublic long getConnectRequestTimeoutInterval()
getConnectRequestTimeoutInterval
in interface LegoBluetoothDeviceManager
public void setConnectRequestTimeoutInterval(long interval)
setConnectRequestTimeoutInterval
in interface LegoBluetoothDeviceManager
interval
- the timeout interval used for device connect attemptspublic void removeConnectTimeoutTimerForDevice(LegoBluetoothDevice device)
public void registerCallbackListener(LegoBluetoothDeviceManagerCallbackListener listener)
LegoBluetoothDeviceManager
registerCallbackListener
in interface LegoBluetoothDeviceManager
listener
- The listener to addpublic void unregisterCallbackListener(LegoBluetoothDeviceManagerCallbackListener listener)
LegoBluetoothDeviceManager
unregisterCallbackListener
in interface LegoBluetoothDeviceManager
listener
- The listener to removepublic long getAdvertisingDevicesInterval()
getAdvertisingDevicesInterval
in interface LegoBluetoothDeviceManager
public void updateAdvertisingDevicesInterval(long interval)
LegoBluetoothDeviceManager
updateAdvertisingDevicesInterval
in interface LegoBluetoothDeviceManager
interval
- Interval to setpublic void cancelDeviceConnection(LegoBluetoothDevice device)
LegoBluetoothDeviceManager
cancelDeviceConnection
in interface LegoBluetoothDeviceManager
device
- The device to disconnect frompublic java.util.List<LegoBluetoothDevice> devicesInState(LegoDevice.DeviceState connectionState)
LegoBluetoothDeviceManager
devicesInState
in interface LegoBluetoothDeviceManager
connectionState
- The state of the devices.public java.util.List<LegoBluetoothDevice> allDevices()
LegoBluetoothDeviceManager
allDevices
in interface LegoBluetoothDeviceManager
public boolean isBluetoothEnabled()
public boolean isBluetoothAvailable()