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