0

I'm trying to send packets to bluetooth low energy (BLE) device from smartphone (Android App)

I know how to send Write Command:

something like this:

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);
                }
            }
        }
    }

when I see this sent command in Wireshark (sniffing app), I see something like this

enter image description here

but I also need to send something like this (not write command, but write request)

enter image description here

official app which controls that devices sends this write request only once after connecting

seems without it I would not be able to control that device

so before I would send any write command I need to send this write request first

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
user25
  • 2,873
  • 2
  • 30
  • 66

1 Answers1

1

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

You need to use the WRITE_TYPE_DEFAULT.

Emil
  • 16,784
  • 2
  • 41
  • 52