devices

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeviceRegisterUnable   = 1
	DeviceAutoCreateEnable = 3
	EncryptionTypeCert     = 1
)
View Source
const (
	Sub = "Sub" //订阅
	Pub = "Pub" //发布
)
View Source
const (
	TopicHeadThing   = "$thing"
	Thing            = "thing"
	TopicHeadOta     = "$ota"
	Ota              = "ota"
	TopicHeadConfig  = "$config"
	Config           = "config"
	TopicHeadLog     = "$log"
	Log              = "log"
	TopicHeadShadow  = "$shadow"
	Shadow           = "shadow"
	TopicHeadGateway = "$gateway"
	Gateway          = "gateway"
	TopicHeadExt     = "$ext"
	Ext              = "ext"
)

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(secretKey string, claims OssJwtToken) (string, error)

CreateToken 创建一个token

func GetJwtToken

func GetJwtToken(secretKey string, iat, seconds int64, bucket string, dir string) (string, error)

func PublishToDev

func PublishToDev(handle string, Type string, payload []byte, productID string, deviceName string) []byte

发送给设备的数据组包

func RefreshToken

func RefreshToken(tokenString string, secretKey string) (string, error)

更新token

Types

type Core added in v0.3.0

type Core struct {
	ProductID  string `json:"productID"`  //产品id
	DeviceName string `json:"deviceName"` //设备名称
}

type DevConn

type DevConn struct {
	UserName  string `json:"username"`
	Timestamp int64  `json:"timestamp"` //毫秒时间戳
	Address   string `json:"addr"`
	ClientID  string `json:"clientID"`
	Reason    string `json:"reason"`
	Action    string `json:"action"` //登录 onLogin 登出 onLogout
}

DevConn ddsvr 发布设备 连接和断连 的结构体

type DevPublish

type DevPublish struct {
	Topic      string `json:"topic"` //只用于日志记录
	Timestamp  int64  `json:"timestamp"`
	ProductID  string `json:"productID"`
	DeviceName string `json:"deviceName"`
	Handle     string `json:"handle"` //对应 mqtt topic的第一个 thing ota config 等等
	Type       string `json:"type"`   //操作类型 从topic中提取 物模型下就是   property属性 event事件 action行为
	Payload    []byte `json:"payload"`
}

DevPublish ddsvr 发布设备 发布信息 的结构体

type Direction

type Direction int

设备通信流向

const (
	Unknown Direction = iota //设备通信流向:未知
	Up                       //设备通信流向:上行
	Down                     //设备通信流向:下行
)

type InnerPublish

type InnerPublish struct {
	Handle     string `json:"handle"` //对应 mqtt topic的第一个 thing ota config 等等
	Type       string `json:"type"`   // 操作类型 从topic中提取 物模型下就是   property属性 event事件 action行为
	Payload    []byte `json:"payload"`
	ProductID  string `json:"productID"`
	DeviceName string `json:"deviceName"`
}

InnerPublish 用于其他服务 发送给ddsvr 转发给设备的

func GetPublish

func GetPublish(data []byte) *InnerPublish

收到发送给设备的数据,解包

type OssJwtToken

type OssJwtToken struct {
	Bucket string //oss的token
	Dir    string //对象路径
	jwt.StandardClaims
}

OssJwtToken Custom claims structure

func ParseToken

func ParseToken(tokenString string, secretKey string) (*OssJwtToken, error)

解析 token

type Tag added in v0.5.1

type Tag struct {
	Key   string `json:"key"`   //设备标签key
	Value string `json:"value"` //设备标签value
}

设备标签

type TopicInfo

type TopicInfo struct {
	ProductID  string
	DeviceName string
	Direction  Direction
	Types      []string
	TopicHead  string
}

func GetTopicInfo

func GetTopicInfo(topic string) (topicInfo *TopicInfo, err error)

Jump to

Keyboard shortcuts

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