Repository navigation
Releases
Releases · metaloomlabs/usmp
USMP v1.3.0
Embedded reliability, zero-heap memory architecture, split RTOS concurrency, CoAP RTT estimation with watchdog protection, and non-blocking handshake state machine.
🚀 Protocol & Library Additions
-
C Core & Arduino — Asynchronous Non-Blocking Handshake State Machine (
usmp_step,beginAsync): Introduced explicit non-blocking finite state machine (USMP_STATE_IDLE,USMP_STATE_CONNECTING_SOCKET,USMP_STATE_AWAITING_CHALLENGE,USMP_STATE_CALCULATING_ECDH,USMP_STATE_AWAITING_SESSION_OK,USMP_STATE_ESTABLISHED). Addedusmp_connect_async(),usmp_reconnect_async(), andusmp_step()in C core. Refactored ArduinoUSMPClientwithbeginAsync()overloads,state()/isConnecting()queries, and non-blockingmaintain()driving connection bring-up and reconnects without synchronous 2–5 second CPU stalls or watchdog timer resets. -
C Core — Split RTOS Mutex Architecture (
tx_mutex&rx_mutex): Embedded dedicated transmission and reception synchronization handles inusmp_t(core/include/usmp.h). Decouples egress encryption from ingress defragmentation, eliminating full-duplex socket deadlocks whenusmp_recv()blocks while completely serializing concurrentusmp_send()calls to prevent AES-GCM nonce reuse. In-band rekeying (usmp_rekey) and session teardown (usmp_close) enforce strict hierarchical lock order (tx_mutexfollowed byrx_mutex) to guarantee deadlock freedom. -
Core HAL — Mutex Primitives (
usmp_port_mutex_*) & Typed Status Code: Addedusmp_mutex_t,usmp_port_mutex_create(),usmp_port_mutex_lock(),usmp_port_mutex_unlock(), andusmp_port_mutex_destroy()declarations tocore/include/usmp_port.h. Implemented priority-inheriting FreeRTOS mutexes (xSemaphoreCreateMutex()) on ESP32, FreeRTOS/no-op stubs on Arduino, and Win32CRITICAL_SECTION/ POSIXpthread_mutex_ton test platforms. AddedUSMP_ERR_MUTEX_FAILED = -10tousmp_err_t. -
C Core — Zero-Heap Handshake Scratchpad Memory: Added
scratchandscratch_lenfields tousmp_tand#define USMP_HANDSHAKE_SCRATCH_LEN 1024incore/include/usmp.h. When provided,usmp_handshake()slices caller-managed memory into 512-byte TX and RX frame buffers with zero dynamic heap allocations, securely zeroizes scratchpad contents upon completion viambedtls_platform_zeroize(), and preserves scratchpad pointers acrossusmp_connect()andusmp_reconnect(). Includes#ifdef USMP_ZERO_HEAPguard for strict static-only build verification. -
Arduino Port — Static Memory Transport Contexts (
init_static): Addedinit_static(usmp_transport_t* t, USMPArduinoTcpCtx* ctx)andinit_static(usmp_transport_t* t, USMPArduinoUdpCtx* ctx)toUSMPTCPTransportandUSMPUDPTransport. Enables caller/BSS allocation of transport contexts, delegating standardinit()toinit_static()and installingdestroy_static()hooks that safely stop sockets without callingdeleteon static pointers. -
Arduino Port — Zero-Heap Client Architecture &
USMPClientStatic: RefactoredUSMPClientto decouple RX buffer storage into pointer + capacity (_rx_buf,_rx_buf_capacity,_owns_rx_buf). Added constructor overload accepting external buffer memory,setHandshakeScratch()for cryptographic scratchpad injection, andbegin(transport, static_ctx = nullptr)overloads. AddedUSMPClientStatic<RxBufferSize, ScratchBufferSize>template wrapper embedding both buffers directly in object memory for pure.bsszero-heap embedded deployments. -
Arduino Examples — Zero-Heap Reference Sketch: Added
ports/usmp-arduino/examples/zero_heap/zero_heap.inodemonstrating 100% static allocation withUSMPClientStaticand static transport contexts. -
Core HAL — Watchdog Timer Service Hook (
usmp_port_wdt_feed): Addedusmp_port_wdt_feed(void)HAL declaration tocore/include/usmp_port.hwith implementations for Arduino (yield()/ESP.wdtFeed()), ESP32 ESP-IDF (esp_task_wdt_reset()), and POSIX test runners. -
Arduino & ESP32 Ports — CoAP RTT Estimation & Watchdog Guard for UDP ARQ: Implemented RFC 7252 / Jacobson-Karn smoothed RTT (
srtt), variance (rttvar), and dynamic timeout (rto) inUSMPArduinoUdpCtx. Retransmission timeout scales with binary exponential backoff ($100\text{ ms} \dots 5000\text{ ms}$ ) on packet loss while avoiding retransmission ambiguity by measuring samples only on first-attempt ACKs. Integratedusmp_port_wdt_feed()inside transmission and reception wait loops to guard against hardware watchdog timer resets during link outages. -
C Core — Fast Table-Driven CRC-16 Lookup Engine: Replaced bitwise 8-iteration software shifting loop in
usmp_crc16_step()with a precomputed 256-word Flash lookup table (.rodata, 512 bytes ROM, 0 bytes RAM). Delivers ~8x faster single-cycle per-byte CRC-16 calculation across all incoming and outgoing frames on microcontrollers (ESP32/ARM Cortex-M/AVR) with 100% bit-exact wire-compatibility (#51). -
Arduino Port — Bounded Handshake Timeouts & Watchdog Protection: Introduced
USMP_HANDSHAKE_RECV_TIMEOUT_MS(default 5000 ms). Replaced unbounded handshake receive loops inUSMPTransport.cpp(both TCP and UDP) with bounded timeouts to prevent MCU hangs when the server is unresponsive. Addedusmp_port_wdt_feed()in all TCP byte reception and progress loops to guard against hardware watchdog timer and FreeRTOS Task Watchdog Timer (TWDT) reset loops during link negotiation. -
C Core — Early Corrupted Packet Rejection: Hardened
usmp_parse_packet()to compute and verify the frame CRC directly over the incoming wire buffer before executingmemcpy(pkt->payload, ...). Discards corrupted, incomplete, or spoofed frames in zero copy cycles, preventing internal buffer pollution and eliminating CPU waste during frame floods. -
C Core & Arduino — Human-Readable Error Translation (
usmp_strerror,lastError,lastErrorString): Addedconst char* usmp_strerror(usmp_err_t err)in C core returning descriptive static string literals for all library error codes. AddedlastError()andlastErrorString()to ArduinoUSMPClient, automatically capturing and exposing status codes from handshake, transmission, and background maintenance. -
C Core & Python SDK — Graceful Teardown Status Code (
USMP_ERR_PEER_CLOSED): AddedUSMP_ERR_PEER_CLOSED = -11tousmp_err_tandUSMPErrorCode.PEER_CLOSED = -11in Python SDK. Graceful peer disconnects viaPKT_BYEframes now return-11instead of ambiguous generic argument errors (-1), enabling clients to cleanly distinguish peer shutdown from malformed traffic. -
Arduino Port — Binary PSK Constructors: Added
USMPClient(const uint8_t* psk, size_t psk_len)andUSMPClientStatic(const uint8_t* psk, size_t psk_len)overloads accepting explicit binary key buffers. Preventsstrlen()from prematurely truncating random high-entropy pre-shared keys containing0x00bytes. -
Arduino Port — Standard Print Interface Inheritance (
usmp.print,usmp.println): InheritedUSMPClientfrom Arduino's standardPrintclass, implementingwrite(uint8_t),write(const uint8_t*, size_t),flush(), andavailableForWrite(). Enables idiomatic stream printing (usmp.print("Sensor: "),usmp.println(val)) with intelligent zero-heap line buffering that aggregates prints into single encrypted frames upon encountering\nor explicitflush()calls. -
Python SDK — Built-in CLI Dev / Echo Server (
python -m usmp.server,usmp-server): Added command-line development and test server with ANSI colored logging, interactive startup banner,--echomode for loopback verification,--generate-psk256-bit key generation, and hex-encoded PSK parsing (hex:<bytes>). Addedis_connectedandinfoproperties toUSMPSession. -
Python SDK — String Transmission, Direct Text Receiving & Payload Inspector (
session.send(str),session.recv_str(),session.print()): EnhancedUSMPSession.send()to natively acceptbytes | str(automatically encodingstras UTF-8). Addedsession.recv_str()for direct string reception. Addedsession.print(data, tag=...)providing rich console payload inspection with timestamps, device ID badges, payload length, and automatic text vs. hex dump formatting integrated with USMP's ANSI logger. -
ESP-IDF Port & Core HAL — Zero-Heap Static Transport Initializers (
usmp_transport_tcp_init_static,usmp_transport_udp_init_static): Exposedusmp_tcp_ctx_tandusmp_udp_ctx_tcontext types incore/include/usmp_transport.halong with static initializers accepting caller-managed static/.bssmemory buffers. Implemented static transport destroy hooks (destroy_static) that safely shut down sockets without callingfree(). Eliminates mandatory dynamic memory (malloc) for transports in safety-critical and zero-heap embedded environments (#DX-06). -
Build & Tooling — MbedTLS 3.x Assertion & UV Build Upper Bound: Added minimum version assert in
CMakeLists.txtenforcing MbedTLS >= 3.0.0 for host builds. Expandeduv_buildupper bound insdk/python/pyproject.tomlto<0.14.0for clean build compatibility with modern uv toolchains.
🛠️ Tooling, CI/CD & Developer Experience (Maintainers)
- Tests — Zero-Heap Static Transport Initialization Suite: Added
test_static_transport_initialization()incore/tests/test_main.casserting NULL argument validation guards, struct layout sizing, static context binding, socket creation, and safe static teardown without heap freeing. - Tests — Error Translation & Graceful Teardown Suite: Added
test_usmp_strerror()tocore/tests/test_main.cvalidating string mapping for all defined error codes and invalid fallback values. Updatedtest_bye_on_close()to verifyUSMP_ERR_PEER_CLOSEDreturn status. - Tests — Asynchronous Handshake State Machine Suite: Added
test_async_handshake_fsm()...
USMP v1.2.2
Core error handling modernization, Python SDK server resilience and logging UI overhaul, alongside DevOps and developer experience improvements spanning automated pre-flight release validation, release dry-run simulations, CI workflow parallelization across Python matrices, cross-platform local developer tooling (Makefile), and stability fixes.
✨ Added
- Python SDK — Graceful Server Shutdown & Signal Traps: Added programmatic
server.stop(), OS signal traps (SIGINT,SIGTERM) on the running asyncio event loop, and clean cancellation/teardown awaiting all active client session tasks without hanging coroutines. - Python SDK — Immediate TCP Socket Rebinding: Added
reuse_address=TruetoTCPListenerto enable immediate server restarts withoutEADDRINUSE/ socketTIME_WAITerrors. - Python SDK — Dev-Tool Colored Logging UI: Added
usmp._loggingmodule featuring a sleek ANSIColoredFormatterwith pill-style level badges (INFO,WARN,ERROR,CRIT,DEBUG), dimmed timestamps, shortened logger namespaces ([server],[client]), andusmp.setup_logging()helper with UTF-8 stream handling. - Core & SDK — Programmatic
usmp_err_tTyped Status Codes: Introducedusmp_err_tenum across C core API, Arduino wrappers, and Python SDK (USMPErrorCodeIntEnum andcode: USMPErrorCodeattributes on all exception classes) (#27). - CI/CD — Hybrid GitHub Release Automation: Added automated monorepo GitHub Release creation to
.github/workflows/split-release.ymlwith Option 3 hybrid notes (curated notes extracted fromCHANGELOG.mdviascripts/extract-release-notes.py, automated PR/commit changelog fallback, and downloadable Arduino ZIP and Python wheel asset distribution). - CI/CD — Release Dry-Run Mode: Added
dry_runsimulation support to.github/workflows/split-release.ymlwithworkflow_dispatchtrigger. Validates tag format, checks version synchronization across all manifests, executes build steps, and outputs simulated publication logs without publishing packages or uploading release assets. - CI/CD — Multi-Version Python Matrix: Expanded CI pipeline to test across Python 3.11, 3.12, and 3.13 concurrently in parallel with Ubuntu 22.04 runners (#35).
- CI/CD — Toolchain Caching: Integrated GitHub Actions caching for Arduino CLI cores (
esp32:esp32) and ESP-IDF tools, slashing build times (#35). - CI/CD — Unified Branch Protection Check: Added aggregate
ci-checksgate job requiringc-core,python-tests,python-lint-security, andarduino-esp32-compilebefore PR merges (#35). - CI/CD — Release Pre-Flight Validation: Automated multi-manifest version consistency checks (
scripts/preflight-release.py) before release deployments, verifying matching version numbers across Python, C Core, ESP32, and Arduino manifests (#34). - CI/CD — Automated C-Python Interoperability Testing: Added
libmbedtls-devto CI Python test runners, enabling automated end-to-end wire compatibility tests (test_c_interop.py) between the compiled C core client binary and PythonUSMPServeracross TCP and UDP. - CI/CD — Workflow Concurrency Controls: Enforced
concurrencygroups (cancel-in-progress: true) across test and release workflows to prevent redundant runner execution and race conditions (#34). - Developer Experience — Root Makefile: Added cross-platform
Makefilewith targets for testing (test,test-v,test-c,test-all), linting & formatting (lint,format), security scanning (security), port packaging (bundle-arduino,bundle-esp32), and artifact cleaning (clean-ports,clean). Automatically detectsuvwith fallback to active virtual environments. - Tests — Pytest Timeout Guard: Added
pytest-timeout(--timeout=60) to guard against hung event loops and deadlock regressions during integration test execution.
🐛 Fixed
- C Core — Handshake Entropy Source Registration: Registered
usmp_mbedtls_entropy_callbackusingusmp_port_randomwithmbedtls_entropy_add_sourceto preventmbedtls_ctr_drbg_seedfailures on platforms without default system entropy (#38). - CI/CD — Node 24 Action Enforcement: Added
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"across CI workflows to enforce Node 24 runtime (#28). - Python SDK — Python 3.11 Datagram Transport: Fixed
AttributeError: '_SelectorDatagramTransport' object has no attribute '_address'inUSMPClient.connect()on Python 3.11 by safely resolving endpoint addresses using standard socket peer discovery (#35). - Tests — Rate Limiter State Pollution: Added autouse session-isolation fixture in
conftest.pyensuring global rate-limiter caches are reset before and after every test, preventing cascading flaky test failures in test suites. - Tests — Concurrent Handshake Teardown: Optimized listener shutdown in
test_concurrent_handshakes_exceeding_capacityusing cancellation task groups, preventing hanging background tasks. - Tests — UDP Teardown Test Session Liveness: Kept server sessions alive in
test_udp_integration.pyuntil client teardown, allowing the server to acknowledgeBYEframes with instant ACKs instead of triggering 15-second ARQ timeouts under Python 3.12/3.13 eager scheduling. - Ports — Shim Alignment: Synchronized
usmp_api.hshim inscripts/bundle-ports.pywith port development shims, ensuringbundle-ports.py --cleanleaves working trees completely clean. - DevOps & Tooling — Scripts Audit & Port Packaging Hardening: Hardened utility scripts across Windows PowerShell and POSIX Bash. Resolved working-directory path sensitivity in
build-arduino-zip.ps1, eliminated case-insensitive filesystem collisions during Arduino staging, included.cppfiles in include patching, cleaneddist/before builds in SDK test scripts to prevent stale wheel conflicts, expanded release tag validation to verifycore/include/usmp.h,__init__.py, and rootpyproject.toml, added base SemVer fallback to release notes extraction, and pruned obsolete localpublish-pypi.{ps1,sh}scripts in favor of downstream OIDC trusted publishing.
What's Changed
- ci: Phase 1 DevOps hardening for CI/CD and release pipelines by @winterx64 in #34
- ci: parallelize jobs, add python matrix testing, and cache arduino toolchain by @winterx64 in #35
- ci: add release dry-run mode, root developer makefile, and docs by @winterx64 in #36
- ci: implement hybrid github release notes automation and downstream mirror releases by @winterx64 in #37
- chore(release): v1.2.2 by @winterx64 in #42
- fix(ci): eliminate Python f-string syntax error in release authorization header by @winterx64 in #43
Full Changelog: v1.2.1...v1.2.2
v1.2.0
What's Changed
- Remove mkdocs by @winterx64 in #17
- feat(transport): Add adaptive RTT estimation and exponential backoff to UDP transport by @winterx64 in #18
- Release/v1.2.0 by @winterx64 in #25
Full Changelog: v1.1.0...v1.2.0
v1.1.0
What's Changed
- Refactor Python SDK, Improve Code Quality, Fix UDP Transport Issues and Bump version to 1.0.1 by @winterx64 in #7
- Improvements : core UDP/reassembly fixes + Python SDK transport refactor by @winterx64 in #8
- fix(arduino): fix UDP/TCP socket blocking and implement transport ref… by @winterx64 in #9
- refactor(esp32): audit port, fix socket timeout/blocking bugs, add DNS hostname resolution, and bump version to 1.0.1 by @winterx64 in #10
- Fix Python SDK implementation and update documentation by @winterx64 in #11
- Revert "Fix Python SDK implementation and update documentation" by @winterx64 in #12
- Fix pythonlib by @winterx64 in #13
- v1.1.0: core security fixes, port hardening, arduino CI by @winterx64 in #14
- Release v1.1.0: Security hardening, Python SDK and C core fixes, and hardware port enhancements by @winterx64 in #15
- Setup community health files and templates for governance by @winterx64 in #16
Full Changelog: v1.0.0...v1.1.0
v1.0.0
What's Changed
- Hotfix by @winterx64 in #4
- Release v1.0.0: security hardening, cross-language parity, and release readiness by @winterx64 in #5
- release: v1.0.0 Stable (Unified Secure Multi-transport Protocol) by @winterx64 in #6
Full Changelog: v0.5.1...v1.0.0
v0.5.1
What's Changed
- feat(udp): add reliable UDP transport support across Python SDK, ESP32, and Arduino ports by @winterx64 in #3
Full Changelog: v0.4.7...v0.5.1
v0.4.7
What's Changed
- Hotfix - Handshake and Deterministic GCM nonces by @winterx64 in #1
- feat: implement dynamic payload fragmentation (v0.4.7) and mitigate SEC-05 rate-limiter vulnerabilities by @winterx64 in #2
New Contributors
- @winterx64 made their first contribution in #1
Full Changelog: v0.4.4...v0.4.7