Pebble 2/LE: fix potential NPE
This commit is contained in:
parent
74c20f3a82
commit
2993bb6b5c
|
@ -40,6 +40,9 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
|
|||
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));
|
||||
|
|
|
@ -33,10 +33,10 @@ public class PebbleLESupport {
|
|||
}
|
||||
|
||||
mPebbleGATTServer = new PebbleGATTServer(this, context, mBtDevice);
|
||||
mPebbleGATTServer.initialize();
|
||||
|
||||
mPebbleGATTClient = new PebbleGATTClient(this, context, mBtDevice);
|
||||
mPebbleGATTClient.initialize();
|
||||
if (mPebbleGATTServer.initialize()) {
|
||||
mPebbleGATTClient = new PebbleGATTClient(this, context, mBtDevice);
|
||||
mPebbleGATTClient.initialize();
|
||||
}
|
||||
}
|
||||
|
||||
void writeToPipedOutputStream(byte[] value, int offset, int count) {
|
||||
|
|
Loading…
Reference in New Issue