mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-05-07 04:21:25 +08:00
【feat】添加http设备接入,优化iothub结构
This commit is contained in:
48
iothub/server/emqxserver/topic.go
Normal file
48
iothub/server/emqxserver/topic.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package emqxserver
|
||||
|
||||
import (
|
||||
"pandax/pkg/rule_engine/message"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
// Topic 上行
|
||||
RowTopic = `v1/devices/me/row`
|
||||
TelemetryTopic = `v1/devices/me/telemetry`
|
||||
AttributesTopic = `v1/devices/me/attributes`
|
||||
|
||||
//网关子设备
|
||||
AttributesGatewayTopic = "v1/gateway/attributes"
|
||||
TelemetryGatewayTopic = "v1/gateway/telemetry"
|
||||
ConnectGatewayTopic = "v1/gateway/connect"
|
||||
DisconnectGatewayTopic = "v1/gateway/disconnect"
|
||||
|
||||
RpcReqReg = `v1/devices/me/rpc/request/(.*?)$`
|
||||
)
|
||||
|
||||
var IotHubTopic = NewIotHubTopic()
|
||||
|
||||
type TopicMeg map[string]string
|
||||
|
||||
// 消息的来源类型
|
||||
func NewIotHubTopic() TopicMeg {
|
||||
return map[string]string{
|
||||
AttributesTopic: message.AttributesMes,
|
||||
RowTopic: message.RowMes,
|
||||
TelemetryTopic: message.TelemetryMes,
|
||||
AttributesGatewayTopic: message.GATEWAY,
|
||||
TelemetryGatewayTopic: message.GATEWAY,
|
||||
ConnectGatewayTopic: message.GATEWAY,
|
||||
DisconnectGatewayTopic: message.GATEWAY,
|
||||
}
|
||||
}
|
||||
|
||||
func (iht TopicMeg) GetMessageType(topic string) string {
|
||||
if meg, ok := iht[topic]; ok {
|
||||
return meg
|
||||
}
|
||||
if strings.Contains(topic, "v1/devices/me/rpc/request") {
|
||||
return message.RpcRequestMes
|
||||
}
|
||||
return ""
|
||||
}
|
||||
Reference in New Issue
Block a user