Pebble: try to support notification dismissal on the Pebble Time (completely untested)

live-activity-data
Andreas Shimokawa 2015-07-22 20:53:18 +02:00
parent 80e93aeaf7
commit 5c26b2281f
1 changed files with 11 additions and 4 deletions

View File

@ -53,6 +53,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
public static final short ENDPOINT_DATALOG = 6778; public static final short ENDPOINT_DATALOG = 6778;
static final short ENDPOINT_RUNKEEPER = 7000; static final short ENDPOINT_RUNKEEPER = 7000;
static final short ENDPOINT_SCREENSHOT = 8000; 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_BLOBDB = (short) 45531; // 3.x only
static final short ENDPOINT_PUTBYTES = (short) 48879; static final short ENDPOINT_PUTBYTES = (short) 48879;
@ -792,18 +793,23 @@ public class PebbleProtocol extends GBDeviceProtocol {
return null; return null;
} }
private GBDeviceEvent decodeResponseExtensibleNotifs(ByteBuffer buf, int length) { private GBDeviceEvent decodeResponseNotificationAction(ByteBuffer buf, int length) {
buf.order(ByteOrder.LITTLE_ENDIAN); buf.order(ByteOrder.LITTLE_ENDIAN);
byte command = buf.get(); byte command = buf.get();
if (command == 0x02) { // dismiss notification ? 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(); int id = buf.getInt();
short unk = buf.getShort(); short action = buf.getShort(); // at least the low byte should be the action - or not?
if (unk == 0x0001) { if (action == 0x0001) {
GBDeviceEventDismissNotification devEvtDismissNotification = new GBDeviceEventDismissNotification(); GBDeviceEventDismissNotification devEvtDismissNotification = new GBDeviceEventDismissNotification();
devEvtDismissNotification.notificationID = id; devEvtDismissNotification.notificationID = id;
return devEvtDismissNotification; return devEvtDismissNotification;
} }
LOG.info("unexpected paramerter in dismiss action: " + action);
} }
return null; return null;
@ -1034,7 +1040,8 @@ public class PebbleProtocol extends GBDeviceProtocol {
devEvt = decodeResponseScreenshot(buf, length); devEvt = decodeResponseScreenshot(buf, length);
break; break;
case ENDPOINT_EXTENSIBLENOTIFS: case ENDPOINT_EXTENSIBLENOTIFS:
devEvt = decodeResponseExtensibleNotifs(buf, length); case ENDPOINT_NOTIFICATIONACTION:
devEvt = decodeResponseNotificationAction(buf, length);
break; break;
default: default:
break; break;