Documentation ¶
Index ¶
- Variables
- func AddCloud(cloud *Cloud) error
- func FlagActuator(deviceID string, actuatorID string, action Action, time time.Time, ...)
- func FlagDevice(deviceID string, action Action, meta edge.Meta)
- func FlagSensor(deviceID string, sensorID string, action Action, time time.Time, ...)
- func GetClouds() map[string]*Cloud
- func IncludeDevice(deviceID string)
- func OnEvent(cb EventCallback)
- func OnStatus(cb StatusCallback)
- func ReadCloudConfig(r io.Reader) error
- func RemoveCloud(id string) bool
- func SetDownstream(ds Downstream)
- func WriteCloudConfig(w io.Writer) error
- type Action
- type Cloud
- func (cloud *Cloud) FlagActuator(deviceID string, actuatorID string, action Action, time time.Time, ...)
- func (cloud *Cloud) FlagDevice(deviceID string, action Action, meta edge.Meta)
- func (cloud *Cloud) FlagSensor(deviceID string, sensorID string, action Action, time time.Time, ...)
- func (cloud *Cloud) IncludeDevice(deviceID string)
- func (cloud *Cloud) Printf(format string, code int, a ...interface{})
- func (cloud *Cloud) ResetStatus()
- func (cloud *Cloud) SetPaused(paused bool) (int, error)
- func (cloud *Cloud) SetToken(token string) (int, error)
- func (cloud *Cloud) SetUsername(username string) (int, error)
- func (cloud *Cloud) Wakeup()
- type Downstream
- type Entity
- type Event
- type EventCallback
- type Meta
- type Status
- type StatusCallback
Constants ¶
This section is empty.
Variables ¶
var MaxCloudEvents = 10
MaxCloudEvents is the number of cloud events to keep in memory.
Functions ¶
func FlagActuator ¶
func FlagActuator(deviceID string, actuatorID string, action Action, time time.Time, meta edge.Meta)
FlagActuator marks the actuator as dirty so that it will be synced wih the clouds.
func FlagDevice ¶
FlagDevice marks the device as dirty so that it will be synced with the clouds.
func FlagSensor ¶
FlagSensor marks the sensor as dirty so that it will be synced wih the clouds.
func IncludeDevice ¶
func IncludeDevice(deviceID string)
func ReadCloudConfig ¶
ReadCloudConfig reads clouds.json into the current configuration.
func RemoveCloud ¶
RemoveCloud pauses the cloud with that id and removes it from the cloud atlas.
func SetDownstream ¶
func SetDownstream(ds Downstream)
SetDownstream changes the global Downstream handler.
func WriteCloudConfig ¶
WriteCloudConfig writes the current configurations back to clouds.json.
Types ¶
type Action ¶
type Action int
A Action is performed by the cloud manager to resolve differences between the local stat and the cloud.
const ( // ActionError indicates that there was an error with this entity. ActionError Action = 1 << iota // ActionNoSync indicates that this entity should not be synced. ActionNoSync // ActionSync will synchronoice values from a sensor or actuator. ActionSync // ActionModify modifiy changes names and metadata. ActionModify // ActionCreate creates (declares) the device/sensor/actuator at the cloud. ActionCreate // ActionDelete delete the device/sensor/actuator ActionDelete )
func (Action) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Action) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type Cloud ¶
type Cloud struct { ID string `json:"id"` Name string `json:"name"` Paused bool `json:"paused"` Pausing bool `json:"pausing"` PausingMQTT bool `json:"pausing_mqtt"` REST string `json:"rest"` MQTT string `json:"mqtt"` Registered bool `json:"registered"` Events []Event `json:"events"` Username string `json:"username"` Token string `json:"token"` Status map[Entity]*Status `json:"-"` StatusMutex sync.Mutex `json:"-"` // contains filtered or unexported fields }
Cloud represents a configuration to access a Waziup Cloud.
func (*Cloud) FlagActuator ¶
func (cloud *Cloud) FlagActuator(deviceID string, actuatorID string, action Action, time time.Time, meta edge.Meta)
FlagActuator marks the actuator as dirty.
func (*Cloud) FlagDevice ¶
FlagDevice marks the device as dirty.
func (*Cloud) FlagSensor ¶
func (cloud *Cloud) FlagSensor(deviceID string, sensorID string, action Action, time time.Time, meta edge.Meta)
FlagSensor marks the sensor as dirty.
func (*Cloud) IncludeDevice ¶
IncludeDevice tells the cloud to sync with that device, especially to monitor that device at the remote cloud for actuation data.
func (*Cloud) SetToken ¶
SetToken changes the token (password) that is used for authentication with the waziup cloud.
func (*Cloud) SetUsername ¶
SetUsername changes the uswername that is used for authentication with the waziup cloud.
type Downstream ¶
Downstream handles incomming MQTT packets.
type Entity ¶
type Entity struct { Device string `json:"device,omitempty"` Sensor string `json:"sensor,omitempty"` Actuator string `json:"actuator,omitempty"` }
A Entity is either a Device, Sensor or Actuator.
type Event ¶
type Event struct { Code int `json:"code"` Message string `json:"msg"` Time time.Time `json:"time"` }
Event repesents cloud events.
type EventCallback ¶
EventCallback is called when a cloud changes its state.
type Status ¶
type Status struct { // Remote is the time the cloud is synced to. Remote time.Time `json:"remote"` // Action to perform. Action Action `json:"action"` // Wakeup Time Wakeup time.Time `json:"wakeup"` // Sleep durtion Sleep time.Duration `json:"sleep"` // Error, if any Error error `json:"error,omitempty"` }
Status describes a single entity.
type StatusCallback ¶
StatusCallback is called when a cloud updates its status.