diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java index 923ee95c..83e26912 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java @@ -117,24 +117,22 @@ class PebbleIoThread extends GBDeviceIoThread { try { JSONArray jsonArray = new JSONArray(jsonString); write(mPebbleProtocol.encodeApplicationMessageFromJSON(uuid, jsonArray)); - sendAppMessageAck(transaction_id); - + if (transaction_id >= 0 && transaction_id <= 255) { + sendAppMessageAck(transaction_id); + } } catch (JSONException e) { e.printStackTrace(); } break; case PEBBLEKIT_ACTION_APP_ACK: - // we do not get a uuid and cannot map a transaction id to it, so we ack in PebbleProtocol early - /* - uuid = (UUID) intent.getSerializableExtra("uuid"); - int transaction_id = intent.getIntExtra("transaction_id", -1); + transaction_id = intent.getIntExtra("transaction_id", -1); if (transaction_id >= 0 && transaction_id <= 255) { - write(mPebbleProtocol.encodeApplicationMessageAck(uuid, (byte) transaction_id)); + write(mPebbleProtocol.encodeApplicationMessageAck(null, (byte) transaction_id)); } else { LOG.warn("illegal transacktion id " + transaction_id); } - */ break; + } } }; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index eff90ef3..121cbb44 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -1698,6 +1698,9 @@ public class PebbleProtocol extends GBDeviceProtocol { } byte[] encodeApplicationMessageAck(UUID uuid, byte id) { + if (uuid == null) { + uuid = currentRunningApp; + } ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + 18); // +ACK buf.order(ByteOrder.BIG_ENDIAN); @@ -1829,14 +1832,15 @@ public class PebbleProtocol extends GBDeviceProtocol { } // this is a hack we send an ack to the Pebble immediately because we cannot map the transaction_id from the intent back to a uuid yet + /* GBDeviceEventSendBytes sendBytesAck = new GBDeviceEventSendBytes(); sendBytesAck.encodedBytes = encodeApplicationMessageAck(uuid, last_id); - + */ GBDeviceEventAppMessage appMessage = new GBDeviceEventAppMessage(); appMessage.appUUID = uuid; appMessage.id = last_id & 0xff; appMessage.message = jsonArray.toString(); - return new GBDeviceEvent[]{appMessage, sendBytesAck}; + return new GBDeviceEvent[]{appMessage}; } byte[] encodeApplicationMessagePush(short endpoint, UUID uuid, ArrayList> pairs) {