mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-23 08:43:15 +02:00
Print descriptor value as text in addition to hex
This commit is contained in:
@@ -96,6 +96,10 @@ public class BluetoothDebug extends BluetoothCommunication {
|
|||||||
return String.format(" (permissions=0x%x)", permissions);
|
return String.format(" (permissions=0x%x)", permissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String byteToString(byte[] value) {
|
||||||
|
return new String(value).replaceAll("\\p{Cntrl}", "?");
|
||||||
|
}
|
||||||
|
|
||||||
private void logService(BluetoothGattService service, boolean included) {
|
private void logService(BluetoothGattService service, boolean included) {
|
||||||
Timber.d("Service %s%s", BluetoothGattUuid.prettyPrint(service.getUuid()),
|
Timber.d("Service %s%s", BluetoothGattUuid.prettyPrint(service.getUuid()),
|
||||||
included ? " (included)" : "");
|
included ? " (included)" : "");
|
||||||
@@ -108,8 +112,7 @@ public class BluetoothDebug extends BluetoothCommunication {
|
|||||||
permissionsToString(characteristic.getPermissions()));
|
permissionsToString(characteristic.getPermissions()));
|
||||||
byte[] value = characteristic.getValue();
|
byte[] value = characteristic.getValue();
|
||||||
if (value != null && value.length > 0) {
|
if (value != null && value.length > 0) {
|
||||||
Timber.d("|--> value: %s (%s)", byteInHex(value),
|
Timber.d("|--> value: %s (%s)", byteInHex(value), byteToString(value));
|
||||||
characteristic.getStringValue(0).replaceAll("\\p{Cntrl}", "?"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (BluetoothGattDescriptor descriptor : characteristic.getDescriptors()) {
|
for (BluetoothGattDescriptor descriptor : characteristic.getDescriptors()) {
|
||||||
@@ -119,7 +122,7 @@ public class BluetoothDebug extends BluetoothCommunication {
|
|||||||
|
|
||||||
value = descriptor.getValue();
|
value = descriptor.getValue();
|
||||||
if (value != null && value.length > 0) {
|
if (value != null && value.length > 0) {
|
||||||
Timber.d("|-----> value: %s", byteInHex(value));
|
Timber.d("|-----> value: %s (%s)", byteInHex(value), byteToString(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user