Documentation ¶
Overview ¶
Package mqttadapter is a package to process mqtt message publish messages to EdgeCore and subscribe to EdgeCore messages
Index ¶
- func CreateMessageData(name string, valueType string, value string) (msg []byte, err error)
- func CreateMessageState(state string) (msg []byte, err error)
- func CreateMessageTwinUpdate(name string, valueType string, value string) (msg []byte, err error)
- func SendData(ctx context.Context, id string, instance *configmap.DeviceInstance, ...)
- func SendDeviceState(ctx context.Context, id string, instance *configmap.DeviceInstance, ...)
- func SendTwin(ctx context.Context, id string, instance *configmap.DeviceInstance, ...)
- func SyncInfo(dic *di.Container, message mqtt.Message)
- func UpdateDevice(dic *di.Container, message mqtt.Message)
- type BaseMessage
- type DataMetadata
- type DataValue
- type DeviceData
- type DeviceTwinDelta
- type DeviceTwinResult
- type DeviceTwinUpdate
- type DeviceUpdate
- type DriverUnit
- type MsgAttr
- type MsgTwin
- type StatusData
- type TwinData
- type TwinValue
- type TwinVersion
- type TypeMetadata
- type ValueMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMessageData ¶
CreateMessageData create binary data for structure of DeviceData
func CreateMessageState ¶
CreateMessageState create binary data for structure of DeviceData
func CreateMessageTwinUpdate ¶
CreateMessageTwinUpdate create twin update message.
func SendData ¶
func SendData(ctx context.Context, id string, instance *configmap.DeviceInstance, drivers models.ProtocolDriver, mqttClient mqttclient.MqttClient, wg *sync.WaitGroup, dic *di.Container, mutex *common.Lock)
SendData send twin to third-part application according to timer
func SendDeviceState ¶
func SendDeviceState(ctx context.Context, id string, instance *configmap.DeviceInstance, drivers models.ProtocolDriver, mqttClient mqttclient.MqttClient, wg *sync.WaitGroup, dic *di.Container, mutex *common.Lock)
SendDeviceState send device's state to EdgeCore according to timer
func SendTwin ¶
func SendTwin(ctx context.Context, id string, instance *configmap.DeviceInstance, drivers models.ProtocolDriver, mqttClient mqttclient.MqttClient, wg *sync.WaitGroup, dic *di.Container, mutex *common.Lock)
SendTwin send twin to EdgeCore according to timer
Types ¶
type BaseMessage ¶
BaseMessage the base structure of mqttadapter message.
type DataMetadata ¶
DataMetadata data metadata.
type DataValue ¶
type DataValue struct { Value string `json:"value"` Metadata DataMetadata `json:"metadata"` }
DataValue data value.
type DeviceData ¶
type DeviceData struct { BaseMessage Data map[string]*DataValue `json:"data"` }
DeviceData device data structure.
type DeviceTwinDelta ¶
type DeviceTwinDelta struct { BaseMessage Twin map[string]*MsgTwin `json:"twin"` Delta map[string]string `json:"delta"` }
DeviceTwinDelta twin delta.
type DeviceTwinResult ¶
type DeviceTwinResult struct { BaseMessage Twin map[string]*MsgTwin `json:"twin"` }
DeviceTwinResult device get result.
type DeviceTwinUpdate ¶
type DeviceTwinUpdate struct { BaseMessage Twin map[string]*MsgTwin `json:"twin"` }
DeviceTwinUpdate the structure of device twin update.
type DeviceUpdate ¶
type DeviceUpdate struct { BaseMessage State string `json:"state,omitempty"` Attributes map[string]*MsgAttr `json:"attributes"` }
DeviceUpdate device update.
type DriverUnit ¶
type DriverUnit struct {
// contains filtered or unexported fields
}
DriverUnit the structure necessary to send a message
type MsgAttr ¶
type MsgAttr struct { Value string `json:"value"` Optional *bool `json:"optional,omitempty"` Metadata *TypeMetadata `json:"metadata,omitempty"` }
MsgAttr the struct of device attr
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 structure of device twin.
type StatusData ¶
type StatusData struct { MqttClient mqttclient.MqttClient // contains filtered or unexported fields }
StatusData the structure of device status.
func (*StatusData) Run ¶
func (sd *StatusData) Run()
Run start timer function to get device's status and send it to mqtt broker
type TwinData ¶
type TwinData struct { Name string Type string Topic string Value string MqttClient mqttclient.MqttClient // contains filtered or unexported fields }
TwinData the structure of device twin
type TwinValue ¶
type TwinValue struct { Value *string `json:"value,omitempty"` Metadata ValueMetadata `json:"metadata,omitempty"` }
TwinValue the structure 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.