mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[feat]网关子设备,直接上传,自动创建设备模型,无需手动创建
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
package mqttclient
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"math/rand"
|
||||
"pandax/pkg/global_model"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -48,7 +46,7 @@ func (rpc RpcRequest) RequestCmd(rpcPayload string) (respPayload string, err err
|
||||
}
|
||||
rpc.Client.Sub(respTopic, 0, mqMessagePubHandler)
|
||||
if rpc.Timeout == 0 {
|
||||
rpc.Timeout = 30
|
||||
rpc.Timeout = 20
|
||||
}
|
||||
defer func() {
|
||||
close(repsChan)
|
||||
@@ -64,19 +62,6 @@ func (rpc RpcRequest) RequestCmd(rpcPayload string) (respPayload string, err err
|
||||
}
|
||||
}
|
||||
|
||||
// RequestAttributes rpc 下发属性
|
||||
func (rpc RpcRequest) RequestAttributes(rpcPayload global_model.RpcPayload) error {
|
||||
topic := fmt.Sprintf(RpcReqTopic, rpc.RequestId)
|
||||
if rpcPayload.Method == "" {
|
||||
rpcPayload.Method = "setAttributes"
|
||||
}
|
||||
payload, err := json.Marshal(rpcPayload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return rpc.Client.Pub(topic, 0, string(payload))
|
||||
}
|
||||
|
||||
func (rpc RpcRequest) Pub(reqPayload string) error {
|
||||
topic := fmt.Sprintf(RpcRespTopic, rpc.RequestId)
|
||||
return rpc.Client.Pub(topic, 0, reqPayload)
|
||||
|
||||
Reference in New Issue
Block a user