Skip to content

Implement AtatLen with heapless LenT#254

Merged
MathiasKoch merged 2 commits into
FactbirdHQ:masterfrom
johann-cm:impl_atatlen_with_heapless_lent
Mar 4, 2026
Merged

Implement AtatLen with heapless LenT#254
MathiasKoch merged 2 commits into
FactbirdHQ:masterfrom
johann-cm:impl_atatlen_with_heapless_lent

Conversation

@johann-cm

Copy link
Copy Markdown
Contributor

heapless 0.9 supports different len types now (besides usize) on vec / string, which saves space if you know that you will have a short vec / string.
AtatLen is currently only implemented for LenT = usize, so I've implemented the trait for
the generic case. That is the main goal of this PR.

While implementing, I've discovered that you had two heapless-bytes versions in the dependency tree (0.3 and 0.4). I've updated both to 0.5 (which matches with the new heapless 0.9 version). Also, I've promoted heapless and heapless-bytes to workspace dependencies, to prevent that version drift between crates from happening again.

I think that it may be nicer to have dependency versions declared in the
workspace Cargo.toml. That way, you don't end up in the situation where
you forget to update a dependency in all of the crate Cargo.tomls (as
seems to have happened with heapless-bytes)
This is a new feature of heapless 0.9, which allows to use a smaller
size type to save space.

@MathiasKoch MathiasKoch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@MathiasKoch MathiasKoch merged commit 832cda6 into FactbirdHQ:master Mar 4, 2026
8 checks passed
MathiasKoch added a commit that referenced this pull request Apr 7, 2026
* Update embedded-io to 0.7.0

* Implement Display and Error traits for IoError and Error enums

* Update dependencies and improve serialization tests

* add logging to from_slice (#251)

* implement AtatLen for NonZero<T> (#252)

with select values for T, since it is currently unstable to implement
traits on a generic NonZero<T>.

* fix serialization of None option in middle of struct fields (#234) (#253)

serialize_none() unconditionally removed the last written byte, which
worked for a single-field struct (removing '=') but broke multi-field
structs by eating the ',' delimiter before a middle None field.

Now serialize_none() only removes the separator when it is the '='
sign (first field of a top-level struct with value_sep enabled).
Commas for non-first fields are preserved, producing empty delimited
fields (e.g. AT+CMD=0,,1).

SerializeStruct now tracks the buffer position after the last field
that wrote content. In end(), written is restored to that position
before appending the termination, stripping trailing commas from
trailing None fields.

* Fix: Handle all escape characters (#245)

* handle all escape characters

* cargo fmt

* bump heapless and embassy

* bump embassy and heapless

* add ESCAPED_LEN to AtatLen for escape-aware buffer sizing

Add ESCAPED_LEN associated constant to the AtatLen trait so commands
with escape_strings=true use worst-case 3x buffer for string fields,
while non-escaping commands keep the original sizing.

Also fix all clippy warnings across the workspace including tests.

---------

Co-authored-by: Kenneth Sylvest Knudsen <ksk@factbird.com>
Co-authored-by: Mathias <mk@factbird.com>

* Implement `AtatLen` with heapless `LenT` (#254)

* update heapless-bytes version and promote to workspace-dependency

I think that it may be nicer to have dependency versions declared in the
workspace Cargo.toml. That way, you don't end up in the situation where
you forget to update a dependency in all of the crate Cargo.tomls (as
seems to have happened with heapless-bytes)

* impl AtatLen for generic LenT parameter in heapless String and Vec

This is a new feature of heapless 0.9, which allows to use a smaller
size type to save space.

* Update embedded-io to 0.7.0

* Implement Display and Error traits for IoError and Error enums

* Update dependencies and improve serialization tests

* Update embassy deps to released crates.io versions, drop [patch] section

- Remove [patch.crates-io] git overrides now that embassy 0.10.0 is released
- embassy-sync: 0.7.2 → 0.8.0
- embassy-executor: 0.9.1 → 0.10.0 (arch-cortex-m → platform-cortex-m feature)
- embassy-rp: 0.9.0 → 0.10.0
- atat/defmt feature: add heapless/defmt (available since heapless 0.9.2)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Restore workspace dependencies and remove unnecessary patch section

* Refactor error handling to use `thiserror`, cleanup redundant implementations

---------

Co-authored-by: Johann Carl Meyer <info@johannc.de>
Co-authored-by: Mathias Koch <mk@blackbird.online>
Co-authored-by: Kenneth Knudsen <98805797+KennethKnudsen97@users.noreply.github.com>
Co-authored-by: Kenneth Sylvest Knudsen <ksk@factbird.com>
Co-authored-by: Mathias <mk@factbird.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants