From ad4f7081402ac364c43fe9e7f6b411cc429b1fab Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sat, 13 Jun 2015 00:26:55 +0200 Subject: [PATCH] Send 2.x style notifications when on FW 3.x (on FW 2.x else use 1.x style notifications) This could improve #24. Unfortunally I cannot test it since I have no Pebble Time. --- .../gadgetbridge/pebble/PebbleProtocol.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleProtocol.java index 18c7b80c..07c856a7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleProtocol.java @@ -164,7 +164,7 @@ public class PebbleProtocol extends GBDeviceProtocol { private static final String[] hwRevisions = {"unknown", "ev1", "ev2", "ev2_3", "ev2_4", "v1_5", "v2_0", "evt2", "dvt"}; private static Random mRandom = new Random(); - boolean isFw3x = true; + boolean isFw3x = false; byte last_id = -1; private ArrayList tmpUUIDS = new ArrayList<>(); @@ -221,14 +221,13 @@ public class PebbleProtocol extends GBDeviceProtocol { ts += (SimpleTimeZone.getDefault().getOffset(ts)); ts /= 1000; - - if (!isFw3x || true) { // remove || true if necessary on FW 3.x + if (isFw3x) { + String[] parts = {from, null, body}; + return encodeExtensibleNotification(mRandom.nextInt(), (int) (ts & 0xffffffff), parts); + } else { String[] parts = {from, body, ts.toString()}; return encodeMessage(ENDPOINT_NOTIFICATION, NOTIFICATION_SMS, 0, parts); } - - String[] parts = {from, null, body}; - return encodeExtensibleNotification(mRandom.nextInt(), (int) (ts & 0xffffffff), parts); } @Override @@ -236,10 +235,14 @@ public class PebbleProtocol extends GBDeviceProtocol { Long ts = System.currentTimeMillis(); ts += (SimpleTimeZone.getDefault().getOffset(ts)); ts /= 1000; - String tsstring = ts.toString(); // SIC - String[] parts = {from, body, tsstring, subject}; - return encodeMessage(ENDPOINT_NOTIFICATION, NOTIFICATION_EMAIL, 0, parts); + if (isFw3x) { + String[] parts = {from, subject, body}; + return encodeExtensibleNotification(mRandom.nextInt(), (int) (ts & 0xffffffff), parts); + } else { + String[] parts = {from, body, ts.toString(), subject}; + return encodeMessage(ENDPOINT_NOTIFICATION, NOTIFICATION_EMAIL, 0, parts); + } } @Override