Documentation ¶
Index ¶
- func BuildDeviceAttrUpdate(baseMessage BaseMessage, attrs map[string]*MsgAttr) ([]byte, error)
- func BuildDeviceState(baseMessage BaseMessage, device Device) ([]byte, error)
- func BuildDeviceTwinDelta(baseMessage BaseMessage, twins map[string]*MsgTwin) ([]byte, bool)
- func BuildDeviceTwinDocument(baseMessage BaseMessage, twins map[string]*TwinDoc) ([]byte, bool)
- func BuildDeviceTwinResult(baseMessage BaseMessage, twins map[string]*MsgTwin, dealType int) ([]byte, error)
- func BuildErrorResult(para Parameter) ([]byte, error)
- func BuildMembershipGetResult(baseMessage BaseMessage, devices []*Device) ([]byte, error)
- func CompareVersion(cloudversion string, edgeversion string) bool
- func DeviceAttrToMsgAttr(deviceAttrs []dtclient.DeviceAttr) map[string]*MsgAttr
- func DeviceTwinToMsgTwin(deviceTwins []dtclient.DeviceTwin) map[string]*MsgTwin
- func MarshalMembershipUpdate(result MembershipUpdate) ([]byte, error)
- func MsgAttrToDeviceAttr(name string, msgAttr *MsgAttr) dtclient.DeviceAttr
- func MsgTwinToDeviceTwin(name string, msgTwin *MsgTwin) dtclient.DeviceTwin
- func UpdateCloudVersion(version string) (string, error)
- func UpdateEdgeVersion(version string) (string, error)
- type BaseMessage
- type ConnectedInfo
- type DTMessage
- type DealAttrResult
- type DealTwinResult
- type Device
- type DeviceAttrUpdate
- type DeviceMsg
- type DeviceTwinDelta
- type DeviceTwinDocument
- type DeviceTwinResult
- type DeviceTwinUpdate
- type DeviceUpdate
- type GetDetailNode
- type MembershipDetail
- type MembershipGetResult
- type MembershipUpdate
- type MsgAttr
- type MsgSubPub
- type MsgTwin
- type Parameter
- type Result
- type TwinDoc
- type TwinValue
- type TwinVersion
- type TypeMetadata
- type ValueMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDeviceAttrUpdate ¶
func BuildDeviceAttrUpdate(baseMessage BaseMessage, attrs map[string]*MsgAttr) ([]byte, error)
BuildDeviceAttrUpdate build the DeviceAttrUpdate
func BuildDeviceState ¶
func BuildDeviceState(baseMessage BaseMessage, device Device) ([]byte, error)
BuildDeviceState build the msg
func BuildDeviceTwinDelta ¶
func BuildDeviceTwinDelta(baseMessage BaseMessage, twins map[string]*MsgTwin) ([]byte, bool)
BuildDeviceTwinDelta build device twin delta
func BuildDeviceTwinDocument ¶
func BuildDeviceTwinDocument(baseMessage BaseMessage, twins map[string]*TwinDoc) ([]byte, bool)
BuildDeviceTwinDocument build device twin document
func BuildDeviceTwinResult ¶
func BuildDeviceTwinResult(baseMessage BaseMessage, twins map[string]*MsgTwin, dealType int) ([]byte, error)
BuildDeviceTwinResult build device twin result, 0:get,1:update,2:sync
func BuildErrorResult ¶
BuildErrorResult build error result
func BuildMembershipGetResult ¶
func BuildMembershipGetResult(baseMessage BaseMessage, devices []*Device) ([]byte, error)
BuildMembershipGetResult build memebership
func CompareVersion ¶
CompareVersion compare cloud version
func DeviceAttrToMsgAttr ¶
func DeviceAttrToMsgAttr(deviceAttrs []dtclient.DeviceAttr) map[string]*MsgAttr
DeviceAttrToMsgAttr deviceattr to msgattr
func DeviceTwinToMsgTwin ¶
func DeviceTwinToMsgTwin(deviceTwins []dtclient.DeviceTwin) map[string]*MsgTwin
DeviceTwinToMsgTwin devicetwin contains meta and version to msgtwin,
func MarshalMembershipUpdate ¶
func MarshalMembershipUpdate(result MembershipUpdate) ([]byte, error)
MarshalMembershipUpdate marshal membership update
func MsgAttrToDeviceAttr ¶
func MsgAttrToDeviceAttr(name string, msgAttr *MsgAttr) dtclient.DeviceAttr
MsgAttrToDeviceAttr msgattr to deviceattr
func MsgTwinToDeviceTwin ¶
func MsgTwinToDeviceTwin(name string, msgTwin *MsgTwin) dtclient.DeviceTwin
MsgTwinToDeviceTwin msgtwin convert to devicetwin
func UpdateCloudVersion ¶
UpdateCloudVersion update cloud version
func UpdateEdgeVersion ¶
UpdateEdgeVersion update Edge version
Types ¶
type BaseMessage ¶
BaseMessage the base struct of event message
func UnmarshalBaseMessage ¶
func UnmarshalBaseMessage(payload []byte) (*BaseMessage, error)
UnmarshalBaseMessage Unmarshal get
func (*BaseMessage) SetEventID ¶
func (bs *BaseMessage) SetEventID(eventID string)
SetEventID set event id
type ConnectedInfo ¶
type ConnectedInfo struct { EventType string `json:"event_type"` TimeStamp int64 `json:"timestamp"` }
ConnectedInfo connected info
func UnmarshalConnectedInfo ¶
func UnmarshalConnectedInfo(payload []byte) (ConnectedInfo, error)
UnmarshalConnectedInfo unmarshal connected info
type DealAttrResult ¶
type DealAttrResult struct { Add []dtclient.DeviceAttr Delete []dtclient.DeviceDelete Update []dtclient.DeviceAttrUpdate Result map[string]*MsgAttr Err error }
DealAttrResult the result of dealing attr
type DealTwinResult ¶
type DealTwinResult struct { Add []dtclient.DeviceTwin Delete []dtclient.DeviceDelete Update []dtclient.DeviceTwinUpdate Result map[string]*MsgTwin SyncResult map[string]*MsgTwin Document map[string]*TwinDoc Err error }
DealTwinResult the result of dealing twin
type Device ¶
type Device struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` State string `json:"state,omitempty"` LastOnline string `json:"last_online,omitempty"` Attributes map[string]*MsgAttr `json:"attributes,omitempty"` Twin map[string]*MsgTwin `json:"twin,omitempty"` }
Device the struct of device
type DeviceAttrUpdate ¶
type DeviceAttrUpdate struct { BaseMessage Attributes map[string]*MsgAttr `json:"attributes"` }
DeviceAttrUpdate the struct of device attr update msg
type DeviceMsg ¶
type DeviceMsg struct { BaseMessage Device Device `json:"device"` }
DeviceMsg the struct of device statte msg
type DeviceTwinDelta ¶
type DeviceTwinDelta struct { BaseMessage Twin map[string]*MsgTwin `json:"twin"` Delta map[string]string `json:"delta"` }
DeviceTwinDelta devicetwin
type DeviceTwinDocument ¶
type DeviceTwinDocument struct { BaseMessage Twin map[string]*TwinDoc `json:"twin"` }
DeviceTwinDocument the struct of twin document
func UnmarshalDeviceTwinDocument ¶
func UnmarshalDeviceTwinDocument(payload []byte) (*DeviceTwinDocument, error)
UnmarshalDeviceTwinDocument unmarshal device twin document
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 struct of device twin update
func UnmarshalDeviceTwinUpdate ¶
func UnmarshalDeviceTwinUpdate(payload []byte) (*DeviceTwinUpdate, error)
UnmarshalDeviceTwinUpdate unmarshal device twin update
type DeviceUpdate ¶
type DeviceUpdate struct { BaseMessage State string `json:"state,omitempty"` Attributes map[string]*MsgAttr `json:"attributes"` }
DeviceUpdate device update
func UnmarshalDeviceUpdate ¶
func UnmarshalDeviceUpdate(payload []byte) (*DeviceUpdate, error)
UnmarshalDeviceUpdate unmarshal device update
type GetDetailNode ¶
type GetDetailNode struct { EventType string `json:"event_type,omitempty"` EventID string `json:"event_id,omitempty"` GroupID string `json:"group_id,omitempty"` Operation string `json:"operation,omitempty"` TimeStamp int64 `json:"timestamp,omitempty"` }
GetDetailNode the info existed in req body
type MembershipDetail ¶
type MembershipDetail struct { BaseMessage Devices []Device `json:"devices"` }
MembershipDetail the struct of membership detail
func UnmarshalMembershipDetail ¶
func UnmarshalMembershipDetail(payload []byte) (*MembershipDetail, error)
UnmarshalMembershipDetail Unmarshal membershipdetail
type MembershipGetResult ¶
type MembershipGetResult struct { BaseMessage Devices []Device `json:"devices"` }
MembershipGetResult membership get result
type MembershipUpdate ¶
type MembershipUpdate struct { BaseMessage AddDevices []Device `json:"added_devices"` RemoveDevices []Device `json:"removed_devices"` }
MembershipUpdate the struct of membership update
func UnmarshalMembershipUpdate ¶
func UnmarshalMembershipUpdate(payload []byte) (*MembershipUpdate, error)
UnmarshalMembershipUpdate Unmarshal membershipupdate
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 MsgSubPub ¶
type MsgSubPub struct { Action string `json:"action"` Payload string `json:"payload"` Qos int `jsob:"qos"` }
MsgSubPub the struct of message for subscribe or publish
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
func CopyMsgTwin ¶
CopyMsgTwin copy msg twin
type Result ¶
type Result struct { BaseMessage Code int `json:"code,omitempty"` Reason string `json:"reason,omitempty"` }
Result the struct of Result for sending
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
func (TwinVersion) CompareWithCloud ¶
func (tv TwinVersion) CompareWithCloud(tvCloud TwinVersion) bool
CompareWithCloud compare with cloud vershon while dealing cloud update req
func (*TwinVersion) UpdateCloudVersion ¶
func (tv *TwinVersion) UpdateCloudVersion()
UpdateCloudVersion update cloud version
func (*TwinVersion) UpdateEdgeVersion ¶
func (tv *TwinVersion) UpdateEdgeVersion()
UpdateEdgeVersion update edge version while dealing edge update
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