Pebble: remove null termination from cstrings when converting to json for PebbleKit
This commit is contained in:
parent
5e74338efe
commit
50cb3c9db3
|
@ -1783,6 +1783,9 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
byte type = buf.get();
|
byte type = buf.get();
|
||||||
short length = buf.getShort();
|
short length = buf.getShort();
|
||||||
jsonObject.put("key", key);
|
jsonObject.put("key", key);
|
||||||
|
if (type == TYPE_CSTRING) {
|
||||||
|
length--;
|
||||||
|
}
|
||||||
jsonObject.put("length", length);
|
jsonObject.put("length", length);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TYPE_UINT:
|
case TYPE_UINT:
|
||||||
|
@ -1815,6 +1818,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
} else {
|
} else {
|
||||||
jsonObject.put("type", "string");
|
jsonObject.put("type", "string");
|
||||||
jsonObject.put("value", new String(bytes));
|
jsonObject.put("value", new String(bytes));
|
||||||
|
buf.get(); // skip null-termination;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue