flutter_ymodem_lib library
A pure Dart implementation of the YModem file transfer protocol for Flutter, working on Android, iOS, Windows, macOS and Linux without any native code — ideal for BLE OTA firmware upgrades.
Typical usage together with flutter_blue_plus:
final ymodem = YModem(
fileName: 'firmware.bin',
source: YModemFileSource('/path/to/firmware.bin'),
onDataReady: (package) => characteristic.write(package, withoutResponse: true),
onProgress: (sent, total) => print('$sent / $total bytes'),
onSuccess: () => print('OTA done'),
onFailed: (reason) => print('OTA failed: $reason'),
);
// Start (optionally with custom hello/handshake data):
ymodem.start('Customized Data');
// Feed every BLE notification from the device back to the engine:
notifyCharacteristic.lastValueStream.listen(ymodem.onReceiveData);
Classes
- Crc16
- CRC-16/XMODEM (a.k.a. CRC-16-CCITT-FALSE).
- FlutterYModemPlugin
-
The plugin class registered by
dartPluginClassfor Android, iOS, Windows, macOS and Linux. - YModem
-
The sender side of the YModem protocol, ported from the well-known
Android library
YModemlib(com.bw.yml.YModem) to pure Dart. - YModemBytesSource
- A YModemSource that reads from an in-memory byte buffer.
- YModemFileSource
- A YModemSource that reads from a file on disk.
- YModemPacket
- Utility class that encapsulates the different YModem packages.
- YModemSource
- Abstract source of the file data that will be transmitted.
Typedefs
- YModemDataReady = void Function(Uint8List data)
- Called when a complete YModem package has been encapsulated and is ready to be sent to the receiver (e.g. written to a BLE characteristic).
- YModemFailedCallback = void Function(String reason)
- Called when the transmission failed after all retries.
- YModemLogCallback = void Function(String reason)
- Optional log callback for debugging the protocol state machine.
- YModemProgressCallback = void Function(int sent, int total)
-
Progress callback:
sentbytes of file data acknowledged so far,totalfile size in bytes. - YModemSuccessCallback = void Function()
- Called once the whole file has been correctly sent and acknowledged.
Exceptions / Errors
- YModemException
- Exception reported by YModem.start / YModem.onFailed.