0

我正在尝试从智能手机(Android 应用程序)向蓝牙低功耗(BLE)设备发送数据包

我知道如何发送写命令:

像这样的东西:

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(嗅探应用程序)中看到这个发送的命令时,我看到了类似这样的内容

在此处输入图像描述

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

在此处输入图像描述

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

似乎没有它我将无法控制该设备

所以在我发送任何写命令之前,我需要先发送这个写请求

4

1 回答 1

1

https://developer.android.com/reference/android/bluetooth/BluetoothGattCharacteristic.html#setWriteType(int)

您需要使用WRITE_TYPE_DEFAULT.

于 2018-06-26T16:40:51.537 回答