mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
【fix】修复设置属性,指令下发,单双向
This commit is contained in:
@@ -14,6 +14,11 @@ const (
|
||||
RpcReqTopic = `v1/devices/me/rpc/request/%d`
|
||||
)
|
||||
|
||||
const (
|
||||
SingleMode = "single"
|
||||
DoubleMode = "double"
|
||||
)
|
||||
|
||||
type RpcRequest struct {
|
||||
Client *IothubMqttClient
|
||||
RequestId int
|
||||
@@ -37,7 +42,7 @@ func (rpc RpcRequest) RequestCmd(rpcPayload RpcPayload) (respPayload string, err
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if rpc.Mode == "single" {
|
||||
if rpc.Mode == "" || rpc.Mode == SingleMode {
|
||||
return "", nil
|
||||
}
|
||||
// 双向才会执行
|
||||
@@ -80,11 +85,6 @@ func (rpc RpcRequest) RequestAttributes(rpcPayload RpcPayload) error {
|
||||
return rpc.Client.Pub(topic, 0, string(payload))
|
||||
}
|
||||
|
||||
// 响应数据处理
|
||||
/*var mqMessagePubHandler mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {
|
||||
//log.Println(fmt.Sprintf("Received message: %s from topic: %s\n", msg.Payload(), msg.Topic()))
|
||||
}*/
|
||||
|
||||
// RespondTpc 处理设备端请求服务端方法
|
||||
func (rpc RpcRequest) RespondTpc(reqPayload RpcPayload) error {
|
||||
topic := fmt.Sprintf(RpcRespTopic, rpc.RequestId)
|
||||
|
||||
Reference in New Issue
Block a user