Documentation
¶
Index ¶
- Constants
- func CreateToken(secretKey string, claims OssJwtToken) (string, error)
- func GenMsgToken(ctx context.Context, nodeID int64) string
- func GetJwtToken(secretKey string, t time.Time, seconds int64, bucket string, dir string) (string, error)
- func IsLikelyText(b []byte) bool
- func PublishToDev(handle string, Type string, payload []byte, protocolCode string, ...) []byte
- func RefreshToken(tokenString string, secretKey string) (string, error)
- type Action
- type Affiliation
- type Auth
- type Core
- type DevConn
- type DevPublish
- type Direction
- type Info
- type InnerPublish
- type MsgHandle
- type OssJwtToken
- type ProductStatus
- type ProtocolKey
- type Tag
- type TopicInfo
- type WithGateway
Constants ¶
View Source
const ( AuthNone = 0 //啥权限没有 AuthNormal = 1 //普通功能权限 AuthSystem = 2 //系统功能权限 AuthAll = 4 //拥有全部权限 )
View Source
const ( DeviceRegisterUnable = 1 DeviceAutoCreateEnable = 3 EncTypeCert = 1 //证书加密 EncTypeKey = 2 //秘钥加密 )
View Source
const ( ProductStatusEnable = 1 //启用 ProductStatusDisEnable = 2 //禁用 ProductStatusDeveloping = 3 //开发中 )
View Source
const ( Sub = "Sub" //订阅 Pub = "Pub" //发布 )
View Source
const ( TopicHeadThing = "$thing" TopicHeadOta = "$ota" TopicHeadConfig = "$config" TopicHeadLog = "$log" TopicHeadShadow = "$shadow" TopicHeadGateway = "$gateway" TopicHeadExt = "$ext" )
Variables ¶
This section is empty.
Functions ¶
func CreateToken ¶
func CreateToken(secretKey string, claims OssJwtToken) (string, error)
CreateToken 创建一个token
func GetJwtToken ¶
Types ¶
type Affiliation ¶
type Affiliation struct {
TenantCode string
ProjectID int64
AreaID int64
AreaIDPath string
BelongGroup map[string]def.IDsInfo
}
归属
type DevConn ¶
type DevConn struct {
UserName string `json:"username"` //选填
Timestamp int64 `json:"timestamp"` //毫秒时间戳
Address string `json:"addr"` //选填
ClientID string `json:"clientID"` //如果填写了下面的产品和设备ID,这个可以不填
/*
https://www.emqx.com/en/blog/emqx-mqtt-broker-connection-troubleshooting
normal:客户端主动断开连接;
kicked:被服务器踢出,通过 REST API;
keepalive_timeout:保持活动超时;
not_authorized:认证失败,或者acl_nomatch=disconnect时,没有权限的Pub/Sub会主动断开客户端连接;
tcp_closed:对端关闭了网络连接;
discard:因为相同ClientID的客户端上线了,并且设置了clean_start=true;
takeovered:因为相同ClientID的客户端上线,并且设置了clean_start=false;
internal_error:格式错误的消息或其他未知错误。
*/
Reason string `json:"reason"`
Action Action `json:"action"` //登录 connected 登出 disconnected
ProductID string `json:"productID"`
DeviceName string `json:"deviceName"`
}
DevConn ddsvr 发布设备 连接和断连 的结构体
type DevPublish ¶
type DevPublish struct {
Topic string `json:"topic"` //只用于日志记录
Handle MsgHandle `json:"handle"` //对应 mqtt topic的第一个 thing ota config 等等
Type string `json:"type"` //操作类型 从topic中提取 物模型下就是 property属性 event事件 action行为
Payload []byte `json:"payload"`
Timestamp int64 `json:"timestamp"` //毫秒时间戳
ProductID string `json:"productID"`
DeviceName string `json:"deviceName"`
Explain string `json:"explain"` //内部使用的拓展字段
ProtocolCode string `json:"protocolCode"` //如果有该字段则回复的时候也会带上该字段
}
DevPublish ddsvr 发布设备 发布信息 的结构体
func (*DevPublish) GetPayload ¶ added in v1.4.1
func (p *DevPublish) GetPayload() string
func (*DevPublish) String ¶
func (p *DevPublish) String() string
type OssJwtToken ¶
type OssJwtToken struct {
Bucket string //oss的token
Dir string //对象路径
jwt.RegisteredClaims
}
OssJwtToken Custom claims structure
func ParseToken ¶
func ParseToken(tokenString string, secretKey string) (*OssJwtToken, error)
解析 token
type ProductStatus ¶
type ProductStatus = int64
type ProtocolKey ¶
type ProtocolKey = string
const (
ProtocolKeyProductID ProtocolKey = "productID"
)
type TopicInfo ¶
type TopicInfo struct {
ProductID string
DeviceName string
Direction Direction
Types []string
TopicHead string
}
func GetTopicInfo ¶
type WithGateway ¶
Click to show internal directories.
Click to hide internal directories.