mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-18 14:31:23 +02:00
Mark active write type with *
instead of a long text string
This commit is contained in:
@@ -58,11 +58,26 @@ public class BluetoothDebug extends BluetoothCommunication {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String propertiesToString(int properties) {
|
private boolean isWriteType(int property, int writeType) {
|
||||||
|
switch (property) {
|
||||||
|
case BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE:
|
||||||
|
return writeType == BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE;
|
||||||
|
case BluetoothGattCharacteristic.PROPERTY_WRITE:
|
||||||
|
return writeType == BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT;
|
||||||
|
case BluetoothGattCharacteristic.PROPERTY_SIGNED_WRITE:
|
||||||
|
return writeType == BluetoothGattCharacteristic.WRITE_TYPE_SIGNED;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String propertiesToString(int properties, int writeType) {
|
||||||
StringBuilder names = new StringBuilder();
|
StringBuilder names = new StringBuilder();
|
||||||
for (int property : propertyString.keySet()) {
|
for (int property : propertyString.keySet()) {
|
||||||
if ((properties & property) != 0) {
|
if ((properties & property) != 0) {
|
||||||
names.append(propertyString.get(property));
|
names.append(propertyString.get(property));
|
||||||
|
if (isWriteType(property, writeType)) {
|
||||||
|
names.append('*');
|
||||||
|
}
|
||||||
names.append(", ");
|
names.append(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,19 +89,6 @@ public class BluetoothDebug extends BluetoothCommunication {
|
|||||||
return names.substring(0, names.length() - 2);
|
return names.substring(0, names.length() - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String writeTypeToString(int type) {
|
|
||||||
if (type == BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE) {
|
|
||||||
return "no response";
|
|
||||||
}
|
|
||||||
if (type == BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT) {
|
|
||||||
return "default";
|
|
||||||
}
|
|
||||||
if (type == BluetoothGattCharacteristic.WRITE_TYPE_SIGNED) {
|
|
||||||
return "signed";
|
|
||||||
}
|
|
||||||
return String.format("unknown type %d", type);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String permissionsToString(int permissions) {
|
private String permissionsToString(int permissions) {
|
||||||
if (permissions == 0) {
|
if (permissions == 0) {
|
||||||
return "";
|
return "";
|
||||||
@@ -99,11 +101,10 @@ public class BluetoothDebug extends BluetoothCommunication {
|
|||||||
included ? " (included)" : "");
|
included ? " (included)" : "");
|
||||||
|
|
||||||
for (BluetoothGattCharacteristic characteristic : service.getCharacteristics()) {
|
for (BluetoothGattCharacteristic characteristic : service.getCharacteristics()) {
|
||||||
Timber.d("|- characteristic %s #%d: %s, write type: %s%s",
|
Timber.d("|- characteristic %s #%d: %s%s",
|
||||||
BluetoothGattUuid.prettyPrint(characteristic.getUuid()),
|
BluetoothGattUuid.prettyPrint(characteristic.getUuid()),
|
||||||
characteristic.getInstanceId(),
|
characteristic.getInstanceId(),
|
||||||
propertiesToString(characteristic.getProperties()),
|
propertiesToString(characteristic.getProperties(), characteristic.getWriteType()),
|
||||||
writeTypeToString(characteristic.getWriteType()),
|
|
||||||
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) {
|
||||||
|
Reference in New Issue
Block a user