Remove app::utils helpers with zero fleet call sites after the app_common merge (as_u8s, hexdump, add_overflow/overflow_error, try_get/try_get_ref, constrain_value_in_range_static — a template-bounds reimplementation of std::clamp) and the unused app_clock milliseconds alias. This drops several heavy includes from a header every consumer compiles. Rewrite deferrer as a stdlib scope guard that owns the callable directly (template<F>, non-copyable/non-movable) instead of type-erasing through std::move_only_function/std::function, so it never heap-allocates. The 3 call sites (band max32664d) are unchanged via CTAD.
1.5 KiB
1.5 KiB
app_common
Shared header-only utilities for the TrackBackFwd / healthy-band-nrf / zephyr_gateway_fwd fleet. Single source of truth for code that used to be hand-copied (and had drifted) between the three repos.
Contents
inc/app_utils.hpp— byte/span casts (as_bytes),overloads,deferrer,to_mac_string(only when the toolchain has<format>; guarded by__cpp_lib_format).inc/app_clock.hpp— monotonic microsecondTrivialClock. The only OS-specific code in this repo:now()isk_uptime_ticks()on Zephyr andesp_timer_get_time()on ESP-IDF, selected by__ZEPHYR__/ESP_PLATFORM.inc/app_clock_instant.hpp—Instant, Rust-style elapsed-time helper on top ofclock_t. Purestd::chrono, no OS dependency.
Everything requires C++23 (all consumers build with -std=gnu++23 /
CONFIG_STD_CPP2B).
Consuming
ESP-IDF: add as a git submodule under components/app_common. The root
CMakeLists.txt registers the component; add app_common to your REQUIRES.
Zephyr: add as a git submodule (e.g. modules/app_common) and append it to
EXTRA_ZEPHYR_MODULES in the application CMakeLists before
find_package(Zephyr). The include directory is registered globally; targets
app_common / app_utils / app_utils_clock exist for explicit linking.
Rules
- Nothing platform-specific beyond the
app_clock.hppseam. If a helper needs ESP-IDF or Zephyr APIs, it belongs in the consuming repo, not here. - Never copy these headers back into a consumer repo. Bump the submodule.