use of android.bluetooth.BluetoothGattCharacteristic in project BleLiteLib4android by afunx.
the class BleGattClientProxyImpl method __discoverCharacteristic.
private BluetoothGattCharacteristic __discoverCharacteristic(BluetoothGattService gattService, UUID uuid) {
final BluetoothGattCharacteristic gattCharacteristic = gattService.getCharacteristic(uuid);
BleLiteLog.i(TAG, "__discoverCharacteristic() gattService uuid: " + gattService.getUuid() + ", characteristic uuid: " + uuid + ", gattCharacteristic is " + (gattCharacteristic != null ? "found" : "missed"));
return gattCharacteristic;
}
use of android.bluetooth.BluetoothGattCharacteristic 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