Pebble 2: only add second service if first one was added sucessfully
This commit is contained in:
parent
3b250a4568
commit
4f3c46f704
|
@ -1,6 +1,7 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.ble;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.ble;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.bluetooth.BluetoothGatt;
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
import android.bluetooth.BluetoothGattDescriptor;
|
import android.bluetooth.BluetoothGattDescriptor;
|
||||||
import android.bluetooth.BluetoothGattServer;
|
import android.bluetooth.BluetoothGattServer;
|
||||||
|
@ -49,10 +50,6 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
|
||||||
pebbleGATTService.addCharacteristic(writeCharacteristics);
|
pebbleGATTService.addCharacteristic(writeCharacteristics);
|
||||||
mBluetoothGattServer.addService(pebbleGATTService);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +145,11 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
|
||||||
|
|
||||||
public void onServiceAdded(int status, BluetoothGattService service) {
|
public void onServiceAdded(int status, BluetoothGattService service) {
|
||||||
LOG.info("onServiceAdded() status = " + status + " service = " + service.getUuid());
|
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) {
|
public void onNotificationSent(BluetoothDevice bluetoothDevice, int status) {
|
||||||
|
|
Loading…
Reference in New Issue