From 439ade356eb3d27cd1afd297aca20722ff05d548 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Thu, 15 Nov 2018 21:10:15 +0100 Subject: [PATCH] Print a bit less information in debug driver --- .../core/bluetooth/BluetoothDebug.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothDebug.java b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothDebug.java index 1efdfb2c..0a978378 100644 --- a/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothDebug.java +++ b/android_app/app/src/main/java/com/health/openscale/core/bluetooth/BluetoothDebug.java @@ -87,15 +87,24 @@ public class BluetoothDebug extends BluetoothCommunication { return String.format("unknown type %d", type); } + private String permissionsToString(int permissions) { + if (permissions == 0) { + return ""; + } + return String.format(" (permissions=0x%x)", permissions); + } + private void logService(BluetoothGattService service, boolean included) { Timber.d("Service %s%s", BluetoothGattUuid.prettyPrint(service.getUuid()), included ? " (included)" : ""); for (BluetoothGattCharacteristic characteristic : service.getCharacteristics()) { - Timber.d("|- characteristic %s (instance %d): %s, write type: %s (permissions=0x%x)", + Timber.d("|- characteristic %s #%d: %s, write type: %s%s", BluetoothGattUuid.prettyPrint(characteristic.getUuid()), - characteristic.getInstanceId(), propertiesToString(characteristic.getProperties()), - writeTypeToString(characteristic.getWriteType()), characteristic.getPermissions()); + characteristic.getInstanceId(), + propertiesToString(characteristic.getProperties()), + writeTypeToString(characteristic.getWriteType()), + permissionsToString(characteristic.getPermissions())); byte[] value = characteristic.getValue(); if (value != null && value.length > 0) { Timber.d("|--> value: %s (%s)", byteInHex(value), @@ -103,9 +112,9 @@ public class BluetoothDebug extends BluetoothCommunication { } for (BluetoothGattDescriptor descriptor : characteristic.getDescriptors()) { - Timber.d("|--- descriptor %s (permissions=0x%x)", + Timber.d("|--- descriptor %s%s", BluetoothGattUuid.prettyPrint(descriptor.getUuid()), - descriptor.getPermissions()); + permissionsToString(descriptor.getPermissions())); value = descriptor.getValue(); if (value != null && value.length > 0) {