1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-15 09:30:30 +02:00

Pebble: Better logging and hexdump for short packages to endpoint 6778

This commit is contained in:
Andreas Shimokawa 2015-04-25 23:13:22 +02:00
parent c773181da3
commit 442ae6499a
2 changed files with 18 additions and 13 deletions

View File

@ -68,4 +68,14 @@ public class GB {
pm.setComponentEnabledSetting(compName, newState, PackageManager.DONT_KILL_APP);
}
}
public static String hexdump(byte[] buffer, int length) {
final char[] hexArray = "0123456789ABCDEF".toCharArray();
char[] hexChars = new char[length * 2];
for (int j = 0; j < length; j++) {
int v = buffer[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars);
}
}

View File

@ -213,7 +213,7 @@ public class PebbleIoThread extends GBDeviceIoThread {
} catch (InterruptedException e) {
e.printStackTrace();
}
Log.i(TAG, "Read " + bytes + ", expected " + length + " reading remaining " + (length - bytes));
//Log.i(TAG, "Read " + bytes + ", expected " + length + " reading remaining " + (length - bytes));
int bytes_rest = mInStream.read(buffer, 4 + bytes, length - bytes);
bytes += bytes_rest;
}
@ -229,7 +229,12 @@ public class PebbleIoThread extends GBDeviceIoThread {
Log.i(TAG, "syncing time");
write(mPebbleProtocol.encodeSetTime(-1));
}
} else if (endpoint != PebbleProtocol.ENDPOINT_DATALOG) {
} else if (endpoint == PebbleProtocol.ENDPOINT_DATALOG) {
Log.i(TAG, "datalog to endpoint " + endpoint + " (" + bytes + " bytes)");
if (bytes <= 64) {
Log.i(TAG, "hexdump: " + GB.hexdump(buffer, bytes));
}
} else {
GBDeviceCommand deviceCmd = mPebbleProtocol.decodeResponse(buffer);
if (deviceCmd == null) {
Log.i(TAG, "unhandled message to endpoint " + endpoint + " (" + bytes + " bytes)");
@ -393,17 +398,7 @@ public class PebbleIoThread extends GBDeviceIoThread {
return;
}
int length = bytes.length;
Log.i(TAG, "got bytes for writeInstallApp()" + length);
/*
final char[] hexArray = "0123456789ABCDEF".toCharArray();
char[] hexChars = new char[length * 2];
for (int j = 0; j < length; j++) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
Log.i(TAG, new String(hexChars));
*/
Log.i(TAG, "got " + length + "bytes for writeInstallApp()");
try {
mOutStream.write(bytes);
mOutStream.flush();