forked from tanchou/Verilog
Enhance ESP32 command processing: add validation, error handling, and new command types for device management
This commit is contained in:
@@ -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 d’un 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 d’un 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 |
|
||||
|
||||
---
|
||||
|
||||
|
Reference in New Issue
Block a user