arenal

package
v0.0.0-...-fdcd839 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: Apache-2.0, MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogTypeDevice = "device"
	LogTypeSDK    = "sdk"
)
View Source
const (
	OTADefaultModule = "default"

	ServiceIDKey = "ServiceID"
)
View Source
const (
	ActionKey  = "Action"
	VersionKey = "Version"

	UploadFileAction               = "UploadFile"
	DynamicRegisterAction          = "DynamicRegister"
	GetDeviceTokenAction           = "GetDeviceToken"
	DeviceMessagePublishHTTPAction = "DeviceMessagePublishHTTP"
)
View Source
const (
	ActionOnInterruptRetry = "Retry"
	ActionOnInterruptFail  = "Fail"
)
View Source
const (
	// PropertySetTopic 属性设置 sys/{productKey}/{deviceName}/thingmodel/service/preset/property/set
	PropertySetTopic string = "sys/%s/%s/thingmodel/service/preset/propertySet/post"

	// PropertySetReplyTopic 属性设置响应 sys/{productKey}/{deviceName}/thingmodel/service/preset/property/set_reply
	PropertySetReplyTopic string = "sys/%s/%s/thingmodel/service/preset/propertySet/post_reply"

	// ServiceCallTopicForSub 服务调用 sys/{productKey}/{deviceName}/thingmodel/service/{moduleKey}/{serviceIdentifier}/post/{uuid}
	ServiceCallTopicForSub string = "sys/%s/%s/thingmodel/service/+/+/post/+"

	// ServiceCallReplyTopic 服务调用响应 sys/{productKey}/{deviceName}/thingmodel/service/{moduleKey}/{serviceIdentifier}/post_reply/{uuid}
	ServiceCallReplyTopic string = "sys/%s/%s/thingmodel/service/%s/%s/post_reply/%s"

	// ShadowReportTopic 设备影子上报 sys/{productKey}/{deviceName}/shadow/report
	ShadowReportTopic string = "sys/%s/%s/shadow/report"
	// ShadowDesiredGetTopic 设备影子获取 sys/{productKey}/{deviceName}/shadow/desired/get
	ShadowDesiredGetTopic string = "sys/%s/%s/shadow/desired/get"
	// ShadowDesiredGetReplyTopic 设备影子获取reply sys/{productKey}/{deviceName}/shadow/desired/get_reply
	ShadowDesiredGetReplyTopic string = "sys/%s/%s/shadow/desired/get/reply"
	// ShadowDesiredClearTopic 设备期望状态清除 sys/{productKey}/{deviceName}/shadow/desired/clear
	ShadowDesiredClearTopic string = "sys/%s/%s/shadow/desired/clear"

	// ShadowReportReplyTopic 设备订阅,设备影子上报reply sys/{productKey}/{deviceName}/shadow/report_reply
	ShadowReportReplyTopic string = "sys/%s/%s/shadow/report_reply"

	// ShadowDesiredSetTopic 设备订阅,设备状态设置 sys/{productKey}/{deviceName}/shadow/set
	ShadowDesiredSetTopic string = "sys/%s/%s/shadow/desired/set"

	// EventReportTopic 事件上报 sys/{productKey}/{deviceName}/thingmodel/event/+/+/post
	EventReportTopic string = "sys/%s/%s/thingmodel/event/%s/%s/post"

	// PropertyReportTopic 属性上报 sys/{productKey}/{deviceName}/thingmodel/property/post
	PropertyReportTopic string = "sys/%s/%s/thingmodel/property/post"

	// PropertyReportReplyTopic 属性上报响应 sys/{productKey}/{deviceName}/thingmodel/property/post_reply
	PropertyReportReplyTopic string = "sys/%s/%s/thingmodel/property/post_reply"

	// EventReportReplyTopicForSub 事件上报响应 sys/{productKey}/{deviceName}/thingmodel/event/+/+/post_reply
	EventReportReplyTopicForSub string = "sys/%s/%s/thingmodel/event/+/+/post_reply"

	// OTAVersionReportTopic OTA设备上报版本信息 sys/{productKey}/{deviceName}/ota/version
	OTAVersionReportTopic string = "sys/%s/%s/ota/version"

	// OTAUpgradeNotifyTopic OTA平台推送升级通知 sys/{productKey}/{deviceName}/ota/notify/{otaJobID}
	OTAUpgradeNotifyTopic string = "sys/%s/%s/ota/notify/%s"

	// OTARequestUpgradeTopic OTA设备请求升级信息 sys/{productKey}/{deviceName}/ota/upgrade/post
	OTARequestUpgradeTopic string = "sys/%s/%s/ota/upgrade/post"

	// OTARequestUpgradeReplyTopic OTA设备请求升级信息相应 sys/{productKey}/{deviceName}/ota/upgrade/post_reply
	OTARequestUpgradeReplyTopic string = "sys/%s/%s/ota/upgrade/post_reply"

	// OTAUpgradeProgressReportTopic OTA设备上报升级进度 sys/{productKey}/{deviceName}/ota/progress/{otaJobID}
	OTAUpgradeProgressReportTopic string = "sys/%s/%s/ota/progress/%s"

	// WebShellCmdPostTopic webshell命令下发topic sys/{productKey}/{deviceName}/webshell/cmd/{uuid}/post
	WebShellCmdPostTopic string = "sys/%s/%s/webshell/cmd/+/post"

	// WebShellCmdReplyTopic webshell命令结果上报topic sys/{productKey}/{deviceName}/webshell/cmd/{uuid}/post_reply
	WebShellCmdReplyTopic string = "sys/%s/%s/webshell/cmd/%s/post_reply"

	// DeviceDelayPostTopic 设备延迟探测topic sys/{productKey}/{deviceName}/delay/{uuid}/post
	DeviceDelayPostTopic string = "sys/%s/%s/delay/+/post"

	// DeviceDelayReplyTopic 设备延迟探测结果上报topic sys/{productKey}/{deviceName}/delay/{uuid}/post
	DeviceDelayReplyTopic string = "sys/%s/%s/delay/%s/post_reply"

	// DeviceLogReportTopic 设备批量日志上报topic sys/{productKey}/{deviceName}/log/batch/report
	DeviceLogReportTopic string = "sys/%s/%s/log/batch/report"

	// DeviceLogReportConfigTopic 设备批量日志配置下发topic sys/{productKey}/{deviceName}/log/batch/config
	DeviceLogReportConfigTopic string = "sys/%s/%s/log/batch/config"

	// DeviceStreamLogConfigTopic 设备实时日志上报配置下发topic sys/{productKey}/{deviceName}/log/stream/config/{uuid}
	DeviceStreamLogConfigTopic string = "sys/%s/%s/log/stream/config/%s"

	// DeviceStreamLogReportTopic 设备实时日志上报topic sys/{productKey}/{deviceName}/log/stream/report/{uuid}
	DeviceStreamLogReportTopic string = "sys/%s/%s/log/stream/report/%s"

	// DeviceLocalLogConfigTopic 设备本地日志上报配置下发topic sys/{productKey}/{deviceName}/log/local/config/{uuid}
	DeviceLocalLogConfigTopic string = "sys/%s/%s/log/local/config/%s"

	// DeviceLocalLogReportTopic 设备本地日志上报topic sys/{productKey}/{deviceName}/log/local/report/{uuid}
	DeviceLocalLogReportTopic string = "sys/%s/%s/log/local/report/%s"

	// DeviceNotifyUploadFileTopic 通知设备上传文件topic sys/{productKey}/{deviceName}/file/upload/notify/{uuid}
	DeviceNotifyUploadFileTopic string = "sys/%s/%s/file/upload/notify/%s"

	// UploadFileProgressTopic 设备上传文件进度上报 sys/{productKey}/{deviceName}/file/upload/progress/{uuid}
	UploadFileProgressTopic string = "sys/%s/%s/file/upload/progress/%s"

	// TaskNotifyTopic 通知设备执行任务topic sys/{productKey}/{deviceName}/task/notify
	TaskNotifyTopic string = "sys/%s/%s/task/notify"

	// TaskProgressTopic 设备任务执行进度上报topic sys/{productKey}/{deviceName}/task/progress
	TaskProgressTopic string = "sys/%s/%s/task/progress"

	// TaskProgressReplyTopic 设备任务执行进度上报响应topic sys/{productKey}/{deviceName}/task/progress_reply
	TaskProgressReplyTopic string = "sys/%s/%s/task/progress_reply"

	// TaskGetTopic 设备获取待执行任务topic sys/{productKey}/{deviceName}/task/get
	TaskGetTopic string = "sys/%s/%s/task/get"

	// TaskGetReplyTopic 设备获取待执行任务响应 sys/{productKey}/{deviceName}/task/get_reply
	TaskGetReplyTopic string = "sys/%s/%s/task/get_reply"

	// NTPRequestTopic 设备NTP请求topic sys/{productKey}/{deviceName}/ntp/request
	NTPRequestTopic string = "sys/%s/%s/ntp/request"

	// NTPResponseTopic 设备NTP请求响应topic sys/{productKey}/{deviceName}/ntp/response
	NTPResponseTopic string = "sys/%s/%s/ntp/response"

	// InitUploadFileRequestTopic 初始化设备上传文件请求topic sys/{productKey}/{deviceName}/file/upload/init/{uuid}
	InitUploadFileRequestTopic string = "sys/%s/%s/file/upload/init/%s"

	// InitUploadFileReplyTopic 初始化设备文件上传响应topic sys/{productKey}/{deviceName}/file/upload/init_reply/{uuid}
	InitUploadFileReplyTopic string = "sys/%s/%s/file/upload/init_reply/%s"

	// EndUploadFileRequestTopic 结束设备上传文件请求topic sys/{productKey}/{deviceName}/file/upload/end/{uuid}
	EndUploadFileRequestTopic string = "sys/%s/%s/file/upload/end/%s"

	// EndUploadFileReplyTopic 结束设备文件上传响应topic sys/{productKey}/{deviceName}/file/upload/end_reply/{uuid}
	EndUploadFileReplyTopic string = "sys/%s/%s/file/upload/end_reply/%s"
)
View Source
const (
	// GatewayTopoAddTopic 增加拓扑关系 sys/{gwProductKey}/{gwDeviceName}/gateway/topo/add
	GatewayTopoAddTopic = "sys/%s/%s/gateway/topo/add"
	// GatewayTopoAddReplyTopic 增加拓扑关系请求响应 sys/{gwProductKey}/{gwDeviceName}/gateway/topo/add_reply
	GatewayTopoAddReplyTopic = "sys/%s/%s/gateway/topo/add_reply"
	// GatewayTopoDeleteTopic 删除拓扑关系 sys/{gwProductKey}/{gwDeviceName}/gateway/topo/delete
	GatewayTopoDeleteTopic = "sys/%s/%s/gateway/topo/delete"
	// GatewayTopoDeleteReplyTopic 删除拓扑关系请求响应 sys/{gwProductKey}/{gwDeviceName}/gateway/topo/delete_reply
	GatewayTopoDeleteReplyTopic = "sys/%s/%s/gateway/topo/delete_reply"
	// GatewayTopoGetTopic 获取拓扑关系 sys/{gwProductKey}/{gwDeviceName}/gateway/topo/get
	GatewayTopoGetTopic = "sys/%s/%s/gateway/topo/get"
	// GatewayTopoGetReplyTopic 获取拓扑关系请求响应 sys/{gwProductKey}/{gwDeviceName}/gateway/topo/get_reply
	GatewayTopoGetReplyTopic = "sys/%s/%s/gateway/topo/get_reply"
	// GatewaySubDeviceSecretGetTopic 子设备密钥获取请求 sys/{gwProductKey}/{gwDeviceName}/gateway/sub/secret/get/{uuid}
	GatewaySubDeviceSecretGetTopic = "sys/%s/%s/gateway/sub/secret/get/%s"
	// GatewaySubDeviceSecretGetReplyTopic 子设备密钥获取请求响应 sys/{gwProductKey}/{gwDeviceName}/gateway/sub/secret/get_reply/{uuid}
	GatewaySubDeviceSecretGetReplyTopic = "sys/%s/%s/gateway/sub/secret/get_reply/%s"
	// GatewaySubDeviceLoginTopic 子设备上线请求 sys/{gwProductKey}/{gwDeviceName}/gateway/sub/login
	GatewaySubDeviceLoginTopic = "sys/%s/%s/gateway/sub/login"
	// GatewaySubDeviceLoginReplyTopic 子设备上线请求响应 sys/{gwProductKey}/{gwDeviceName}/gateway/sub/login_reply
	GatewaySubDeviceLoginReplyTopic = "sys/%s/%s/gateway/sub/login_reply"
	// GatewaySubDeviceLogoutTopic 子设备下线请求 sys/{gwProductKey}/{gwDeviceName}/gateway/sub/logout"
	GatewaySubDeviceLogoutTopic = "sys/%s/%s/gateway/sub/logout"
	// GatewaySubDeviceLogoutReplyTopic 子设备下线请求响应 sys/{gwProductKey}/{gwDeviceName}/gateway/sub/logout_reply
	GatewaySubDeviceLogoutReplyTopic = "sys/%s/%s/gateway/sub/logout_reply"
	// GatewaySubDeviceDiscoveryTopic 上报发现的子设备列表 sys/{gwProductKey}/{gwDeviceName}/gateway/sub/discovery
	GatewaySubDeviceDiscoveryTopic = "sys/%s/%s/gateway/sub/discovery"
	// GatewaySubDeviceDiscoveryReplyTopic 发现子设备列表请求响应 sys/{gwProductKey}/{gwDeviceName}/gateway/sub/discovery_reply
	GatewaySubDeviceDiscoveryReplyTopic = "sys/%s/%s/gateway/sub/discovery_reply"
	// GatewayTopoAddNotifyTopic 通知网关添加子设备 sys/{gwProductKey}/{gwDeviceName}/gateway/topo/add/notify/{uuid}
	GatewayTopoAddNotifyTopic = "sys/%s/%s/gateway/topo/notify/+"
	// GatewayTopoAddNotifyReplyTopic 通知网关添加子设备响应 sys/{gwProductKey}/{gwDeviceName}/gateway/topo/add/notify_reply/{uuid}
	GatewayTopoAddNotifyReplyTopic = "sys/%s/%s/gateway/topo/notify_reply/%s"
	// GatewayTopoChangeTopic 通知网关拓扑关系变化 sys/{gwProductKey}/{gwDeviceName}/gateway/topo/chang
	GatewayTopoChangeTopic = "sys/%s/%s/gateway/topo/change"
	// GatewayTopoChangeReplyTopic 通知网关拓扑关系变化响应 sys/{gwProductKey}/{gwDeviceName}/gateway/topo/change_reply
	GatewayTopoChangeReplyTopic = "sys/%s/%s/gateway/topo/change_reply"
	// GatewaySubDeviceChangeTopic 通知网关子设备状态变化 sys/{gwProductKey}/{gwDeviceName}/gateway/sub/change
	GatewaySubDeviceChangeTopic = "sys/%s/%s/gateway/sub/change"
	// GatewaySubDeviceChangeReplyTopic 通知网关子设备状态变化响应 sys/{gwProductKey}/{gwDeviceName}/gateway/sub/change_reply
	GatewaySubDeviceChangeReplyTopic = "sys/%s/%s/gateway/sub/change_reply"
	// GatewaySubDeviceLoginReport 网关定期上报在线子设备 sys/{gwProductKey}/{gwDeviceName}/gateway/sub/report
	GatewaySubDeviceLoginReport = "sys/%s/%s/gateway/sub/report"
)

