mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-24 19:06:53 +01:00
Pebble: only ACK appmessages from pebble to pebblekit android apps after the app actually sent one
This commit is contained in:
parent
0218cee0e1
commit
38e234552d
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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<Pair<Integer, Object>> pairs) {
|
||||
|
Loading…
Reference in New Issue
Block a user