1
0
forked from tanchou/Verilog

Enhance ESP32 command processing: add validation, error handling, and new command types for device management

This commit is contained in:
Gamenight77
2025-04-23 15:52:36 +02:00
parent 2b7582808e
commit 0eeecbca2e
2 changed files with 141 additions and 10 deletions

View File

@@ -8,21 +8,39 @@ Ce protocole permet la communication entre le FPGA et l'ESP32 via UART, principa
Chaque trame est encadrée par des caractères spéciaux :
- **STX** (Start of Text) : `0x02`
- **ETX** (End of Text) : `0x03`
- **ESCAPE** (Before special char) : `0x1B`
- **STX** (Start of Text) : `0x02`
- **ETX** (End of Text) : `0x03`
**Format de trame :**
```
0x02 OP_CODE VALUE_1 VALUE_2 ... 0x1B 0x03
```
---
## Détail des commandes
| OP_CODE | Nom | Description | Format |
|---------|---------------------------|--------------------------------------------------------------|------------------------------------------------------------------------|
| 0x01 | Wi-Fi State | Indique l'état du Wi-Fi (0 = down, 1 = up) | `0x02 0x01 [0x00/0x01] 0x03` |
| 0x02 | Connection Update | Notification de connexion ou déconnexion dun appareil | `0x02 0x02 [0x00/0x01] [MAC_ADDR (6 bytes)] 0x03` |
| 0x03 | Request Connected Devices | Demande la liste des appareils connectés | `0x02 0x03 0x03` |
| 0x04 | Send Message | Envoie un message à un appareil connecté via son MAC | `0x02 0x04 [MAC_ADDR (6 bytes)] [LEN (1 byte)] [MESSAGE] 0x03` |
| OP_CODE | Nom | Description | Format |
|---------|---------------------------|---------------------------------------------------------|-------------------------------------------------------------------------------|
| 0x00 | Error | Indique une erreur | `0x02 0x00 [ERROR_CODE] 0x1B 0x03` |
| 0x01 | Wi-Fi State | Indique l'état du Wi-Fi (0 = down, 1 = up) | `0x02 0x01 [0x00/0x01] 0x1B 0x03` |
| 0x02 | Connection Update | Notification de connexion ou déconnexion dun appareil | `0x02 0x02 [0x00/0x01] [MAC_ADDR (6 bytes)] 0x1B 0x03` |
| 0x03 | Request Connected Devices | Demande la liste des appareils connectés | `0x02 0x03 0x1B 0x03` |
| 0x04 | Send Connected Devices | Envoie la liste des appareil connecter | `0x02 0x04 [LEN (1 byte)] [MAC_LIST (n bytes)[MAC_ADDR (6 bytes)]] 0x1B 0x03` |
| 0x05 | Send Message | Envoie un message à un appareil connecté via son MAC | `0x02 0x05 [MAC_ADDR (6 bytes)] [LEN (1 byte)] [MESSAGE] 0x1B 0x03` |
---
## Détail des code erreur
| ERROR_CODE | Description |
|---------------|---------------------------------------------------------------|
| 0x00 | |
| 0x01 | Unknow command |
| 0x02 | Args error |
| 0x03 | Invalid Trame |
| 0x04 | Too long trame |
---