diff --git a/TODO.md b/TODO.md index 1dcf2f4..b80a184 100644 --- a/TODO.md +++ b/TODO.md @@ -23,7 +23,7 @@ - [DISPATCHED] (root_agent) Kick off milestone v0.4.0 planning - [DISPATCHED] (esp_agent) Implement bidirectional serial protocol and WiFi config -- [DISPATCHED] (protocol_agent) Define command bridge and heartbeat messages +- [DONE] (protocol_agent) Define command bridge and heartbeat messages (see docs/progress/2025-06-18_20-45_protocol_agent_esp_commands.md) - [DISPATCHED] (firmware_agent) Integrate ESP bridge with Arduino Due - [DISPATCHED] (ui_agent) Host minimal Web UI for real-time DDS control - [DISPATCHED] (docs_agent) Document Web UI and ESP configuration diff --git a/docs/impl/commands.md b/docs/impl/commands.md index 182f3f6..9acb60e 100644 --- a/docs/impl/commands.md +++ b/docs/impl/commands.md @@ -19,3 +19,21 @@ human-readable tokens documented in `command_spec.md`. Hardware pin names referenced here match the tables in [`docs/configuration/pins.md`](../configuration/pins.md). + +## ESP Interface Commands + +These commands target the optional ESP8266-01 WiFi bridge. All ESP commands +start with the letter `E` to distinguish them from the regular DDS commands. + +| Constant | Command | Description | +| --- | --- | --- | +| `CMD_ESP_ON` | `EON` | Enable the ESP bridge | +| `CMD_ESP_OFF` | `EOF` | Disable the ESP bridge | +| `CMD_ESP_STATUS` | `EST` | Query ESP status | +| `CMD_ESP_VERSION` | `EVR` | Request ESP firmware version | +| `CMD_ESP_MODE` | `EMD` | Set bridge mode / argument required | +| `CMD_ESP_LED_ON` | `EL1` | Turn WiFi status LED on | +| `CMD_ESP_LED_OFF` | `EL0` | Turn WiFi status LED off | + +General diagnostic commands `CMD_STATUS` and `CMD_VERSION` are also available +and apply to the Arduino Due firmware itself. diff --git a/docs/progress/2025-06-18_20-45_protocol_agent_esp_commands.md b/docs/progress/2025-06-18_20-45_protocol_agent_esp_commands.md new file mode 100644 index 0000000..f1a7d7b --- /dev/null +++ b/docs/progress/2025-06-18_20-45_protocol_agent_esp_commands.md @@ -0,0 +1,13 @@ +# ESP command finalization +Date: 2025-06-18 20:45 CEST + +- added diagnostic macros `CMD_STATUS` and `CMD_VERSION` +- shortened ESP command tokens and introduced `CMD_ESP_VERSION` +- updated `CommandParser` to handle the new constants +- documented all ESP commands in `docs/impl/commands.md` + +Affected files: +- `firmware/shared/commands.h` +- `protocol/ascii/constants.py` +- `firmware/due/CommandParser.cpp` +- `docs/impl/commands.md` diff --git a/firmware/due/CommandParser.cpp b/firmware/due/CommandParser.cpp index 8fc356d..c0e7663 100644 --- a/firmware/due/CommandParser.cpp +++ b/firmware/due/CommandParser.cpp @@ -75,6 +75,10 @@ String CommandParser::handleCommand(const String& cmd) { esp_send(CMD_ESP_STATUS); return "OK:REQ"; } + if (cmd == CMD_ESP_VERSION) { + esp_send(CMD_ESP_VERSION); + return "OK:REQ"; + } if (cmd.rfind(CMD_ESP_MODE, 0) == 0) { esp_send(cmd); return "OK:MODE"; @@ -92,11 +96,11 @@ String CommandParser::handleCommand(const String& cmd) { return "ERR:ESP_DISABLED"; } #endif - if (cmd == "STATUS") { + if (cmd == CMD_STATUS) { return String("OK:FREQ ") + std::to_string(dds->getFrequency()) + " WAVE " + std::to_string(dds->getWaveform()); } - if (cmd == "VERSION") { + if (cmd == CMD_VERSION) { return "OK:VERSION 0.0.1"; } return "ERR:INVALID_COMMAND"; diff --git a/firmware/shared/commands.h b/firmware/shared/commands.h index 8bb8b0a..72e6930 100644 --- a/firmware/shared/commands.h +++ b/firmware/shared/commands.h @@ -14,17 +14,22 @@ #define CMD_OUTPUT_ON "ON" #define CMD_OUTPUT_OFF "OFF" +// Diagnostic commands +#define CMD_STATUS "STATUS" +#define CMD_VERSION "VERSION" + // Preset management #define CMD_SAVE "SAVE" // Save to EEPROM or preset slot #define CMD_LOAD "LOAD" // Load from EEPROM or preset slot #define CMD_DELETE "DELETE" // Delete preset slot -// ESP8266 control commands -#define CMD_ESP_ON "ESPON" -#define CMD_ESP_OFF "ESPOFF" -#define CMD_ESP_STATUS "ESPSTS" -#define CMD_ESP_MODE "ESPMODE" -#define CMD_ESP_LED_ON "ESPLEDON" -#define CMD_ESP_LED_OFF "ESPLEDOFF" +// ESP8266 control commands (all prefixed with 'E') +#define CMD_ESP_ON "EON" +#define CMD_ESP_OFF "EOF" +#define CMD_ESP_STATUS "EST" +#define CMD_ESP_VERSION "EVR" +#define CMD_ESP_MODE "EMD" +#define CMD_ESP_LED_ON "EL1" +#define CMD_ESP_LED_OFF "EL0" #endif // SHARED_COMMANDS_H diff --git a/protocol/ascii/constants.py b/protocol/ascii/constants.py index 41df9ac..8393aa2 100644 --- a/protocol/ascii/constants.py +++ b/protocol/ascii/constants.py @@ -8,3 +8,14 @@ CMD_LOAD = "LOAD" CMD_DELETE = "DELETE" +CMD_STATUS = "STATUS" +CMD_VERSION = "VERSION" + +CMD_ESP_ON = "EON" +CMD_ESP_OFF = "EOF" +CMD_ESP_STATUS = "EST" +CMD_ESP_VERSION = "EVR" +CMD_ESP_MODE = "EMD" +CMD_ESP_LED_ON = "EL1" +CMD_ESP_LED_OFF = "EL0" +