如何设置BluetoothGattCharacteristic名称(Android)

时间:2019-04-30 22:49:58

标签: android bluetooth-lowenergy bluetooth-gatt

如何设置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添加用户描述。但是我找不到执行此操作的方法。

enter image description here

0 个答案:

没有答案