黄学彪
2020-09-18 c7df85937f73fb347ee0b19e9c052d2d00a6df6c
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceCommonLogic.cs
@@ -67,6 +67,8 @@
        {
            var reResult = new ReceiptGatewayResult();
            reResult.listReceiptData = new string[listReceiptTopic.Count];
            reResult.JsonData = new string[listReceiptTopic.Count];
            var myGateway = device.Gateway;
            if (myGateway == null)
            {
@@ -120,6 +122,12 @@
                            return;
                        }
                        reResult.listReceiptData[i] = jobject["Data"].ToString();
                        if (jobject.Property("Time") != null)
                        {
                            //需要移除time这个字段
                            jobject.Remove("Time");
                        }
                        reResult.JsonData[i] = jobject.ToString();
                        receiptCount++;
                    }
                }
@@ -151,7 +159,6 @@
                {
                    //如果只有一个主题,则替换变量
                    reResult.ReceiptData = reResult.listReceiptData[0];
                    reResult.listReceiptData = null;
                }
            }
@@ -166,8 +173,10 @@
        /// <param name="receiptCommand">指定接收命令符</param>
        /// <param name="receiptDataLength">指定接收数据的长度</param>
        /// <param name="waitTime">超时时间(秒)</param>
        /// <param name="listReceiptLength">附加检测数据接收长度,当接收的长度在这列表里面时,代表接收成功(旨在对应新旧设备,透传回复的长度可能不同)</param>
        /// <returns>网关返回的数据</returns>
        public ReceiptGatewayResult SendJobjectDataToGateway2(CommonDevice device, string sendData, string receiptCommand, int receiptDataLength, int waitTime = 5)
        public ReceiptGatewayResult SendJobjectDataToGateway2(CommonDevice device, string sendData, string receiptCommand, int receiptDataLength,
            int waitTime = 5, List<int> listReceiptLength = null)
        {
            var reResult = new ReceiptGatewayResult();
            var myGateway = device.Gateway;
@@ -217,18 +226,36 @@
                    }
                    var responseData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ClientDataPassthroughResponseData>(jobject["Data"].ToString());
                    //长度一致
                    if (responseData.PassData.Length == receiptDataLength)
                    //长度不一致
                    if (responseData.PassData.Length != receiptDataLength)
                    {
                        var command = responseData.PassData[4].ToString()
                        + responseData.PassData[5].ToString()
                        + responseData.PassData[2].ToString()
                        + responseData.PassData[3].ToString();
                        //并且是这个命令
                        if (command == receiptCommand)
                        if (listReceiptLength == null)
                        {
                            reResult.ReceiptData = responseData.PassData;
                            //如果没有附加检测长度,则直接返回
                            return;
                        }
                        if (listReceiptLength.Contains(responseData.PassData.Length) == false)
                        {
                            //如果附加的检测长度里面,还不存在的话,直接返回
                            return;
                        }
                    }
                    var command = responseData.PassData[4].ToString()
                        + responseData.PassData[5].ToString()
                        + responseData.PassData[2].ToString()
                        + responseData.PassData[3].ToString();
                    //并且是这个命令
                    if (command == receiptCommand)
                    {
                        reResult.ReceiptData = responseData.PassData;
                        reResult.JsonData = new string[1];
                        if (jobject.Property("Time") != null)
                        {
                            //需要移除time这个字段
                            jobject.Remove("Time");
                        }
                        reResult.JsonData[0] = jobject.ToString();
                    }
                }
            };