How th-luan05/master works
This repository implements an ESP32 smart-home master that connects MQTT controls to nearby devices over ESP-NOW or UDP, reports device state back to MQTT, and supports configuration, safety, automation, provisioning, and firmware updates. The runtime is concentrated in main/main.c, with main/proto.h defining shared packet and provisioning formats. The excerpts show startup, parts of command and rule handling, and OTA behavior; other links between subsystems are omitted where their call paths were not shown.
Main entry points: main.c ESP-NOW / UDP · proto.h Packet protocol
Components 16
Connectivity
- MQTT client
main/main.c - MQTT command routing
main/main.c - Packet protocol
main/proto.h - ESP-NOW / UDP
main/main.c
Device control
- Telemetry and alerts
main/main.c - Node configuration
main/main.c - Thermal safety
main/main.c
Automation
- Automation rules
main/main.c - Rule persistence
main/main.c - Time service
main/main.c
Device lifecycle
- BLE provisioning
main/main.c - Firmware updates
main/main.c
Other components
- Home controller
- ESP32 master
- Smart-home nodes
- Update service
Connections 23
- Home controller → MQTT client: publishes commands
- MQTT client → MQTT command routing: routes messages
main/main.c - MQTT command routing → ESP-NOW / UDP: sends device commands
main/main.c - ESP-NOW / UDP → Smart-home nodes: forwards packets
- Smart-home nodes → ESP-NOW / UDP: returns packets
- ESP-NOW / UDP → Telemetry and alerts: delivers telemetry
main/main.c - Telemetry and alerts → MQTT client: publishes state
main/main.c - ESP32 master → Packet protocol: uses packet formats
- Smart-home nodes → Packet protocol: shares packet formats
- ESP32 master → ESP-NOW / UDP: starts transport
main/main.c - ESP32 master → Time service: starts time service
main/main.c - ESP32 master → Automation rules: starts automation
main/main.c - ESP32 master → MQTT client: starts client
main/main.c - MQTT command routing → Node configuration: handles config
main/main.c - MQTT command routing → Automation rules: handles rule updates
main/main.c - Automation rules → Rule persistence: loads and saves
main/main.c - Automation rules → MQTT client: publishes retained rules
main/main.c - Automation rules → ESP-NOW / UDP: controls nodes
main/main.c - Smart-home nodes → BLE provisioning: provisions over BLE
- MQTT command routing → Firmware updates: handles update requests
main/main.c - Firmware updates → Update service: checks and downloads
main/main.c - Firmware updates → MQTT client: publishes update status
main/main.c - Firmware updates → ESP-NOW / UDP: sends node update status
main/main.c