【feat】完成tcp,http的设备上报,及模拟设备测试

This commit is contained in:
XM-GO
2023-09-27 15:15:15 +08:00
parent 950e8d8814
commit 9eff841b81
16 changed files with 778 additions and 168 deletions

View File

@@ -6,6 +6,7 @@ import (
"pandax/apps/device/services"
"pandax/iothub/server/emqxserver/protobuf"
"pandax/pkg/global"
"pandax/pkg/tdengine"
"pandax/pkg/tool"
"regexp"
"strings"
@@ -122,3 +123,26 @@ func GetRequestIdFromTopic(reg, topic string) (requestId string) {
}
return ""
}
func CreateConnectionInfo(msgType, protocol, clientID, peerHost string, deviceAuth *tool.DeviceAuth) *DeviceEventInfo {
ts := time.Now().Format("2006-01-02 15:04:05.000")
ci := &tdengine.ConnectInfo{
ClientID: clientID,
DeviceId: deviceAuth.DeviceId,
PeerHost: peerHost,
Protocol: protocol,
Type: msgType,
Ts: ts,
}
v, err := EncodeData(*ci)
if err != nil {
return nil
}
// 添加设备上线记录
return &DeviceEventInfo{
DeviceId: deviceAuth.DeviceId,
DeviceAuth: deviceAuth,
Datas: string(v),
Type: msgType,
}
}