Documentation
¶
Index ¶
- Constants
- Variables
- type AlertLevel
- type AppCallBack
- type AppDriverReq
- type BaseProperty
- type DataType
- type DeviceInfo
- type DeviceMeta
- type DeviceNotifyType
- type DeviceOnlineStatus
- type DeviceStatus
- type ExtendedProperty
- type GatewayInfo
- type Header
- type LoggerConfig
- type MqttDriver
- type Option
- type Options
- type ProductNotifyType
- type ProtocolProperties
- type ProxyInfo
- type RWType
- type Response
- type RunningModel
- type SubDataType
- type TMDeviceInfo
- type TMDeviceMeta
- type TedgeLogger
Constants ¶
const ( // 设备激活状态 未激活、已激活、激活失败 DeviceActiveStatusInactivated = "inactivated" DeviceActiveStatusActivated = "activated" DeviceActiveStatusActiveFail = "activeFail" )
//////////////////////////////////////////////////////////////////////////// device
const ( DEVICE_REPORT_EVENT = "report" DEVICE_ALERT_EVENT = "alert" )
const ( DebugLevel = "DEBUG" InfoLevel = "INFO" WarnLevel = "WARN" ErrorLevel = "ERROR" )
const SDKVersion = "v1.0.0"
Variables ¶
var LogLevelMap = map[string]zapcore.Level{ DebugLevel: zapcore.DebugLevel, InfoLevel: zapcore.InfoLevel, WarnLevel: zapcore.WarnLevel, ErrorLevel: zapcore.ErrorLevel, }
Functions ¶
This section is empty.
Types ¶
type AlertLevel ¶
type AlertLevel int
////////////////////////////////////////////////////////////////////////////
const ( ERROR AlertLevel = iota + 1 WARN NOTIFY )
type AppCallBack ¶ added in v1.0.2
type AppCallBack func(appName string, req AppDriverReq) (Response, error)
type AppDriverReq ¶
func (*AppDriverReq) ToRpc ¶
func (req *AppDriverReq) ToRpc() *proto.Data
type BaseProperty ¶
type BaseProperty struct { Name string `json:"name"` //子设备名 Ip string `json:"ip"` //子设备IP地址 Lat string `json:"lat"` //纬度 Lon string `json:"lon"` //经度 }
BaseProperty 子设备基础属性:子设备名、IP地址、经度、纬度
type DataType ¶
type DataType string
const ( ValueType DataType = "value" // int64 BoolType DataType = "bool" StringType DataType = "string" RawType DataType = "raw" // []byte EnumType DataType = "enum" // string FaultType DataType = "fault" // []string FlotType DataType = "float" DoubleType DataType = "double" DateType DataType = "date" BitmapType DataType = "bitmap" StructType DataType = "struct" ArrayType DataType = "array" )
type DeviceInfo ¶
type DeviceInfo struct { DeviceMeta // 原始信息 ActiveStatus string // 设备激活状态 OnLineStatus string // 设备在线/离线状态 CloudDeviceId string // 设备云端对应的🆔(如果设备已激活) }
DeviceInfo 回调接口, 包含激活信息
type DeviceMeta ¶
type DeviceMeta struct { Cid string `json:"cid"` //子设备cid,网关下唯一 ProductId string `json:"productKey"` //产品id BaseAttr BaseProperty `json:"baseAttr"` //设备属性 ExtendedAttr ExtendedProperty `json:"extendedAttr"` //设备属性 Protocols map[string]ProtocolProperties `json:"protocols"` //设备自定义协议配置 }
DeviceMeta 新增子设备
type DeviceNotifyType ¶
type DeviceNotifyType string
const ( DeviceAddNotify DeviceNotifyType = "add" DeviceUpdateNotify DeviceNotifyType = "update" DeviceDeleteNotify DeviceNotifyType = "delete" DeviceActiveNotify DeviceNotifyType = "active" )
type DeviceOnlineStatus ¶
type DeviceOnlineStatus string
const ( Online DeviceOnlineStatus = "online" Offline DeviceOnlineStatus = "offline" )
type DeviceStatus ¶
DeviceStatus device status 设备状态上报
type ExtendedProperty ¶
type ExtendedProperty struct { //VendorCode string `json:"vendorCode"` //设备厂商 InstallLocation string `json:"installLocation"` //安装地址 ExtendData map[string]interface{} `json:"extendData"` //扩展字段 //map[string]interface{} }
ExtendedProperty 子设备扩展属性
type GatewayInfo ¶
type LoggerConfig ¶
type MqttDriver ¶
type MqttDriver interface { // Auth mqtt设备连接鉴权,broker会将与该驱动相关的mqtt设备连接鉴权信息转发给sdk,sdk会回调该接口,将鉴 // 权信息发送给驱动应用层做校验,鉴权通过返回true,mqtt broker允许连接,否则拒接连接。 // clientId:mqtt设备连接时指定的clientID // username:mqtt设备连接时指定的username // password: mqtt设备连接时指定的password Auth(clientId, username, password string) (bool, error) // Sub mqtt设备订阅topic校验,broker会将与该驱动相关的mqtt设备订阅topic的信息转发给sdk,sdk会回调该接 // 口,将topic校验信息发送给驱动应用层做校验,校验通过返回true,mqtt broker允许订阅,否则拒绝订阅。 // topic:设备要订阅的topic // qos:设备要订阅topic的QoS Sub(clientId, username, topic string, qos byte) (bool, error) // Pub mqtt设备向topic中发布消息前校验,broker会将与该驱动相关的mqtt设备要发布消息的topic的信息转发给 // sdk,sdk会回调该接口,将topic校验信息发送给驱动应用层做校验,校验通过返回true,mqtt broker允许发布 // 消息,否则拒绝发布消息 Pub(clientId, username, topic string, qos byte, retained bool) (bool, error) // UnSub mqtt设备取消订阅通知,mqtt设备取消订阅topic后broker会将取消订阅topic的消息通知给对应的驱动 UnSub(clientId, username string, topics []string) // Connected mqtt设备连接成功通知,mqtt设备连接成功后broker会将连接成功消息通知给对应的驱动 Connected(clientId, username, ip, port string) // Closed mqtt设备断开连接后通知,mqtt设备断开连接后broker会将断开连接信息通知给对应的驱动 Closed(clientId, username string) }
type Options ¶ added in v1.0.2
type Options struct { MqttUsername string MqttDriver MqttDriver ConnHandler mqtt.OnConnectHandler AppService []string AppDataHandler AppCallBack EnableRTS bool }
func DefaultOptions ¶ added in v1.0.2
func DefaultOptions() Options
type ProductNotifyType ¶
type ProductNotifyType string
////////////////////////////////////////////////////////////////////////////
const ( ProductAddNotify ProductNotifyType = "add" ProductUpdateNotify ProductNotifyType = "update" ProductDeleteNotify ProductNotifyType = "delete" )
type ProtocolProperties ¶
type ProtocolProperties map[string]interface{}
ProtocolProperties 子设备的自定义配置,通过config.json配置
type ProxyInfo ¶
////////////////////////////////////////////////////////////////////////////////////
func DefaultProxyInfo ¶
type RWType ¶
type RWType string
////////////////////////////////////////////////////////////////////////////
type RunningModel ¶
type RunningModel string
const ( // DPModel dp模型 DPModel RunningModel = "dp_model" // ThingModel 物模型 ThingModel RunningModel = "thing_model" )
type SubDataType ¶
type SubDataType string
///////////////////////////////////////////////////////////////////////////////////
const ( ValueTypeUint8 SubDataType = "uint8" ValueTypeUint16 SubDataType = "uint16" ValueTypeUint32 SubDataType = "uint32" ValueTypeUint64 SubDataType = "uint64" ValueTypeInt8 SubDataType = "int8" ValueTypeInt16 SubDataType = "int16" ValueTypeInt32 SubDataType = "int32" ValueTypeInt64 SubDataType = "int64" ValueTypeFloat32 SubDataType = "float32" ValueTypeFloat64 SubDataType = "float64" )
type TMDeviceInfo ¶
type TMDeviceInfo struct { TMDeviceMeta `json:",inline"` DeviceId string `json:"deviceId"` // 设备在云端的IotId ActiveStatus string `json:"activeStatus"` // 设备激活状态 OnLineStatus string `json:"onlineStatus"` // 设备在线/离线状态 }
TMDeviceInfo 物模型设备信息
type TMDeviceMeta ¶
type TMDeviceMeta struct { Cid string `json:"cid"` //子设备cid,网关下唯一 ProductId string `json:"productKey"` //产品pid BaseAttr BaseProperty `json:"baseAttr"` //设备属性 ExtendedAttr ExtendedProperty `json:"extendedAttr"` //设备属性 Protocols map[string]ProtocolProperties `json:"protocols"` //设备自定义协议配置 }
TMDeviceMeta 物模型设备添加
type TedgeLogger ¶
type TedgeLogger interface { SetLogLevel(level string) Debugf(template string, args ...interface{}) Infof(template string, args ...interface{}) Warnf(template string, args ...interface{}) Errorf(template string, args ...interface{}) }
func DefaultLogger ¶
func DefaultLogger(logLevel, serviceName string) TedgeLogger
func NewDefaultLogger ¶
func NewDefaultLogger(fileName, logLevel, serviceName string) TedgeLogger