Search in sources :

Example 41 with BluetoothGattCharacteristic

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;
}
Also used : BluetoothGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic)

Example 42 with BluetoothGattCharacteristic

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;
}
Also used : BaseSensor(sample.ble.sensortag.sensor.BaseSensor) BluetoothGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic) DeviceDef(com.chimeraiot.android.ble.sensor.DeviceDef) TiPeriodicalSensor(sample.ble.sensortag.sensor.ti.TiPeriodicalSensor) Sensor(com.chimeraiot.android.ble.sensor.Sensor) BaseSensor(sample.ble.sensortag.sensor.BaseSensor)

Aggregations

BluetoothGattCharacteristic (android.bluetooth.BluetoothGattCharacteristic)42 BluetoothGattService (android.bluetooth.BluetoothGattService)8 TransactionBuilder (nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder)7 IOException (java.io.IOException)6 BluetoothGattDescriptor (android.bluetooth.BluetoothGattDescriptor)5 GregorianCalendar (java.util.GregorianCalendar)4 GBAlarm (nodomain.freeyourgadget.gadgetbridge.impl.GBAlarm)4 Alarm (nodomain.freeyourgadget.gadgetbridge.model.Alarm)4 Calendar (java.util.Calendar)3 HashMap (java.util.HashMap)3 Prefs (nodomain.freeyourgadget.gadgetbridge.util.Prefs)3 UUID (java.util.UUID)2 CalendarEvents (nodomain.freeyourgadget.gadgetbridge.model.CalendarEvents)2 BaseSensor (sample.ble.sensortag.sensor.BaseSensor)2 TiPeriodicalSensor (sample.ble.sensortag.sensor.ti.TiPeriodicalSensor)2 BluetoothAdapter (android.bluetooth.BluetoothAdapter)1 BluetoothDevice (android.bluetooth.BluetoothDevice)1 BluetoothGatt (android.bluetooth.BluetoothGatt)1 BluetoothManager (android.bluetooth.BluetoothManager)1 Context (android.content.Context)1