Documentation ¶
Index ¶
- Constants
- Variables
- func CheckDeviceName(name string) bool
- func FormatUniqueFieldName(moduleKey, identifier string) string
- func GetTimeMill() int64
- func PKCS5UnPadding(origData []byte) []byte
- type AccessType
- type ActionOnInterrupt
- type AuthType
- type BaseDevice
- type ClearPayload
- type CommonHttpResponse
- type CommonLogCondition
- type CommonReply
- type CommonRequest
- type ConsoleLogger
- type CustomJobHandler
- type CustomJobMessage
- type CustomTaskPayload
- type CustomTopicHandler
- type CustomTopicParam
- type Device
- func (d *Device) AddTopologies(subDevices []DeviceAuthWithProductSecret) (failedDevices []DeviceIdentification, errCode ErrorCode)
- func (d *Device) Close()
- func (d *Device) DeleteTopologies(subDevices []DeviceIdentification) ErrorCode
- func (d *Device) DeviceLog(level LogLevel, content string)
- func (d *Device) DeviceLogf(level LogLevel, format string, args ...interface{})
- func (d *Device) DisConnect()
- func (d *Device) EventReport(param EventReportParam, deviceIdentification ...DeviceIdentification) ErrorCode
- func (d *Device) GetDeviceToken() (*GetDeviceTokenResult, ErrorCode)
- func (d *Device) GetOTAInfo(otaModuleIdentification []OTAModuleIdentification) map[string]JobInfo
- func (d *Device) GetServerTime() (int64, ErrorCode)
- func (d *Device) GetShadowDesired(deviceIdentification ...DeviceIdentification) ErrorCode
- func (d *Device) GetSubDeviceSecrets(subDevices []DeviceIdentification) ErrorCode
- func (d *Device) GetTopologies() ErrorCode
- func (d *Device) Init() bool
- func (d *Device) InitOTAJob(deviceIdentification DeviceIdentification, data OTAReplyData) (ErrorCode, OTAMetadata)
- func (d *Device) IsConnected() bool
- func (d *Device) IsConnectionOpen() bool
- func (d *Device) OTADownload(module string, deviceIdentification ...DeviceIdentification) ErrorCode
- func (d *Device) OTAInstall(module string, deviceIdentification ...DeviceIdentification) ErrorCode
- func (d *Device) OTAUpgradeRequest(module, otaJobID string, deviceIdentification ...DeviceIdentification) ErrorCode
- func (d *Device) OTAVersionReport(versionMap map[string]string, deviceIdentification ...DeviceIdentification) ErrorCode
- func (d *Device) PropertyReport(propertyValues map[string]PropertyValue, ...) ErrorCode
- func (d *Device) PropertyReportAsync(propertyValues map[string]PropertyValue, ...) (paho.Token, ErrorCode)
- func (d *Device) PublishMessageHTTP(param *PublishMessageParam) (*PublishMessageHTTPResult, ErrorCode)
- func (d *Device) ReportDiscoveryList(subDevices []DeviceIdentification) ErrorCode
- func (d *Device) SendCustomTopicMessage(topicSuffix, payload string, qos int) ErrorCode
- func (d *Device) SendNTPRequest() ErrorCode
- func (d *Device) SetAddTopologiesReplyHandler(handler GatewayCommonHandler)
- func (d *Device) SetCustomJobHandler(handler CustomJobHandler)
- func (d *Device) SetCustomTopicHandler(topicSuffix string, handler CustomTopicHandler)
- func (d *Device) SetDeleteTopologiesReplyHandler(handler GatewayCommonHandler)
- func (d *Device) SetDiffAlgorithm(diffAlgorithm DiffAlgorithm)
- func (d *Device) SetEventReportReplyHandler(handler EventReportReplyHandler)
- func (d *Device) SetGetTopologiesReplyHandler(handler GatewayCommonHandler)
- func (d *Device) SetInstallAlgorithm(installAlgorithm InstallAlgorithm)
- func (d *Device) SetNTPResponseHandler(handler NTPResponseHandler)
- func (d *Device) SetNotifyAddSubDeviceHandler(handler GatewayCommonHandler)
- func (d *Device) SetOTANotifyHandler(handler OTANotifyHandler)
- func (d *Device) SetOTAReplyHandler(handler OTAReplyHandler)
- func (d *Device) SetOnConnectHandler(handler OnConnectHandler)
- func (d *Device) SetPropertyReportReplyHandler(handler PropertyReportReplyHandler)
- func (d *Device) SetPropertySetHandler(handler PropertySetHandler)
- func (d *Device) SetQueryUpgradeConfig(config QueryUpgradeConfig)
- func (d *Device) SetServiceCallHandler(handler ServiceCallHandler)
- func (d *Device) SetShadowSetHandler(handler ShadowSetHandler)
- func (d *Device) SetSubDeviceChangeHandler(handler SubDeviceChangeHandler)
- func (d *Device) SetSubDeviceCommonInstallAlgorithm(subDeviceCommonInstallAlgorithm SubDeviceCommonInstallAlgorithm)
- func (d *Device) SetSubDeviceCustomInstallAlgorithm(subDeviceCustomInstallAlgorithm map[string]SubDeviceCustomInstallAlgorithm)
- func (d *Device) SetSubDeviceLoginReplyHandler(handler GatewayCommonHandler)
- func (d *Device) SetSubDeviceLogoutReplyHandler(handler GatewayCommonHandler)
- func (d *Device) SetSubDeviceSecretGetReplyHandler(handler SubDeviceSecretGetReplyHandler)
- func (d *Device) SetTopologyChangeHandler(handler TopologyChangeHandler)
- func (d *Device) ShadowReport(reported Reported, deviceIdentification ...DeviceIdentification) ErrorCode
- func (d *Device) SubDeviceLogin(subDevices []DeviceIdentification) (failedDevices []DeviceIdentification, errCode ErrorCode)
- func (d *Device) SubDeviceLogout(subDevices []DeviceIdentification) ErrorCode
- func (d *Device) UploadFile(param UploadFileParam) (fileID string, errCode ErrorCode)
- type DeviceAuthWithDeviceSecret
- type DeviceAuthWithProductSecret
- type DeviceConfig
- type DeviceIdentification
- type DeviceOperateType
- type DeviceOption
- func (o *DeviceOption) WithAllowMultiple(allowMultiple bool) *DeviceOption
- func (o *DeviceOption) WithCloudHTTPEndpoint(endpoint string) *DeviceOption
- func (o *DeviceOption) WithDeviceInfo(productKey, productSecret, deviceName, deviceSecret string, ...) *DeviceOption
- func (o *DeviceOption) WithEnableTls(enableTls bool) *DeviceOption
- func (o *DeviceOption) WithFilePath(path string) *DeviceOption
- func (o *DeviceOption) WithInstanceID(instanceID string) *DeviceOption
- func (o *DeviceOption) WithIsGateway(isGateway bool) *DeviceOption
- func (o *DeviceOption) WithKeepAlive(keepAlive int64) *DeviceOption
- func (o *DeviceOption) WithLogReportConfig(logReportConfig LogReportConfig) *DeviceOption
- func (o *DeviceOption) WithMQTTDebugLogEnabled(enabled bool) *DeviceOption
- func (o *DeviceOption) WithMQTTEndpoint(endpoint string) *DeviceOption
- func (o *DeviceOption) WithMQTTPort(port int) *DeviceOption
- func (o *DeviceOption) WithMaxReconnectInterval(maxReconnectInterval int64) *DeviceOption
- func (o *DeviceOption) WithModuleConfig(moduleConfig map[string]ModuleInfo) *DeviceOption
- func (o *DeviceOption) WithOTAHistoryJobReloadMode(mode OTAHistoryJobReloadMode) *DeviceOption
- func (o *DeviceOption) WithReportSubDeviceLoginIntv(reportSubDeviceLoginIntv time.Duration) *DeviceOption
- func (o *DeviceOption) WithSubDeviceModuleConfig(subDeviceModuleConfig map[string]ModuleInfo) *DeviceOption
- func (o *DeviceOption) WithUploadHistoryPropertyIntv(uploadHistoryPropertyIntv time.Duration) *DeviceOption
- func (o *DeviceOption) WithUserDefineTopicQosMap(userDefineTopicQosMap map[string]byte) *DeviceOption
- func (o *DeviceOption) WithWebshellExecutor(webshellExecutor string) *DeviceOption
- type DeviceVerifyMode
- type DiffAlgorithm
- type DiffAlgorithmResult
- type DiffFilePathConfig
- type DynamicRegisterBasicParam
- type DynamicRegisterHttpResponse
- type DynamicRegisterParam
- type DynamicRegisterResponse
- type EndUploadFileParams
- type EndUploadFileRequest
- type ErrorCode
- type ErrorObj
- type EventParam
- type EventPayload
- type EventReportParam
- type EventReportReplyHandler
- type ExecutingJob
- type ExecutingJobMeta
- type FileDownloader
- type FileUploader
- type Gateway
- type GatewayCommonHandler
- type GetDeviceTokenParam
- type GetDeviceTokenResponse
- type GetDeviceTokenResult
- type GetServerTimeHttpResponse
- type GetServerTimeParam
- type InitUploadFileParams
- type InitUploadFileRequest
- type InitUploadFileResponse
- type InitUploadFileResponseData
- type InstallAlgorithm
- type InstallAlgorithmResult
- type IoTGateway
- type JobInfo
- type JobStatus
- type JobType
- type LocalLogCondition
- type LocalLogConfigPayload
- type LocalLogReportPayload
- type LocalLogResult
- type Log
- type LogLevel
- type LogReportCommonConfig
- type LogReportConfig
- type LogReportConfigPayload
- type LogReportPayload
- type ModuleInfo
- type NTPRequest
- type NTPResponse
- type NTPResponseData
- type NTPResponseHandler
- type NotifyAction
- type NotifyAddTopoReply
- type NotifyAddTopoRequest
- type NotifyData
- type NotifyType
- type OTA
- type OTACurrentJobInfo
- type OTAHistoryJobReloadMode
- type OTAMetadata
- type OTAModuleIdentification
- type OTANotifyHandler
- type OTANotifyPayload
- type OTAReplyData
- type OTAReplyHandler
- type OTAReplyPayload
- type OTAUpgradeProcessReportPayload
- type OTAUpgradeRequestPayload
- type OTAVersionReportPayload
- type OnConnectHandler
- type ProcessReportParam
- type PropertyPayload
- type PropertyReportReplyHandler
- type PropertySetHandler
- type PropertySetMessage
- type PropertyValue
- type PublishMessageHTTPParam
- type PublishMessageHTTPResponse
- type PublishMessageHTTPResult
- type PublishMessageParam
- type QueryUpgradeConfig
- type Region
- type ReplyParam
- type ReplyPayload
- type Reported
- type ResponseMetadata
- type SecretType
- type ServiceCallHandler
- type ServiceCallMessage
- type ServiceCallParam
- type ServiceCallPayload
- type ShadowDesiredParam
- type ShadowDesiredSetPayload
- type ShadowGetReplyPayload
- type ShadowReportParam
- type ShadowReportPayload
- type ShadowSetHandler
- type ShadowSetMessage
- type StreamLogConfig
- type StreamLogConfigPayload
- type SubDeviceChangeHandler
- type SubDeviceChangeParam
- type SubDeviceChangePayload
- type SubDeviceCommonInstallAlgorithm
- type SubDeviceCustomInstallAlgorithm
- type SubDeviceInstallParam
- type SubDeviceLoginReportParams
- type SubDeviceLoginReportRequest
- type SubDeviceLoginRequest
- type SubDeviceLogoutRequest
- type SubDeviceParamWithAuth
- type SubDeviceSecret
- type SubDeviceSecretGetReplyHandler
- type SubDeviceSecretReply
- type SyncCallParam
- type TaskGetPayload
- type TaskGetReply
- type TaskNotifyPayload
- type TaskParam
- type TaskPayloadParams
- type TaskProgressReportParam
- type TaskProgressReportPayload
- type TaskProgressReportReply
- type TopoChangeParam
- type TopoChangeParamWithSecret
- type TopoChangePayload
- type TopoReplyParam
- type TopologyChangeHandler
- type TopologyOperateType
- type TopologyRequest
- type TopologyRequestWithAuth
- type UpgradeDeviceStatusEnum
- type UpgradeRequestParam
- type UpgradeStepEnum
- type UploadFileParam
- type UploadFilePayload
- type UploadFileProgressPayload
- type UploadFileReport
- type UploadFileStatus
- type UploadFileURL
- type UploadType
- type UploadedPart
- type UserDefineTopicConfig
Constants ¶
const ( LogTypeDevice = "device" LogTypeSDK = "sdk" )
const ( OTADefaultModule = "default" ServiceIDKey = "ServiceID" )
const ( ActionKey = "Action" VersionKey = "Version" UploadFileAction = "UploadFile" DynamicRegisterAction = "DynamicRegister" GetDeviceTokenAction = "GetDeviceToken" DeviceMessagePublishHTTPAction = "DeviceMessagePublishHTTP" )
const ( ActionOnInterruptRetry = "Retry" ActionOnInterruptFail = "Fail" )
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" )
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
const APIVerion = "2021-12-14"
const (
DefaultMQTTPort = 1883
)
const (
IOTHTTPAccessHeaderKey = "X-IoT-AccessToken"
)
const (
InstanceIDFieldKey = "InstanceID"
)
const ServicePropertySet string = "propertySet"
Variables ¶
var ConfigFilePath = "config.yaml"
Functions ¶
func CheckDeviceName ¶
func FormatUniqueFieldName ¶
FormatUniqueFieldName 构建唯一标识的方法 传递moduleKey,identifier
func PKCS5UnPadding ¶
Types ¶
type AccessType ¶
type AccessType string
const ( DeviceAccessTypeHTTP AccessType = "http" DeviceAccessTypeMQTT AccessType = "mqtt" )
type ActionOnInterrupt ¶
type ActionOnInterrupt string
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 CommonRequest ¶
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 CustomTopicHandler ¶
type CustomTopicHandler func(param CustomTopicParam) ErrorCode
type CustomTopicParam ¶
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) DeviceLogf ¶
DeviceLogf 格式化打印设备日志 传递 level 日志级别;format 日志格式化字符串;args 参数
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 ¶
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 ¶
GetTopologies 从平台拉取最新拓扑关系,异步方法,结果在GetTopologiesReplyHandler中处理
func (*Device) Init ¶
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 ¶
IsConnected 判断设备是否连接 连接中返回true,未连接返回false
func (*Device) IsConnectionOpen ¶
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 ¶
SendCustomTopicMessage 发送消息到自定义topic,需要预先在平台创建自定义topic 传递 topicSuffix 自定义topic后缀;payload 消息体;qos 服务质量,0: 最多传递一次,1: 至少传递一次
func (*Device) SendNTPRequest ¶
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 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 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 EventParam ¶
type EventPayload ¶
type EventPayload struct { ID string `json:"ID"` Version string `json:"Version"` Params EventParam `json:"Params"` }
type EventReportParam ¶
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 下载器工厂入口
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 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 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 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 LogReportCommonConfig ¶
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 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 NTPResponseHandler ¶
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 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 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 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 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 ReplyParam ¶
type ReplyParam struct { DeviceIdentification ReplyPayload }
type ReplyPayload ¶
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 ServiceCallPayload ¶
type ShadowDesiredParam ¶
type ShadowDesiredSetPayload ¶
type ShadowDesiredSetPayload struct { CommonRequest Params ShadowDesiredParam `json:"Params"` }
type ShadowGetReplyPayload ¶
type ShadowGetReplyPayload struct { CommonReply Data ShadowDesiredParam `json:"Data"` }
type ShadowReportParam ¶
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 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 TaskGetPayload ¶
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 TaskProgressReportPayload ¶
type TaskProgressReportPayload struct { ID string `json:"ID"` Version string `json:"Version"` Params TaskProgressReportParam `json:"Params"` }
type TaskProgressReportReply ¶
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 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 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" )