mcumgr_dart 0.3.0
mcumgr_dart: ^0.3.0 copied to clipboard
Pure-Dart client for the SMP / MCUmgr protocol (OS, Image/DFU and Filesystem groups) on Zephyr and MCUboot devices. Bring your own transport; no Flutter.
Changelog #
0.3.0 #
Serial and other byte-stream transports no longer have to reimplement Zephyr's
framing. Purely additive — no breaking changes, no new dependencies, and the
package stays platform-agnostic (the codec is dart:convert + dart:typed_data
only, so Web support is unaffected).
-
uart_mcumgrencapsulation (UartMcumgrCodec/UartMcumgrDecoder). On BLE the bytes on the characteristic are the SMP frame, soSmpTransportneeds nothing else. A byte stream has no packet boundaries, and Zephyr'suart_mcumgrwraps each frame in a length prefix, a CRC-16/XMODEM and base64 lines marked0x06 0x09/0x04 0x14.UartMcumgrCodec.encode()produces those lines andUartMcumgrDecoder.add()recovers whole SMP frames from arbitrary chunk boundaries, leaving a serial or TCP transport with nothing to do but move bytes.The decoder is deliberately forgiving, because a device's console log usually shares the pipe: unmarked lines are skipped, and a packet failing its length or CRC check is dropped rather than thrown, so one bad packet cannot wedge the stream. Both are counted in
badFrames.encode()emits a single line by default and splits across continuation lines when given amaxLineLength.Accumulation is bounded by
maxPacketBytes(default 4096). A device that emits a start marker and then never completes the packet — wedged mid-transmission, or a console line that happens to open with the marker bytes — would otherwise grow the buffer without limit. An oversized packet is discarded, counted, and the decoder resumes at the next start marker.
0.2.0 #
Adds the two remaining read/write management groups from stock Zephyr, both requested in #1. Purely additive — no breaking changes.
-
Statistics group (2) —
StatMgmt.list()enumerates the groups a device exposes,show()reads one group's counters,showAll()does both. Results come back asStatGroup, whosefieldsare the entries that decoded as integers and whoserawFieldspreserves everything as received, so a non-stock stats implementation loses nothing silently. Read-only, because MCUmgr is: there is no command to reset a counter. -
Settings group (3) —
SettingsMgmtcovers read/write (id 0), delete (1), commit (2) and load/save (3).save({name})saves one subtree when named and the whole tree when not; an empty name is rejected locally, since Zephyr answersEINVALfor it.Values are opaque bytes both ways — the settings subsystem carries no type information, so the API does not invent any.
SettingValueoffersasInt,asBoolandasStringfor the common cases with their assumptions stated (little-endian, caller-known width), andwriteInt/writeBool/writeStringencode the same way.Truncation is handled explicitly: a device that hits
CONFIG_MCUMGR_GRP_SETTINGS_VALUE_LENreturns a short value in an ordinary success response, flagged only by an extramax_sizekey.SettingValue.truncatedsurfaces it, andasIntrefuses to decode a truncated value — a short integer is a different number, not a partial one. -
Group-specific error names for groups 2 and 3, so
SmpExceptionreadssettings: key not found (rc=3)rather thangroup 3 rc=3. Previously only the image group had a table. -
FakeTransportmoved totest/fake_transport.dartand is shared by the suite; both new groups are covered without hardware.
0.1.0 #
Initial release. Extracted from the ProtoCentral OpenView 3 / HealthyPi Move apps as a standalone, pure-Dart library.
- SMP core —
SmpMessage(8-byte header + CBOR, SMP v1rc/ v2errnormalisation and error labels),SmpTransport(abstract byte transport),SmpClient(rollingseqrequest/response matching, fragment reassembly, per-request timeout). - OS group (
OsMgmt, group 0) — echo, mcumgr params, task stat, datetime get/set, reset. - Image group (
ImgMgmt, group 1) — list, chunked/hashed/resumableupload, test, confirm, erase (the DFU flow). - FS group (
FsMgmt, group 8) — stat, download, upload by path.