mirror of
https://github.com/IS1DI/x0gp.git
synced 2026-07-16 20:47:55 +00:00
feat(server): integrate UDP video service and normalize database schema
- Implement UDPVideoService to stream MJPEG video frames from ESP32s via UDP and send control commands. - Normalize race database schema: - Remove redundant driver_ids array from races table (migration 011). - Move per-driver outcomes (total_time_ms, best_lap_ms, position) to race_drivers table (migration 012). - Add device_id column to lobby_drivers to link active physical devices (migration 013). - Update WebSocket handler to pass lobbySvc, driversSvc, and videoSvc for driver identity tracking, syncing in-memory driver metadata, and forwarding WS controls to physical cars. - Add CORS middleware to HTTP routes. - Regenerate Swagger documentation.
This commit is contained in:
@@ -1331,6 +1331,50 @@ paths:
|
||||
summary: Get / update / delete a driver by id
|
||||
tags:
|
||||
- drivers
|
||||
/api/drivers/{id}/device:
|
||||
put:
|
||||
description: Dispatches on HTTP method. Path `/api/drivers/by-nick/{nick}` is
|
||||
a convenience that returns the driver by 3-letter nickname.
|
||||
parameters:
|
||||
- description: Driver id
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: Patch payload (only for PUT)
|
||||
in: body
|
||||
name: driver
|
||||
schema:
|
||||
$ref: '#/definitions/transport.DriverUpdateRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Driver payload or update result
|
||||
schema:
|
||||
$ref: '#/definitions/transport.Driver'
|
||||
"204":
|
||||
description: Delete ack
|
||||
schema:
|
||||
$ref: '#/definitions/transport.Driver'
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
"404":
|
||||
description: Driver not found
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
"500":
|
||||
description: Internal server error
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
summary: Get / update / delete a driver by id
|
||||
tags:
|
||||
- drivers
|
||||
/api/races:
|
||||
get:
|
||||
description: |-
|
||||
@@ -1850,6 +1894,58 @@ paths:
|
||||
summary: Get / update / delete a track by id
|
||||
tags:
|
||||
- tracks
|
||||
/api/video/control:
|
||||
post:
|
||||
description: Sends a text command (e.g. start, stop, left, right) to the ESP32
|
||||
command port (UDP 8888).
|
||||
parameters:
|
||||
- description: Device ID (0..127)
|
||||
in: query
|
||||
name: id
|
||||
type: integer
|
||||
- description: Command text
|
||||
in: query
|
||||
name: cmd
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Command sent
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
"400":
|
||||
description: Missing cmd parameter
|
||||
schema:
|
||||
type: string
|
||||
"500":
|
||||
description: Internal error
|
||||
schema:
|
||||
type: string
|
||||
summary: Send command to ESP32
|
||||
tags:
|
||||
- video
|
||||
/api/video/stream:
|
||||
get:
|
||||
description: Streams video frames received via UDP as multipart/x-mixed-replace.
|
||||
Suitable for raw img tags in browser.
|
||||
parameters:
|
||||
- description: Device ID (0..127)
|
||||
in: query
|
||||
name: id
|
||||
type: integer
|
||||
produces:
|
||||
- multipart/x-mixed-replace
|
||||
responses:
|
||||
"200":
|
||||
description: MJPEG stream
|
||||
schema:
|
||||
type: string
|
||||
summary: Get MJPEG video stream from ESP32
|
||||
tags:
|
||||
- video
|
||||
/health:
|
||||
get:
|
||||
description: Returns 200 OK with current engine phase, WS connection count and
|
||||
|
||||
Reference in New Issue
Block a user