如何设置BluetoothGattCharacteristic
名称
fun createBLEService(): BluetoothGattService {
val service = BluetoothGattService(UUID,
BluetoothGattService.SERVICE_TYPE_PRIMARY)
val characteristic = BluetoothGattCharacteristic(VUUID,
//Read-only characteristic, supports notifications
BluetoothGattCharacteristic.PROPERTY_READ or BluetoothGattCharacteristic.PROPERTY_NOTIFY,
BluetoothGattCharacteristic.PERMISSION_READ)
val configDescriptor = BluetoothGattDescriptor(CLIENT_CONFIG,
//Read/write descriptor
BluetoothGattDescriptor.PERMISSION_READ or BluetoothGattDescriptor.PERMISSION_WRITE)
val configDescriptor2 = BluetoothGattDescriptor(USER_DESCRIPTION,
BluetoothGattDescriptor.PERMISSION_READ or BluetoothGattDescriptor.PERMISSION_WRITE)
configDescriptor2.setValue("VSP".toByteArray())
characteristic.addDescriptor(configDescriptor)
characteristic.addDescriptor(configDescriptor2)
service.addCharacteristic(characteristic)
return service
}
BluetoothGattDescriptor
应该能够为BluetoothGattCharacteristic
添加用户描述。但是我找不到执行此操作的方法。