网关相关topic

View Source
const APIVerion = "2021-12-14"
View Source
const (
	DefaultMQTTPort = 1883
)
View Source
const (
	IOTHTTPAccessHeaderKey = "X-IoT-AccessToken"
)
View Source
const (
	InstanceIDFieldKey = "InstanceID"
)
View Source
const ServicePropertySet string = "propertySet"

Variables

View Source
var ConfigFilePath = "config.yaml"

Functions

func CheckDeviceName

func CheckDeviceName(name string) bool

func FormatUniqueFieldName

func FormatUniqueFieldName(moduleKey, identifier string) string

FormatUniqueFieldName 构建唯一标识的方法 传递moduleKey,identifier

func GetTimeMill

func GetTimeMill() int64

GetTimeMill 获取时间戳 返回 int64 类型时间戳

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

Types

type AccessType

type AccessType string
const (
	DeviceAccessTypeHTTP AccessType = "http"
	DeviceAccessTypeMQTT AccessType = "mqtt"
)

type ActionOnInterrupt

type ActionOnInterrupt string

type AuthType

type AuthType int
const (
	AuthTypePreRegistration AuthType = iota
	AuthTypeNoPreRegistration
)

type BaseDevice

type BaseDevice interface {
	Init() bool
	DisConnect()
	Close()
	IsConnected() bool
	SetPropertySetHandler(handler PropertySetHandler)
	SetServiceCallHandler(handler ServiceCallHandler)
	SetShadowSetHandler(handler ShadowSetHandler)
	SetEventReportReplyHandler(handler EventReportReplyHandler)
	SetPropertyReportReplyHandler(handler PropertyReportReplyHandler)
	SetCustomTopicHandler(topic string, handler CustomTopicHandler)
	PropertyReport(properties map[string]PropertyValue, deviceIdentification ...DeviceIdentification) ErrorCode
	PropertyReportAsync(properties map[string]PropertyValue, deviceIdentification ...DeviceIdentification) (paho.Token, ErrorCode)
	ShadowReport(reported Reported, deviceIdentification ...DeviceIdentification) ErrorCode
	GetShadowDesired(deviceIdentification ...DeviceIdentification) ErrorCode
	EventReport(param EventReportParam, deviceIdentification ...DeviceIdentification) ErrorCode
	SendCustomTopicMessage(topicSuffix, payload string, qos int) ErrorCode
	SetCustomJobHandler(handler CustomJobHandler)
	SendNTPRequest() ErrorCode
	SetNTPResponseHandler(handler NTPResponseHandler)
	GetServerTime() (int64, ErrorCode)
	SetOnConnectHandler(handler OnConnectHandler)
	UploadFile(param UploadFileParam) (string, ErrorCode)
	GetDeviceToken() (*GetDeviceTokenResult, ErrorCode)
	PublishMessageHTTP(param *PublishMessageParam) (*PublishMessageHTTPResult, ErrorCode)
}

type ClearPayload

type ClearPayload struct {
	CommonRequest
	ShadowVersion int64 `json:"Params"`
}

type CommonHttpResponse

type CommonHttpResponse struct {
	// 请求元信息
	ResponseMetadata ResponseMetadata `json:"ResponseMetadata"`
}

type CommonLogCondition

type CommonLogCondition struct {
	// 内容关键字
	// Required: false
	ContentKeyWord string `json:"ContentKeyword"`
	// 日志类型(sdk、device)
	// Required: false
	Type string `json:"Type"`
	// 日志等级(debug、info、warn、error、fatal)
	// Required: false
	LogLevel string `json:"LogLevel"`
	// 开始时间
	// Required: false
	StartTime int64 `json:"StartTime"`
	// 结束时间
	// Required: false
	EndTime int64 `json:"EndTime"`
}

type CommonReply

type CommonReply struct {
	ID   string    `json:"ID"`
	Code ErrorCode `json:"Code"`
}

type CommonRequest

type CommonRequest struct {
	ID      string `json:"ID"`
	Version string `json:"Version"`
}

type ConsoleLogger

type ConsoleLogger struct {
	Prefix string
}

func NewConsoleLogger

func NewConsoleLogger(prefix string) *ConsoleLogger

func (*ConsoleLogger) Printf

func (l *ConsoleLogger) Printf(format string, v ...interface{})

func (*ConsoleLogger) Println

func (l *ConsoleLogger) Println(v ...interface{})

type CustomJobHandler

type CustomJobHandler func(message CustomJobMessage) (ErrorCode, string)

type CustomJobMessage

type CustomJobMessage struct {
	DeviceIdentification
	Param string `json:"Param"`
	// 文件路径,如果没有携带文件则为空
	FilePath string `json:"FilePath"`
}

type CustomTaskPayload

type CustomTaskPayload struct {
	// 自定义任务参数
	Param string `json:"Param"`
	// 文件URL
	URL string `json:"URL"`
	// 文件签名
	Sign string `json:"Sign"`
	// 文件大小
	FileSize int64 `json:"FileSize"`
}

type CustomTopicHandler

type CustomTopicHandler func(param CustomTopicParam) ErrorCode

type CustomTopicParam

type CustomTopicParam struct {
	Topic   string
	Payload string
}

type Device

type Device struct {
	DeviceOption
	// contains filtered or unexported fields
}

func CreateDeviceWithConfig

func CreateDeviceWithConfig(config DeviceOption) Device

func (*Device) AddTopologies

func (d *Device) AddTopologies(subDevices []DeviceAuthWithProductSecret) (failedDevices []DeviceIdentification, errCode ErrorCode)

AddTopologies 将子设备添加到网关拓扑关系,遇到错误时返回失败的设备列表,添加的结果在AddTopologiesReplyHandler中处理 传递 subDevices 子设备身份标识和产品密钥

func (*Device) Close

func (d *Device) Close()

Close()方法用于清理Device后台worker,包括日志、任务查询等 Warning: 调用Close()之后不会等待所有worker都退出,所以调用Close()函数之后不要复用Device

func (*Device) DeleteTopologies

func (d *Device) DeleteTopologies(subDevices []DeviceIdentification) ErrorCode

