First api draft for ui communication

This commit is contained in:
2026-02-08 19:11:49 +01:00
parent f4f3c695af
commit 7534459e73
3 changed files with 46 additions and 9 deletions
+40 -4
View File
@@ -4,8 +4,44 @@ const (
TopicFrontendCmd = "front:cmd"
)
type FrontendCmd struct {
Action string `json:"action"`
ID byte `json:"id"`
Data []byte `json:"data"`
const (
CmdUpdateValue = "update_value"
CmdInitState = "init_state"
CmdConnect = "connect"
CmdDisconnect = "disconnect"
CmdRX = "uart_rx"
CmdTX = "uart_tx"
)
type WsMessage struct {
Cmd string `json:"cmd"`
Payload any `json:"payload"`
}
type SystemState struct {
Adapters []string `json:"adapters"`
SelectedAdapter string `json:"selected_adapter"`
Baudrates string `json:"baudrates"`
SelectedBaudrate string `json:"selected_baudrate"`
UartConnected bool `json:"uart_connected"`
}
type WsUartConnect struct {
SelectedAdapter string `json:"selected_adapter"`
Baudrates string `json:"baudrates"`
}
type WsUartDisconnect struct {
}
type WsUartSendMessage struct {
Data []byte `json:"data"`
}
type WsUartRX struct {
Data []byte `json:"data"`
}
type WsUartTX struct {
Data []byte `json:"data"`
}
+4 -3
View File
@@ -2,9 +2,10 @@ package api
// Topics
const (
TopicUARTRx = "uart:rx"
TopicUARTTx = "uart:tx"
TopicUARTError = "uart:error"
TopicUARTRx = "uart:rx"
TopicUARTTx = "uart:tx"
TopicUARTError = "uart:error"
TopicUartAction = "uart:action"
TopicOTA = "ota"
)