Python SDK
Available
For gateways and capable devices: signed envelopes, a queue that holds them while offline, MQTT and HTTPS transports, drivers.
agritrace-iot is the reference implementation of the device side of the API (the ingest operation in the API reference and in /developers/openapi.json): it turns readings into envelopes, signs each one, keeps it in a local queue (the outbox) until the backend has it, and sends it over MQTT (with a device certificate) or HTTPS (/v1/ingest). If you write your own firmware, the envelope's structure is at /developers/downloads/envelope-v1.schema.json, the event types at /developers/downloads/event-types-v1.json, the kinds of reading at /developers/downloads/capabilities-v1.json and the device profiles below /developers/downloads/profiles/ (listed at the end of this page).
Download the wheel from this portal's Downloads page (/developers/downloads), check its SHA-256 against the .sha256 file next to it, then install it with pip as below. CropPath distributes its SDKs only through this portal, not through public package registries. The mqtt, modbus and serial extras add the transport and drivers used in production.
curl -fLO https://txng.theio.vn/developers/downloads/sdk/agritrace_iot-0.3.0-py3-none-any.whl
curl -fLO https://txng.theio.vn/developers/downloads/sdk/agritrace_iot-0.3.0-py3-none-any.whl.sha256
sha256sum -c agritrace_iot-0.3.0-py3-none-any.whl.sha256 # macOS: shasum -a 256 -c
pip install "./agritrace_iot-0.3.0-py3-none-any.whl[mqtt]" # extras: mqtt, modbus, serialfrom agritrace_iot import Agent, Context, Outbox, SoftwareSigner
from agritrace_iot.transport.mqtt import MqttTransport
transport = MqttTransport("broker.example.vn", client_id="gw-01", tenant="coop-dl", site="packhouse-01",
ca_file="ca.pem", cert_file="gw-01.pem", key_file="gw-01.key")
agent = Agent(tenant="coop-dl", site="packhouse-01", transport=transport,
outbox=Outbox("/var/lib/agritrace/outbox.db"),
signer=SoftwareSigner.generate("gw-01"), # use a secure-element Signer in production
context=Context.of(facility="66-DL-SR-0001-CHN"))
knocker = agent.add_device("knk-1", "vn.agritrace.durian-knocker", config={"modelVersion": "m-2026.09"})
agent.set_session("knk-1", Context.of(lot="LOT-0930-A", operator="op-7"))
knocker.on_frame({"idx": 83, "cls": "chin", "conf": 0.91})
agent.run_forever()A new product joins as a driver package with a device profile; agritrace_iot.conformance.check_driver() checks the driver.
Cheap “NPK” soil probes do not measure nutrients: they estimate nitrogen, phosphorus and potassium from the soil's conductivity, so the measurement vocabulary has no nitrogen, phosphorus or potassium. Send a probe's values under the vendor's own name ending in npk_estimate, for example x-acme.npk_estimate, with quality set to uncertain; the backend quarantines an envelope whose NPK estimate has any other quality. An NPK estimate is never evidence: it appears on no public page, in no EPCIS document or customs dossier, and never counts toward a trust tier. Nutrient evidence comes from lab tests. The moisture, temperature and EC channels of the same probe stay usable.
New in 0.2.0: MqttTransport.wait_subscribed() waits until the broker granted the gateway's command subscription (its SUBACK). wait_connected() returns earlier, on the CONNACK, and on a first connection to a broker a command sent in between can be lost, so wait for wait_subscribed() before anything that makes the backend send a command (tests, provisioning checks). Both return False on timeout; wait_subscribed() raises TransportError when the broker refuses the subscription.
transport.connect() # or agent.run_forever() on another thread
transport.wait_connected(20) # True once the broker accepted the connection (CONNACK)
transport.wait_subscribed(20) # True once the broker granted the command subscription (SUBACK)In the API reference
Downloads
This portal serves these files: you do not need access to the source repository.