first
This commit is contained in:
38
pkg/protocol/types.go
Normal file
38
pkg/protocol/types.go
Normal file
@@ -0,0 +1,38 @@
|
||||
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"
|
||||
)
|
||||
Reference in New Issue
Block a user