use of com.chimeraiot.android.ble.sensor.DeviceDef in project BleSensorTag by StevenRudenko.
the class DeviceServicesActivity method displayGattServices.
private void displayGattServices(List<BluetoothGattService> gattServices) {
if (gattServices == null) {
return;
}
final DeviceDef def = getBleManager().getDeviceDefCollection().get(getDeviceName(), getDeviceAddress());
gattServiceAdapter = new BleServicesAdapter(this, gattServices, def);
gattServiceAdapter.setServiceListener(this);
gattServicesList.setAdapter(gattServiceAdapter);
}
use of com.chimeraiot.android.ble.sensor.DeviceDef in project BleSensorTag by StevenRudenko.
the class DeviceServicesActivity method onChildClick.
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
if (gattServiceAdapter == null) {
return false;
}
final BluetoothGattCharacteristic characteristic = gattServiceAdapter.getChild(groupPosition, childPosition);
final DeviceDef def = getBleManager().getDeviceDefCollection().get(getDeviceName(), getDeviceAddress());
if (def == null) {
return false;
}
final Sensor<?> sensor = (Sensor<?>) def.getSensor(characteristic.getService().getUuid().toString());
if (sensor == null) {
return true;
}
if (sensor == activeSensor) {
return true;
}
final String address = getDeviceAddress();
if (sensor instanceof BaseSensor) {
final BaseSensor<?> baseSensor = (BaseSensor<?>) sensor;
if (activeSensor != null) {
activeSensor.setEnabled(false);
getBleManager().update(address, activeSensor, activeSensor.getConfigUUID(), null);
}
activeSensor = baseSensor;
baseSensor.setEnabled(true);
getBleManager().update(address, sensor, baseSensor.getConfigUUID(), null);
getBleManager().listen(address, sensor, baseSensor.getDataUUID());
} else {
getBleManager().read(address, sensor, characteristic.getUuid().toString());
}
return true;
}
Aggregations