android Table api oncharacteristicchanged未响应特征写入

android Table api oncharacteristicchanged未响应特征写入,android,characteristics,Android,Characteristics,我一直在研究谷歌Nexus6&9上的BLE读写功能 我想在远程设备上写入一个特征,并在写入后通知远程设备 下面的代码编写特征 if ((charaProp & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) { byte[] test = hexStringToByteArray("3132333435363738393031323334353637383930"); //byte[] value = new byt

我一直在研究谷歌Nexus6&9上的BLE读写功能

我想在远程设备上写入一个特征,并在写入后通知远程设备

下面的代码编写特征

if ((charaProp & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) {
    byte[] test = hexStringToByteArray("3132333435363738393031323334353637383930");
    //byte[] value = new byte[1];
    //value[0] = (byte) (21 & 0xFF);
    Log.d("text",characteristic.getDescriptors().size()+"");
    BluetoothGattDescriptor descriptor1 =  characteristic.getDescriptor(UUID.fromString(serviceOneCharUuid));
    descriptor1.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
    characteristic.setValue(test);
    if(mBluetoothGatt.writeDescriptor(descriptor1)){Log.d("text","writedescriptor");}
    if(mBluetoothGatt.writeCharacteristic(characteristic)){Log.d("text","setValue");}}
我看过一些帖子,告诉我先写描述符,但它不起作用

我试着写usb设备,它显示了写功能的预期工作。而且,本地设备上的回调函数也可以工作

但是,不会调用远程设备上的oncharacteristicchanged函数 下面是在名为BluetoothLeService的类中编写的所有回调函数的代码

    @Override
    public void onCharacteristicWrite(BluetoothGatt gatt,BluetoothGattCharacteristic characteristic, int status){
        Log.d("text",new String(characteristic.getValue()));
    }
    @Override
    public void onCharacteristicRead(BluetoothGatt gatt,BluetoothGattCharacteristic characteristic, int status) {
        if (status == BluetoothGatt.GATT_SUCCESS) {
            broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
            Log.d("text","on read");
        }
    }

    @Override
    public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
        Log.d("text", new String(characteristic.getValue()));
    }

有人知道这些代码中可能有什么错误,或者我遗漏了什么吗?

我在更改oncharacteristics以调用时遇到了类似的问题。我让它工作的方法是在调用onDescriptorWrite之后,再将特性写入可扩展设备