DeleteTopologies 将子设备从网关拓扑关系中删除,删除的结果在DeleteTopologiesReplyHandler中处理 传递 subDevices 子设备身份标识

func (*Device) DeviceLog

func (d *Device) DeviceLog(level LogLevel, content string)

DeviceLog 打印设备日志 传递 level 日志级别;content 日志内容

func (*Device) DeviceLogf

func (d *Device) DeviceLogf(level LogLevel, format string, args ...interface{})

DeviceLogf 格式化打印设备日志 传递 level 日志级别;format 日志格式化字符串;args 参数

func (*Device) DisConnect

func (d *Device) DisConnect()

DisConnect 设备断开链接 调用方法可以断开设备的MQTT连接

func (*Device) EventReport

func (d *Device) EventReport(param EventReportParam, deviceIdentification ...DeviceIdentification) ErrorCode

EventReport 主动调用,进行事件上报 传递 ModuleKey 事件所属模块标识; Identifier 事件标识; Values 输出参数列表:key为标识符,value为具体值; DeviceIdentification 为子设备进行事件上报还需要指定子设备标识 返回 成功标识

func (*Device) GetDeviceToken

func (d *Device) GetDeviceToken() (*GetDeviceTokenResult, ErrorCode)

获取http接入token 有过期时间,需要自己处理token过期

func (*Device) GetOTAInfo

func (d *Device) GetOTAInfo(otaModuleIdentification []OTAModuleIdentification) map[string]JobInfo

GetOTAInfo 查询设备的OTA升级任务相关信息

func (*Device) GetServerTime

func (d *Device) GetServerTime() (int64, ErrorCode)

SendNTPRequest 获取服务端当前时间戳,无需init,单位ms 获取服务端事件

func (*Device) GetShadowDesired

func (d *Device) GetShadowDesired(deviceIdentification ...DeviceIdentification) ErrorCode

GetShadowDesired 主动调用,主动获取设备影子期望值,返回的消息会发送至ShadowSetHandler中进行处理 传递 DeviceIdentification 为子设备获取设备影子期望值需要指定子设备标识 返回 成功标识

func (*Device) GetSubDeviceSecrets

func (d *Device) GetSubDeviceSecrets(subDevices []DeviceIdentification) ErrorCode

GetSubDeviceSecrets 获取子设备密钥,异步方法,结果在SubDeviceSecretGetReplyHandler中处理 传递 subDevices 要获取密钥的子设备标识,为空则获取全部子设备密钥

func (*Device) GetTopologies

func (d *Device) GetTopologies() ErrorCode

GetTopologies 从平台拉取最新拓扑关系,异步方法,结果在GetTopologiesReplyHandler中处理

func (*Device) Init

func (d *Device) Init() bool

Init 设备初始化方法,设备必须经过初始化才能够使用 必须对设备所属产品、产品密钥、设备名称、服务质量QoS、认证方式、所属区域进行配置 文件下载路径:FilePath默认配置为当前工作目录,密钥Secret可以通过配置认证方式为VerifyModeDynamicPreRegistered、VerifyModeDynamicNoPreRegistered动态获取 Warning: 在Init函数失败或者调用Device.Close()之后不要复用Device,否则可能会造成内存泄露

func (*Device) InitOTAJob

func (d *Device) InitOTAJob(deviceIdentification DeviceIdentification, data OTAReplyData) (ErrorCode, OTAMetadata)

InitOTAJob 主动调用,初始化OTA升级任务 传递 DeviceIdentification 为子设备升级需要指定子设备身份标识;OTAReplyData 升级任务相关参数

func (*Device) IsConnected

func (d *Device) IsConnected() bool

IsConnected 判断设备是否连接 连接中返回true,未连接返回false

func (*Device) IsConnectionOpen

func (d *Device) IsConnectionOpen() bool

IsConnectionOpen 判断设备是否与MQTT broker存在活动连接,即不为断开或重连状态 存在活动连接返回true,否则返回false

func (*Device) OTADownload

func (d *Device) OTADownload(module string, deviceIdentification ...DeviceIdentification) ErrorCode

OTADownload 下载升级包 传递 module OTA模块;为子设备下载安装包还需要指定子设备标识 DeviceIdentification

func (*Device) OTAInstall

func (d *Device) OTAInstall(module string, deviceIdentification ...DeviceIdentification) ErrorCode

OTADownload 安装升级包 传递 module OTA模块;为子设备进行安装还需要指定子设备标识 DeviceIdentification

func (*Device) OTAUpgradeRequest

func (d *Device) OTAUpgradeRequest(module, otaJobID string, deviceIdentification ...DeviceIdentification) ErrorCode

OTAUpgradeRequest 主动调用,进行OTA升级任务信息请求 传递 module模块标识; 若otaJobID为空,表示请求最新的升级任务,建议不指定;为子设备请求升级还需要指定子设备标识 DeviceIdentification 返回 成功标识

func (*Device) OTAVersionReport

func (d *Device) OTAVersionReport(versionMap map[string]string, deviceIdentification ...DeviceIdentification) ErrorCode

OTAVersionReport 主动调用,进行OTA模块版本信息上报 传递 versionMap key为OTA模块标识 value为对应模块的版本号; 为子设备进行OTA模块版本信息上报还需要指定子设备标识 DeviceIdentification 返回 成功标识

func (*Device) PropertyReport

func (d *Device) PropertyReport(propertyValues map[string]PropertyValue, deviceIdentification ...DeviceIdentification) ErrorCode

PropertyReport 主动调用,进行属性上报,该方法会阻塞直到获取发送结果状态,在断连情况下若未收到ACK则会一直阻塞住 传递 map[string]PropertyValue key为 FormatUniqueFieldName 方法创建的唯一key,value为 PropertyValue; DeviceIdentification 为子设备进行属性上报还需要指定子设备标识 返回 成功标识

func (*Device) PropertyReportAsync

func (d *Device) PropertyReportAsync(propertyValues map[string]PropertyValue, deviceIdentification ...DeviceIdentification) (paho.Token, ErrorCode)

PropertyReportAsync 主动调用,进行属性上报,该方法会立即返回,若需要感知发送状态,可以通过操作返回结果中的token获取发送状态, token.wait(),判断token.Error() 传递 map[string]PropertyValue key为 FormatUniqueFieldName 方法创建的唯一key,value为 PropertyValue; DeviceIdentification 为子设备进行属性上报还需要指定子设备标识 返回 成功标识

func (*Device) PublishMessageHTTP

func (d *Device) PublishMessageHTTP(param *PublishMessageParam) (*PublishMessageHTTPResult, ErrorCode)

发布消息

func (*Device) ReportDiscoveryList

func (d *Device) ReportDiscoveryList(subDevices []DeviceIdentification) ErrorCode

ReportDiscoveryList 上报网关发现的子设备列表,需要在平台进行确认才会添加拓扑关系。无需确认时直接用AddTopologies方法 传递 subDevices 发现的子设备

func (*Device) SendCustomTopicMessage

func (d *Device) SendCustomTopicMessage(topicSuffix, payload string, qos int) ErrorCode

SendCustomTopicMessage 发送消息到自定义topic,需要预先在平台创建自定义topic 传递 topicSuffix 自定义topic后缀;payload 消息体;qos 服务质量,0: 最多传递一次,1: 至少传递一次

func (*Device) SendNTPRequest

func (d *Device) SendNTPRequest() ErrorCode

SendNTPRequest 发送NTP请求到服务端 获取服务端事件

func (*Device) SetAddTopologiesReplyHandler

func (d *Device) SetAddTopologiesReplyHandler(handler GatewayCommonHandler)

SetAddTopologiesReplyHandler 配置添加拓扑关系返回消息的Handler

func (*Device) SetCustomJobHandler

func (d *Device) SetCustomJobHandler(handler CustomJobHandler)

SetCustomJobHandler 配置自定义任务Handler 传递 CustomJobHandler 根据参数中的身份标识区分设备自身或子设备,根据Param和FilePath执行相应的任务

func (*Device) SetCustomTopicHandler

func (d *Device) SetCustomTopicHandler(topicSuffix string, handler CustomTopicHandler)

SetCustomTopicHandler 配置自定义topic的Handler,需要预先在平台创建自定义topic 自定义格式为 sys/{ProductKey}/{DeviceName}/custom/{TopicSuffix}

func (*Device) SetDeleteTopologiesReplyHandler

func (d *Device) SetDeleteTopologiesReplyHandler(handler GatewayCommonHandler)

SetAddTopologiesReplyHandler 配置删除拓扑关系返回消息的Handler

func (*Device) SetDiffAlgorithm

func (d *Device) SetDiffAlgorithm(diffAlgorithm DiffAlgorithm)

SetDiffAlgorithm 配置差分还原算法,用于安装前还原差分包,如果安装包为差分包,必须配置 传递 DiffAlgorithm

func (*Device) SetEventReportReplyHandler

func (d *Device) SetEventReportReplyHandler(handler EventReportReplyHandler)

SetEventReportReplyHandler 配置处理事件报告返回消息的Handler 传递 EventReportReplyHandler 根据参数中的身份标识区分设备自身或子设备

func (*Device) SetGetTopologiesReplyHandler

func (d *Device) SetGetTopologiesReplyHandler(handler GatewayCommonHandler)

SetAddTopologiesReplyHandler 配置获取拓扑关系返回消息的Handler

func (*Device) SetInstallAlgorithm

func (d *Device) SetInstallAlgorithm(installAlgorithm InstallAlgorithm)

SetInstallAlgorithm 配置安装算法,必须配置,用于安装升级包 传递 InstallAlgorithm

func (*Device) SetNTPResponseHandler

func (d *Device) SetNTPResponseHandler(handler NTPResponseHandler)

SetNTPResponseHandler 配置NTP响应的Handler serverTimeMS 服务端当前时间戳(单位ms)

func (*Device) SetNotifyAddSubDeviceHandler

func (d *Device) SetNotifyAddSubDeviceHandler(handler GatewayCommonHandler)

SetNotifyAddSubDeviceHandler 设置通知添加子设备消息的Handler 调用ReportDiscoveryList上报后在平台确认添加时,设备会收到NotifyAddSubDevice消息

func (*Device) SetOTANotifyHandler

func (d *Device) SetOTANotifyHandler(handler OTANotifyHandler)

SetOTANotifyHandler 配置处理OTA升级通知消息的Handler 传递 OTANotifyHandler

func (*Device) SetOTAReplyHandler

func (d *Device) SetOTAReplyHandler(handler OTAReplyHandler)

SetOTAReplyHandler 配置处理OTA请求回复消息的Handler 传递 OTAReplyHandler

func (*Device) SetOnConnectHandler

func (d *Device) SetOnConnectHandler(handler OnConnectHandler)

func (*Device) SetPropertyReportReplyHandler

