lijian 1 anno fa
parent
commit
dc6bad72f7
2 ha cambiato i file con 11 aggiunte e 8 eliminazioni
  1. 10 7
      services/emqx-agent/emqx-agent.go
  2. 1 1
      services/emqx-agent/sub_dev.go

+ 10 - 7
services/emqx-agent/emqx-agent.go

@@ -1,26 +1,29 @@
 package main
 
-import "sparrow/pkg/protocol"
+import (
+	"fmt"
+	"sparrow/pkg/protocol"
+)
 
 type Agent struct {
 }
 
 // Message 收到设备上报消息处理
 func (a *Agent) Message(topic string, payload []byte) error {
-	//TODO implement me
-	panic("implement me")
+	fmt.Printf("%s, %s\r\n", topic, payload)
+	return nil
 }
 
 // Connected 设备接入时
 func (a *Agent) Connected(status *protocol.DevConnectStatus) error {
-	//TODO implement me
-	panic("implement me")
+	fmt.Printf("%v\r\n", status)
+	return nil
 }
 
 // Disconnected 设备断开连接时
 func (a *Agent) Disconnected(status *protocol.DevConnectStatus) error {
-	//TODO implement me
-	panic("implement me")
+	fmt.Printf("%v\r\n", status)
+	return nil
 }
 
 func NewAgent() *Agent {

+ 1 - 1
services/emqx-agent/sub_dev.go

@@ -152,7 +152,7 @@ func (d *MqttClient) subConnectStatus(handle Handle) func(ctx context.Context, t
 			DeviceCode: msg.Username,
 			DeviceId:   msg.Clientid,
 		}
-		if strings.HasSuffix(topic, "/disconnected") {
+		if strings.HasSuffix(topic, "/connected") {
 			status.Action = "LOGIN"
 			return handle(ctx).Connected(&status)
 		} else {