|
|
package events
import ( "fmt" "git.aiterp.net/lucifer3/server/device" )
type DeviceConnected struct { Prefix string `json:"prefix"` }
func (e DeviceConnected) EventDescription() string { return fmt.Sprintf("DeviceConnected(prefix:%s)", e.Prefix) }
type DeviceDisconnected struct { Prefix string `json:"prefix"` Reason string `json:"reason"` }
func (e DeviceDisconnected) EventDescription() string { return fmt.Sprintf("DeviceDisconnected(prefix:%s, reason:%s)", e.Prefix, e.Reason) }
type HardwareState struct { ID string `json:"internalId"` InternalName string `json:"internalName"` SupportFlags device.SupportFlags `json:"deviceFlags"` ColorFlags device.ColorFlag `json:"colorFlags"` Buttons []string `json:"buttons"` State device.State `json:"state"` }
func (e HardwareState) EventDescription() string { return fmt.Sprintf("HardwareState(id:%s, iname:%#+v, sflags:%s, cflags:%s, buttons:%v, state:%s)", e.ID, e.InternalName, e.SupportFlags, e.ColorFlags, e.Buttons, e.State, ) }
type HardwareMetadata struct { ID string `json:"id"` X int `json:"x,omitempty"` Y int `json:"y,omitempty"` O int `json:"o,omitempty"` ShapeType string `json:"shapeType,omitempty"` Icon string `json:"icon,omitempty"` SerialNumber string `json:"serialNumber,omitempty"` FirmwareVersion string `json:"firmwareVersion,omitempty"` }
func (e HardwareMetadata) EventDescription() string { return fmt.Sprintf("HardwareMetadata(id:%s, icon:%s, ...)", e.ID, e.Icon) }
// DeviceReady is triggered to indicate that all hardware states have been pushed to the bus ahead of this event.
type DeviceReady struct { ID string `json:"id"` }
func (d DeviceReady) EventDescription() string { return fmt.Sprintf("DeviceReady(id:%s)", d.ID) }
type DevicesUnreachable struct { ID string `json:"id"` }
func (d DevicesUnreachable) EventDescription() string { return fmt.Sprintf("DevicesUnreachable(id:%s)", d.ID) }
type DeviceFailed struct { ID string `json:"id"` Error string `json:"error"` }
func (e DeviceFailed) EventDescription() string { return fmt.Sprintf("DeviceFailed(id:%s, err:%s)", e.ID, e.Error) }
type DeviceAvailable struct { ID string Name string }
func (e DeviceAvailable) EventDescription() string { return fmt.Sprintf("DeviceAvailable(id:%s, name:%s)") }
type DeviceAccepted struct { ID string `json:"id"` APIKey string `json:"apiKey"` Extras map[string]string `json:"extras"` }
func (e DeviceAccepted) EventDescription() string { // TODO: Use formattools.Asterisks
return fmt.Sprintf("DeviceAccepted(id:%s, apiKey:%s)", e.ID, e.APIKey) }
|