public class LegoBluetoothDeviceImpl extends LegoDeviceImpl implements LegoBluetoothDevice
LegoDevice.DeviceCategory, LegoDevice.DeviceFunction, LegoDevice.DeviceState
Modifier and Type | Field and Description |
---|---|
static int |
NUMBER_OF_RSSI_VALUES_TO_AVERAGE |
batteryLevel, buttonPressed, callbackHelper, category, connectState, deviceId, deviceInfo, lastConnectedNetworkId, lowVoltage, name, services, supportedFunctions, UNDEFINED_DEVICE_ID
Modifier and Type | Method and Description |
---|---|
void |
addWriteOfCharacteristicToQueue(android.bluetooth.BluetoothGattCharacteristic characteristic,
byte[] data,
int writeType)
Wrapper for
BluetoothGatt.writeCharacteristic(android.bluetooth.BluetoothGattCharacteristic)
On Android we need to maintain a queue of read/write requests to ensure proper functionning. |
void |
calculateAverageRSSI(int newRSSI) |
void |
cleanUp() |
protected void |
connectGatt(android.content.Context applicationContext,
boolean autoConnect,
android.bluetooth.BluetoothGattCallback bluetoothGattCallback) |
static LegoBluetoothDevice |
deviceWithWrapper(AndroidBluetoothDeviceWrapper androidBluetoothDeviceWrapper,
byte[] scanRecord,
int rssi) |
protected void |
disconnectAndCloseGatt() |
boolean |
equals(java.lang.Object o) |
android.bluetooth.BluetoothDevice |
getAndroidBluetoothDevice() |
LegoDevice.DeviceCategory |
getCategory()
The System Category of the connected Device
|
java.lang.String |
getDeviceId()
A unique identifier for the device
|
int |
getLastConnectedNetworkId()
The ID of the network this Device was connected to last
|
int |
getRSSIValue() |
ScanRecord |
getScanRecord() |
LegoDevice.DeviceFunction |
getSupportedFunctions()
The Fuction(s) supported by the connected Device
|
void |
handleReadOrUpdatedCharacteristic(android.bluetooth.BluetoothGattCharacteristic characteristic) |
int |
hashCode() |
boolean |
isAdvertising() |
boolean |
isLowVoltage()
True if the a low voltage alert has been received from the Device, indicating that batteries should be changed/charged
|
void |
setAdvertising(boolean advertising) |
void |
setCharacteristicNotification(android.bluetooth.BluetoothGattCharacteristic characteristic,
boolean enable)
Wrapper for
BluetoothGatt.setCharacteristicNotification(android.bluetooth.BluetoothGattCharacteristic, boolean) |
void |
setName(java.lang.String newName)
Writing a new name will immediately update the property value, even though the actual write to the
hardware is asynchronously, and may potentially fail.
|
void |
updateConnectionStateUponConnectionStateChange(int status,
int newState) |
void |
updateDeviceState(LegoDevice.DeviceState newDeviceState) |
void |
updateWithAdvertisementDataAndRSSI(byte[] scanRecord,
int rssi) |
getBatteryLevel, getConnectState, getDeviceInfo, getExternalServices, getInternalServices, getName, getServices, isButtonPressed, registerCallbackListener, unregisterCallbackListener
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getBatteryLevel, getConnectState, getDeviceInfo, getExternalServices, getInternalServices, getName, getServices, isButtonPressed, registerCallbackListener, unregisterCallbackListener
public static final int NUMBER_OF_RSSI_VALUES_TO_AVERAGE
public static LegoBluetoothDevice deviceWithWrapper(AndroidBluetoothDeviceWrapper androidBluetoothDeviceWrapper, byte[] scanRecord, int rssi)
public boolean isAdvertising()
public void setAdvertising(boolean advertising)
public java.lang.String getDeviceId()
LegoDevice
getDeviceId
in interface LegoDevice
getDeviceId
in class LegoDeviceImpl
public void setName(java.lang.String newName)
LegoDevice
DeviceCallbackListener.didChangeNameFrom(dk.lego.devicesdk.device.LegoDevice, java.lang.String, java.lang.String)
is invoked.setName
in interface LegoDevice
public void updateWithAdvertisementDataAndRSSI(byte[] scanRecord, int rssi)
public void calculateAverageRSSI(int newRSSI)
public void updateDeviceState(LegoDevice.DeviceState newDeviceState)
public int getRSSIValue()
getRSSIValue
in interface LegoBluetoothDevice
public LegoDevice.DeviceCategory getCategory()
LegoDevice
getCategory
in interface LegoDevice
public LegoDevice.DeviceFunction getSupportedFunctions()
LegoDevice
getSupportedFunctions
in interface LegoDevice
public int getLastConnectedNetworkId()
LegoDevice
getLastConnectedNetworkId
in interface LegoDevice
public boolean isLowVoltage()
LegoDevice
isLowVoltage
in interface LegoDevice
protected void connectGatt(android.content.Context applicationContext, boolean autoConnect, android.bluetooth.BluetoothGattCallback bluetoothGattCallback)
public void handleReadOrUpdatedCharacteristic(android.bluetooth.BluetoothGattCharacteristic characteristic)
public android.bluetooth.BluetoothDevice getAndroidBluetoothDevice()
getAndroidBluetoothDevice
in interface LegoBluetoothDevice
protected void disconnectAndCloseGatt()
public void addWriteOfCharacteristicToQueue(android.bluetooth.BluetoothGattCharacteristic characteristic, byte[] data, int writeType)
LegoBluetoothDevice
BluetoothGatt.writeCharacteristic(android.bluetooth.BluetoothGattCharacteristic)
On Android we need to maintain a queue of read/write requests to ensure proper functionning.
This call adds write requests to the queue.addWriteOfCharacteristicToQueue
in interface LegoBluetoothDevice
characteristic
- Characteristic to write on the remote devicedata
- The value data to write. See BluetoothGattCharacteristic.setValue(String)
writeType
- The type of write to perform. See BluetoothGattCharacteristic.setWriteType(int)
public void setCharacteristicNotification(android.bluetooth.BluetoothGattCharacteristic characteristic, boolean enable)
LegoBluetoothDevice
BluetoothGatt.setCharacteristicNotification(android.bluetooth.BluetoothGattCharacteristic, boolean)
setCharacteristicNotification
in interface LegoBluetoothDevice
characteristic
- The characteristic for which to enable notificationsenable
- Set to true to enable notifications/indicationspublic ScanRecord getScanRecord()
getScanRecord
in interface LegoBluetoothDevice
public void updateConnectionStateUponConnectionStateChange(int status, int newState)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public void cleanUp()