mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-25 08:40:43 +02:00
Pebble: add a dev option to always and immediately ACK PebbleKit messages to the watch
Might help #509
This commit is contained in:
parent
0042ffc514
commit
ee28ccd4fe
@ -85,6 +85,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
mBtAdapter = btAdapter;
|
||||
mPebbleSupport = pebbleSupport;
|
||||
mEnablePebblekit = prefs.getBoolean("pebble_enable_pebblekit", false);
|
||||
mPebbleProtocol.setAlwaysACKPebbleKit(prefs.getBoolean("pebble_always_ack_pebblekit", false));
|
||||
}
|
||||
|
||||
private int readWithException(InputStream inputStream, byte[] buffer, int byteOffset, int byteCount) throws IOException {
|
||||
|
@ -64,10 +64,12 @@ class PebbleKitSupport {
|
||||
break;
|
||||
case PEBBLEKIT_ACTION_APP_ACK:
|
||||
transaction_id = intent.getIntExtra("transaction_id", -1);
|
||||
if (transaction_id >= 0 && transaction_id <= 255) {
|
||||
mPebbleIoThread.write(mPebbleProtocol.encodeApplicationMessageAck(null, (byte) transaction_id));
|
||||
} else {
|
||||
LOG.warn("illegal transaction id " + transaction_id);
|
||||
if (!mPebbleProtocol.mAlwaysACKPebbleKit) {
|
||||
if (transaction_id >= 0 && transaction_id <= 255) {
|
||||
mPebbleIoThread.write(mPebbleProtocol.encodeApplicationMessageAck(null, (byte) transaction_id));
|
||||
} else {
|
||||
LOG.warn("illegal transaction id " + transaction_id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -253,6 +253,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
private static final Random mRandom = new Random();
|
||||
|
||||
int mFwMajor = 3;
|
||||
boolean mAlwaysACKPebbleKit = false;
|
||||
private boolean mForceProtocol = false;
|
||||
private GBDeviceEventScreenshot mDevEventScreenshot = null;
|
||||
private int mScreenshotRemaining = -1;
|
||||
@ -1833,16 +1834,17 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
jsonArray.put(jsonObject);
|
||||
}
|
||||
|
||||
// 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);
|
||||
*/
|
||||
GBDeviceEventSendBytes sendBytesAck = null;
|
||||
if (mAlwaysACKPebbleKit) {
|
||||
// this is a hack we send an ack to the Pebble immediately because somebody said it helps some PebbleKit apps :P
|
||||
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};
|
||||
return new GBDeviceEvent[]{appMessage, sendBytesAck};
|
||||
}
|
||||
|
||||
byte[] encodeApplicationMessagePush(short endpoint, UUID uuid, ArrayList<Pair<Integer, Object>> pairs) {
|
||||
@ -2584,6 +2586,11 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
mForceProtocol = force;
|
||||
}
|
||||
|
||||
void setAlwaysACKPebbleKit(boolean alwaysACKPebbleKit) {
|
||||
LOG.info("setting always ACK Pebbleit to " + alwaysACKPebbleKit);
|
||||
mAlwaysACKPebbleKit = alwaysACKPebbleKit;
|
||||
}
|
||||
|
||||
private String getFixedString(ByteBuffer buf, int length) {
|
||||
byte[] tmp = new byte[length];
|
||||
buf.get(tmp, 0, length);
|
||||
|
@ -149,6 +149,8 @@
|
||||
<string name="pref_summary_pebble_mtu_limit">If your Pebble 2/Pebble LE does not work as expected, try this setting to limit the MTU (valid range 20–512)</string>
|
||||
<string name="pref_title_pebble_enable_applogs">Enable Watch App Logging</string>
|
||||
<string name="pref_summary_pebble_enable_applogs">Will cause logs from watch apps to be logged by Gadgetbridge (requires reconnect)</string>
|
||||
<string name="pref_title_pebble_always_ack_pebblekit">Prematurely ACK PebbleKit</string>
|
||||
<string name="pref_summary_pebble_always_ack_pebblekit">Will cause messages that are sent to external 3rd party apps to be acknowledged always and immediately</string>
|
||||
|
||||
<string name="pref_title_pebble_reconnect_attempts">Reconnection Attempts</string>
|
||||
|
||||
|
@ -386,6 +386,11 @@
|
||||
android:key="pebble_enable_applogs"
|
||||
android:summary="@string/pref_summary_pebble_enable_applogs"
|
||||
android:title="@string/pref_title_pebble_enable_applogs" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pebble_always_ack_pebblekit"
|
||||
android:summary="@string/pref_summary_pebble_always_ack_pebblekit"
|
||||
android:title="@string/pref_title_pebble_always_ack_pebblekit" />
|
||||
<EditTextPreference
|
||||
android:digits="0123456789."
|
||||
android:key="pebble_emu_addr"
|
||||
|
Loading…
Reference in New Issue
Block a user