You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(mqtt): make req_id optional for all MQTT command payloads
The 'req_id' field in MQTT command payloads is now optional. This required
changes to the JSON schema validation and the response handling logic.
- Updates `BASE_SCHEMA` and `SEND_MSG_SCHEMA` in `signalduino/commands.py` to remove the `req_id` requirement.
- Modifies `MqttCommandDispatcher.dispatch` to return `None` for `req_id` if not present in the payload.
- Adjusts `MqttPublisher._handle_command` to correctly extract the optional `req_id` for success and error responses.
- Adds `test_controller_handles_get_frequency_without_req_id` to verify the new optional behavior.
- Updates `docs/architecture/proposals/mqtt_set_commands.adoc` to document the optional nature of `req_id`.
Copy file name to clipboardExpand all lines: docs/architecture/proposals/mqtt_set_commands.adoc
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,13 @@ Die Methoden in `SignalduinoCommands` sind für die Umrechnung und das Senden de
93
93
* **Befehlssatz:** Verwendet den generischen Register-Write-Befehl `W1D`. Die Umrechnungslogik von dB-Wert in den Registerindex (`00`-`07`) erfolgt in der Python-Implementierung.
94
94
* **Serial Command:** `W1D<Index>`, gefolgt von `cc1101_write_init()`.
95
95
96
+
=== 3.2. MQTT Payload und `req_id`-Behandlung
97
+
98
+
Das Feld `req_id` in allen MQTT-Command-Payloads (sowohl `set/...` als auch `get/...` und `command/...`) ist ab sofort *optional*.
99
+
100
+
* **Anfrage:** Wird `req_id` nicht in der Anfrage gesendet, darf die Payload-Validierung nicht fehlschlagen.
101
+
* **Antwort:** Bei Fehlen der `req_id` in der Anfrage wird das Feld `req_id` in der Antwort-Payload (Topics `responses` und `errors`) den Wert `null` (JSON null) annehmen.
102
+
96
103
== 4. Fehlerbehandlung und Validierung
97
104
1. **Validierung (Dispatcher):** Die MQTT-Payloads werden durch das in [`SignalduinoCommands.COMMAND_MAP`](signalduino/commands.py) definierte `schema` (z.B. `FREQ_SCHEMA`, `DATARATE_SCHEMA`) vor dem Aufruf der Controller-Methode validiert.
98
105
2. **Serial-Kommunikation:** `SignalduinoCommands._send_command` wird bei Timeout eine `SignalduinoCommandTimeout` werfen. Diese wird im `SignalduinoController` gefangen und als NACK-Statusmeldung zurückgegeben.
0 commit comments