Initial commit — firmware WireClaw ESP32-S3 fonctionnel
- Heartbeat MAVLink v1 toutes les 1s (broadcast 192.168.4.255:14553) - Relais WiFi <-> UART (Jetson <-> Pi Zero) sur ports 14550-14553 - LED RGB WS2812 GPIO48 : rouge pulsé (attente), vert dim (idle), flash vert (heartbeat) - MODE_AP=true : hotspot WireClaw-CAM / false : connexion Jetson - Fix: retrait ARDUINO_USB_CDC_ON_BOOT (carte Freenove utilise CH343/UART0)
This commit is contained in:
95
CLAUDE.md
Normal file
95
CLAUDE.md
Normal file
@ -0,0 +1,95 @@
|
||||
# WireClaw ESP32-S3 — Contexte projet
|
||||
|
||||
## Carte
|
||||
- **Freenove ESP32-S3-WROOM** (8MB Flash, PSRAM OPI)
|
||||
- LED RGB WS2812 sur **GPIO48** (adressable, lib FastLED)
|
||||
- UART2 : RX=GPIO16, TX=GPIO17 (vers Pi Zero, 57600 baud)
|
||||
- Flash mode : QIO 80MHz (`board_build.flash_mode = qio`)
|
||||
|
||||
## Rôle de ce firmware
|
||||
Nœud de communication drone WireClaw :
|
||||
- Envoie un **HEARTBEAT MAVLink v1** toutes les 1 seconde
|
||||
- Relaie les trames MAVLink **WiFi ↔ UART** (Jetson ↔ Pi Zero)
|
||||
- Indique l'état par la **LED RGB** (voir section LED)
|
||||
|
||||
## Basculer entre mode AP et mode Jetson
|
||||
En haut de `src/main.cpp`, une seule constante suffit :
|
||||
|
||||
```cpp
|
||||
#define MODE_AP true // true = ESP32 crée son propre hotspot (test sans Jetson)
|
||||
// false = ESP32 se connecte au hotspot WireClaw du Jetson
|
||||
```
|
||||
|
||||
- **`MODE_AP true`** : hotspot `WireClaw-CAM`, IP fixe `192.168.4.1`, heartbeat broadcast `192.168.4.255`
|
||||
- **`MODE_AP false`** : connexion à `WIFI_SSID`, heartbeat envoyé à `JETSON_IP:14553`
|
||||
|
||||
Les credentials sont dans `include/credentials.h` :
|
||||
```cpp
|
||||
// Mode AP
|
||||
#define AP_SSID "WireClaw-CAM"
|
||||
#define AP_PASSWORD ""
|
||||
|
||||
// Mode STA (Jetson)
|
||||
#define WIFI_SSID "WireClaw"
|
||||
#define WIFI_PASSWORD ""
|
||||
#define JETSON_IP "10.42.0.1"
|
||||
```
|
||||
|
||||
## LED RGB (GPIO48, WS2812, FastLED)
|
||||
| État | Couleur | Pattern |
|
||||
|---|---|---|
|
||||
| Attente WiFi / AP init | Rouge | Pulsé fade in/out |
|
||||
| Connecté, idle | Vert | Très dim fixe |
|
||||
| Heartbeat envoyé | Vert | Flash vif 80ms — 1 Hz |
|
||||
|
||||
## MAVLink Heartbeat
|
||||
- Implémenté sans lib externe dans `include/mavlink_heartbeat.h`
|
||||
- MAVLink v1, msg_id=0, SYS_ID=255 (GCS), CRC-16/MCRF4XX
|
||||
- Séquence incrémentale `mavSeq` (uint8_t, overflow auto)
|
||||
- Log hex dans le monitor série à chaque envoi
|
||||
|
||||
## Ports UDP
|
||||
| Constante | Port | Usage |
|
||||
|---|---|---|
|
||||
| `LOCAL_PORT` | 14550 | Écoute ESP32 (commandes depuis Jetson) |
|
||||
| `JETSON_PORT_MAVSDK` | 14551 | MAVLink vers Jetson (MAVLink SDK) |
|
||||
| `JETSON_PORT_PYMAV` | 14552 | MAVLink vers Jetson (pymavlink) |
|
||||
| `JETSON_PORT_HB` | 14553 | Heartbeat vers Jetson |
|
||||
|
||||
## Architecture réseau
|
||||
|
||||
### Mode AP (test)
|
||||
```
|
||||
PC/smartphone → WiFi "WireClaw-CAM" → ESP32-S3 (192.168.4.1)
|
||||
```
|
||||
|
||||
### Mode STA (production)
|
||||
```
|
||||
Jetson (10.42.0.1) ←→ WiFi "WireClaw" ←→ ESP32-S3 (10.42.0.77)
|
||||
↕ UART 57600
|
||||
Pi Zero (caméra CSI)
|
||||
```
|
||||
|
||||
## platformio.ini points importants
|
||||
- `board_build.flash_mode = qio` — obligatoire pour cette carte
|
||||
- `board_build.f_flash = 80000000L` — 80MHz
|
||||
- Ne PAS utiliser `-DARDUINO_USB_CDC_ON_BOOT=1` — la carte Freenove passe par un chip CH343 (UART0→COM11), pas par l'USB natif ESP32. Ce flag redirige Serial vers l'USB OTG qui n'est pas connecté → app muette.
|
||||
- Ne pas utiliser `board_build.arduino.memory_type = qio_opi` — cause boot loop
|
||||
|
||||
## Fichiers
|
||||
```
|
||||
wireclaw-esp32/
|
||||
├── CLAUDE.md ← ce fichier
|
||||
├── platformio.ini
|
||||
├── include/
|
||||
│ ├── credentials.h ← SSID, passwords, IP Jetson
|
||||
│ └── mavlink_heartbeat.h ← construction trame MAVLink v1
|
||||
└── src/
|
||||
└── main.cpp ← firmware principal
|
||||
```
|
||||
|
||||
## Travail futur
|
||||
- [ ] IP statique ESP32 via `WiFi.config()` en mode STA
|
||||
- [ ] Valider réception heartbeat côté Jetson (pymavlink)
|
||||
- [ ] Câblage UART ESP32 ↔ Pi Zero (GPIO16/17 ↔ GPIO14/15)
|
||||
- [ ] Remplacer broadcast par IP Jetson fixe une fois en production
|
||||
Reference in New Issue
Block a user