From 6cdac03ef4f4bba8a73de78500a86fc206c4f53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=B7=E8=8D=89=60?= Date: Wed, 15 Feb 2023 08:42:29 +0800 Subject: [PATCH] fix: IotSharp RPC response topic error. (#38) --- Plugins/Plugin/DeviceThread.cs | 2 +- Plugins/Plugin/MyMqttClient.cs | 2 +- Plugins/PluginInterface/RpcResponse.cs | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Plugin/DeviceThread.cs b/Plugins/Plugin/DeviceThread.cs index b0d15269..44b6b7f1 100644 --- a/Plugins/Plugin/DeviceThread.cs +++ b/Plugins/Plugin/DeviceThread.cs @@ -209,7 +209,7 @@ public void MyMqttClient_OnExcRpc(object? sender, RpcRequest e) _logger.LogInformation($"{Device.DeviceName}收到RPC,{e}"); RpcResponse rpcResponse = new() - { DeviceName = e.DeviceName, RequestId = e.RequestId, IsSuccess = false }; + { DeviceName = e.DeviceName, RequestId = e.RequestId, IsSuccess = false, Method = e.Method}; //执行写入变量RPC if (e.Method.ToLower() == "write") { diff --git a/Plugins/Plugin/MyMqttClient.cs b/Plugins/Plugin/MyMqttClient.cs index c16cec18..9000a7da 100644 --- a/Plugins/Plugin/MyMqttClient.cs +++ b/Plugins/Plugin/MyMqttClient.cs @@ -390,7 +390,7 @@ public async Task ResponseRpcAsync(RpcResponse rpcResponse) await ResponseIsRpcAsync(new ISRpcResponse { DeviceId = rpcResponse.DeviceName, - Method = "Method", + Method = rpcResponse.Method, ResponseId = rpcResponse.RequestId, Data = JsonConvert.SerializeObject(new Dictionary { diff --git a/Plugins/PluginInterface/RpcResponse.cs b/Plugins/PluginInterface/RpcResponse.cs index c508c686..f210867b 100644 --- a/Plugins/PluginInterface/RpcResponse.cs +++ b/Plugins/PluginInterface/RpcResponse.cs @@ -9,6 +9,7 @@ namespace PluginInterface public class RpcResponse { public string RequestId { get; set; } + public string Method { get; set; } public string DeviceName { get; set; } public bool IsSuccess { get; set; } public string Description { get; set; }