39 lines
992 B
Go
39 lines
992 B
Go
package protocol
|
|
|
|
import "time"
|
|
|
|
// WebSocketMessage represents messages sent between server and client
|
|
type WebSocketMessage struct {
|
|
Type string `json:"type"`
|
|
Device string `json:"device,omitempty"`
|
|
Data interface{} `json:"data,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
Timestamp time.Time `json:"timestamp"`
|
|
}
|
|
|
|
// DeviceStatus represents the status of any device
|
|
type DeviceStatus struct {
|
|
Connected bool `json:"connected"`
|
|
LastSeen time.Time `json:"last_seen"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
|
|
// Message types
|
|
const (
|
|
MsgTypeStatus = "status"
|
|
MsgTypeCommand = "command"
|
|
MsgTypeUpdate = "update"
|
|
MsgTypeError = "error"
|
|
MsgTypeWeather = "weather"
|
|
MsgTypeLightning = "lightning"
|
|
)
|
|
|
|
// Device names
|
|
const (
|
|
DeviceWebSwitch = "webswitch"
|
|
DevicePowerGenius = "power_genius"
|
|
DeviceTunerGenius = "tuner_genius"
|
|
DeviceAntennaGenius = "antenna_genius"
|
|
DeviceRotatorGenius = "rotator_genius"
|
|
)
|