Skip to content

Data Plane and Message Broker

GiZano edited this page Aug 31, 2026 · 2 revisions

Data Plane & Message Broker (MQTT)

With v1.1.0, QuakeGuard migrated its Data Plane from HTTP/local MQTT to a robust cloud infrastructure.

HiveMQ Cloud Infrastructure

  • Encrypted Transport: Telemetry is transmitted over port 8883 using strict TLS.
  • Authentication: Requires explicit MQTT_USERNAME and MQTT_PASSWORD.
  • Topic Topology: Anomalies are published to quakeguard/telemetry.

Edge Node Implementation (Firmware)

On the ESP32-C3, the networkTask handles transmission asynchronously:

  • Uses WiFiClientSecure::setInsecure() with PubSubClient.
  • On SeismicEvent pop, packages JSON and fire-and-forgets to the broker — milliseconds, never starving sensorTask.

Host Serial Bridge — Second Ingestion Path (v1.2.2)

When MQTT is unreachable, the host collects [QG:FB] frames over USB CDC and forwards them to the same ingestion endpoint:

  • Tool: firmware/tools/serial_bridge.py tails /dev/ttyACM0 (or $SERIAL_PORT), filters lines starting with [QG:FB], parses JSON suffix, and POSTs to /readings/ with X-API-Key — identical security gates as the MQTT bridge.
  • SSRF guard: _validate_api_url() allows only http/https, rejects credentials in URL and non-alphanumeric hostnames; parse_frame() returns None on boot-log noise.
  • Testability: --stdin and --dry-run modes plus a parser smoke test in iot-ci.yml keep the bridge testable without hardware.

Internal MQTT Bridge Service

The backend securely ingests data via mqtt_subscriber.py.

  • Uses paho.mqtt.client with secure TLS settings (client.tls_set(cert_reqs=ssl.CERT_REQUIRED)).
  • Forwards payloads to the internal FastAPI ingestion endpoint (/readings/) via HTTP POST.
  • Injects the X-API-Key header, acting as a trusted proxy.

Clone this wiki locally