Initial release 1.2.2
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the convention is to give header files names that end with `.h'.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
+31
-5
@@ -3,21 +3,28 @@
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/semphr.h>
|
||||
|
||||
// ── Version ─────────────────────────────────────────────────────────
|
||||
#define FIRMWARE_VERSION "1.2.2"
|
||||
|
||||
// ── Constantes matérielles ──────────────────────────────────────────
|
||||
#define ONE_WIRE_BUS 4 // GPIO 4 — bus OneWire DS18B20
|
||||
#define ONE_WIRE_BUS 27 // GPIO27 / D6 — 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
|
||||
#define HIST_TAILLE 288 // 24h × 12 points/h = 288 moyennes de 5 min
|
||||
#define HIST_PERIODE_MS 300000 // 5 min par point d'historique
|
||||
#define HIST_ECHANTILLONS (HIST_PERIODE_MS / MESURE_INTERVALLE) // 30 mesures
|
||||
#define HIST_SAVE_POINTS 12 // sauvegarde LittleFS toutes les 12 moyennes = 1h
|
||||
|
||||
// ── Constantes réseau ───────────────────────────────────────────────
|
||||
#define WIFI_SSID "Mon_Reseau_WiFi"
|
||||
#define WIFI_PASS "Mon_Mot_De_Passe_Securise"
|
||||
#define WIFI_SSID_1 "Livebox-5F80"
|
||||
#define WIFI_PASS_1 "3LU7fupGoVMta3qRcW"
|
||||
#define WIFI_SSID_2 "WifiHome2"
|
||||
#define WIFI_PASS_2 "louca2212"
|
||||
#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"
|
||||
@@ -26,11 +33,15 @@
|
||||
#define MQTT_PASS_STR ""
|
||||
#define MQTT_CLIENT_ID "esp_jardin"
|
||||
#define MQTT_RETRY_MS 5000
|
||||
#define MQTT_TOPIC_BASE "maison/jardin"
|
||||
#define MQTT_TOPIC_STATUS "maison/jardin/status"
|
||||
#define MQTT_HEARTBEAT_MS 60000 // publication "online" toutes les 60s
|
||||
|
||||
// ── Structure : configuration d'une sonde (immuable) ────────────────
|
||||
struct SondeConfig {
|
||||
const char* nom;
|
||||
const char* topic;
|
||||
const char* topicErreur;
|
||||
uint32_t intervalleMs;
|
||||
float deadband;
|
||||
};
|
||||
@@ -47,6 +58,7 @@ struct SondeEtat {
|
||||
struct PointHistorique {
|
||||
uint32_t timestamp;
|
||||
float temps[NB_SONDES]; // NAN si sonde en erreur
|
||||
uint8_t samples[NB_SONDES];
|
||||
};
|
||||
|
||||
// ── Structure : état réseau ─────────────────────────────────────────
|
||||
@@ -63,9 +75,23 @@ extern SondeConfig sondesConfig[NB_SONDES];
|
||||
extern SondeEtat sondesEtat[NB_SONDES];
|
||||
extern PointHistorique historique[HIST_TAILLE];
|
||||
extern uint16_t histIdx;
|
||||
extern uint32_t histSeq;
|
||||
extern NetworkStatus netStatus;
|
||||
extern char mqttBrokerActif[64];
|
||||
extern uint16_t mqttPortActif;
|
||||
// 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;
|
||||
// Mutex FreeRTOS protégeant l'accès concurrent à sondesEtat[]
|
||||
extern SemaphoreHandle_t xSondesMutex;
|
||||
|
||||
struct WifiCredential {
|
||||
const char* ssid;
|
||||
const char* password;
|
||||
};
|
||||
|
||||
static constexpr WifiCredential WIFI_RESEAUX[] = {
|
||||
{ WIFI_SSID_1, WIFI_PASS_1 },
|
||||
{ WIFI_SSID_2, WIFI_PASS_2 },
|
||||
};
|
||||
static constexpr uint8_t NB_WIFI_RESEAUX = sizeof(WIFI_RESEAUX) / sizeof(WIFI_RESEAUX[0]);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
void history_load();
|
||||
void history_save();
|
||||
@@ -5,3 +5,6 @@ void mqtt_init();
|
||||
|
||||
// À appeler à chaque loop() : reconnexion non-bloquante + publication deadband
|
||||
void mqtt_update();
|
||||
|
||||
// Applique un nouveau broker/port et force une reconnexion MQTT.
|
||||
void mqtt_reconfigure();
|
||||
|
||||
Reference in New Issue
Block a user