Search in sources :

Example 21 with BluetoothGattCharacteristic

use of android.bluetooth.BluetoothGattCharacteristic in project physical-web by google.

the class FatBeaconBroadcastService method initGattServer.

private void initGattServer() {
    mGattServer = mBluetoothManager.openGattServer(this, mGattServerCallback);
    BluetoothGattService service = new BluetoothGattService(UUID.fromString(SERVICE_UUID), BluetoothGattService.SERVICE_TYPE_PRIMARY);
    BluetoothGattCharacteristic webpage = new BluetoothGattCharacteristic(CHARACTERISTIC_WEBPAGE_UUID, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ);
    service.addCharacteristic(webpage);
    mGattServer.addService(service);
}
Also used : BluetoothGattService(android.bluetooth.BluetoothGattService) BluetoothGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic)

Example 22 with BluetoothGattCharacteristic

use of android.bluetooth.BluetoothGattCharacteristic in project Gadgetbridge by Freeyourgadget.

the class PebbleGATTServer method initialize.

boolean initialize() {
    BluetoothManager bluetoothManager = (BluetoothManager) mContext.getSystemService(Context.BLUETOOTH_SERVICE);
    mBluetoothGattServer = bluetoothManager.openGattServer(mContext, this);
    if (mBluetoothGattServer == null) {
        return false;
    }
    BluetoothGattService pebbleGATTService = new BluetoothGattService(SERVER_SERVICE, BluetoothGattService.SERVICE_TYPE_PRIMARY);
    pebbleGATTService.addCharacteristic(new BluetoothGattCharacteristic(READ_CHARACTERISTICS, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ));
    writeCharacteristics = new BluetoothGattCharacteristic(WRITE_CHARACTERISTICS, BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE | BluetoothGattCharacteristic.PROPERTY_NOTIFY, BluetoothGattCharacteristic.PERMISSION_WRITE);
    writeCharacteristics.addDescriptor(new BluetoothGattDescriptor(CHARACTERISTICS_CONFIGURATION_DESCRIPTOR, BluetoothGattDescriptor.PERMISSION_WRITE));
    pebbleGATTService.addCharacteristic(writeCharacteristics);
    mBluetoothGattServer.addService(pebbleGATTService);
    return true;
}
Also used : BluetoothManager(android.bluetooth.BluetoothManager) BluetoothGattService(android.bluetooth.BluetoothGattService) BluetoothGattDescriptor(android.bluetooth.BluetoothGattDescriptor) BluetoothGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic)

Example 23 with BluetoothGattCharacteristic

use of android.bluetooth.BluetoothGattCharacteristic in project Gadgetbridge by Freeyourgadget.

the class VibratissimoSupport method onSetConstantVibration.

@Override
public void onSetConstantVibration(int intensity) {
    getQueue().clear();
    BluetoothGattCharacteristic characteristic2 = getCharacteristic(UUID.fromString("00001526-1212-efde-1523-785feabcd123"));
    BluetoothGattCharacteristic characteristic1 = getCharacteristic(UUID.fromString("00001524-1212-efde-1523-785feabcd123"));
    TransactionBuilder builder = new TransactionBuilder("vibration");
    builder.write(characteristic1, new byte[] { 0x03, (byte) 0x80 });
    builder.write(characteristic2, new byte[] { (byte) intensity, 0x00 });
    builder.queue(getQueue());
}
Also used : TransactionBuilder(nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder) BluetoothGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic)

Example 24 with BluetoothGattCharacteristic

use of android.bluetooth.BluetoothGattCharacteristic in project Gadgetbridge by Freeyourgadget.

the class PebbleGATTClient method setMTU.

private void setMTU(BluetoothGatt gatt) {
    LOG.info("setting MTU");
    BluetoothGattCharacteristic characteristic = gatt.getService(SERVICE_UUID).getCharacteristic(MTU_CHARACTERISTIC);
    BluetoothGattDescriptor descriptor = characteristic.getDescriptor(CHARACTERISTIC_CONFIGURATION_DESCRIPTOR);
    // unknown
    descriptor.setValue(new byte[] { 0x0b, 0x01 });
    gatt.writeCharacteristic(characteristic);
}
Also used : BluetoothGattDescriptor(android.bluetooth.BluetoothGattDescriptor) BluetoothGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic)

Example 25 with BluetoothGattCharacteristic

use of android.bluetooth.BluetoothGattCharacteristic in project Gadgetbridge by Freeyourgadget.

the class V1NotificationStrategy method sendDefaultNotification.

@Override
public void sendDefaultNotification(TransactionBuilder builder, SimpleNotification simpleNotification, BtLEAction extraAction) {
    BluetoothGattCharacteristic characteristic = support.getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT);
    builder.write(characteristic, getDefaultNotification());
    builder.add(extraAction);
}
Also used : BluetoothGattCharacteristic(android.bluetooth.BluetoothGattCharacteristic)

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