chore: print permissions characteristics
This commit is contained in:
@@ -85,7 +85,14 @@ private fun BluetoothGatt.printGattTable() {
|
|||||||
val characteristicsTable = service.characteristics.joinToString(
|
val characteristicsTable = service.characteristics.joinToString(
|
||||||
separator = "\n|--",
|
separator = "\n|--",
|
||||||
prefix = "|--"
|
prefix = "|--"
|
||||||
) { it.uuid.toString() }
|
) {
|
||||||
|
"${it.uuid.toString()} | " +
|
||||||
|
"readable: ${it.isReadable()}, " +
|
||||||
|
"writable: ${it.isWritable()}, " +
|
||||||
|
"writableWithoutResponse: ${it.isWritableWithoutResponse()}, " +
|
||||||
|
"notifiable: ${it.isNotifiable()}, " +
|
||||||
|
"indicatable: ${it.isIndicatable()}, "
|
||||||
|
}
|
||||||
Log.i(
|
Log.i(
|
||||||
"printGattTable", "\nService ${service.uuid}\nCharacteristics:\n$characteristicsTable"
|
"printGattTable", "\nService ${service.uuid}\nCharacteristics:\n$characteristicsTable"
|
||||||
)
|
)
|
||||||
@@ -102,9 +109,14 @@ fun BluetoothGattCharacteristic.isWritable(): Boolean =
|
|||||||
fun BluetoothGattCharacteristic.isWritableWithoutResponse(): Boolean =
|
fun BluetoothGattCharacteristic.isWritableWithoutResponse(): Boolean =
|
||||||
containsProperty(BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE)
|
containsProperty(BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE)
|
||||||
|
|
||||||
fun BluetoothGattCharacteristic.containsProperty(property: Int): Boolean {
|
fun BluetoothGattCharacteristic.isIndicatable(): Boolean =
|
||||||
return properties and property != 0
|
containsProperty(BluetoothGattCharacteristic.PROPERTY_INDICATE)
|
||||||
}
|
|
||||||
|
fun BluetoothGattCharacteristic.isNotifiable(): Boolean =
|
||||||
|
containsProperty(BluetoothGattCharacteristic.PROPERTY_NOTIFY)
|
||||||
|
|
||||||
|
fun BluetoothGattCharacteristic.containsProperty(property: Int): Boolean =
|
||||||
|
properties and property != 0
|
||||||
|
|
||||||
fun ByteArray.toHexString(): String =
|
fun ByteArray.toHexString(): String =
|
||||||
joinToString(separator = "", prefix = "0x") { String.format("%02X", it) }
|
joinToString(separator = "", prefix = "0x") { String.format("%02X", it) }
|
||||||
|
|||||||
Reference in New Issue
Block a user