mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-18 14:31:23 +02:00
Pretty print uuids in BluetoothCommunication
This commit is contained in:
@@ -266,7 +266,7 @@ public abstract class BluetoothCommunication {
|
|||||||
BluetoothGattCharacteristic gattCharacteristic = bluetoothGatt.getService(service)
|
BluetoothGattCharacteristic gattCharacteristic = bluetoothGatt.getService(service)
|
||||||
.getCharacteristic(characteristic);
|
.getCharacteristic(characteristic);
|
||||||
|
|
||||||
Timber.d("Read characteristic %s", characteristic);
|
Timber.d("Read characteristic %s", BluetoothGattUuid.prettyPrint(characteristic));
|
||||||
bluetoothGatt.readCharacteristic(gattCharacteristic);
|
bluetoothGatt.readCharacteristic(gattCharacteristic);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +274,7 @@ public abstract class BluetoothCommunication {
|
|||||||
BluetoothGattDescriptor gattDescriptor = bluetoothGatt.getService(service)
|
BluetoothGattDescriptor gattDescriptor = bluetoothGatt.getService(service)
|
||||||
.getCharacteristic(characteristic).getDescriptor(descriptor);
|
.getCharacteristic(characteristic).getDescriptor(descriptor);
|
||||||
|
|
||||||
Timber.d("Read descriptor %s", descriptor);
|
Timber.d("Read descriptor %s", BluetoothGattUuid.prettyPrint(descriptor));
|
||||||
bluetoothGatt.readDescriptor(gattDescriptor);
|
bluetoothGatt.readDescriptor(gattDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,7 +285,7 @@ public abstract class BluetoothCommunication {
|
|||||||
* @param characteristic the Bluetooth UUID characteristic
|
* @param characteristic the Bluetooth UUID characteristic
|
||||||
*/
|
*/
|
||||||
protected void setIndicationOn(UUID service, UUID characteristic, UUID descriptor) {
|
protected void setIndicationOn(UUID service, UUID characteristic, UUID descriptor) {
|
||||||
Timber.d("Set indication on for %s", characteristic);
|
Timber.d("Set indication on for %s", BluetoothGattUuid.prettyPrint(characteristic));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BluetoothGattCharacteristic gattCharacteristic =
|
BluetoothGattCharacteristic gattCharacteristic =
|
||||||
@@ -310,7 +310,7 @@ public abstract class BluetoothCommunication {
|
|||||||
* @param characteristic the Bluetooth UUID characteristic
|
* @param characteristic the Bluetooth UUID characteristic
|
||||||
*/
|
*/
|
||||||
protected void setNotificationOn(UUID service, UUID characteristic, UUID descriptor) {
|
protected void setNotificationOn(UUID service, UUID characteristic, UUID descriptor) {
|
||||||
Timber.d("Set notification on for %s", characteristic);
|
Timber.d("Set notification on for %s", BluetoothGattUuid.prettyPrint(characteristic));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BluetoothGattCharacteristic gattCharacteristic =
|
BluetoothGattCharacteristic gattCharacteristic =
|
||||||
@@ -335,7 +335,7 @@ public abstract class BluetoothCommunication {
|
|||||||
* @param characteristic the Bluetooth UUID characteristic
|
* @param characteristic the Bluetooth UUID characteristic
|
||||||
*/
|
*/
|
||||||
protected void setNotificationOff(UUID service, UUID characteristic, UUID descriptor) {
|
protected void setNotificationOff(UUID service, UUID characteristic, UUID descriptor) {
|
||||||
Timber.d("Set notification off for %s", characteristic);
|
Timber.d("Set notification off for %s", BluetoothGattUuid.prettyPrint(characteristic));
|
||||||
|
|
||||||
BluetoothGattCharacteristic gattCharacteristic =
|
BluetoothGattCharacteristic gattCharacteristic =
|
||||||
bluetoothGatt.getService(service).getCharacteristic(characteristic);
|
bluetoothGatt.getService(service).getCharacteristic(characteristic);
|
||||||
@@ -579,11 +579,12 @@ public abstract class BluetoothCommunication {
|
|||||||
descriptor.gattObject.setValue(descriptor.value);
|
descriptor.gattObject.setValue(descriptor.value);
|
||||||
|
|
||||||
Timber.d("Write descriptor %s: %s (queue: %d %d)",
|
Timber.d("Write descriptor %s: %s (queue: %d %d)",
|
||||||
descriptor.gattObject.getUuid(), byteInHex(descriptor.gattObject.getValue()),
|
BluetoothGattUuid.prettyPrint(descriptor.gattObject.getUuid()),
|
||||||
|
byteInHex(descriptor.gattObject.getValue()),
|
||||||
descriptorRequestQueue.size(), characteristicRequestQueue.size());
|
descriptorRequestQueue.size(), characteristicRequestQueue.size());
|
||||||
if (!bluetoothGatt.writeDescriptor(descriptor.gattObject)) {
|
if (!bluetoothGatt.writeDescriptor(descriptor.gattObject)) {
|
||||||
Timber.e("Failed to initiate write of descriptor %s",
|
Timber.e("Failed to initiate write of descriptor %s",
|
||||||
descriptor.gattObject.getUuid());
|
BluetoothGattUuid.prettyPrint(descriptor.gattObject.getUuid()));
|
||||||
}
|
}
|
||||||
openRequest = true;
|
openRequest = true;
|
||||||
return;
|
return;
|
||||||
@@ -595,12 +596,13 @@ public abstract class BluetoothCommunication {
|
|||||||
characteristic.gattObject.setValue(characteristic.value);
|
characteristic.gattObject.setValue(characteristic.value);
|
||||||
|
|
||||||
Timber.d("Write characteristic %s: %s (type: %d; queue: %d %d)",
|
Timber.d("Write characteristic %s: %s (type: %d; queue: %d %d)",
|
||||||
characteristic.gattObject.getUuid(), byteInHex(characteristic.gattObject.getValue()),
|
BluetoothGattUuid.prettyPrint(characteristic.gattObject.getUuid()),
|
||||||
|
byteInHex(characteristic.gattObject.getValue()),
|
||||||
characteristic.gattObject.getWriteType(),
|
characteristic.gattObject.getWriteType(),
|
||||||
descriptorRequestQueue.size(), characteristicRequestQueue.size());
|
descriptorRequestQueue.size(), characteristicRequestQueue.size());
|
||||||
if (!bluetoothGatt.writeCharacteristic(characteristic.gattObject)) {
|
if (!bluetoothGatt.writeCharacteristic(characteristic.gattObject)) {
|
||||||
Timber.e("Failed to initiate write of characteristic %s",
|
Timber.e("Failed to initiate write of characteristic %s",
|
||||||
characteristic.gattObject.getUuid());
|
BluetoothGattUuid.prettyPrint(characteristic.gattObject.getUuid()));
|
||||||
}
|
}
|
||||||
openRequest = true;
|
openRequest = true;
|
||||||
return;
|
return;
|
||||||
@@ -732,7 +734,8 @@ public abstract class BluetoothCommunication {
|
|||||||
final BluetoothGattCharacteristic characteristic,
|
final BluetoothGattCharacteristic characteristic,
|
||||||
final int status) {
|
final int status) {
|
||||||
Timber.d("onCharacteristicRead %s (status=%d): %s",
|
Timber.d("onCharacteristicRead %s (status=%d): %s",
|
||||||
characteristic.getUuid(), status, byteInHex(characteristic.getValue()));
|
BluetoothGattUuid.prettyPrint(characteristic.getUuid()),
|
||||||
|
status, byteInHex(characteristic.getValue()));
|
||||||
|
|
||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -747,7 +750,8 @@ public abstract class BluetoothCommunication {
|
|||||||
public void onCharacteristicChanged(final BluetoothGatt gatt,
|
public void onCharacteristicChanged(final BluetoothGatt gatt,
|
||||||
final BluetoothGattCharacteristic characteristic) {
|
final BluetoothGattCharacteristic characteristic) {
|
||||||
Timber.d("onCharacteristicChanged %s: %s",
|
Timber.d("onCharacteristicChanged %s: %s",
|
||||||
characteristic.getUuid(), byteInHex(characteristic.getValue()));
|
BluetoothGattUuid.prettyPrint(characteristic.getUuid()),
|
||||||
|
byteInHex(characteristic.getValue()));
|
||||||
|
|
||||||
handler.post(new Runnable() {
|
handler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -762,7 +766,8 @@ public abstract class BluetoothCommunication {
|
|||||||
BluetoothGattDescriptor descriptor,
|
BluetoothGattDescriptor descriptor,
|
||||||
int status) {
|
int status) {
|
||||||
Timber.d("onDescriptorRead %s (status=%d): %s",
|
Timber.d("onDescriptorRead %s (status=%d): %s",
|
||||||
descriptor.getUuid(), status, byteInHex(descriptor.getValue()));
|
BluetoothGattUuid.prettyPrint(descriptor.getUuid()),
|
||||||
|
status, byteInHex(descriptor.getValue()));
|
||||||
|
|
||||||
postDelayedHandleRequests();
|
postDelayedHandleRequests();
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,10 @@ public class BluetoothGattUuid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final String prettyPrint(UUID uuid) {
|
public static final String prettyPrint(UUID uuid) {
|
||||||
|
if (uuid == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
|
||||||
String str = uuid.toString();
|
String str = uuid.toString();
|
||||||
|
|
||||||
if (str.endsWith(STANDARD_SUFFIX)) {
|
if (str.endsWith(STANDARD_SUFFIX)) {
|
||||||
|
Reference in New Issue
Block a user