Documentation ¶
Index ¶
- Variables
- func AddUser(user *User) error
- func CheckCustomJSCodecsAvailable() error
- func Connect(addr string) error
- func ConnectWithInfo(info *mgo.DialInfo) error
- func DeleteActuator(deviceID string, actuatorID string) (int, error)
- func DeleteCodec(id string) error
- func DeleteSensor(deviceID string, sensorID string) (int, error)
- func DeleteUser(userID string) error
- func GenerateNewGatewayID() string
- func GetConfig(key string) (string, error)
- func GetDeviceMeta(deviceID string) (map[string]interface{}, error)
- func GetDeviceName(deviceID string) (string, error)
- func GetMessages(query *MessagesQuery) *messagesIterator
- func LocalID() string
- func MakeDefaultUser() error
- func MarshalDevice(deviceID string, headers http.Header, w io.Writer) (string, error)
- func NewError(code int, text string) error
- func NewErrorf(code int, format string, a ...interface{}) error
- func PostActuator(deviceID string, actuator *Actuator) error
- func PostCodec(codec *ScriptCodec) error
- func PostDevices(device *Device) error
- func PostMessage(m *Message) error
- func PostSensor(deviceID string, sensor *Sensor) error
- func SetActuatorMeta(deviceID string, actuatorID string, meta map[string]interface{}) error
- func SetConfig(key string, value string) error
- func SetDeviceID(newID string) error
- func SetDeviceMeta(deviceID string, meta Meta) error
- func SetSensorMeta(deviceID string, sensorID string, meta Meta) error
- func SetSensorMetaField(deviceID string, sensorID string, field string, value interface{}) error
- func UnmarshalDevice(deviceID string, headers http.Header, r io.Reader) error
- func UpdateUser(userID string, newProfileData *User) error
- type Actuator
- type CodeError
- type Codec
- type CodecsIter
- type Config
- type Device
- type DeviceIterator
- type Message
- type MessagesQuery
- type Meta
- func PostActuatorValue(deviceID string, actuatorID string, val Value) (Meta, error)
- func PostActuatorValues(deviceID string, actuatorID string, vals []Value) (Meta, error)
- func PostSensorValue(deviceID string, sensorID string, val Value) (Meta, error)
- func PostSensorValues(deviceID string, sensorID string, vals []Value) (Meta, error)
- func SetActuatorName(deviceID string, actuatorID string, name string) (Meta, error)
- func SetDeviceName(deviceID string, name string) (Meta, error)
- func SetSensorName(deviceID string, sensorID string, name string) (Meta, error)
- type Query
- type ScriptCodec
- type ScriptExecutor
- type Sensor
- type User
- type Value
- type ValueIterator
- type ValuesQuery
Constants ¶
This section is empty.
Variables ¶
var Codecs = map[string]Codec{}
var DefaultInterval = time.Second * 5
DefaultInterval for sync.
var ErrNotFound = CodeError{404, "device or sensor/actuator not found"}
ErrNotFound is returned when the entity was not found.
var ScriptExecutors = map[string]ScriptExecutor{}
Functions ¶
func CheckCustomJSCodecsAvailable ¶
func CheckCustomJSCodecsAvailable() error
TODO: use proper logging and error handling
func ConnectWithInfo ¶
ConnectWithInfo initializes the edge core by connecting to the database.
func DeleteActuator ¶
DeleteActuator removes this actuator from the device and deletes all data points. This returns the number of data points deleted.
func DeleteCodec ¶
func DeleteSensor ¶
DeleteSensor removes this sensor from the device and deletes all data points. This returns the number of data points deleted.
func GenerateNewGatewayID ¶
func GenerateNewGatewayID() string
GenerateNewGatewayID generated a new ID for the gateway that will be Unique and Random
func GetDeviceMeta ¶
GetDeviceMeta returns the metadata of that device.
func GetDeviceName ¶
GetDeviceName returns the name of that device.
func GetMessages ¶
func GetMessages(query *MessagesQuery) *messagesIterator
func MakeDefaultUser ¶
func MakeDefaultUser() error
MakeDefaultUser checks if there is no user registered in database, it makes a default user user: admin pass: loragateway
func MarshalDevice ¶
MarshalDevice writes complex data to the device. This might be JSON data, LoRaWAN XLPP payload or something else.
func PostActuator ¶
PostActuator creates a new actuator for this device.
func PostCodec ¶
func PostCodec(codec *ScriptCodec) error
func PostDevices ¶
PostDevices creates a new device a the database.
func PostMessage ¶
func PostSensor ¶
PostSensor creates a new sensor for this device.
func SetActuatorMeta ¶
SetActuatorMeta changes this actuators metadata.
func SetDeviceMeta ¶
SetDeviceMeta changes a device metadata.
func SetSensorMeta ¶
SetSensorMeta changes this sensors metadata.
func SetSensorMetaField ¶
func UnmarshalDevice ¶
UnmarshalDevice writes complex data to the device. This might be JSON data, LoRaWAN XLPP payload or something else.
func UpdateUser ¶
Types ¶
type Actuator ¶
type Actuator struct { ID string `json:"id" bson:"id"` Name string `json:"name" bson:"name"` Modified time.Time `json:"modified" bson:"modified"` Created time.Time `json:"created" bson:"created"` Time *time.Time `json:"time" bson:"time"` Value interface{} `json:"value" bson:"value"` Meta Meta `json:"meta" bson:"meta"` // contains filtered or unexported fields }
Actuator represents a Waziup actuator
func GetActuator ¶
GetActuator returns the Waziup actuator.
func (*Actuator) MarshalJSON ¶
func (*Actuator) SetJSONSelect ¶
type Codec ¶
type CodecsIter ¶
type CodecsIter struct {
// contains filtered or unexported fields
}
CodecsIter iterates over codecs. Call .Next() to get the next codec.
func (*CodecsIter) Next ¶
func (iter *CodecsIter) Next() (*ScriptCodec, error)
Next returns the next codec or nil.
type Device ¶
type Device struct { Name string `json:"name" bson:"name"` ID string `json:"id" bson:"_id"` Sensors []*Sensor `json:"sensors" bson:"sensors"` Actuators []*Actuator `json:"actuators" bson:"actuators"` Modified time.Time `json:"modified" bson:"modified"` Created time.Time `json:"created" bson:"created"` Meta Meta `json:"meta" bson:"meta"` // contains filtered or unexported fields }
Device represents a Waziup Device.
func DeleteDevice ¶
DeleteDevice removes the device and all sensor and actuator values from the database. This returns the removed device and the number of sensor and actuator values that were removed.
func (*Device) MarshalJSON ¶
func (*Device) SetJSONSelect ¶
type DeviceIterator ¶
type DeviceIterator struct {
// contains filtered or unexported fields
}
DeviceIterator iterates over devices. Call .Next() to get the next device.
func GetDevices ¶
func GetDevices(query *Query) *DeviceIterator
GetDevices returns an iterator over all devices.
func (*DeviceIterator) Next ¶
func (iter *DeviceIterator) Next() (*Device, error)
Next returns the next device or nil.
type Message ¶
type Message struct { ID bson.ObjectId `json:"id" bson:"_id"` Text string `json:"text" bson:"text"` Title string `json:"title" bson:"title"` Severity string `json:"severity" bson:"severity"` HRef string `json:"href" bson:"href"` Target string `json:"target" bson:"target"` Time time.Time `json:"time" bson:"time"` DisplayDuration int `json:"displayDuration" bson:"displayDuration"` }
type MessagesQuery ¶
type Meta ¶
type Meta map[string]interface{}
Meta holds entity metadata.
func PostActuatorValue ¶
PostActuatorValue stores a new actuator value for this actuator.
func PostActuatorValues ¶
PostActuatorValues can be used to post multiple data point for this actuator.
func PostSensorValue ¶
PostSensorValue stores a new sensor value for this sensor.
func PostSensorValues ¶
PostSensorValues can be used to post multiple data point for this sensor.
func SetActuatorName ¶
SetActuatorName changes this actuators name.
func SetDeviceName ¶
SetDeviceName changes a device name.
func SetSensorName ¶
SetSensorName changes this sensors name.
func (Meta) SyncInterval ¶
SyncInterval = min time between syncs
type ScriptCodec ¶
type ScriptCodec struct { ID string `json:"id" bson:"_id"` Internal bool `json:"internal" bson:"-"` Name string `json:"name" bson:"name"` ServeMime string `json:"serveMime" bson:"serveMime"` Mime string `json:"mime" bson:"mime"` Script string `json:"script" bson:"script"` }
func (ScriptCodec) CodecName ¶
func (codec ScriptCodec) CodecName() string
func (*ScriptCodec) MarshalDevice ¶
func (*ScriptCodec) UnmarshalDevice ¶
type ScriptExecutor ¶
type Sensor ¶
type Sensor struct { ID string `json:"id" bson:"id"` Name string `json:"name" bson:"name"` Modified time.Time `json:"modified" bson:"modified"` Created time.Time `json:"created" bson:"created"` Kind ontology.SensingKind `json:"kind" bson:"kind"` Quantity ontology.Quantity `json:"quantity" bson:"quantity"` Unit ontology.Unit `json:"unit" bson:"unit"` Time *time.Time `json:"time" bson:"time"` Value interface{} `json:"value" bson:"value"` Meta Meta `json:"meta" bson:"meta"` // contains filtered or unexported fields }
Sensor represents a Waziup sensor
func (*Sensor) MarshalJSON ¶
func (*Sensor) SetJSONSelect ¶
type User ¶
type User struct { ID string `json:"id" bson:"_id"` Name string `json:"name" bson:"name"` Username string `json:"username" bson:"username"` Password string `json:"password" bson:"password"` NewPassword string `json:"newPassword"` }
User represents a Wazigate user
func CheckUserCredentials ¶
func FindUserByUsername ¶
FindUserByUsername finds and returns the Wazigate user based on a given username
type Value ¶
type Value struct { Value interface{} `json:"value" bson:"value"` Time time.Time `json:"time" bson:"time"` }
Value is one datapoint
type ValueIterator ¶
ValueIterator iterates over data points. Call .Next() to get the next value.
func GetActuatorValues ¶
func GetActuatorValues(deviceID string, actuatorID string, query *ValuesQuery) ValueIterator
GetActuatorValues returns an iterator over all actuator values.
func GetSensorValues ¶
func GetSensorValues(deviceID string, sensorID string, query *ValuesQuery) ValueIterator
GetSensorValues returns an iterator over all sensor values.