1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-03 17:02:13 +01:00

Pebble: Pass datalog creation timestamp to PebbleKit, properly announce PebbleKit datalogging support

This commit is contained in:
Andreas Shimokawa 2017-02-20 08:47:42 +01:00
parent 946ed5f000
commit ad9cfae6f9
10 changed files with 24 additions and 20 deletions

View File

@ -58,17 +58,17 @@ public class PebbleContentProvider extends ContentProvider {
if (uri.equals(CONTENT_URI)) {
MatrixCursor mc = new MatrixCursor(columnNames);
int connected = 0;
int appMessage = 0;
int pebbleKit = 0;
Prefs prefs = GBApplication.getPrefs();
if (prefs.getBoolean("pebble_enable_pebblekit", false)) {
appMessage = 1;
pebbleKit = 1;
}
String fwString = "unknown";
if (mGBDevice != null && mGBDevice.getType() == DeviceType.PEBBLE && mGBDevice.isInitialized()) {
connected = 1;
fwString = mGBDevice.getFirmwareVersion();
}
mc.addRow(new Object[]{connected, appMessage, 0, 3, 8, 2, fwString});
mc.addRow(new Object[]{connected, pebbleKit, pebbleKit, 3, 8, 2, fwString});
return mc;
} else {

View File

@ -10,6 +10,7 @@ public class GBDeviceEventDataLogging extends GBDeviceEvent {
public int command;
public UUID appUUID;
public long timestamp;
public long tag;
public byte pebbleDataType;
public Object data;

View File

@ -17,12 +17,14 @@ class DatalogSession {
final UUID uuid;
final byte itemType;
final short itemSize;
final int timestamp;
String taginfo = "(unknown)";
DatalogSession(byte id, UUID uuid, int tag, byte itemType, short itemSize) {
DatalogSession(byte id, UUID uuid, int timestamp, int tag, byte itemType, short itemSize) {
this.id = id;
this.tag = tag;
this.uuid = uuid;
this.timestamp = timestamp;
this.itemType = itemType;
this.itemSize = itemSize;
}
@ -62,6 +64,7 @@ class DatalogSession {
dataLogging.command = GBDeviceEventDataLogging.COMMAND_RECEIVE_DATA;
dataLogging.appUUID = uuid;
dataLogging.timestamp = timestamp & 0xffffffffL;
dataLogging.tag = tag;
dataLogging.pebbleDataType = itemType;
gbDeviceEvents[i] = dataLogging;

View File

@ -13,8 +13,8 @@ class DatalogSessionHealthHR extends DatalogSessionPebbleHealth {
private static final Logger LOG = LoggerFactory.getLogger(DatalogSessionHealthHR.class);
DatalogSessionHealthHR(byte id, UUID uuid, int tag, byte item_type, short item_size, GBDevice device) {
super(id, uuid, tag, item_type, item_size, device);
DatalogSessionHealthHR(byte id, UUID uuid, int timestamp, int tag, byte item_type, short item_size, GBDevice device) {
super(id, uuid, timestamp, tag, item_type, item_size, device);
taginfo = "(Health - HR " + tag + " )";
}

View File

@ -22,8 +22,8 @@ class DatalogSessionHealthOverlayData extends DatalogSessionPebbleHealth {
private static final Logger LOG = LoggerFactory.getLogger(DatalogSessionHealthOverlayData.class);
public DatalogSessionHealthOverlayData(byte id, UUID uuid, int tag, byte item_type, short item_size, GBDevice device) {
super(id, uuid, tag, item_type, item_size, device);
DatalogSessionHealthOverlayData(byte id, UUID uuid, int timestamp, int tag, byte item_type, short item_size, GBDevice device) {
super(id, uuid, timestamp, tag, item_type, item_size, device);
taginfo = "(Health - overlay data " + tag + " )";
}

View File

@ -22,8 +22,8 @@ class DatalogSessionHealthSleep extends DatalogSessionPebbleHealth {
private static final Logger LOG = LoggerFactory.getLogger(DatalogSessionHealthSleep.class);
public DatalogSessionHealthSleep(byte id, UUID uuid, int tag, byte item_type, short item_size, GBDevice device) {
super(id, uuid, tag, item_type, item_size, device);
DatalogSessionHealthSleep(byte id, UUID uuid, int timestamp, int tag, byte item_type, short item_size, GBDevice device) {
super(id, uuid, timestamp, tag, item_type, item_size, device);
taginfo = "(Health - sleep " + tag + " )";
}

View File

@ -20,8 +20,8 @@ class DatalogSessionHealthSteps extends DatalogSessionPebbleHealth {
private static final Logger LOG = LoggerFactory.getLogger(DatalogSessionHealthSteps.class);
public DatalogSessionHealthSteps(byte id, UUID uuid, int tag, byte item_type, short item_size, GBDevice device) {
super(id, uuid, tag, item_type, item_size, device);
DatalogSessionHealthSteps(byte id, UUID uuid, int timestamp, int tag, byte item_type, short item_size, GBDevice device) {
super(id, uuid, timestamp, tag, item_type, item_size, device);
taginfo = "(Health - steps)";
}

View File

@ -10,8 +10,8 @@ abstract class DatalogSessionPebbleHealth extends DatalogSession {
private final GBDevice mDevice;
DatalogSessionPebbleHealth(byte id, UUID uuid, int tag, byte itemType, short itemSize, GBDevice device) {
super(id, uuid, tag, itemType, itemSize);
DatalogSessionPebbleHealth(byte id, UUID uuid, int timestamp, int tag, byte itemType, short itemSize, GBDevice device) {
super(id, uuid, timestamp, tag, itemType, itemSize);
mDevice = device;
}

View File

@ -132,7 +132,7 @@ class PebbleKitSupport {
void sendDataLoggingIntent(GBDeviceEventDataLogging dataLogging) {
Intent intent = new Intent();
intent.putExtra("data_log_timestamp", System.currentTimeMillis() / 1000); // is this data really not present in data from watch?!
intent.putExtra("data_log_timestamp", dataLogging.timestamp);
intent.putExtra("uuid", dataLogging.appUUID);
intent.putExtra("data_log_uuid", dataLogging.appUUID); // Is that really the same?
intent.putExtra("data_log_tag", dataLogging.tag);

View File

@ -2248,15 +2248,15 @@ public class PebbleProtocol extends GBDeviceProtocol {
LOG.info("DATALOG OPENSESSION. id=" + (id & 0xff) + ", App UUID=" + uuid.toString() + ", log_tag=" + log_tag + ", item_type=" + item_type + ", itemSize=" + item_size);
if (!mDatalogSessions.containsKey(id)) {
if (uuid.equals(UUID_ZERO) && log_tag == 81) {
mDatalogSessions.put(id, new DatalogSessionHealthSteps(id, uuid, log_tag, item_type, item_size, getDevice()));
mDatalogSessions.put(id, new DatalogSessionHealthSteps(id, uuid, timestamp, log_tag, item_type, item_size, getDevice()));
} else if (uuid.equals(UUID_ZERO) && log_tag == 83) {
mDatalogSessions.put(id, new DatalogSessionHealthSleep(id, uuid, log_tag, item_type, item_size, getDevice()));
mDatalogSessions.put(id, new DatalogSessionHealthSleep(id, uuid, timestamp, log_tag, item_type, item_size, getDevice()));
} else if (uuid.equals(UUID_ZERO) && log_tag == 84) {
mDatalogSessions.put(id, new DatalogSessionHealthOverlayData(id, uuid, log_tag, item_type, item_size, getDevice()));
mDatalogSessions.put(id, new DatalogSessionHealthOverlayData(id, uuid, timestamp, log_tag, item_type, item_size, getDevice()));
} else if (uuid.equals(UUID_ZERO) && log_tag == 85) {
mDatalogSessions.put(id, new DatalogSessionHealthHR(id, uuid, log_tag, item_type, item_size, getDevice()));
mDatalogSessions.put(id, new DatalogSessionHealthHR(id, uuid, timestamp, log_tag, item_type, item_size, getDevice()));
} else {
mDatalogSessions.put(id, new DatalogSession(id, uuid, log_tag, item_type, item_size));
mDatalogSessions.put(id, new DatalogSession(id, uuid, timestamp, log_tag, item_type, item_size));
}
}
break;