mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +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 {
|
try {
|
||||||
JSONArray jsonArray = new JSONArray(jsonString);
|
JSONArray jsonArray = new JSONArray(jsonString);
|
||||||
write(mPebbleProtocol.encodeApplicationMessageFromJSON(uuid, jsonArray));
|
write(mPebbleProtocol.encodeApplicationMessageFromJSON(uuid, jsonArray));
|
||||||
sendAppMessageAck(transaction_id);
|
if (transaction_id >= 0 && transaction_id <= 255) {
|
||||||
|
sendAppMessageAck(transaction_id);
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PEBBLEKIT_ACTION_APP_ACK:
|
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
|
transaction_id = intent.getIntExtra("transaction_id", -1);
|
||||||
/*
|
|
||||||
uuid = (UUID) intent.getSerializableExtra("uuid");
|
|
||||||
int transaction_id = intent.getIntExtra("transaction_id", -1);
|
|
||||||
if (transaction_id >= 0 && transaction_id <= 255) {
|
if (transaction_id >= 0 && transaction_id <= 255) {
|
||||||
write(mPebbleProtocol.encodeApplicationMessageAck(uuid, (byte) transaction_id));
|
write(mPebbleProtocol.encodeApplicationMessageAck(null, (byte) transaction_id));
|
||||||
} else {
|
} else {
|
||||||
LOG.warn("illegal transacktion id " + transaction_id);
|
LOG.warn("illegal transacktion id " + transaction_id);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1698,6 +1698,9 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte[] encodeApplicationMessageAck(UUID uuid, byte id) {
|
byte[] encodeApplicationMessageAck(UUID uuid, byte id) {
|
||||||
|
if (uuid == null) {
|
||||||
|
uuid = currentRunningApp;
|
||||||
|
}
|
||||||
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + 18); // +ACK
|
ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + 18); // +ACK
|
||||||
|
|
||||||
buf.order(ByteOrder.BIG_ENDIAN);
|
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
|
// 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();
|
GBDeviceEventSendBytes sendBytesAck = new GBDeviceEventSendBytes();
|
||||||
sendBytesAck.encodedBytes = encodeApplicationMessageAck(uuid, last_id);
|
sendBytesAck.encodedBytes = encodeApplicationMessageAck(uuid, last_id);
|
||||||
|
*/
|
||||||
GBDeviceEventAppMessage appMessage = new GBDeviceEventAppMessage();
|
GBDeviceEventAppMessage appMessage = new GBDeviceEventAppMessage();
|
||||||
appMessage.appUUID = uuid;
|
appMessage.appUUID = uuid;
|
||||||
appMessage.id = last_id & 0xff;
|
appMessage.id = last_id & 0xff;
|
||||||
appMessage.message = jsonArray.toString();
|
appMessage.message = jsonArray.toString();
|
||||||
return new GBDeviceEvent[]{appMessage, sendBytesAck};
|
return new GBDeviceEvent[]{appMessage};
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] encodeApplicationMessagePush(short endpoint, UUID uuid, ArrayList<Pair<Integer, Object>> pairs) {
|
byte[] encodeApplicationMessagePush(short endpoint, UUID uuid, ArrayList<Pair<Integer, Object>> pairs) {
|
||||||
|
Loading…
Reference in New Issue
Block a user