C SDK
Available
For microcontroller devices (ESP32, STM32) that cannot run Python.
A C99 library for microcontroller devices (ESP32, STM32) that cannot run the Python SDK. It builds the signed envelope, gives each message a sequence number that survives power cuts, keeps a bounded outbox in flash, and hands finished frames to your platform's MQTT or HTTP client. Its frames verify at the backend ingest and match, byte for byte, the Python SDK's frames for the same input.
No heap allocation and no dependency beyond the C library: crypto, storage, transport and clock are small interfaces your platform supplies. One crypto backend ships, for mbedTLS 3.6 (ESP-IDF 5.3 or later; on another vendor SDK, check MBEDTLS_VERSION_STRING); a secure element (ATECC608, a TPM) can replace it through the same interface.
Download the source archive croppath-c-0.3.0.tar.gz and its .sha256 file from this portal's Downloads page (/developers/downloads), check its SHA-256 and unpack it as below. CropPath distributes its SDKs only through this portal, not through public package registries. Then add the three core files and the include directory to your firmware build, plus the mbedTLS backend if you use it.
curl -fLO https://txng.theio.vn/developers/downloads/sdk/croppath-c-0.3.0.tar.gz
curl -fLO https://txng.theio.vn/developers/downloads/sdk/croppath-c-0.3.0.tar.gz.sha256
sha256sum -c croppath-c-0.3.0.tar.gz.sha256 # macOS: shasum -a 256 -c croppath-c-0.3.0.tar.gz.sha256
tar xzf croppath-c-0.3.0.tar.gzsrc/at_json.c src/at_envelope.c src/at_client.c # the core: C99, no heap
src/at_crypto_mbedtls.c # the mbedTLS 3.6 backend
include/ # agritrace/agritrace.h, agritrace/agritrace_mbedtls.h#include "agritrace/agritrace.h"
#include "agritrace/agritrace_mbedtls.h"
static at_mbedtls key; /* loaded once from secure storage */
static at_client client;
static uint8_t work[2048]; /* route + largest frame */
at_client_config cfg = {0};
cfg.tenant = "coop-dl"; cfg.site = "ph1";
cfg.device_id = "knk-1"; cfg.profile = "vn.agritrace.durian-knocker@1.3.0";
cfg.kid = "knk-1-key"; /* the key id registered with the backend */
cfg.crypto = at_mbedtls_crypto(&key);
cfg.storage = my_nvs_storage(); /* atomic key/value writes */
cfg.transport = (at_transport){&mqtt, my_publish};
cfg.clock = (at_clock){NULL, my_unix_ms};
cfg.outbox_capacity = 32;
at_client_init(&client, &cfg, work, sizeof work);
at_kv ctx[] = {{"lot", "LOT-A"}, {"facility", "66-DL-SR-0001-CHN"}};
at_reading r = {.capability = "mass.net", .value = at_decimal(2135, 3), .unit = "kg"};
at_message m = {.kind = AT_KIND_EVENT, .event_type = "inspect",
.context = ctx, .context_count = 2, .readings = &r, .reading_count = 1};
at_client_emit(&client, &m, NULL); /* signs and stores; nothing is sent yet */
at_client_flush(&client, 8, NULL); /* from the network task; AT_ERR_RETRY = try later */Events are sent before status and telemetry, oldest first. When the outbox is full, the oldest telemetry frame makes room; an event is never dropped silently (AT_ERR_FULL). A frame the server refuses for good leaves the outbox through on_rejected. The client is not thread-safe: call at_client_emit and at_client_flush from one task, or hold a mutex around both. The backend, not the SDK, checks readings against the capability catalogue: use the capabilities and units your device profile declares.
Porting to a device: on ESP-IDF, make a component that registers those sources with INCLUDE_DIRS include and REQUIRES mbedtls; on STM32Cube, add the sources and the include directory and link the project's mbedTLS middleware. Compile with -std=c99 or later. A port supplies a crypto backend (mbedTLS or a secure element), a random source, a key/value store, a transport and a clock. Every storage write must be atomic (after a power cut the key holds the old value or the new one, never a mix): NVS on ESP32, a power-loss safe file system such as littlefs on STM32. The transport returns AT_OK for HTTP 2xx and 409, AT_ERR_RETRY for no link, a timeout, 408, 429 and 5xx, and AT_ERR_REJECTED for any other 4xx. The clock returns Unix time in milliseconds (UTC), and non-zero while it is not set, so that at_client_emit refuses the message (AT_ERR_INVALID). To check a port, run tests/test_json.c and tests/test_vectors.c on the board, then post a frame to a test backend: it must be answered 202; 401 bad_signature means the bytes differ, most often a number formatted by the platform's printf.