func (d *Device) SetPropertyReportReplyHandler(handler PropertyReportReplyHandler)

SetPropertyReportReplyHandler 配置处理属性上报返回消息的Handler 传递 PropertyReportReplyHandler 根据参数中的身份标识区分设备自身或子设备

func (*Device) SetPropertySetHandler

func (d *Device) SetPropertySetHandler(handler PropertySetHandler)

SetPropertySetHandler 配置处理属性设置消息的Handler 传递 PropertySetHandler 根据参数中的身份标识区分设备自身或子设备

func (*Device) SetQueryUpgradeConfig

func (d *Device) SetQueryUpgradeConfig(config QueryUpgradeConfig)

SetQueryUpgradeConfig 配置定时轮询OTA升级任务配置 传递 QueryUpgradeConfig

func (*Device) SetServiceCallHandler

func (d *Device) SetServiceCallHandler(handler ServiceCallHandler)

SetServiceCallHandler 配置处理服务调用消息的Handler 传递 ServiceCallHandler 根据参数中的身份标识区分设备自身或子设备

func (*Device) SetShadowSetHandler

func (d *Device) SetShadowSetHandler(handler ShadowSetHandler)

SetShadowSetHandler 配置处理设备影子设置期望值消息的Handler 传递 ShadowSetHandler

func (*Device) SetSubDeviceChangeHandler

func (d *Device) SetSubDeviceChangeHandler(handler SubDeviceChangeHandler)

SetSubDeviceChangeHandler 设置子设备变化消息的Handler,子设备变化包括:删除/启用/禁用

func (*Device) SetSubDeviceCommonInstallAlgorithm

func (d *Device) SetSubDeviceCommonInstallAlgorithm(subDeviceCommonInstallAlgorithm SubDeviceCommonInstallAlgorithm)

SetSubDeviceCommonInstallAlgorithm 配置子设备通用安装算法,网关设备必须配置,用于网关设备处理子设备安装相关流程 传递 SubDeviceCommonInstallAlgorithm

func (*Device) SetSubDeviceCustomInstallAlgorithm

func (d *Device) SetSubDeviceCustomInstallAlgorithm(subDeviceCustomInstallAlgorithm map[string]SubDeviceCustomInstallAlgorithm)

SetSubDeviceCustomInstallAlgorithm 配置子设备定制化安装算法,即针对不同产品的子设备,采用不同的定制化安装方法,不配置则采用默认的通用安装算法 传递 SubDeviceCustomInstallAlgorithm

func (*Device) SetSubDeviceLoginReplyHandler

func (d *Device) SetSubDeviceLoginReplyHandler(handler GatewayCommonHandler)

SetSubDeviceLoginReplyHandler 设置子设备登陆返回消息的Handler

func (*Device) SetSubDeviceLogoutReplyHandler

func (d *Device) SetSubDeviceLogoutReplyHandler(handler GatewayCommonHandler)

SetSubDeviceLogoutReplyHandler 设置子设备下线返回消息的Handler

func (*Device) SetSubDeviceSecretGetReplyHandler

func (d *Device) SetSubDeviceSecretGetReplyHandler(handler SubDeviceSecretGetReplyHandler)

SetSubDeviceSecretGetReplyHandler 设置获取子设备密钥返回消息的Handler

func (*Device) SetTopologyChangeHandler

func (d *Device) SetTopologyChangeHandler(handler TopologyChangeHandler)

SetTopologyChangeHandler 设置拓扑关系变化消息的Handler,拓扑关系变化包括:创建/删除/启用/禁用

func (*Device) ShadowReport

func (d *Device) ShadowReport(reported Reported, deviceIdentification ...DeviceIdentification) ErrorCode

ShadowReport 主动调用,进行设备影子上报 传递 Reported 要上报的属性信息; DeviceIdentification 为子设备进行设备影子上报还需要指定子设备标识 返回 成功标识

func (*Device) SubDeviceLogin

func (d *Device) SubDeviceLogin(subDevices []DeviceIdentification) (failedDevices []DeviceIdentification, errCode ErrorCode)

SubDeviceLogin 子设备登陆,遇到错误时返回失败的设备列表,异步方法,结果在SubDeviceLoginReplyHandler中处理 传递 subDevices 要登录的子设备

func (*Device) SubDeviceLogout

func (d *Device) SubDeviceLogout(subDevices []DeviceIdentification) ErrorCode

SubDeviceLogout 子设备下线,异步方法,结果在SubDeviceLogoutReplyHandler中处理 传递 subDevices 要下线的子设备

func (*Device) UploadFile

func (d *Device) UploadFile(param UploadFileParam) (fileID string, errCode ErrorCode)

UploadFile 上传文件到云端 可选择 1、上传到物联网平台,此时无需指定ServiceID。限制单实例文件数不超过1000个,单设备文件数不超过20个 2、直接上传到火山引擎TOS,此时需要提前在物联网平台产品详情中配置文件上传配置,文件数量和大小无限制 注意:如果在平台设置了上传到TOS的配置,并且没有设置默认,则上传时ServiceID为空将报错 返回 远端存储名称 成功标识

type DeviceAuthWithDeviceSecret

type DeviceAuthWithDeviceSecret struct {
	DeviceIdentification
	// 设备密钥
	// Required: true
	DeviceSecret string `json:"device_secret"`
}

DeviceAuthWithProductSecret 带设备密钥的设备认证信息

type DeviceAuthWithProductSecret

type DeviceAuthWithProductSecret struct {
	DeviceIdentification
	// 产品密钥
	// Required: true
	ProductSecret string `json:"product_secret"`
}

DeviceAuthWithProductSecret 带产品密钥的设备认证信息

type DeviceConfig

type DeviceConfig struct {
	InstanceID              string                `yaml:"instance_id" json:"instance_id"`
	DeviceName              string                `yaml:"device_name" json:"device_name"`
	ProductKey              string                `yaml:"product_key" json:"product_key"`
	ProductSecret           string                `yaml:"product_secret" json:"product_secret"`
	DeviceSecret            string                `yaml:"device_secret" json:"device_secret"`
	VerifyMode              string                `yaml:"verify_mode" json:"verify_mode"`
	IsGateway               bool                  `yaml:"is_gateway" json:"is_gateway"`
	CloudHTTPHost           string                `yaml:"cloud_http_host" json:"cloud_http_host"`
	MQTTHost                string                `yaml:"mqtt_host" json:"mqtt_host"`
	MQTTPort                int                   `yaml:"mqtt_port" json:"mqtt_port"`
	Region                  string                `yaml:"region" json:"region"`
	EnableTls               bool                  `yaml:"enable_tls" json:"enable_tls"`
	FilePath                string                `yaml:"file_path" json:"file_path"`
	OTAHistoryJobReloadMode string                `yaml:"ota_history_job_reload_mode" json:"ota_history_job_reload_mode"`
	OTAModule               []ModuleInfo          `yaml:"ota_module" json:"ota_module"`
	SubDeviceOTAModule      []ModuleInfo          `yaml:"sub_device_ota_module" json:"sub_device_ota_module"`
	TopicConfig             UserDefineTopicConfig `yaml:"user_define_topic" json:"user_define_topic"`
	LogReportConfig         LogReportCommonConfig `yaml:"log_report_config" json:"log_report_config"`
	WebshellExecutor        string                `yaml:"webshell_executor" json:"webshell_executor"`
	KeepAlive               *int64                `yaml:"keep_alive" json:"keep_alive"`
}

type DeviceIdentification

type DeviceIdentification struct {
	// 设备产品标识
	// Required: true
	ProductKey string `json:"ProductKey"`
	// 设备名称
	// Required: true
	DeviceName string `json:"DeviceName"`
}

DeviceIdentification 设备标识

type DeviceOperateType

type DeviceOperateType string

type DeviceOption

type DeviceOption struct {
	// 接入方式 MQTT/HTTP 默认MQTT
	// Required:false
	AccessType AccessType `yaml:"access_type"`
	// 实例ID
	// Required: true
	InstanceID string `yaml:"instance_id" json:"instance_id"`
	// 设备名称
	// Required:true
	Name string
	// 设备密钥
	// Required:false 无Secret时必须修改设备认证方式,动态获取secret
	Secret string
	// 产品标示
	// Required:true
	ProductKey string
	// 产品密钥
	// Required:false 设备Secret未获取到时,必须填写
	ProductSecret string
	// MQTT接入域名
	// Required: true
	MQTTHost string
	// MQTT接入端口,默认1883
	// Required: true
	MQTTPort int
	// 云端API地址 todo 设备侧不与云端API交互
	// Required: true
	CloudHTTPHost string
	// 是否启动tls认证,默认为false
	// Required:false
	EnableTls bool
	// 设备认证方式,默认为 DeviceSecret
	// Required:true
	VerifyMode DeviceVerifyMode
	// 是否是网关设备
	// Required:true
	IsGateway bool
	// OTA历史任务重入模式,不重入/新任务抢占/历史任务优先,默认为不重入
	// Required:false
	OTAHistoryJobReloadMode OTAHistoryJobReloadMode
	// 默认的文件存放路径,包括安装包下载文件,日志文件以及OTA升级历史任务文件等,不填则默认为当前工作目录
	// Required:false
	FilePath string
	// 设备OTA模块配置
	// Required:false 不填写无法进行OTA升级,key为设备OTAModuleKey
	ModuleConfig map[string]ModuleInfo
	// 子设备OTA模块配置
	// Required:false 不填写子设备无法进行OTA升级,key为子设备ProductKey:DeviceName:OTAModuleKey
	SubDeviceModuleConfig map[string]ModuleInfo
	// topic qos配置
	// Required:false key为topic,value为qos等级
	UserDefineTopicQosMap map[string]byte
	// Webshell执行器,默认为sh,如果系统不支持sh,请配置合适的执行器,比如bash,zsh 等
	// Required:false
	WebshellExecutor string
	// log report 配置
	// Required: false 默认配置为关闭,最低为info
	LogReportConfig LogReportConfig
	// 是否允许多个设备同时在线(临时方案)
	// Required:false
	AllowMultiple bool
	// mqtt连接保活时间,单位s,超过keepalive*1.5时间未收到消息认为客户端掉线。默认3分钟
	// Required:false
	KeepAlive *int64
	// 尝试重连的最大间隔时间,单位s。默认10秒
	// Required:false
	MaxReconnectInterval *int64
	// 是否开启mqtt debug日志,定位问题使用,不要在生产环境中默认打开
	// Required: false
	MQTTDebugLogEnabled bool
	// 断点重传property时的时间间隔,默认1s
	// Required:false
	UploadHistoryPropertyIntv *time.Duration
	// 网关定期上报在线子设备的时间间隔,默认5min
	// Required:false
	ReportSubDeviceLoginIntv *time.Duration
}

func InitOptionWithConfigFile

func InitOptionWithConfigFile(configPath string) (*DeviceOption, error)

