Skip to content

offcode-oy/mcumgr-dart

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A client library for the mcumgr device management protocol.

This is offcode's fork of the original mcumgr.dart package. The original package was not maintained and had some issues. This fork aims to fix those issues and add new features.

Features

  • Upload firmware updates (DFU)
  • Read and write files
  • Run commands

Usage (!NOT UPDATED)

This package just implements the protocol, you need to bring your own transport layer.

import 'package:mcumgr/mcumgr.dart';

final client = Client(
    input: receiveStream, // bytes received from the device (Stream<List<int>>)
    output: (bytes) { /* send bytes (List<int>) to the device */ }
);

Bluetooth LE

Implementing the SMP Bluetooth transport using flutter_blue:

final serviceUuid = Guid('8d53dc1d-1db7-4cd3-868b-8a527460aa84');
final characteristicUuid = Guid('da2e7828-fbce-4e01-ae9e-261174997c48');

// Increase the Bluetooth MTU (this is important!)
await device.requestMtu(252);

// Find the service and its characteristic
final service = services.singleWhere((e) => e.uuid == serviceUuid);
final characteristic = service.characteristics.singleWhere((e) => e.uuid == characteristicUuid);

// Subscribe to messages from the device
await characteristic.setNotifyValue(true);

final client = Client(
  // Used to receive messages from the device
  input: characteristic.onValueChangedStream,
  // Used to send messages to the device
  output: (value) => characteristic.write(value, withoutResponse: true),
);

Firmware updates

  1. Send the image to the device
  2. Set the image to pending (bootloader will load it on the next boot only)
  3. Tell the device to reboot
  4. Reconnect to the device
  5. Confirm the new image (bootloader will always load it)

About

Dart mcumgr client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 96.3%
  • Ruby 1.9%
  • Kotlin 1.1%
  • Other 0.7%