Enhance USB serial plugin for Android and iPadOS with DriverKit support

- Updated README.md to reflect platform support for iPadOS.
- Implemented isDriverAvailable method in FlutterUsbSerialPlugin for DriverKit readiness check.
- Added DriverKitSerialClient C source and header files for iPadOS integration.
- Created Swift Package for iPadOS support.
- Updated pubspec.yaml and flutter_usb_serial.dart to clarify platform compatibility.
- Enhanced tests to verify isDriverAvailable functionality.

Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
Tony
2026-08-01 20:40:46 +08:00
parent 2d7fc43ea2
commit 17414656a9
11 changed files with 724 additions and 31 deletions
+25 -12
View File
@@ -1,18 +1,31 @@
# flutter_usb_serial
A new Flutter plugin project.
Flutter USB serial transport for Android and DriverKit-enabled iPadOS.
## Getting Started
## Platforms
This project is a starting point for a Flutter
[plug-in package](https://flutter.dev/to/develop-plugins),
a specialized package that includes platform-specific implementation code for
Android and/or iOS.
- Android uses `usb-serial-for-android` and the normal Android USB permission
flow.
- iPadOS 16+ uses Swift Package Manager and a user client exposed by a
USBDriverKit extension embedded in the host app. DriverKit USB support is
available only on iPads with an M-series chip.
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
The package contains the SwiftPM client plugin, not a reusable pre-signed
DriverKit extension. Apple provisions USB transport entitlements to the host
app and driver for a specific USB vendor. The host app must:
The plugin project was generated without specifying the `--platforms` flag, no platforms are currently supported.
To add platforms, run `flutter create -t plugin --platforms <platforms> .` in this directory.
You can also find a detailed instruction on how to add platforms in the `pubspec.yaml` at https://flutter.dev/to/pubspec-plugin-platforms.
1. Embed a DriverKit extension whose `IOUserClass` is
`DaliMasterEspressifUsbDriver`, or adapt the client service name.
2. Add `com.apple.developer.driverkit.communicates-with-drivers` to the app.
3. Sign the extension with `com.apple.developer.driverkit` and a
`com.apple.developer.driverkit.transport.usb` entitlement approved for its
USB vendor ID.
4. Enable Swift Package Manager integration for Flutter iOS plugins.
Call `FlutterUsbSerial.isDriverAvailable()` during startup before showing a USB
transport. It returns `true` only when a compatible driver service is loaded.
The DaliMaster host implementation is deliberately restricted to Espressif
vendor ID `0x303A` and the USB Serial/JTAG interface. Serial parameter and modem
line methods are accepted for API compatibility; the ESP USB Serial/JTAG bulk
transport does not use UART baud or line coding.