dttype

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

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

func BuildErrorResult(para Parameter) ([]byte, error)

BuildErrorResult build error result

func BuildMembershipGetResult

func BuildMembershipGetResult(baseMessage BaseMessage, devices []*Device) ([]byte, error)

BuildMembershipGetResult build memebership

func CompareVersion

func CompareVersion(cloudversion string, edgeversion string) bool

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

func UpdateCloudVersion(version string) (string, error)

UpdateCloudVersion update cloud version

func UpdateEdgeVersion

func UpdateEdgeVersion(version string) (string, error)

UpdateEdgeVersion update Edge version

Types

type BaseMessage

type BaseMessage struct {
	EventID   string `json:"event_id"`
	Timestamp int64  `json:"timestamp"`
}

BaseMessage the base struct of event message

func BuildBaseMessage

func BuildBaseMessage() BaseMessage

BuildBaseMessage build base msg

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 DTMessage

type DTMessage struct {
	Msg      *model.Message
	Identity string
	Action   string
	Type     string
}

DTMessage the struct of message for commutinating between cloud and edge

func BuildDTMessage

func BuildDTMessage(identity string, action string, actionType string, msg *model.Message) *DTMessage

BuildDTMessage build devicetwin message

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

func CopyMsgAttr

func CopyMsgAttr(msgAttr *MsgAttr) MsgAttr

CopyMsgAttr copy msg 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

func CopyMsgTwin(msgTwin *MsgTwin, noVersion bool) MsgTwin

CopyMsgTwin copy msg twin

type Parameter

type Parameter struct {
	EventID string
	Code    int
	Reason  string
}

Parameter container para

type Result

type Result struct {
	BaseMessage
	Code   int    `json:"code,omitempty"`
	Reason string `json:"reason,omitempty"`
}

Result the struct of Result for sending

type TwinDoc

type TwinDoc struct {
	LastState    *MsgTwin `json:"last"`
	CurrentState *MsgTwin `json:"current"`
}

TwinDoc the struct of twin document

type TwinValue

type TwinValue struct {
	Value    *string        `json:"value, omitempty"`
	Metadata *ValueMetadata `json:"metadata,omitempty"`
}

TwinValue the struct of twin value

type TwinVersion

type TwinVersion struct {
	CloudVersion int64 `json:"cloud"`
	EdgeVersion  int64 `json:"edge"`
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL