diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleIoThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleIoThread.java index 1854e025..a6dfa41e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleIoThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleIoThread.java @@ -115,6 +115,10 @@ public class PebbleIoThread extends GBDeviceIoThread { mBtSocket = null; return false; } + + SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + mPebbleProtocol.setForceProtocol(sharedPrefs.getBoolean("pebble_force_protocol", false)); + gbDevice.setState(GBDevice.State.CONNECTED); gbDevice.sendDeviceUpdateIntent(getContext()); 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 82b7da35..be741c31 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleProtocol.java @@ -165,6 +165,8 @@ public class PebbleProtocol extends GBDeviceProtocol { private static Random mRandom = new Random(); boolean isFw3x = false; + boolean mForceProtocol = false; + byte last_id = -1; private ArrayList tmpUUIDS = new ArrayList<>(); @@ -221,13 +223,16 @@ public class PebbleProtocol extends GBDeviceProtocol { ts += (SimpleTimeZone.getDefault().getOffset(ts)); ts /= 1000; - if (isFw3x) { + if (isFw3x && mForceProtocol) { String[] parts = {from, null, body}; return encodeBlobdbNotification((int) (ts & 0xffffffff), parts); - } else { + } else if (!isFw3x && !mForceProtocol) { 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,13 +241,16 @@ public class PebbleProtocol extends GBDeviceProtocol { ts += (SimpleTimeZone.getDefault().getOffset(ts)); ts /= 1000; - if (isFw3x) { + if (isFw3x && mForceProtocol) { String[] parts = {from, subject, body}; return encodeBlobdbNotification((int) (ts & 0xffffffff), parts); - } else { + } else if (!isFw3x && !mForceProtocol) { String[] parts = {from, body, ts.toString(), subject}; return encodeMessage(ENDPOINT_NOTIFICATION, NOTIFICATION_EMAIL, 0, parts); } + + String[] parts = {from, subject, body}; + return encodeExtensibleNotification(mRandom.nextInt(), (int) (ts & 0xffffffff), parts); } @Override @@ -913,4 +921,9 @@ public class PebbleProtocol extends GBDeviceProtocol { return cmd; } + + public void setForceProtocol(boolean force) { + LOG.info("setting force protocol to " + force); + mForceProtocol = force; + } } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 1b61f966..947f8f5f 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -93,4 +93,5 @@ Anzahl der Vibrationen Log-Dateien schreiben (Neustart erforderlich) Schlafmonitor + Pebble Einstellungen diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e9f52eae..088b793c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -42,6 +42,10 @@ Developer Options Mi Band address + Pebble Settings + Force Notification Protocol + This option forces using the latest notification protocol depending on the firmware version. ENABLE ONLY IF YOU KNOW WHAT YOU ARE DOING! + not connected connecting diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 274e8744..8123d047 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -59,6 +59,19 @@ + + + + +