7aa8cd2a1c
Spec, plan d'implémentation, design system, documentation de déploiement. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
78 lines
2.8 KiB
Markdown
78 lines
2.8 KiB
Markdown
# plan.md — esp_jardin v1.0
|
|
|
|
Résumé du plan d'implémentation. Plan détaillé avec code complet :
|
|
`docs/superpowers/plans/2026-05-23-esp-jardin-firmware.md`
|
|
|
|
## Stack technique retenu
|
|
|
|
| Besoin | Bibliothèque | Justification |
|
|
|---|---|---|
|
|
| HTTP + WebSocket async | `esp32async/ESPAsyncWebServer` | Fork actif (jan. 2025), non-bloquant |
|
|
| TCP async | `esp32async/AsyncTCP` | Dépendance d'ESPAsyncWebServer |
|
|
| Sondes DS18B20 | `paulstoffregen/OneWire` + `milesburton/DallasTemperature` | Standard, bien documenté |
|
|
| MQTT | `knolleary/PubSubClient` | Plus documenté, non-bloquant avec millis() |
|
|
| JSON | `bblanchon/ArduinoJson ^7` | Sérialization REST + WebSocket |
|
|
| Filesystem | LittleFS (natif framework) | SPIFFS déprécié |
|
|
| OTA + mDNS | ArduinoOTA + ESPmDNS (natifs) | Inclus dans Espressif32 |
|
|
|
|
## Architecture : structures globales partagées
|
|
|
|
Modules indépendants (.h / .cpp) communiquant via structs globales dans `config.h`.
|
|
`main.cpp` = `setup()` + `loop()` uniquement.
|
|
|
|
```
|
|
network_init() → setup()
|
|
sensors_init() → setup()
|
|
web_server_init()→ setup()
|
|
mqtt_init() → setup()
|
|
|
|
network_update() → loop() — à chaque itération
|
|
sensors_update() → bool → loop() — toutes les 10s, retourne true si nouvelle mesure
|
|
└─ si true → web_server_notify_clients()
|
|
mqtt_update() → loop() — à chaque itération
|
|
```
|
|
|
|
## Séquence d'implémentation
|
|
|
|
| Tâche | Fichiers | Livrable |
|
|
|---|---|---|
|
|
| 1 | `platformio.ini`, `parametrage.md` | Config PlatformIO complète |
|
|
| 2 | `include/config.h`, `src/main.cpp` | Structs globales, compilation OK |
|
|
| 3 | `include/network.h`, `src/network.cpp` | WiFi STA/AP, mDNS, OTA |
|
|
| 4 | `include/sensors.h`, `src/sensors.cpp` | DS18B20 non-bloquant, buffer circulaire |
|
|
| 5 | `include/web_server.h`, `src/web_server.cpp` | HTTP REST + WebSocket |
|
|
| 6 | `include/mqtt_manager.h`, `src/mqtt_manager.cpp` | MQTT + deadband |
|
|
| 7 | `data/index.html` | Interface web complète |
|
|
| 8 | Flash + validation série | Protocole de test robustesse |
|
|
|
|
## Principe non-bloquant (DS18B20)
|
|
|
|
```
|
|
loop() itération N → sensors.requestTemperatures() (retour immédiat)
|
|
loop() itération N+75 → getTempCByIndex() après 750 ms (conversion terminée)
|
|
```
|
|
|
|
## Format JSON WebSocket (push)
|
|
|
|
```json
|
|
{
|
|
"sondes": [
|
|
{ "nom": "T°C Ext", "temp": "19.3", "erreur": false },
|
|
{ "nom": "T°C Serre", "temp": "28.7", "erreur": false },
|
|
{ "nom": "T°C Sol", "temp": null, "erreur": true }
|
|
],
|
|
"uptime": 3600,
|
|
"rssi": -62
|
|
}
|
|
```
|
|
|
|
## Commandes essentielles
|
|
|
|
```bash
|
|
pio run # Compilation
|
|
pio run -t upload # Flash firmware via USB
|
|
pio run -t uploadfs # Flash filesystem LittleFS (index.html)
|
|
pio device monitor # Moniteur série 115200 baud
|
|
pio run -t upload --upload-port 10.0.0.42 # OTA après déploiement
|
|
```
|