|
@@ -193,8 +193,6 @@ func SubScribe(client mqtt.Client) {
|
|
payload.M = realMac
|
|
payload.M = realMac
|
|
marshal, _ := json.Marshal(payload)
|
|
marshal, _ := json.Marshal(payload)
|
|
content = string(marshal)
|
|
content = string(marshal)
|
|
-
|
|
|
|
- //连接成功或连接失败,发送已连接设备列表
|
|
|
|
}
|
|
}
|
|
for i := 0; i < 6; i++ {
|
|
for i := 0; i < 6; i++ {
|
|
topic := "/" + global.Config.EmqConfig.GatewayMac + constant.TopicConnectSub
|
|
topic := "/" + global.Config.EmqConfig.GatewayMac + constant.TopicConnectSub
|
|
@@ -203,15 +201,15 @@ func SubScribe(client mqtt.Client) {
|
|
case constant.PayloadDisConnect:
|
|
case constant.PayloadDisConnect:
|
|
messageMap["msgType"] = constant.MessageTypeDisConnect
|
|
messageMap["msgType"] = constant.MessageTypeDisConnect
|
|
//content = "断开设备连接"
|
|
//content = "断开设备连接"
|
|
- if payload.State == "SUCCESS" && payload.ReasonCode == "62" {
|
|
|
|
- messageMap["msgType"] = constant.MessageTypeConnect
|
|
|
|
- }
|
|
|
|
realMac := transMac(payload.M)
|
|
realMac := transMac(payload.M)
|
|
deviceInfo := global.DeviceMap[realMac]
|
|
deviceInfo := global.DeviceMap[realMac]
|
|
payload.T = deviceInfo.Type
|
|
payload.T = deviceInfo.Type
|
|
payload.M = realMac
|
|
payload.M = realMac
|
|
marshal, _ := json.Marshal(payload)
|
|
marshal, _ := json.Marshal(payload)
|
|
content = string(marshal)
|
|
content = string(marshal)
|
|
|
|
+ if payload.State == "SUCCESS" && payload.ReasonCode == "62" {
|
|
|
|
+ messageMap["msgType"] = constant.MessageTypeConnect
|
|
|
|
+ }
|
|
//断开连接成功或连接失败,发送已连接设备列表
|
|
//断开连接成功或连接失败,发送已连接设备列表
|
|
for i := 0; i < 6; i++ {
|
|
for i := 0; i < 6; i++ {
|
|
topic := "/" + global.Config.EmqConfig.GatewayMac + constant.TopicConnectSub
|
|
topic := "/" + global.Config.EmqConfig.GatewayMac + constant.TopicConnectSub
|
|
@@ -264,6 +262,7 @@ func SubScribe(client mqtt.Client) {
|
|
var receiveData gateway.DeviceDataReceived
|
|
var receiveData gateway.DeviceDataReceived
|
|
receiveData.Mac = realMac
|
|
receiveData.Mac = realMac
|
|
receiveData.Value = payload.D
|
|
receiveData.Value = payload.D
|
|
|
|
+
|
|
if deviceInfo.Type == "0" { //脑电
|
|
if deviceInfo.Type == "0" { //脑电
|
|
messageMap["msgType"] = constant.MessageTypeEEGData
|
|
messageMap["msgType"] = constant.MessageTypeEEGData
|
|
marshal, _ := json.Marshal(receiveData)
|
|
marshal, _ := json.Marshal(receiveData)
|
|
@@ -318,10 +317,10 @@ func SubScribe(client mqtt.Client) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
if sendFlag && content != "成功" && content != "失败" {
|
|
if sendFlag && content != "成功" && content != "失败" {
|
|
- if messageMap["msgType"] == constant.MessageTypeECGData {
|
|
|
|
|
|
+ if messageMap["msgType"] == constant.MessageTypeConnectList {
|
|
|
|
|
|
- fmt.Printf("发送心电数据===" + common.NowTime("2006-01-02 15:04:05") + "=====" + string(bytes))
|
|
|
|
- _ = global.Log4J.Info("发送心电数据===" + common.NowTime("2006-01-02 15:04:05") + "=====" + string(bytes))
|
|
|
|
|
|
+ fmt.Printf("已连接列表===" + common.NowTime("2006-01-02 15:04:05") + "=====" + string(bytes))
|
|
|
|
+ _ = global.Log4J.Info("已连接列表===" + common.NowTime("2006-01-02 15:04:05") + "=====" + string(bytes))
|
|
}
|
|
}
|
|
for k := range messageMap {
|
|
for k := range messageMap {
|
|
delete(messageMap, k)
|
|
delete(messageMap, k)
|