InitOptionWithConfigFile 根据指定的配置文件生成对应的 DeviceOption 输入: 配置文件所在的位置(路径) 输出: *DeviceOption,error

func NewDeviceOption

func NewDeviceOption() *DeviceOption

func (*DeviceOption) WithAllowMultiple

func (o *DeviceOption) WithAllowMultiple(allowMultiple bool) *DeviceOption

func (*DeviceOption) WithCloudHTTPEndpoint

func (o *DeviceOption) WithCloudHTTPEndpoint(endpoint string) *DeviceOption

func (*DeviceOption) WithDeviceInfo

func (o *DeviceOption) WithDeviceInfo(productKey, productSecret, deviceName, deviceSecret string, verifyMode DeviceVerifyMode) *DeviceOption

func (*DeviceOption) WithEnableTls

func (o *DeviceOption) WithEnableTls(enableTls bool) *DeviceOption

func (*DeviceOption) WithFilePath

func (o *DeviceOption) WithFilePath(path string) *DeviceOption

func (*DeviceOption) WithInstanceID

func (o *DeviceOption) WithInstanceID(instanceID string) *DeviceOption

func (*DeviceOption) WithIsGateway

func (o *DeviceOption) WithIsGateway(isGateway bool) *DeviceOption

func (*DeviceOption) WithKeepAlive

func (o *DeviceOption) WithKeepAlive(keepAlive int64) *DeviceOption

func (*DeviceOption) WithLogReportConfig

func (o *DeviceOption) WithLogReportConfig(logReportConfig LogReportConfig) *DeviceOption

func (*DeviceOption) WithMQTTDebugLogEnabled

func (o *DeviceOption) WithMQTTDebugLogEnabled(enabled bool) *DeviceOption

func (*DeviceOption) WithMQTTEndpoint

func (o *DeviceOption) WithMQTTEndpoint(endpoint string) *DeviceOption

func (*DeviceOption) WithMQTTPort

func (o *DeviceOption) WithMQTTPort(port int) *DeviceOption

func (*DeviceOption) WithMaxReconnectInterval

func (o *DeviceOption) WithMaxReconnectInterval(maxReconnectInterval int64) *DeviceOption

func (*DeviceOption) WithModuleConfig

func (o *DeviceOption) WithModuleConfig(moduleConfig map[string]ModuleInfo) *DeviceOption

func (*DeviceOption) WithOTAHistoryJobReloadMode

func (o *DeviceOption) WithOTAHistoryJobReloadMode(mode OTAHistoryJobReloadMode) *DeviceOption

func (*DeviceOption) WithReportSubDeviceLoginIntv

func (o *DeviceOption) WithReportSubDeviceLoginIntv(reportSubDeviceLoginIntv time.Duration) *DeviceOption

func (*DeviceOption) WithSubDeviceModuleConfig

func (o *DeviceOption) WithSubDeviceModuleConfig(subDeviceModuleConfig map[string]ModuleInfo) *DeviceOption

func (*DeviceOption) WithUploadHistoryPropertyIntv

func (o *DeviceOption) WithUploadHistoryPropertyIntv(uploadHistoryPropertyIntv time.Duration) *DeviceOption

func (*DeviceOption) WithUserDefineTopicQosMap

func (o *DeviceOption) WithUserDefineTopicQosMap(userDefineTopicQosMap map[string]byte) *DeviceOption

func (*DeviceOption) WithWebshellExecutor

func (o *DeviceOption) WithWebshellExecutor(webshellExecutor string) *DeviceOption

type DeviceVerifyMode

type DeviceVerifyMode string
const VerifyModeDeviceSecret DeviceVerifyMode = "DeviceSecret"

一机一密,需要提供ProductKey、Name、Secret

const VerifyModeDynamicNoPreRegistered DeviceVerifyMode = "DynamicUnRegistered"

一型一密免预注册,需要提供ProductKey、ProductSecret、Name

const VerifyModeDynamicPreRegistered DeviceVerifyMode = "DynamicRegistered"

一型一密预注册,需要提供ProductKey、ProductSecret、Name

type DiffAlgorithm

type DiffAlgorithm func(diffFileName string) DiffAlgorithmResult

DiffAlgorithm 差分还原算法方法定义 传递 diffFileName 差分包源文件 返回 差分还原结果

type DiffAlgorithmResult

type DiffAlgorithmResult struct {
	// 差分还原结果
	IsSuccess bool
	// 结果描述信息
	ResDesc string
	// 完整安装包路径
	TargetFilePath string
}

type DiffFilePathConfig

type DiffFilePathConfig struct {
	// 差分包所在路径
	DiffFilePath string
}

type DynamicRegisterBasicParam

type DynamicRegisterBasicParam struct {
	// 实例ID
	// Required: true
	InstanceID string `json:"InstanceID"`
	// 产品标识
	// Required: true
	ProductKey string `json:"product_key" `
	// 设备名称
	// Required: true
	DeviceName string `json:"device_name" `
	// 随机数
	// Required: true
	RandomNum int64 `json:"random_num" `
	// 时间戳
	// Required: true
	Timestamp int64 `json:"timestamp" `
	// 认证类型,0-预认证;1-免认证
	// swagger:model
	// Required: true
	AuthType AuthType `json:"auth_type" `
}

type DynamicRegisterHttpResponse

type DynamicRegisterHttpResponse struct {
	Result           DynamicRegisterResponse `json:"Result"`
	ResponseMetadata ResponseMetadata        `json:"ResponseMetadata"`
}

type DynamicRegisterParam

type DynamicRegisterParam struct {
	DynamicRegisterBasicParam
	// 签名
	// Required: true
	Signature string `json:"signature" `
}

type DynamicRegisterResponse

type DynamicRegisterResponse struct {
	// 有效字节数
	// Required: true
	Len int `json:"len" `
	// 加密后的数据
	// Required: true
	Payload string `json:"payload" `
}

type EndUploadFileParams

type EndUploadFileParams struct {
	UploadID      string         `json:"UploadID"`
	Success       bool           `json:"Success"`
	CRC64         uint64         `json:"CRC64"`
	UploadedParts []UploadedPart `json:"UploadedParts"`
}

type EndUploadFileRequest

type EndUploadFileRequest struct {
	ID      string              `json:"ID"`
	Version string              `json:"Version"`
	Params  EndUploadFileParams `json:"Params"`
}

type ErrorCode

type ErrorCode int
const (
	// 成功
	SuccessCode ErrorCode = 0
	// 参数解析失败
	ErrorCodeParamUnmarshalFailed ErrorCode = 100001
	// 执行函数异常panic
	ErrorCodeFuncExecPanic ErrorCode = 100002
	// 消息Pub失败
	ErrorCodePubFailed ErrorCode = 100003
	// 文件操作失败
	ErrorCodeFileOperateFailed ErrorCode = 100004
	// 暂无可用升级任务
	ErrorCodeAvailableOTAJobNotFound ErrorCode = 100005
	// 当前设备的该OTA模块已经处于升级流程中
	ErrorCodeOTAJobLocked ErrorCode = 100006
	// 模块不存在
	ErrorCodeModuleNotExist ErrorCode = 100007
	// Handler不存在
	ErrorCodeHandlerNotExist ErrorCode = 100008
	// Decode失败
	ErrorCodeDecodeFailed ErrorCode = 100009
	// 升级取消
	ErrorCodeUpgradeCanceled ErrorCode = 100010
	// 订阅失败
	ErrorCodeSubFailed ErrorCode = 100011
	// 参数不合法
	ErrorCodeParamNotValid ErrorCode = 100012
	// 设备名称不合法
	ErrorCodeDeviceNameInvalid     ErrorCode = 100013
	ErrorCodeInternalError         ErrorCode = 100014
	ErrorCodeDeviceNameInvalidDesc           = "The device name only supports English letters, numbers, and special characters _-.:@, and no more than 128 characters."
	// 加密失败
	ErrorCodeEncryptFailed ErrorCode = 100015
	// 同步调用超时
	ErrorCodeSyncCallTimeout ErrorCode = 100016
	// OTA ResultCode
	OTAErrorCodeModuleNotExist    ErrorCode = 100017
	OTAErrorCodeDownloadFailed    ErrorCode = 100018
	OTAErrorCodeCheckFailed       ErrorCode = 100019
	OTAErrorCodeInstallFailed     ErrorCode = 100020
	OTAErrorCodeTimeout           ErrorCode = 100021
	OTAErrorCodeDiffRecoverFailed ErrorCode = 100022
	// 网关错误码
	GatewayErrorCodeTopoNotExist ErrorCode = 100023
	// Task ResultCode
	JobErrorCodeDownloadFailed      ErrorCode = 100024
	JobErrorCodeFileSignCheckFailed ErrorCode = 100025
	JobErrorCodeCanceled            ErrorCode = 100026
	JobErrorCodeTimeout             ErrorCode = 100027
	JobErrorCodeJobNotFound         ErrorCode = 100028

	// common
	CommonErrorCodeResourceNotFound   ErrorCode = 100029
	CommonErrorCodeCloudInternalError           = 100030 // 内部错误

	// http access
	HTTPErrorCodeEncrypt                ErrorCode = 100031
	HTTPErrorCodeDoRequest              ErrorCode = 100032
	HTTPErrorCodeUnmarshalBody          ErrorCode = 100033
	HTTPErrorCodeParamInvalid           ErrorCode = 100034
	HTTPErrorCodeSignInvalid            ErrorCode = 100035
	HTTPErrorCodeTokenInvalid           ErrorCode = 100036
	HTTPErrorCodeTokenExpired           ErrorCode = 100037
	HTTPErrorCodeTopicNotSupport        ErrorCode = 100038
	HTTPErrorCodeMessageTPSLimitReached ErrorCode = 100039 // TPS达到阈值

	//  物模型
	ThingModelErrorCodeReportPropertyLimitReached ErrorCode = 100040 // 单次上报属性数量限制500

	// QoS当前仅支持0和1
	ErrorCodeQoSNotSupport ErrorCode = 100041
)

type ErrorObj

type ErrorObj struct {
	CodeN   int    `json:",omitempty"`
	Code    string `json:",omitempty"`
	Message string `json:",omitempty"`
}

type EventParam

type EventParam struct {
	Values   map[string]interface{} `json:"Value"`
	TimeMill int64                  `json:"Time"`
}

type EventPayload

type EventPayload struct {
	ID      string     `json:"ID"`
	Version string     `json:"Version"`
	Params  EventParam `json:"Params"`
}

type EventReportParam

type EventReportParam struct {
	// 事件所属模块标识
	ModuleKey string
	// 事件标识
	Identifier string
	// 输出参数列表:key为标识符,value为具体值
	Values map[string]interface{}
}

type EventReportReplyHandler

type EventReportReplyHandler func(message ReplyParam)

type ExecutingJob

