Skip to content

feat(ble): expose advertised service UUIDs on MidiDevice - #168

Open
mortenboye wants to merge 3 commits into
masterfrom
feat/ble-service-uuids
Open

feat(ble): expose advertised service UUIDs on MidiDevice#168
mortenboye wants to merge 3 commits into
masterfrom
feat/ble-service-uuids

Conversation

@mortenboye

Copy link
Copy Markdown
Contributor

Reimplements the feature proposed in #134 by @LEggcookies for the current federated / universal_ble architecture. The original patch targeted the pre-federation native Android/iOS sources, which no longer exist — credit for the idea is theirs.

What

MidiDevice.serviceUUIDs exposes the service UUIDs a BLE peripheral advertised, so an app can narrow discovery beyond the MIDI service filter to specific hardware:

const vendorService = '0000fe59-0000-1000-8000-00805f9b34fb';
final devices = await midi.devices ?? const <MidiDevice>[];
final vendorDevices = devices.where((d) => d.serviceUUIDs.contains(vendorService));

Notes

  • Populated only on the Dart BLE transport path. Host-native devices — including Bluetooth devices routed through host MIDI APIs such as CoreMIDI — report an empty list.
  • UUIDs are normalized to lowercase 128-bit form via BleUuidParser. The pigeon-backed platforms already do this, but Linux and Web pass advertisement UUIDs through raw; normalizing keeps the field comparable everywhere. Unparseable entries are dropped.
  • An advertisement without a service list does not clear previously seen UUIDs: advertisement and scan-response packets arrive separately and only one carries the list.
  • Additive field with a const [] default, so the MidiDevice constructor and all subclasses stay source-compatible.

Tests

Four new cases in packages/flutter_midi_command_ble/test/ (exposure, normalization, empty-advertisement retention, replacement), plus an assertion in the platform-interface test pinning the empty-for-host-devices contract. flutter analyze clean; BLE, platform-interface and root suites pass.

Closes #134

mortenboye and others added 3 commits September 3, 2026 11:03
The `format` script existed but no job ran it, and four files on master
were already unformatted. `melos run test` skipped the example package,
so `example/test/widget_test.dart` — two tests over 230 lines of fakes
covering transport toggles and connection-error mapping — ran nowhere.
Nothing verified that the packages are still publishable, so a missing
LICENSE or an unresolvable constraint would surface at release.

dart_checks now runs `format:check` and `publish:dry-run`, and `test`
includes the example. The four drifted files are reformatted.

Also drops `native_linux_checks`: it ran the same `flutter test` on the
same OS that dart_checks had already run, so it added no signal while
reading as native coverage. The linux backend is pure Dart; example_linux
is what exercises it on a Linux host, and now depends on dart_checks
directly.

Adds a concurrency group so a new push cancels the run it superseded
(PRs only), and drops the stale `codex/restructure-repo-into-mono-repo-
with-melon` push trigger.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`test:native:android` ran only the android package's Kotlin unit tests,
so `FlutterMidiCommandBlePlugin.java` compiled for the first time during
the example app build in a later job. Adding `:flutter_midi_command_ble:
assembleDebug` moves that failure into the fast native job.

Verified it exits non-zero on a deliberate Java syntax error, and adds
~2s to the task when warm.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Adds `MidiDevice.serviceUUIDs`, populated from the universal_ble scan
result, so apps can narrow BLE discovery beyond the MIDI service filter
to specific hardware. UUIDs are normalized to lowercase 128-bit strings
because the Linux and Web backends pass advertisement UUIDs through raw.

An advertisement without a service list does not clear previously seen
UUIDs, since advertisement and scan-response packets arrive separately
and only one of them carries the list.

Reimplements the idea from #134 by @LEggcookies, whose original patch
targeted the pre-federation native Android/iOS code that no longer
exists.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mortenboye
mortenboye force-pushed the feat/ble-service-uuids branch from d72f53f to 47b971a Compare September 3, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant