Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android BLE:如何发送写请求而不是写命令?_Android_Bluetooth_Bluetooth Lowenergy_Android Bluetooth_Bluetooth Gatt - Fatal编程技术网

Android BLE:如何发送写请求而不是写命令?

Android BLE:如何发送写请求而不是写命令?,android,bluetooth,bluetooth-lowenergy,android-bluetooth,bluetooth-gatt,Android,Bluetooth,Bluetooth Lowenergy,Android Bluetooth,Bluetooth Gatt,我正在尝试从智能手机安卓应用程序向蓝牙低能耗蓝牙设备发送数据包 我知道如何发送Write命令: 大概是这样的: public void onServicesDiscovered(final BluetoothGatt gatt, int status) { List<BluetoothGattService> services = gatt.getServices(); for (BluetoothGattService service : servi

我正在尝试从智能手机安卓应用程序向蓝牙低能耗蓝牙设备发送数据包

我知道如何发送Write命令:

大概是这样的:

public void onServicesDiscovered(final BluetoothGatt gatt, int status) {
        List<BluetoothGattService> services = gatt.getServices();
        for (BluetoothGattService service : services) {
            for (final BluetoothGattCharacteristic characteristic : service.getCharacteristics()) {
                if (characteristic.getUuid().toString().equals(CONTROL_UUID)) {
                    boolean setValue = characteristic.setValue(new byte[]{/*..BYTES.*/});
                    boolean writeCharacteristic = gatt.writeCharacteristic(characteristic);
                }
            }
        }
    }
当我在Wireshark嗅探应用程序中看到这个sent命令时,我看到了类似这样的东西

但是我还需要发送这样的东西,不是写命令,而是写请求

控制设备在连接后仅发送此写入请求一次的官方应用程序

似乎没有它我就无法控制那个装置

因此,在发送任何写入命令之前,我需要先发送此写入请求,请参见

您需要使用WRITE_TYPE_默认值