49c54f4e48
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
70 lines
3.1 KiB
C
70 lines
3.1 KiB
C
#pragma once
|
||
#include <Arduino.h>
|
||
#include <freertos/FreeRTOS.h>
|
||
#include <freertos/semphr.h>
|
||
|
||
// ── Constantes matérielles ──────────────────────────────────────────
|
||
#define ONE_WIRE_BUS 4 // GPIO 4 — bus OneWire DS18B20
|
||
#define NB_SONDES 3
|
||
#define HIST_TAILLE 288 // 24h × (3600/10/300 × 60) = 288 pts
|
||
#define MESURE_INTERVALLE 10000 // ms entre deux acquisitions
|
||
|
||
// ── Constantes réseau ───────────────────────────────────────────────
|
||
#define WIFI_SSID "Mon_Reseau_WiFi"
|
||
#define WIFI_PASS "Mon_Mot_De_Passe_Securise"
|
||
#define AP_SSID "ESP_CHEF_JARDIN"
|
||
#define AP_PASS "Jardin2026"
|
||
#define WIFI_TIMEOUT_MS 30000 // timeout avant bascule AP
|
||
#define WIFI_RETRY_MS 30000 // délai entre retries STA
|
||
#define MDNS_NOM "esp_jardin"
|
||
#define OTA_PASS "Jardin2026"
|
||
|
||
// ── Constantes MQTT ─────────────────────────────────────────────────
|
||
#define MQTT_BROKER "10.0.0.3"
|
||
#define MQTT_PORT 1883
|
||
#define MQTT_USER ""
|
||
#define MQTT_PASS_STR ""
|
||
#define MQTT_CLIENT_ID "esp_jardin"
|
||
#define MQTT_RETRY_MS 5000
|
||
|
||
// ── Structure : configuration d'une sonde (immuable) ────────────────
|
||
struct SondeConfig {
|
||
const char* nom;
|
||
const char* topic;
|
||
uint32_t intervalleMs;
|
||
float deadband;
|
||
};
|
||
|
||
// ── Structure : état runtime d'une sonde ───────────────────────────
|
||
struct SondeEtat {
|
||
float tempActuelle; // NAN si erreur
|
||
float dernierPublie; // dernière valeur publiée MQTT
|
||
uint32_t dernierPubliMs; // timestamp dernière publication
|
||
bool erreur;
|
||
};
|
||
|
||
// ── Structure : point d'historique ─────────────────────────────────
|
||
struct PointHistorique {
|
||
uint32_t timestamp;
|
||
float temps[NB_SONDES]; // NAN si sonde en erreur
|
||
};
|
||
|
||
// ── Structure : état réseau ─────────────────────────────────────────
|
||
struct NetworkStatus {
|
||
bool wifiConnecte;
|
||
bool modeAP;
|
||
bool mqttConnecte;
|
||
int8_t rssi;
|
||
uint32_t uptimeDemarrage; // millis() au moment de la connexion STA
|
||
};
|
||
|
||
// ── Déclarations extern (définies dans main.cpp) ────────────────────
|
||
extern SondeConfig sondesConfig[NB_SONDES];
|
||
extern SondeEtat sondesEtat[NB_SONDES];
|
||
extern PointHistorique historique[HIST_TAILLE];
|
||
extern uint16_t histIdx;
|
||
extern NetworkStatus netStatus;
|
||
// Mutex FreeRTOS protégeant l'accès concurrent au buffer historique
|
||
// (Core 0 : callbacks AsyncWebServer vs Core 1 : loop/sensors_update)
|
||
extern SemaphoreHandle_t xHistMutex;
|