1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +01:00

Pebble 2: only add second service if first one was added sucessfully

This commit is contained in:
Andreas Shimokawa 2016-11-20 00:12:41 +01:00
parent 3b250a4568
commit 4f3c46f704

View File

@ -1,6 +1,7 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.ble;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattServer;
@ -49,10 +50,6 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
pebbleGATTService.addCharacteristic(writeCharacteristics);
mBluetoothGattServer.addService(pebbleGATTService);
final BluetoothGattService badbadService = new BluetoothGattService(SERVER_SERVICE_BADBAD, BluetoothGattService.SERVICE_TYPE_PRIMARY);
badbadService.addCharacteristic(new BluetoothGattCharacteristic(SERVER_SERVICE_BADBAD, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ));
mBluetoothGattServer.addService(badbadService);
return true;
}
@ -148,6 +145,11 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
public void onServiceAdded(int status, BluetoothGattService service) {
LOG.info("onServiceAdded() status = " + status + " service = " + service.getUuid());
if (status == BluetoothGatt.GATT_SUCCESS && service.getUuid().equals(SERVER_SERVICE)) {
final BluetoothGattService badbadService = new BluetoothGattService(SERVER_SERVICE_BADBAD, BluetoothGattService.SERVICE_TYPE_PRIMARY);
badbadService.addCharacteristic(new BluetoothGattCharacteristic(SERVER_SERVICE_BADBAD, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ));
mBluetoothGattServer.addService(badbadService);
}
}
public void onNotificationSent(BluetoothDevice bluetoothDevice, int status) {