Ana içeriğe geç

ESP32 Firmware

Donanım

  • MCU: ESP32-WROOM-32E (4MB flash, 240MHz dual-core)
  • Framework: Arduino + PlatformIO (espressif32)
  • RTOS: FreeRTOS (dual-core task scheduling)

Dizin Yapısı

embedded/zeus-esp32-gateway/src/
├── main.cpp # Giriş noktası + task oluşturma
├── core/
│ ├── network_task.cpp/h # WiFi + MQTT + OTA (Core 0)
│ ├── modbus_task.cpp/h # Modbus polling (Core 1)
│ ├── app_task.cpp/h # Button + LED + State (Core 1)
│ └── task_common.cpp/h # Ortak queue, event, mutex
├── application/
│ ├── state_machine.cpp/h # Operasyonel durum makinesi
│ ├── command_handler.cpp/h # MQTT komut işleme
│ ├── data_publisher.cpp/h # Telemetri yayınlama
│ ├── ota_command_handler.cpp/h # OTA firmware güncelleme
│ ├── ownership_handler.cpp/h # Claim/unclaim yönetimi
│ ├── led_controller.cpp/h # LED durum göstergeleri
│ ├── button_handler.cpp/h # Düğme olay işleme
│ └── factory_reset_handler.cpp/h
├── services/
│ ├── modbus_service.cpp/h # Modbus RTU implementasyonu
│ ├── template_service.cpp/h # Template parse
│ ├── device_manager.cpp/h # Cihaz kayıt yönetimi
│ ├── polling_service.cpp/h # Polling zamanlayıcı
│ ├── telemetry_service.cpp/h # JSON serialize
│ ├── raw_modbus_service.cpp/h # Raw hex okuma
│ ├── alarm_service.cpp/h # Yerel alarm kontrolü
│ └── config_service.cpp/h # NVS config persist
├── drivers/
│ ├── mqtt_driver.cpp/h # AsyncMqttClient
│ ├── wifi_driver.cpp/h # WiFi yönetimi
│ └── ble_driver.cpp/h # BLE provisioning
└── hal/
├── gpio.cpp/h # GPIO kontrol
├── uart.cpp/h # RS485 UART
├── nvs.cpp/h # Non-volatile storage
└── watchdog.cpp/h # Watchdog timer

İletişim Protokolleri

ProtokolKullanımArayüz
Modbus RTUCihaz okuma/yazmaRS485 (UART)
MQTTBulut iletişimiWiFi (TCP/TLS)
BLEProvisioningBluetooth
HTTPOTA downloadWiFi

Başlatma Sırası

setup()
├── 1. HAL init (GPIO, UART, NVS, Watchdog)
├── 2. Driver init (WiFi, BLE)
├── 3. Service init (Config, Modbus, Template, Device, Polling, Alarm, Telemetry)
├── 4. Application init (StateMachine, LED, Button, DataPublisher, CommandHandler)
├── 5. FreeRTOS task oluşturma (NetworkTask, ModbusTask, AppTask)
└── 6. TASK_EVT_SYSTEM_READY event

loop()
└── Watchdog feed + minimal housekeeping (100ms delay)