Skip to content

feat: migrate AT/SysEx protocol from Dart to Rust FFI#38

Merged
husamettinarabaci merged 2 commits into
developfrom
feat/ffi-proto-migration
Mar 4, 2026
Merged

feat: migrate AT/SysEx protocol from Dart to Rust FFI#38
husamettinarabaci merged 2 commits into
developfrom
feat/ffi-proto-migration

Conversation

@husamettinarabaci

Copy link
Copy Markdown
Member

Summary

Migrate AT command encoding/parsing and SysEx framing from pure Dart implementation to Rust FFI via hexaTuneProto shared library (Option A: Pure FFI from PLANS.md).

Changes

New Files

  • lib/src/core/proto/hexa_tune_proto_ffi.dart — Dart FFI binding (from hexaTuneProto v0.1.0)
  • lib/src/core/proto/proto_service.dart — Singleton native library loader (Android .so / iOS static)
  • lib/src/core/proto/at_command.dart — FFI-backed ATCommand (drop-in replacement)
  • lib/src/core/proto/at_response.dart — FFI-backed ATResponse + parseATResponse() + extractAndParseATResponse()
  • android/app/src/main/jniLibs/{arm64-v8a,armeabi-v7a,x86_64}/libhexa_tune_proto_ffi.so — Android native libs
  • ios/Frameworks/HexaTuneProto.xcframework/ — iOS framework

Modified Files

  • pubspec.yaml — Added ffi: ^2.1.0
  • lib/src/core/device/device.dart — Updated imports, replaced SysEx+AT parsing with FFI
  • lib/src/core/service/device_service.dart — Updated imports
  • lib/src/pages/layout.dart — Updated imports
  • android/gradle.properties — Set JDK 21 for Gradle (system JDK 25 incompatible)
  • android/app/build.gradle.kts — Updated desugar_jdk_libs 2.0.4 → 2.1.4

Deleted Files

  • lib/src/core/at/at.dart — Old Dart AT implementation (255 lines)
  • lib/src/core/sysex/sysex.dart — Old Dart SysEx implementation (161 lines)

Testing

  • flutter analyze — 0 errors
  • ✅ Build + run on Pixel 9a (Android 16, arm64)
  • ✅ Real device test: hexaTune hexaGenMini connected via USB MIDI
    • VERSION query → v1.0.0
    • PREPARE → COMPLETED
    • 2x FREQ commands → success
    • GENERATE → GENERATING stepId 0→1 → COMPLETED
  • ✅ Simulation mode: works without device (auto-detect)
  • ✅ Wire protocol byte-identical (SysEx framing verified via logs)

husamettinarabaci and others added 2 commits March 4, 2026 09:21
Replace hand-written Dart AT command encoding/parsing and SysEx framing
with FFI calls to the hexaTuneProto Rust library (v0.1.0).

- Add lib/src/core/proto/ with FFI-backed ATCommand, ATResponse,
  ProtoService singleton, and Dart FFI binding
- Bundle native libraries: Android .so (3 ABIs) + iOS xcframework
- Update device.dart, device_service.dart, layout.dart imports
- Replace SysEx.extractSysexPayload() + parseATResponse() with
  extractAndParseATResponse() using FFI pipeline
- Delete old lib/src/core/at/at.dart and lib/src/core/sysex/sysex.dart
- Add ffi ^2.1.0 dependency to pubspec.yaml

Public API (ATCommand factories, ATResponse getters) is unchanged —
no modifications needed in UI or service layer method signatures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add org.gradle.java.home=/usr/lib/jvm/java-21-openjdk to gradle.properties
  (system default JDK 25 is not supported by Gradle 8.12)
- Update desugar_jdk_libs from 2.0.4 to 2.1.4

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added type:infra Infrastructure, CI/CD, build system module:source Source Code labels Mar 4, 2026
@github-project-automation github-project-automation Bot moved this to 📥 Inbox / Ideas in hexaTune Project Mar 4, 2026
@husamettinarabaci husamettinarabaci merged commit 99ceec2 into develop Mar 4, 2026
6 of 8 checks passed
@github-project-automation github-project-automation Bot moved this from 📥 Inbox / Ideas to Done in hexaTune Project Mar 4, 2026
@husamettinarabaci husamettinarabaci deleted the feat/ffi-proto-migration branch March 4, 2026 06:38
This was referenced Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:source Source Code type:infra Infrastructure, CI/CD, build system

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant