Documentation ¶
Index ¶
- Constants
- type ACK
- type Action
- type ActionDataIn
- type ActionDataOut
- type ActionExecuteRequest
- type ActionExecuteResponse
- type AddProductReq
- type BatchData
- type BatchEvent
- type BatchProperty
- type BatchReport
- type CommonRequest
- type CommonResponse
- type Event
- type EventData
- type EventReport
- type HttpRequestParam
- type InputOutput
- type Property
- type PropertyData
- type PropertyDesiredDelete
- type PropertyDesiredDeleteResponse
- type PropertyDesiredDeleteValue
- type PropertyDesiredGet
- type PropertyDesiredGetResponse
- type PropertyDesiredGetValue
- type PropertyGet
- type PropertyGetResponse
- type PropertyReport
- type PropertySet
- type PropertySpec
- type ThingModelDriver
- type ThingModelProduct
- type TypeSpec
Constants ¶
const Version = "1.0"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACK ¶
type ACK struct { // 默认情况下设备属性上报后云端不会返回应答消息, // 但可以通过ack参数改变这一默认行为: // 0:不做应答(默认) // :处理之后返回应答消息 Ack int8 `json:"ack"` }
type Action ¶
type Action struct { AbilityId string ProductId string Code string Name string Description string InputParams []InputOutput OutputParams []InputOutput Attributes map[string]string // 自定义 }
Action 物模型动作定义
type ActionDataIn ¶
type ActionDataIn struct { ActionCode string `json:"actionCode"` InputParams map[string]interface{} `json:"inputParams"` }
云端-->TEdge-->驱动:设备执行动作入参
type ActionDataOut ¶
type ActionDataOut struct { ActionCode string `json:"actionCode"` OutputParams map[string]interface{} `json:"outputParams"` }
驱动-->云端-->TEdge:设备执行动作结果出参
type ActionExecuteRequest ¶
type ActionExecuteRequest struct { CommonRequest `json:",inline"` Data ActionDataIn `json:"data"` Spec Action `json:"-"` }
ActionExecuteRequest 执行设备动作请求
type ActionExecuteResponse ¶
type ActionExecuteResponse struct { CommonResponse `json:",inline"` Data ActionDataOut `json:"data"` }
ActionExecuteResponse 执行设备动作响应
func NewActionExecuteResponse ¶
func NewActionExecuteResponse(statusCode int64, msgId string, data ActionDataOut) ActionExecuteResponse
statusCode: 响应状态码,0代表成功,非0代表失败,默认0
type AddProductReq ¶
AddProductReq 添加产品
type BatchData ¶
type BatchData struct { Properties map[string]BatchProperty `json:"properties"` Events map[string]BatchEvent `json:"events"` }
BatchReport 设备批量上报
type BatchEvent ¶
type BatchEvent struct { EventTime int64 `json:"eventTime"` OutputParams map[string]interface{} `json:"outputParams"` }
BatchReport 设备批量上报
type BatchProperty ¶
type BatchProperty struct { Value interface{} `json:"value"` // 上报的属性值 Time int64 `json:"time"` // 属性变更时间戳 }
BatchReport 设备批量上报
type BatchReport ¶
type BatchReport struct { CommonRequest `json:",inline"` Data BatchData `json:"data"` }
BatchReport 设备批量上报
func NewBatchReport ¶
func NewBatchReport(needACK bool, data BatchData) BatchReport
type CommonRequest ¶
type CommonResponse ¶
type CommonResponse struct { Version string `json:"version"` MsgId string `json:"msgId"` Time int64 `json:"time"` Code int64 `json:"code"` // 0代表成功,非0代表失败,默认0 }
CommonResponse 云端一般响应
func NewCommonResponse ¶
func NewCommonResponse(t, code int64, msgId string) CommonResponse
type Event ¶
type Event struct { AbilityId string ProductId string Code string Name string Description string OutputParams []InputOutput Attributes map[string]string // 自定义 }
Event 物模型事件定义
type EventData ¶
type EventReport ¶
type EventReport struct { CommonRequest `json:",inline"` Data EventData `json:"data"` }
驱动-->云端-->TEdge:设备向云端上报事件
func NewEventReport ¶
func NewEventReport(needACK bool, data EventData) EventReport
type HttpRequestParam ¶
type InputOutput ¶
type Property ¶
type Property struct { Value interface{} `json:"value"` // 上报的属性值 Time int64 `json:"time"` // 属性变更时间戳 }
func NewProperty ¶
func NewProperty(value interface{}) Property
type PropertyData ¶
type PropertyData struct {
Properties []string `json:"properties"`
}
type PropertyDesiredDelete ¶
type PropertyDesiredDelete struct { CommonRequest `json:",inline"` Data map[string]PropertyDesiredDeleteValue `json:"data"` }
PropertyDesiredDelete 设备清除属性期望值
func NewPropertyDesiredDelete ¶
func NewPropertyDesiredDelete(data map[string]PropertyDesiredDeleteValue) PropertyDesiredDelete
type PropertyDesiredDeleteResponse ¶
type PropertyDesiredDeleteResponse struct { CommonResponse `json:",inline"` Data map[string]PropertyDesiredGetValue `json:"data"` }
PropertyDesiredDeleteResponse 设备清除属性期望值响应
type PropertyDesiredDeleteValue ¶
type PropertyDesiredDeleteValue struct {
Version int64 `json:"version"`
}
type PropertyDesiredGet ¶
type PropertyDesiredGet struct { CommonRequest `json:",inline"` //Data []string `json:"data"` PropertyData `json:"data"` }
PropertyDesiredGet 设备拉取属性期望值
func NewPropertyDesiredGet ¶
func NewPropertyDesiredGet(data []string) PropertyDesiredGet
type PropertyDesiredGetResponse ¶
type PropertyDesiredGetResponse struct { CommonResponse `json:",inline"` Data map[string]PropertyDesiredGetValue `json:"data"` }
PropertyDesiredGetResponse 设备拉取属性期望值响应
type PropertyDesiredGetValue ¶
type PropertyDesiredGetValue struct { Value interface{} `json:"value"` Version int64 `json:"version"` }
type PropertyGet ¶
type PropertyGet struct { CommonRequest `json:",inline"` Data []string `json:"data"` Spec map[string]PropertySpec `json:"-"` }
PropertyGet 属性查询,查询的属性code列表,如果为空代表查询所有属性
type PropertyGetResponse ¶
type PropertyGetResponse struct { CommonResponse `json:",inline"` Data map[string]Property `json:"data"` }
PropertyGetResponse 属性查询设备响应
func NewPropertyGetResponse ¶
func NewPropertyGetResponse(statusCode int64, msgId string, data map[string]Property) PropertyGetResponse
statusCode: 响应状态码,0 代表成功,非 0 代表失败,默认 0
type PropertyReport ¶
type PropertyReport struct { CommonRequest `json:",inline"` Data map[string]Property `json:"data"` }
PropertyReport 属性上报 属性查询响应
func NewPropertyReport ¶
func NewPropertyReport(needACK bool, data map[string]Property) PropertyReport
type PropertySet ¶
type PropertySet struct { CommonRequest `json:",inline"` Data map[string]interface{} `json:"data"` Spec map[string]PropertySpec `json:"-"` }
云端-->TEdge-->驱动:设备属性下发
type PropertySpec ¶
type PropertySpec struct { AbilityId string ProductId string Code string Name string AccessMode string TypeSpec TypeSpec Attributes map[string]string // 自定义 }
PropertySpec 物模型属性定义
type ThingModelDriver ¶
type ThingModelDriver interface { // DeviceNotify 设备增删改通知,删除设备时device参数为空 DeviceNotify(ctx context.Context, t commons.DeviceNotifyType, cid string, device commons.TMDeviceInfo) error // ProductNotify 产品增删改通知,删除产品时product参数为空 ProductNotify(ctx context.Context, t commons.ProductNotifyType, pid string, product ThingModelProduct) error // HandlePropertySet set device property, from cloud or web HandlePropertySet(ctx context.Context, cid string, data PropertySet, protocols map[string]commons.ProtocolProperties) error // HandlePropertyGet get device property, from cloud HandlePropertyGet(ctx context.Context, cid string, data PropertyGet, protocols map[string]commons.ProtocolProperties) error // HandleActionExecute device command, from cloud or web HandleActionExecute(ctx context.Context, cid string, data ActionExecuteRequest, protocols map[string]commons.ProtocolProperties) error Stop(ctx context.Context) error }
type ThingModelProduct ¶
type ThingModelProduct struct { Id string Name string Description string Model string Action []Action Event []Event Property []PropertySpec DeviceLibraryId string }
ThingModelProduct 物模型产品定义