juliansteenbakker / flutter_ble_peripheral

A Flutter package for advertising BLE data in peripheral mode
BSD 3-Clause "New" or "Revised" License
72 stars 50 forks source link

MIDI BLE peripheral - How to send events #192

Open sensn opened 3 months ago

sensn commented 3 months ago

Hello, I previously used an android lib, to make my phone act as a BLE MIDI device and send data.

private @NotNull final BluetoothGattCharacteristic measurement = new BluetoothGattCharacteristic(MIDI_MEASUREMENT_CHARACTERISTIC_UUID, PROPERTY_READ | PROPERTY_WRITE_NO_RESPONSE | PROPERTY_NOTIFY, PERMISSION_READ | PERMISSION_WRITE);

While playing around with the flutter example, I found out that I need to set service UUID, and now I can connect to the MIDI-BLE-peripheral. But I don't know how to send changing data (from a loop etc...) .

In weliems BleSeverExample I can just call " notifyCharacteristicChanged(event, measurement); after setting up and establishing the connection.

My config with weliems Java example is:

  public void startAdvertising(UUID serviceUUID) {
        AdvertiseSettings advertiseSettings = new AdvertiseSettings.Builder()
                .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
                .setConnectable(true)
                .setTimeout(0)
                .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
                .build();
    AdvertiseData advertiseData = new AdvertiseData.Builder()
            .setIncludeTxPowerLevel(true)
            .addServiceUuid(new ParcelUuid(serviceUUID))
            .build();

    AdvertiseData scanResponse = new AdvertiseData.Builder()
            .setIncludeDeviceName(true)
            .build();

    peripheralManager.startAdvertising(advertiseSettings, advertiseData, scanResponse);`

My questions are:

thanks