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; return;
} }
mPebbleLESupport.mIsConnected = true; mPebbleLESupport.mIsConnected = true;
synchronized (mPebbleLESupport) {
mPebbleLESupport.notify();
}
LOG.info("write request: offset = " + offset + " value = " + GB.hexdump(value, 0, -1)); LOG.info("write request: offset = " + offset + " value = " + GB.hexdump(value, 0, -1));
int header = value[0] & 0xff; int header = value[0] & 0xff;
int command = header & 7; int command = header & 7;

View File

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