type ExecutingJob struct {
	ExecutingJobMeta
	// contains filtered or unexported fields
}

type ExecutingJobMeta

type ExecutingJobMeta struct {
	TaskPayloadParams
	// 状态
	Status JobStatus `json:"Status"`
}

type FileDownloader

type FileDownloader struct {
	// contains filtered or unexported fields
}

FileDownloader 文件下载器

func NewFileDownloader

func NewFileDownloader(url, outputFile string, offset, filesize int64) *FileDownloader

NewFileDownloader 下载器工厂入口

func (*FileDownloader) Download

func (d *FileDownloader) Download() error

Download 开始下载任务

type FileUploader

type FileUploader interface {
	// contains filtered or unexported methods
}

type Gateway

type Gateway interface {
	AddTopologies(subDevices []DeviceAuthWithProductSecret) ([]DeviceIdentification, ErrorCode)
	DeleteTopologies(subDevices []DeviceIdentification) ErrorCode
	GetTopologies() ErrorCode
	GetSubDeviceSecrets(subDevices []DeviceIdentification) ErrorCode
	ReportDiscoveryList(subDevices []DeviceIdentification) ErrorCode
	SubDeviceLogin(subDevices []DeviceIdentification) ([]DeviceIdentification, ErrorCode)
	SubDeviceLogout(subDevices []DeviceIdentification) ErrorCode
	SetAddTopologiesReplyHandler(handler GatewayCommonHandler)
	SetDeleteTopologiesReplyHandler(handler GatewayCommonHandler)
	SetGetTopologiesReplyHandler(handler GatewayCommonHandler)
	SetNotifyAddSubDeviceHandler(handler GatewayCommonHandler)
	SetTopologyChangeHandler(handler TopologyChangeHandler)
	SetSubDeviceChangeHandler(handler SubDeviceChangeHandler)
	SetSubDeviceSecretGetReplyHandler(handler SubDeviceSecretGetReplyHandler)
	SetSubDeviceLoginReplyHandler(handler GatewayCommonHandler)
	SetSubDeviceLogoutReplyHandler(handler GatewayCommonHandler)
}

type GatewayCommonHandler

type GatewayCommonHandler func(subDevices []DeviceIdentification) ErrorCode

type GetDeviceTokenParam

type GetDeviceTokenParam struct {
	DeviceIdentification
	ClientID   string `json:"ClientID"`
	Timestamp  int64  `json:"Timestamp"`
	Sign       string `json:"Sign"`
	InstanceID string `json:"InstanceID"`
}

internal communicate with arenal

type GetDeviceTokenResponse

type GetDeviceTokenResponse struct {
	Result           GetDeviceTokenResult `json:"Result"`
	ResponseMetadata ResponseMetadata     `json:"ResponseMetadata"`
}

type GetDeviceTokenResult

type GetDeviceTokenResult struct {
	Token string `json:"Token"`
}

type GetServerTimeHttpResponse

type GetServerTimeHttpResponse struct {
	Result           NTPResponseData  `json:"Result"`
	ResponseMetadata ResponseMetadata `json:"ResponseMetadata"`
}

type GetServerTimeParam

type GetServerTimeParam struct {
	DynamicRegisterParam
	DeviceSendTime int64      `json:"DeviceSendTime"`
	SecretType     SecretType `json:"SecretType"`
}

type InitUploadFileParams

type InitUploadFileParams struct {
	FileName  string     `json:"FileName"`
	FileSize  int64      `json:"FileSize"`
	PartSize  int64      `json:"PartSize"`
	ServiceID string     `json:"ServiceID"`
	Source    sourceType `json:"Source"`
}

type InitUploadFileRequest

type InitUploadFileRequest struct {
	ID      string               `json:"ID"`
	Version string               `json:"Version"`
	Params  InitUploadFileParams `json:"Params"`
}

type InitUploadFileResponse

type InitUploadFileResponse struct {
	CommonReply
	Data InitUploadFileResponseData `json:"Data"`
}

type InitUploadFileResponseData

type InitUploadFileResponseData struct {
	UploadID       string          `json:"UploadID"`
	FileID         string          `json:"FileID"`
	UploadFileURLs []UploadFileURL `json:"UploadFileURLs"`
}

type InstallAlgorithm

type InstallAlgorithm func(module, installFile string) InstallAlgorithmResult

InstallAlgorithm 安装算法方法定义 传递 module:模块标识符,installFile:安装包 返回 安装结果

type InstallAlgorithmResult

type InstallAlgorithmResult struct {
	// 安装结果
	IsSuccess bool
	// 结果描述信息
	ResDesc string
	// 安装后版本号
	DeviceVersion string
	// 安装完成后是否需要重启,子设备升级时可不填
	NeedReboot bool
}

type IoTGateway

type IoTGateway struct {
	// contains filtered or unexported fields
}

********************** 网关相关模型 ************************

type JobInfo

type JobInfo struct {
	DeviceIdentification
	OTAJobID           string    `json:"ota_job_id"`
	InstallPackageFile string    `json:"install_package_file"` // 用于安装的安装包文件,整包则为下载的升级包文件,差分包则为差分还原后的完整升级包文件
	OTAPackageFile     string    `json:"ota_package_file"`     // 下载的升级包文件
	DurationInMinutes  int64     `json:"duration_in_minutes"`  // 升级持续时长,用于计算升级是否超时,从下载升级包开始算起,对于重试的升级任务则从重试时间开始算起
	Step               string    `json:"step"`                 // 断点保存,用于历史任务中断恢复
	StepErrorCode      ErrorCode `json:"step_error_code"`      // 当前阶段的状态
	RetryTime          int64     `json:"retry_time"`           // 重试次数,若为0,表示该任务当前是第一次执行,重试超过5次将从历史任务中删除
	OTAReplyData
}

type JobStatus

type JobStatus string
const (
	JobStatusCreated     JobStatus = "Created"
	JobStatusDownloading JobStatus = "Downloading"
	JobStatusInProgress  JobStatus = "InProgress"
	JobStatusSuccess     JobStatus = "Success"
	JobStatusFailed      JobStatus = "Failed"
)

type JobType

type JobType string
const (
	JobTypePropertySet  JobType = "PropertySet"
	JobTypeServiceCall  JobType = "ServiceCall"
	JobTypeConfigUpdate JobType = "ConfigUpdate"
	JobTypeShadowUpdate JobType = "ShadowUpdate"
	JobTypeCustom       JobType = "Custom"
)

type LocalLogCondition

type LocalLogCondition struct {
	CommonLogCondition
	// 日志偏移量,表明从这个偏移量开始读取。默认为0
	// Required: false
	Offset int64 `json:"Offset"`
	// 每次读取的日志数。默认为40
	// Required: false
	Count int `json:"Count"`
}

type LocalLogConfigPayload

type LocalLogConfigPayload struct {
	ID                string            `json:"ID"`
	Version           string            `json:"Version"`
	LocalLogCondition LocalLogCondition `json:"Data"`
}

type LocalLogReportPayload

type LocalLogReportPayload struct {
	ID      string         `json:"Id"`
	Version string         `json:"Version"`
	Data    LocalLogResult `json:"Data"`
}

type LocalLogResult

type LocalLogResult struct {
	// 设备日志列表
	// swagger:model
	// Required: true
	Logs []Log `json:"List"`
	// 日志偏移量,表明下次从这个偏移量开始读取。如果为0说明查询结束
	// Required: true
	Offset int64 `form:"Offset"`
}

type Log

type Log struct {
	CreateTime int64  `json:"CreateTime"`
	LogLevel   string `json:"LogLevel"`
	Content    string `json:"Content"`
	Type       string `json:"Type"`
}

type LogLevel

type LogLevel string
const (
	LogLevelDebug LogLevel = "debug"
	LogLevelInfo  LogLevel = "info"
	LogLevelWarn  LogLevel = "warn"
	LogLevelError LogLevel = "error"
	LogLevelFatal LogLevel = "fatal"
)

type LogReportCommonConfig

type LogReportCommonConfig struct {
	Switch      bool   `json:"Switch" yaml:"switch"`
	LowestLevel string `json:"LowestLevel" yaml:"lowest_level"`
}

type LogReportConfig

type LogReportConfig struct {
	LogReportCommonConfig
	// contains filtered or unexported fields
}

type LogReportConfigPayload

type LogReportConfigPayload struct {
	ID      string                `json:"id"`
	Version string                `json:"version"`
	Data    LogReportCommonConfig `json:"data"`
}

type LogReportPayload

type LogReportPayload struct {
	ID      string      `json:"id"`
	Version string      `json:"version"`
	Data    interface{} `json:"data"`
}

type ModuleInfo

type ModuleInfo struct {
	ModuleKey    string `yaml:"module_key" json:"module_key"`
	Version      string `yaml:"version" json:"version"`
	FileName     string `yaml:"file_name" json:"file_name"`
	LastVersion  string `yaml:"last_version" json:"last_version,omitempty"`
	LastFileName string `yaml:"last_file_name" json:"last_file_name,omitempty"`
}

type NTPRequest

type NTPRequest struct {
	CommonRequest
	DeviceSendTime int64 `json:"Params"`
}

type NTPResponse

type NTPResponse struct {
	CommonReply
	Data NTPResponseData `json:"Data"`
}

type NTPResponseData

type NTPResponseData struct {
	DeviceSendTime int64 `json:"DeviceSendTime"`
	ServerRecvTime int64 `json:"ServerRecvTime"`
	ServerSendTime int64 `json:"ServerSendTime"`
}

type NTPResponseHandler

type NTPResponseHandler func(serverTimeMS int64) ErrorCode

type NotifyAction

type NotifyAction string
const (
	NotifyActionExecute NotifyAction = "Execute"
	NotifyActionCancel  NotifyAction = "Cancel"
)

type NotifyAddTopoReply

type NotifyAddTopoReply struct {
	CommonReply
	Timestamp int64 `json:"timestamp"`
}

type NotifyAddTopoRequest

type NotifyAddTopoRequest struct {
	TopologyRequest
	Timestamp int64 `json:"timestamp"`
}

type NotifyData

type NotifyData struct {
	Type          string `json:"type"`
	DestVersion   string `json:"dest_version"`
	Module        string `json:"module"`
	CustomMessage string `json:"custom_message"`
}

type NotifyType

type NotifyType string
const (
	NotifyTypeUpgrade NotifyType = "Upgrade"
	NotifyTypeCancel  NotifyType = "Cancel"
)

type OTA

