Documentation ¶
Index ¶
- Variables
- func ChangeDeviceState(state string, deviceID string)
- func ChangeTwinValue(updateMessage DeviceTwinUpdate, deviceID string)
- func GetTwin(updateMessage DeviceTwinUpdate, deviceID string)
- func HubClientInit(server, clientID, username, password string) *MQTT.ClientOptions
- func MqttConnect(mqttMode int, mqttInternalServer, mqttServer string)
- func OnTwinMessageReceived(client MQTT.Client, message MQTT.Message)
- func SyncToCloud(updateMessage DeviceTwinUpdate, deviceID string)
- func TwinSubscribe(deviceID string)
- type BaseMessage
- type DeviceStateUpdate
- type DeviceTwinResult
- type DeviceTwinUpdate
- type MsgTwin
- type Token
- type TwinValue
- type TwinVersion
- type TypeMetadata
- type ValueMetadata
Constants ¶
This section is empty.
Variables ¶
var ( DeviceETPrefix = "$hw/events/device/" DeviceETStateUpdateSuffix = "/state/update" TwinETUpdateSuffix = "/twin/update" TwinETCloudSyncSuffix = "/twin/cloud_updated" TwinETGetSuffix = "/twin/get" TwinETGetResultSuffix = "/twin/get/result" )
var Client MQTT.Client
var ClientOpts *MQTT.ClientOptions
var ControllerWg sync.WaitGroup
var TwinAttributes []string
var Wg sync.WaitGroup
Functions ¶
func ChangeDeviceState ¶
ChangeDeviceState function is used to change the state of the device
func ChangeTwinValue ¶
func ChangeTwinValue(updateMessage DeviceTwinUpdate, deviceID string)
ChangeTwinValue sends the updated twin value to the edge through the MQTT broker
func GetTwin ¶
func GetTwin(updateMessage DeviceTwinUpdate, deviceID string)
GetTwin function is used to get the device twin details from the edge
func HubClientInit ¶
func HubClientInit(server, clientID, username, password string) *MQTT.ClientOptions
HubclientInit create mqtt client config
func MqttConnect ¶
MqttConnect function felicitates the MQTT connection
func OnTwinMessageReceived ¶
OnTwinMessageReceived callback function which is called when message is received
func SyncToCloud ¶
func SyncToCloud(updateMessage DeviceTwinUpdate, deviceID string)
SyncToCloud function syncs the updated device twin information to the cloud
func TwinSubscribe ¶
func TwinSubscribe(deviceID string)
subscribe function subscribes the device twin information through the MQTT broker
Types ¶
type BaseMessage ¶
BaseMessage the base struct of event message
type DeviceStateUpdate ¶
type DeviceStateUpdate struct {
State string `json:"state,omitempty"`
}
DeviceStateUpdate is the structure used in updating the device state
type DeviceTwinResult ¶
type DeviceTwinResult struct { BaseMessage Twin map[string]*MsgTwin `json:"twin"` }
DeviceTwinResult device get result
var TwinResult DeviceTwinResult
type DeviceTwinUpdate ¶
type DeviceTwinUpdate struct { BaseMessage Twin map[string]*MsgTwin `json:"twin"` }
DeviceTwinUpdate the struct of device twin update
func CreateActualUpdateMessage ¶
func CreateActualUpdateMessage(updatedTwinAttributes map[string]string) DeviceTwinUpdate
CreateActualUpdateMessage function is used to create the device twin update message
type MsgTwin ¶
type MsgTwin struct { Expected *TwinValue `json:"expected,omitempty"` Actual *TwinValue `json:"actual,omitempty"` Optional *bool `json:"optional,omitempty"` Metadata *TypeMetadata `json:"metadata,omitempty"` ExpectedVersion *TwinVersion `json:"expected_version,omitempty"` ActualVersion *TwinVersion `json:"actual_version,omitempty"` }
MsgTwin the struct of device twin
type TwinValue ¶
type TwinValue struct { Value *string `json:"value,omitempty"` Metadata *ValueMetadata `json:"metadata,omitempty"` }
TwinValue the struct of twin value
type TwinVersion ¶
TwinVersion twin version
type TypeMetadata ¶
type TypeMetadata struct {
Type string `json:"type,omitempty"`
}
TypeMetadata the meta of value type
type ValueMetadata ¶
type ValueMetadata struct {
Timestamp int64 `json:"timestamp,omitempty"`
}
ValueMetadata the meta of value