Documentation
¶
Index ¶
- Constants
- type Action
- type Connector
- type Gateway
- func (g *Gateway) CallAction(data map[string]interface{})
- func (g *Gateway) Deregister(id string)
- func (g *Gateway) IsRegistered() bool
- func (g *Gateway) Register(id string, name string, instance Instance)
- func (g *Gateway) SendData(data map[string]interface{}) error
- func (g *Gateway) Start() error
- func (g *Gateway) Stop() error
- type Instance
- type MqttConnector
- type Property
- type Thing
Constants ¶
const ( // PropertyTypeInt represents number type of a property PropertyTypeInt = 0 // PropertyTypeString represents string type of a property PropertyTypeString = 1 // PropertyTypeBool represents boolean type of a property PropertyTypeBool = 2 // PropertyTypeColor represents color type of a property PropertyTypeColor = 3 )
const GatewayModeHttpPull = 0
GatewayModeHttpPull connect to DevIoT using pull based HTTP protocol
const GatewayModeHttpPush = 1
GatewayModeHttpPush connect to DevIoT using push based HTTP protocol
const GatewayModeMqtt = 2
GatewayModeMqtt connect to DevIoT using MQTT protocol
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct {
Name string `json:"name,omitempty"`
Parameters []Property `json:"parameters,omitempty"`
}
Action represents a action model in DevIoT
func (*Action) AddParameter ¶
AddParameter add a parameter to action model
type Gateway ¶
type Gateway struct {
Name string `json:"name"`
Kind string `json:"kind,omitempty"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
Data string `json:"data,omitempty"`
Action string `json:"action,omitempty"`
Account string `json:"owner,omitempty"`
Mode int `json:"mode"`
Things map[string]wrapper `json:"sensors,omitempty"`
Logger *log.Logger
// contains filtered or unexported fields
}
Gateway represents gateway service
func NewGateway ¶
func NewGateway(name string, deviotServer string, connectorServer string, account string, opts map[string]interface{}) (*Gateway, error)
NewGateway create a gateway service
func (*Gateway) CallAction ¶
CallAction call an action on thing
func (*Gateway) Deregister ¶
Deregister a thing from gateway service
func (*Gateway) IsRegistered ¶
IsRegistered check if gateway service has been registered to DevIoT
type Instance ¶
type Instance interface {
Init(thing *Thing)
}
Instance represents a thing instance can be registered to DevIoT
type MqttConnector ¶
type MqttConnector struct {
DataTopic string
ActionTopic string
// contains filtered or unexported fields
}
MqttConnector represents mqtt based connector
func NewMqttConnector ¶
func NewMqttConnector(gateway *Gateway, connectorServer string) (*MqttConnector, error)
NewMqttConnector create a mqtt based connector
func (*MqttConnector) Publish ¶
func (c *MqttConnector) Publish(data map[string]interface{}) error
Publish to DevioT server
type Property ¶
type Property struct {
Name string `json:"name"`
Type int `json:"type"`
Value interface{} `json:"value,omitempty"`
Range []interface{} `json:"range,omitempty"`
Unit string `json:"unit,omitempty"`
Description string `json:"description,omitempty"`
}
Property represents a property model in DevIoT
type Thing ¶
type Thing struct {
Id string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind,omitempty"`
Actions []Action `json:"actions,omitempty"`
Properties []Property `json:"properties,omitempty"`
}
Thing represents a thing model in DevIoT
func (*Thing) AddProperty ¶
AddProperty add a property to thing model