From 5c26b2281f7c7c194c7209eae8e97775d1dedb7d Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Wed, 22 Jul 2015 20:53:18 +0200 Subject: [PATCH] Pebble: try to support notification dismissal on the Pebble Time (completely untested) --- .../gadgetbridge/pebble/PebbleProtocol.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 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 48782617..bf957136 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/pebble/PebbleProtocol.java @@ -53,6 +53,7 @@ public class PebbleProtocol extends GBDeviceProtocol { public static final short ENDPOINT_DATALOG = 6778; static final short ENDPOINT_RUNKEEPER = 7000; static final short ENDPOINT_SCREENSHOT = 8000; + static final short ENDPOINT_NOTIFICATIONACTION = 11440; // 3.x only, TODO: find a better name static final short ENDPOINT_BLOBDB = (short) 45531; // 3.x only static final short ENDPOINT_PUTBYTES = (short) 48879; @@ -792,18 +793,23 @@ public class PebbleProtocol extends GBDeviceProtocol { return null; } - private GBDeviceEvent decodeResponseExtensibleNotifs(ByteBuffer buf, int length) { + private GBDeviceEvent decodeResponseNotificationAction(ByteBuffer buf, int length) { buf.order(ByteOrder.LITTLE_ENDIAN); byte command = buf.get(); if (command == 0x02) { // dismiss notification ? + if (isFw3x) { + buf.getLong(); // skip 8 bytes of UUID + buf.getInt(); // skip 4 bytes of UUID + } int id = buf.getInt(); - short unk = buf.getShort(); - if (unk == 0x0001) { + short action = buf.getShort(); // at least the low byte should be the action - or not? + if (action == 0x0001) { GBDeviceEventDismissNotification devEvtDismissNotification = new GBDeviceEventDismissNotification(); devEvtDismissNotification.notificationID = id; return devEvtDismissNotification; } + LOG.info("unexpected paramerter in dismiss action: " + action); } return null; @@ -1034,7 +1040,8 @@ public class PebbleProtocol extends GBDeviceProtocol { devEvt = decodeResponseScreenshot(buf, length); break; case ENDPOINT_EXTENSIBLENOTIFS: - devEvt = decodeResponseExtensibleNotifs(buf, length); + case ENDPOINT_NOTIFICATIONACTION: + devEvt = decodeResponseNotificationAction(buf, length); break; default: break;