Added ECHO cmd and fixed some timing issues
This commit is contained in:
@@ -216,6 +216,54 @@ Content-Type: application/json
|
||||
{"client_id": 16, "seq": 42}
|
||||
```
|
||||
|
||||
### Echo ping (ESP-NOW round-trip latency)
|
||||
|
||||
```http
|
||||
POST /api/echo-ping
|
||||
Content-Type: application/json
|
||||
{"client_id": 16}
|
||||
```
|
||||
|
||||
`client_id` must be a registered slave id (`> 0`). The host sends a microsecond timestamp; the master forwards it over ESP-NOW and the slave echoes it back unchanged.
|
||||
|
||||
**Flow:** Host → UART → `cmd_espnow_echo_ping` → `ESPNOW_ECHO_PING` (with `master_time_us` from `esp_timer_get_time()`) → Slave → `ESPNOW_ECHO_PONG` → Master `recv_cb` → UART response.
|
||||
|
||||
**Response fields:**
|
||||
|
||||
| Field | Unit | Meaning |
|
||||
|-------|------|---------|
|
||||
| `success` | — | `true` if pong received within 500 ms |
|
||||
| `client_id` | — | Echo of request |
|
||||
| `timestamp_us` | µs (Unix) | Echoed host timestamp; must match request on success |
|
||||
| `rtt_ms` | ms | **Host-side** round-trip: goTool send → UART response (full chain incl. USB serial) |
|
||||
| `esp_rtt_us` | µs | **Master-side** ESP-NOW only: `esp_timer_get_time()` delta from ping send to pong recv |
|
||||
|
||||
`esp_rtt_us` is the raw firmware value (microseconds, not converted). The web dashboard displays it converted to milliseconds for readability (`esp_rtt_us / 1000`, 3 decimal places). The success banner stays visible for at least 5 seconds.
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"client_id": 16,
|
||||
"timestamp_us": 1717654321123456,
|
||||
"rtt_ms": 49.729,
|
||||
"esp_rtt_us": 18234
|
||||
}
|
||||
```
|
||||
|
||||
On failure (`success: false`), `esp_rtt_us` is omitted; `rtt_ms` still reflects the host round-trip. HTTP 503 if UART exchange fails (e.g. timeout, client not in registry).
|
||||
|
||||
**CLI:**
|
||||
|
||||
```bash
|
||||
go run . -port /dev/ttyUSB0 echo-ping -client 16
|
||||
```
|
||||
|
||||
Example output:
|
||||
|
||||
```
|
||||
echo ping: success=true client_id=16 rtt_ms=49.729 esp_rtt_us=18234
|
||||
```
|
||||
|
||||
### Find me
|
||||
|
||||
```http
|
||||
@@ -280,5 +328,6 @@ Same as external API:
|
||||
| Einzelner Slave | `client_id: <id>` |
|
||||
| Alle Slaves deadzone | `all_clients` + `slaves_only` on POST |
|
||||
| Unicast test | `POST /api/unicast-test` |
|
||||
| Echo ping | `POST /api/echo-ping` (per-slave latency; UI shows Host ms + ESP ms) |
|
||||
| Tap notify S/D/T | `PUT /api/clients/{id}/tap-notify` |
|
||||
| Tap receive (UI) | Live stream + tap notify; see WebSocket doc for external API |
|
||||
|
||||
Reference in New Issue
Block a user