First api draft for ui communication
This commit is contained in:
+40
-4
@@ -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
@@ -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"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user