type OTA interface {
	SetOTANotifyHandler(handler OTANotifyHandler)
	SetOTAReplyHandler(handler OTAReplyHandler)
	SetDiffAlgorithm(diffAlgorithm DiffAlgorithm)
	SetInstallAlgorithm(installAlgorithm InstallAlgorithm)
	SetSubDeviceCommonInstallAlgorithm(subDeviceCommonInstallAlgorithm SubDeviceCommonInstallAlgorithm)
	SetSubDeviceCustomInstallAlgorithm(subDeviceCustomInstallAlgorithm map[string]SubDeviceCustomInstallAlgorithm)
	SetQueryUpgradeConfig(config QueryUpgradeConfig)
	OTAVersionReport(versionMap map[string]string, deviceIdentification ...DeviceIdentification) ErrorCode
	OTAUpgradeRequest(module, otaJobID string, deviceIdentification ...DeviceIdentification) ErrorCode
	InitOTAJob(deviceIdentification DeviceIdentification, data OTAReplyData) (ErrorCode, OTAMetadata)
	OTADownload(module string, deviceIdentification ...DeviceIdentification) ErrorCode
	OTAInstall(module string, deviceIdentification ...DeviceIdentification) ErrorCode
	GetOTAInfo(otaModuleIdentification []OTAModuleIdentification) map[string]JobInfo
}

type OTACurrentJobInfo

type OTACurrentJobInfo struct {
	Info             JobInfo
	JobCancelChannel chan struct{}
}

type OTAHistoryJobReloadMode

type OTAHistoryJobReloadMode string
const (
	OTAReloadModeIgnore             OTAHistoryJobReloadMode = "Ignore"
	OTAReloadModeNewJobCoverage     OTAHistoryJobReloadMode = "NewJobCoverage"
	OTAReloadModeHistoryJobPriority OTAHistoryJobReloadMode = "HistoryJobPriority"
)

type OTAMetadata

type OTAMetadata struct {
	// 升级任务唯一标识
	OTAJobID string
	// 产品唯一标识
	ProductKey string
	// 设备名称
	DeviceName string
	// OTA模块名称
	OTAModuleName string
	// 重试次数
	RetryTime int64
	// 历史任务断点
	Step string
}

type OTAModuleIdentification

type OTAModuleIdentification struct {
	// 设备产品标识
	ProductKey string
	// 设备名称
	DeviceName string
	// OTA模块
	ModuleName string
}

OTAModuleIdentification 设备OTA模块标识

type OTANotifyHandler

type OTANotifyHandler func(message OTANotifyPayload)

type OTANotifyPayload

type OTANotifyPayload struct {
	DeviceIdentification
	OTAJobID string     `json:"ota_job_id"`
	ID       string     `json:"id"`
	Code     int        `json:"code"`
	Data     NotifyData `json:"data"`
}

type OTAReplyData

type OTAReplyData struct {
	// OTA任务ID
	OTAJobID string `json:"ota_job_id"`
	// 安装包大小
	Size int64 `json:"size,omitempty"`
	// 目标版本
	DestVersion string `json:"dest_version,omitempty"`
	// 模块标识
	Module string `json:"module,omitempty"`
	// 是否为差分包
	IsDiff bool `json:"is_diff,omitempty"`
	// 下载地址url
	Url string `json:"url,omitempty"`
	// 签名值,用于校验完整性
	Sign string `json:"sign,omitempty"`
	// 单设备超时时间(单位:分钟)
	TimeoutInMinutes int64 `json:"timeout_in_minutes,omitempty"`
}

type OTAReplyHandler

type OTAReplyHandler func(message OTAReplyPayload)

type OTAReplyPayload

type OTAReplyPayload struct {
	DeviceIdentification
	ID   string       `json:"id"`
	Code int          `json:"code"`
	Data OTAReplyData `json:"data"`
}

type OTAUpgradeProcessReportPayload

type OTAUpgradeProcessReportPayload struct {
	ID      string             `json:"id"`
	Version string             `json:"version"`
	Params  ProcessReportParam `json:"params"`
}

type OTAUpgradeRequestPayload

type OTAUpgradeRequestPayload struct {
	ID      string              `json:"id"`
	Version string              `json:"version"`
	Params  UpgradeRequestParam `json:"params"`
}

type OTAVersionReportPayload

type OTAVersionReportPayload struct {
	ID      string            `json:"id"`
	Version string            `json:"version"`
	Params  map[string]string `json:"params"`
}

type OnConnectHandler

type OnConnectHandler func() ErrorCode

type ProcessReportParam

type ProcessReportParam struct {
	// 目前状态,下载中/下载完成/安装中/安装完成/升级成功/升级失败
	Status UpgradeDeviceStatusEnum `json:"status"`
	// 结果码 OTAProcessReportResultCode
	ResultCode ErrorCode `json:"result_code"`
	// 结果说明
	ResultDesc string `json:"result_desc,omitempty"`
	// 时间戳,毫秒
	Time int64 `json:"time"`
}

type PropertyPayload

type PropertyPayload struct {
	ID      string                   `json:"ID"`
	Version string                   `json:"Version"`
	Params  map[string]PropertyValue `json:"Params"`
}

type PropertyReportReplyHandler

type PropertyReportReplyHandler func(message ReplyParam)

type PropertySetHandler

type PropertySetHandler func(message PropertySetMessage) ErrorCode

type PropertySetMessage

type PropertySetMessage struct {
	DeviceIdentification
	Params map[string]interface{} `json:"Params"`
}

type PropertyValue

type PropertyValue struct {
	// 属性具体值
	Value interface{} `json:"Value"`
	// 属性值获取时间
	TimeMill int64 `json:"Time"`
}

type PublishMessageHTTPParam

type PublishMessageHTTPParam struct {
	AccessToken string `json:"AccessToken,omitempty"` // header
	Topic       string `json:"Topic"`                 // body
	Payload     []byte `json:"Payload"`               // body
	InstanceID  string `json:"InstanceID"`            // body
	ProductKey  string `json:"ProductKey,omitempty"`  // path
	DeviceName  string `json:"DeviceName,omitempty"`  // path
}

type PublishMessageHTTPResponse

type PublishMessageHTTPResponse struct {
	Result           PublishMessageHTTPResult `json:"Result"`
	ResponseMetadata ResponseMetadata         `json:"ResponseMetadata"`
}

type PublishMessageHTTPResult

type PublishMessageHTTPResult struct {
}

type PublishMessageParam

type PublishMessageParam struct {
	AccessToken string `json:"AccessToken,omitempty"`
	Topic       string `json:"Topic"`
	Payload     []byte `json:"Payload"`
}

type QueryUpgradeConfig

type QueryUpgradeConfig struct {
	// 间隔时间(单位:小时),默认为24小时
	TimeInterval int `json:"time_interval"`
	// 时间段起始时间(单位:小时),默认为每天0点
	StartTime int `json:"start_time"`
	// 时间段结束时间(单位:小时),默认为每天24点
	EndTime int `json:"end_time"`
}

QueryUpgradeConfig 查询OTA升级频次配置

type Region

type Region string
const (
	RegionBoe          Region = "global-boe"
	RegionOffline      Region = "global-offline"
	RegionPublic       Region = "global-public"
	RegionOnline       Region = "global-online"
	RegionOnlinePublic Region = "global-online-public"
)

type ReplyParam

type ReplyParam struct {
	DeviceIdentification
	ReplyPayload
}

type ReplyPayload

type ReplyPayload struct {
	ID   string                 `json:"ID"`
	Code ErrorCode              `json:"Code"`
	Data map[string]interface{} `json:"Data"`
}

type Reported

type Reported struct {
	// 设备影子内容,key为 FormatUniqueFieldName 构建的唯一key,value为对应属性的值
	Reported map[string]interface{} `json:"reported"`
}

type ResponseMetadata

type ResponseMetadata struct {
	Error *ErrorObj `json:",omitempty"`
}

type SecretType

type SecretType string

密钥类型,支持Product/Device

const (
	SecretTypeProduct SecretType = "Product"
	SecretTypeDevice  SecretType = "Device"
)

type ServiceCallHandler

type ServiceCallHandler func(message ServiceCallMessage) (map[string]interface{}, ErrorCode)

type ServiceCallMessage

type ServiceCallMessage struct {
	DeviceIdentification
	ServiceCallParam
}

type ServiceCallParam

type ServiceCallParam struct {
	// 模块标示
	// Required: true
	ModuleKey string `json:"ModuleKey"`
	// 功能标示ID
	// Required: true
	ElementIdentifier string `json:"ElementIdentifier"`
	// 输入参数
	// Required: false
	Params map[string]interface{} `json:"Params"`
}

type ServiceCallPayload

type ServiceCallPayload struct {
	ID      string                 `json:"ID"`
	Version string                 `json:"Version"`
	Params  map[string]interface{} `json:"Params"`
}

type ShadowDesiredParam

type ShadowDesiredParam struct {
	Desired map[string]interface{} `json:"Desired"`
	Version int64                  `json:"Version"`
}

type ShadowDesiredSetPayload

type ShadowDesiredSetPayload struct {
	CommonRequest
	Params ShadowDesiredParam `json:"Params"`
}

type ShadowGetReplyPayload

type ShadowGetReplyPayload struct {
	CommonReply
	Data ShadowDesiredParam `json:"Data"`
}

type ShadowReportParam

type ShadowReportParam struct {
	// 设备上报的版本
	Version int64 `json:"Version"`
	// 上报的各个属性
	Reported map[string]interface{} `json:"Reported"`
}

type ShadowReportPayload

type ShadowReportPayload struct {
	CommonRequest
	Params ShadowReportParam `json:"Params"`
}

type ShadowSetHandler

type ShadowSetHandler func(message ShadowSetMessage) ErrorCode

type ShadowSetMessage

type ShadowSetMessage struct {
	DeviceIdentification
	ShadowDesiredParam
}

type StreamLogConfig

type StreamLogConfig struct {
	// 是否开启实时流日志上报
	Switch bool `json:"Switch"`
	// 内容关键字
	// Required: false
	ContentKeyWord string `json:"ContentKeyword"`
	// 日志类型(sdk、device)
	// Required: false
	Type string `json:"Type"`
	// 日志等级(debug、info、warn、error、fatal)
	// Required: false
	LogLevel string `json:"LogLevel"`
	// 开始时间
	// Required: true
	StartTime int64 `json:"StartTime"`
}

type StreamLogConfigPayload

type StreamLogConfigPayload struct {
	ID              string          `json:"ID"`
	Version         string          `json:"Version"`
	StreamLogConfig StreamLogConfig `json:"Data"`
}

type SubDeviceChangeHandler

type SubDeviceChangeHandler func(param SubDeviceChangeParam) ErrorCode

type SubDeviceChangeParam

type SubDeviceChangeParam struct {
	OperateType DeviceOperateType      `json:"operate_type"`
	SubDevices  []DeviceIdentification `json:"sub_devices"`
}

type SubDeviceChangePayload

type SubDeviceChangePayload struct {
	CommonRequest
	Params SubDeviceChangeParam `json:"params"`
}

type SubDeviceCommonInstallAlgorithm

type SubDeviceCommonInstallAlgorithm func(SubDeviceCommonInstallParam SubDeviceInstallParam) InstallAlgorithmResult

