Pebble 2/LE: on connect wait 30s max and stop waiting immediately if a real PP connection got establish (ie write request on the gatt server)

This commit is contained in:
Andreas Shimokawa 2016-12-02 08:07:44 +01:00
parent 3eda2d4b81
commit bc9041a4c9
2 changed files with 8 additions and 3 deletions

View File

@ -104,6 +104,9 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
return;
}
mPebbleLESupport.mIsConnected = true;
synchronized (mPebbleLESupport) {
mPebbleLESupport.notify();
}
LOG.info("write request: offset = " + offset + " value = " + GB.hexdump(value, 0, -1));
int header = value[0] & 0xff;
int command = header & 7;

View File

@ -36,9 +36,11 @@ public class PebbleLESupport {
if (mPebbleGATTServer.initialize()) {
mPebbleGATTClient = new PebbleGATTClient(this, context, mBtDevice);
try {
Thread.sleep(6000);
if (mIsConnected) {
return;
synchronized (this) {
wait(30000);
if (mIsConnected) {
return;
}
}
} catch (InterruptedException ignored) {
}