Android 关贸总协定';写入后没有通知数据

Android 关贸总协定';写入后没有通知数据,android,bluetooth,bluetooth-lowenergy,Android,Bluetooth,Bluetooth Lowenergy,我有一个定制服务(0000fff0),服务中有应报告特征(0000fff1)和可写特征(0000fff2)。(没有“读取”特性) 根据我的蓝牙设备的API文档, 数据包格式如下: 68 xx xxxx xx ... xx 16 (one pair of 'xx' is a byte hex code) 68->标题(1字节) xx->功能代码(1字节) xxxx->数据长度(2字节) …->数据(…字节) xx->校验和(1字节) 16->尾部(1字节) 写在文档上的示例数据请求代码是 6

我有一个定制服务(
0000fff0
),服务中有应报告特征(
0000fff1
)和可写特征(
0000fff2
)。(没有“读取”特性) 根据我的蓝牙设备的API文档, 数据包格式如下:

68 xx xxxx xx ... xx 16
(one pair of 'xx' is a byte hex code)
  • 68->标题(1字节)
  • xx->功能代码(1字节)
  • xxxx->数据长度(2字节)
  • …->数据(…字节)
  • xx->校验和(1字节)
  • 16->尾部(1字节)
写在文档上的示例数据请求代码是

68 06 01 00 00 6f 16
  • 68->收割台
  • 06->功能代码
  • 01 00->数据长度
  • 00->数据
  • 6f->校验和
  • 16->尾部
然后根据文档,我应该从设备获得响应,比如
68 86 0e 00 46 00 00 00 00 00 00 00 00 43 16
,但是我从通知特性中没有得到任何响应

从onCharacteristicWrite回调中,我也获得了GATT\U成功。所以我认为写作不是问题。该通知也适用于其他心率设备(标准<代码>心率测量特性)

该文档没有说明响应数据将通过通知特性提供。我只是想它可能在那里

我想知道API文档上的示例是错误的还是遗漏了什么?有没有像http通信这样的“请求-响应”格式?所以每次我写一些关于可写特征的东西,我都会从设备或类似的东西得到一些响应

    private final ExpandableListView.OnChildClickListener servicesListClickListner =
        new ExpandableListView.OnChildClickListener() {
            @Override
            public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
                                        int childPosition, long id) {
                if (mGattCharacteristics != null) {
                    final BluetoothGattCharacteristic characteristic =
                            mGattCharacteristics.get(groupPosition).get(childPosition);
                    final int charaProp = characteristic.getProperties();
                    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) > 0) {
                        // If there is an active notification on a characteristic, clear
                        // it first so it doesn't update the data field on the user interface.
                        if (mNotifyCharacteristic != null) {
                            mBluetoothLeService.setCharacteristicNotification(
                                    mNotifyCharacteristic, false);
                            mNotifyCharacteristic = null;
                        }
                        mBluetoothLeService.readCharacteristic(characteristic);
                    }
                    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
                        mNotifyCharacteristic = characteristic;
                        mBluetoothLeService.setCharacteristicNotification(
                                characteristic, true);
                    }

                    if ((charaProp | BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) {
                        if(SampleGattAttributes.BLACK_WRITE.equals(characteristic.getUuid().toString())){
                            mBluetoothLeService.writeRemoteCharacteristic(characteristic);
                        }
                    }

                        return true;
                }
                return false;
            }
};
public void writeRemoteCharacteristic(BluetoothGattCharacteristic characteristic) {
    if(mBluetoothAdapter == null || mBluetoothGatt == null) {
        Log.w(TAG, "BluetoothAdapter not initialized");
        return;
    }
    if (SampleGattAttributes.BLACK_WRITE.equals(characteristic.getUuid().toString())) {
        byte[] data = new byte[7];
        data[0] = (byte)0x68;
        data[1] = (byte)0x06;
        data[2] = (byte)0x01;
        data[3] = (byte)0x00;
        data[4] = (byte)0x01;
        data[5] = (byte)0x70;
        data[6] = (byte)0x16;

        characteristic.setValue(data);
        mBluetoothGatt.writeCharacteristic(characteristic);
    }
    mBluetoothGatt.writeCharacteristic(characteristic);
}

private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
    @Override
    public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status){
        if (status == BluetoothGatt.GATT_SUCCESS) {
            broadcastUpdate(ACTION_DATA_AVAILABLE,characteristic);
        }
    }

你同意那个特征吗?是的,我同意。。。我添加了我的源代码片段。你订阅了那个特性吗?是的,我订阅了。。。我添加了源代码的片段。