SubDeviceCommonInstallAlgorithm 子设备通用安装算法方法定义 传递 SubDeviceInstallParam 返回 子设备安装结果

type SubDeviceCustomInstallAlgorithm

type SubDeviceCustomInstallAlgorithm func(SubDeviceCustomInstallParam SubDeviceInstallParam) InstallAlgorithmResult

SubDeviceCustomInstallAlgorithm 子设备定制化安装算法方法定义 传递 SubDeviceCustomInstallParam 返回 子设备安装结果

type SubDeviceInstallParam

type SubDeviceInstallParam struct {
	// 子设备所属产品标识
	ProductKey string
	// 子设备名称
	DeviceName string
	// OTA模块标识符
	OTAModule string
	// 安装包路径
	FileName string
	// 是否是差分包
	IsDiff bool
}

type SubDeviceLoginReportParams

type SubDeviceLoginReportParams struct {
	TriggerTime int64                  `json:"trigger_time"`
	SubDevices  []DeviceIdentification `json:"sub_devices"`
}

type SubDeviceLoginReportRequest

type SubDeviceLoginReportRequest struct {
	CommonRequest
	Params SubDeviceLoginReportParams `json:"params"`
}

type SubDeviceLoginRequest

type SubDeviceLoginRequest struct {
	CommonRequest
	TriggerTime int64                    `json:"trigger_time"`
	SubDevices  []SubDeviceParamWithAuth `json:"params"`
}

type SubDeviceLogoutRequest

type SubDeviceLogoutRequest struct {
	CommonRequest
	TriggerTime int64                  `json:"trigger_time"`
	SubDevices  []DeviceIdentification `json:"params"`
}

type SubDeviceParamWithAuth

type SubDeviceParamWithAuth struct {
	DeviceIdentification
	// 随机数
	// Required: true
	RandomNum int64 `json:"random_num" `
	// 时间戳
	// Required: true
	Timestamp int64 `json:"timestamp"`
	// 签名
	// Required: true
	Signature string `json:"signature"`
}

type SubDeviceSecret

type SubDeviceSecret struct {
	DeviceIdentification
	DeviceSecret DynamicRegisterResponse `json:"device_secret"`
}

type SubDeviceSecretGetReplyHandler

type SubDeviceSecretGetReplyHandler func(subDeviceSecrets []DeviceAuthWithDeviceSecret) ErrorCode

type SubDeviceSecretReply

type SubDeviceSecretReply struct {
	CommonReply
	Data []SubDeviceSecret `json:"data"`
}

type SyncCallParam

type SyncCallParam struct {
	RequestTopic string
	RequestQos   byte
	ReplyTopic   string
	ReplyQos     byte
	Payload      string
	TimeoutMs    int64
}

type TaskGetPayload

type TaskGetPayload struct {
	ID      string `json:"ID"`
	Version string `json:"Version"`
}

type TaskGetReply

type TaskGetReply struct {
	ID   string              `json:"ID"`
	Code ErrorCode           `json:"Code"`
	Data []TaskPayloadParams `json:"Data"`
}

type TaskNotifyPayload

type TaskNotifyPayload struct {
	ID      string            `json:"ID"`
	Version string            `json:"Version"`
	Params  TaskPayloadParams `json:"Params"`
}

type TaskParam

type TaskParam struct {
	// 属性设置参数
	PropertySetParams map[string]interface{} `json:"PropertySetParam,omitempty"`
	// 服务调用参数
	ServiceCallParams *ServiceCallParam `json:"ServiceCallParams,omitempty"`
	// 配置下发参数
	ConfigUpdateParams *LogReportConfig `json:"ConfigUpdateParams,omitempty"`
	// 设备影子更新参数
	ShadowUpdateParams *ShadowDesiredParam `json:"ShadowUpdateParams,omitempty"`
	// 自定义任务参数,格式和内容自定义
	CustomParams *CustomTaskPayload `json:"CustomParams,omitempty"`
}

type TaskPayloadParams

type TaskPayloadParams struct {
	// 任务ID,任务的唯一标识
	JobID string `json:"JobID"`
	// 任务类型
	Type JobType `json:"Type"`
	// 通知操作,有 Execute/Cancel 执行/取消
	Action NotifyAction `json:"Action"`
	// 任务超时时间
	TimeoutInMinutes int64 `json:"TimeoutInMinutes"`
	// 任务参数
	Param TaskParam `json:"Param"`
	// 任务异常中断处理,可选 重试/失败 Retry/Failed,默认失败
	ActionOnInterrupt string `json:"ActionOnInterrupt"`
}

type TaskProgressReportParam

type TaskProgressReportParam struct {
	// 任务ID
	JobID string `json:"JobID"`
	// 状态
	Status JobStatus `json:"Status"`
	// 时间
	Time int64 `json:"Time"`
	// 错误吗
	ResultCode ErrorCode `json:"ResultCode"`
	// 错误描述
	ResultDesc string `json:"ResultDesc"`
}

type TaskProgressReportPayload

type TaskProgressReportPayload struct {
	ID      string                  `json:"ID"`
	Version string                  `json:"Version"`
	Params  TaskProgressReportParam `json:"Params"`
}

type TaskProgressReportReply

type TaskProgressReportReply struct {
	ID    string    `json:"ID"`
	Code  ErrorCode `json:"Code"`
	JobID string    `json:"Data"`
}

type TopoChangeParam

type TopoChangeParam struct {
	OperateType TopologyOperateType    `json:"operate_type"`
	SubDevices  []DeviceIdentification `json:"sub_devices"`
}

type TopoChangeParamWithSecret

type TopoChangeParamWithSecret struct {
	OperateType TopologyOperateType `json:"operate_type"`
	SubDevices  []SubDeviceSecret   `json:"sub_devices"`
}

type TopoChangePayload

type TopoChangePayload struct {
	CommonRequest
	Params TopoChangeParamWithSecret `json:"params"`
}

type TopoReplyParam

type TopoReplyParam struct {
	CommonReply
	Data []DeviceIdentification `json:"data"`
}

type TopologyChangeHandler

type TopologyChangeHandler func(param TopoChangeParam) ErrorCode

type TopologyOperateType

type TopologyOperateType string
const (
	TopologyOperateTypeCreate  TopologyOperateType = "create"
	TopologyOperateTypeDelete  TopologyOperateType = "delete"
	TopologyOperateTypeEnable  TopologyOperateType = "enable"
	TopologyOperateTypeDisable TopologyOperateType = "disable"
)

type TopologyRequest

type TopologyRequest struct {
	CommonRequest
	SubDevices []DeviceIdentification `json:"params"`
}

type TopologyRequestWithAuth

type TopologyRequestWithAuth struct {
	CommonRequest
	SubDevices []SubDeviceParamWithAuth `json:"params"`
}

type UpgradeDeviceStatusEnum

type UpgradeDeviceStatusEnum string
const (
	UpgradeDeviceStatusDownloading UpgradeDeviceStatusEnum = "Downloading" // 下载中
	UpgradeDeviceStatusDownloaded  UpgradeDeviceStatusEnum = "Downloaded"  // 下载完成
	UpgradeDeviceStatusInstalling  UpgradeDeviceStatusEnum = "Installing"  // 安装中
	UpgradeDeviceStatusInstalled   UpgradeDeviceStatusEnum = "Installed"   // 安装完成
	UpgradeDeviceStatusSuccess     UpgradeDeviceStatusEnum = "Success"     // 升级成功
	UpgradeDeviceStatusFailed      UpgradeDeviceStatusEnum = "Failed"      // 升级失败
)

type UpgradeRequestParam

type UpgradeRequestParam struct {
	OTAJobID   string `json:"ota_job_id,omitempty"`
	SrcVersion string `json:"src_version"`
	Module     string `json:"module"`
}

type UpgradeStepEnum

type UpgradeStepEnum string
const (
	UpgradeStepEnumToUpgrade      UpgradeStepEnum = "ToUpgrade"      // 待升级
	UpgradeStepEnumDownloading    UpgradeStepEnum = "Downloading"    // 下载中
	UpgradeStepEnumDownloaded     UpgradeStepEnum = "Downloaded"     // 下载完成
	UpgradeStepEnumDiffRecovering UpgradeStepEnum = "DiffRecovering" // 差分还原中
	UpgradeStepEnumDiffRecovered  UpgradeStepEnum = "DiffRecovered"  // 差分还原完成
	UpgradeStepEnumInstalling     UpgradeStepEnum = "Installing"     // 安装中
	UpgradeStepEnumInstalled      UpgradeStepEnum = "Installed"      // 安装完成
	UpgradeStepEnumSuccess        UpgradeStepEnum = "Success"        // 升级成功
)

type UploadFileParam

type UploadFileParam struct {
	// 文件名称,必传
	Filename string
	// 文件大小,必传
	Filesize int64
	// 分片大小,非必传,默认50MiB,必须大于等于5MiB,并且保证总分片数小于等于100
	PartSize int64
	// 业务ID,非必传,上传到用户TOS时可以传递,如果有默认的业务ID bucket可不传
	ServiceID string
	// 文件read seeker,必传
	FileReader io.ReadSeeker
}

type UploadFilePayload

type UploadFilePayload struct {
	ID      string `json:"ID"`
	Version string `json:"Version"`
	Params  struct {
		// 文件在设备上的路径
		// Required: true
		FilePath string `json:"FilePath"`
		// 上传类型
		// Required: true
		UploadType UploadType `json:"UploadType"`
		// 业务ID
		// Required: false
		ServiceID string `json:"ServiceID"`
	} `json:"Params"`
}

type UploadFileProgressPayload

type UploadFileProgressPayload struct {
	ID      string           `json:"ID"`
	Version string           `json:"Version"`
	Params  UploadFileReport `json:"Params"`
}

type UploadFileReport

type UploadFileReport struct {
	Status      UploadFileStatus `json:"Status"`
	Description string           `json:"Description"`
}

type UploadFileStatus

type UploadFileStatus string
const (
	UploadFileStatusUploading UploadFileStatus = "Uploading"
	UploadFileStatusSuccess   UploadFileStatus = "Success"
	UploadFileStatusFailed    UploadFileStatus = "Failed"
)

type UploadFileURL

type UploadFileURL struct {
	PartNum   int    `json:"PartNum"`
	UploadURL string `json:"UploadURL"`
}

type UploadType

type UploadType string
const UploadTypeArenal UploadType = "Arenal"

type UploadedPart

type UploadedPart struct {
	PartNumber int    `json:"PartNumber"`
	ETag       string `json:"ETag"`
}

type UserDefineTopicConfig

type UserDefineTopicConfig struct {
	Qos0 []string `yaml:"qos_0" json:"qos_0"`
	Qos1 []string `yaml:"qos_1" json:"qos_1"`
}

Directories

Path Synopsis
common

Jump to

Keyboard shortcuts

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