{"id":28948042,"url":"https://github.com/maximilianfeldthusen/mqtt","last_synced_at":"2026-05-04T09:33:38.281Z","repository":{"id":300520508,"uuid":"1006381002","full_name":"maximilianfeldthusen/mqtt","owner":"maximilianfeldthusen","description":"Simple C Code – MQTT with TLS, JSON, and Reconnect","archived":false,"fork":false,"pushed_at":"2026-04-16T06:14:38.000Z","size":95,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"TFD","last_synced_at":"2026-04-16T06:43:44.796Z","etag":null,"topics":["c","json","linux","mqtt","mqtt-broker","reconnect","tls","ubuntu"],"latest_commit_sha":null,"homepage":"https://github.com/maximilianfeldthusen/mqtt","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maximilianfeldthusen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-22T06:14:57.000Z","updated_at":"2026-04-16T06:14:42.000Z","dependencies_parsed_at":"2025-06-22T07:36:01.899Z","dependency_job_id":null,"html_url":"https://github.com/maximilianfeldthusen/mqtt","commit_stats":null,"previous_names":["maximilianfeldthusen/mqtt"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/maximilianfeldthusen/mqtt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianfeldthusen%2Fmqtt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianfeldthusen%2Fmqtt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianfeldthusen%2Fmqtt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianfeldthusen%2Fmqtt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maximilianfeldthusen","download_url":"https://codeload.github.com/maximilianfeldthusen/mqtt/tar.gz/refs/heads/TFD","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianfeldthusen%2Fmqtt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32601576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","json","linux","mqtt","mqtt-broker","reconnect","tls","ubuntu"],"created_at":"2025-06-23T10:05:08.389Z","updated_at":"2026-05-04T09:33:38.270Z","avatar_url":"https://github.com/maximilianfeldthusen.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# Advanced MQTT Embedded Publisher\n\n[![C](https://img.shields.io/badge/language-C-blue.svg)](https://www.gnu.org/software/gnu-c-manual/)  \n[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)  \n\nAn advanced MQTT client for embedded systems featuring:\n\n- Offline message queueing\n- JSON payload validation\n- TLS support with certificates\n- Telemetry reporting (CPU and memory usage)\n- Robust retry and error handling\n\n---\n\n## Features\n\n- Modular and maintainable C code\n- Publishes telemetry and sensor data\n- Handles broker disconnections with local queue replay\n- Configurable via command-line options\n- Senior-style code: clear variable names, logging, and formatting\n\n---\n\n## Requirements\n\n- C compiler (GCC recommended)\n- [Paho MQTT C Client](https://www.eclipse.org/paho/index.php?page=clients/c/index.php)\n- [Jansson JSON Library](https://digip.org/jansson/)\n- Linux or POSIX-compliant OS for `sysinfo()` telemetry\n\n---\n\n## Installation\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/yourusername/mqtt-embedded-publisher.git\ncd mqtt-embedded-publisher\n````\n\n2. Install dependencies:\n\n```bash\nsudo apt-get install libpaho-mqtt-dev libjansson-dev\n```\n\n3. Compile:\n\n```bash\ngcc -o mqtt_publisher mqtt_publisher.c -lpaho-mqtt3c -ljansson\n```\n\n---\n\n## Usage\n\n```bash\n./mqtt_publisher [OPTIONS]\n```\n\n### Options\n\n| Option                      | Description                                           |\n| --------------------------- | ----------------------------------------------------- |\n| `--address`                 | MQTT broker address (default: `tcp://localhost:1883`) |\n| `--client-id`               | MQTT client ID (default: `embedded_publisher`)        |\n| `--topic`                   | Sensor data topic (default: `sensors/data`)           |\n| `--telemetry-topic`         | Telemetry topic (default: `sensors/telemetry`)        |\n| `--qos`                     | MQTT QoS level (0, 1, or 2; default: 1)               |\n| `--interval`                | Publish interval in seconds (default: 5)              |\n| `--username` / `--password` | MQTT authentication credentials                       |\n| `--ca-cert`                 | Path to CA certificate for TLS                        |\n| `--client-cert`             | Path to client certificate for TLS                    |\n| `--client-key`              | Path to client private key for TLS                    |\n| `--key-password`            | Password for private key (if required)                |\n\n---\n\n## Example Output\n\n```text\nMQTT Connected\nReplayed 3 queued messages\n[1] Published: {\"temperature\":21.34,\"humidity\":42.11,\"timestamp\":1681700000,\"count\":1}\nTelemetry published: {\"uptime\":12345,\"loadavg\":0.52,\"totalram\":104857600,\"freeram\":52428800}\n[2] Published: {\"temperature\":20.87,\"humidity\":45.23,\"timestamp\":1681700005,\"count\":2}\nTelemetry published: {\"uptime\":12350,\"loadavg\":0.48,\"totalram\":104857600,\"freeram\":52200000}\n...\nShutdown complete. Total messages: 250\n```\n\n---\n\n## How It Works\n\n1. **Initialization:** Parses command-line arguments and sets up MQTT client.\n2. **Offline Queue:** Messages that fail to publish are stored locally.\n3. **MQTT Connection:** Attempts reconnect with retries if broker is unreachable.\n4. **Telemetry:** Periodically publishes system info (CPU load, memory usage) to a dedicated topic.\n5. **Main Loop:** Publishes simulated sensor data at configurable intervals.\n6. **Graceful Shutdown:** Handles Ctrl+C and cleans up resources.\n\n---\n\n## File Structure\n\n* `mqtt_publisher.c` — Main program file\n* `README.md` — Project documentation\n* `LICENSE` — MIT license\n\n---\n\n## License\n\nMIT License © 2026\nSee [LICENSE](LICENSE) for details.\n\n---\n\n## Website \n\n[https://mafeforge.com]\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximilianfeldthusen%2Fmqtt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaximilianfeldthusen%2Fmqtt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximilianfeldthusen%2Fmqtt/lists"}