Android BLE:如何发送写请求而不是写命令?
我正在尝试从智能手机安卓应用程序向蓝牙低能耗蓝牙设备发送数据包 我知道如何发送Write命令: 大概是这样的: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
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_默认值