From 351bdda734832d821a9764b0cde8be5d83c4ec50 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 01 十二月 2022 09:56:25 +0800
Subject: [PATCH] 2022年12月01日09:56:23

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs |   72 ++++++++++++++++++++++++++++++-----
 1 files changed, 61 insertions(+), 11 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs
index f263cf4..facd31c 100644
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayReceiveLogic.cs
@@ -252,11 +252,14 @@
             }
 
             var tempList = Common.LocalDevice.Current.GetDevicesByMac(report.DeviceAddr, false);
-            var res = Common.LocalDevice.Current.GetMyDeviceEnumInfo(tempList);
-            if (res.ConcreteType == Common.DeviceConcreteType.Airer)
+            if (tempList.Count > 0)
             {
-                //鏅捐。鏋剁壒娈婂鐞嗭紝鏈湴鍙瓨浜嗙鐐�1锛屽叾浣�2锝�5绔偣閮戒笉瀛�
-                deviceEpoint = 1;
+                var res = Common.LocalDevice.Current.GetMyDeviceEnumInfo(tempList);
+                if (res.ConcreteType == Common.DeviceConcreteType.Airer)
+                {
+                    //鏅捐。鏋剁壒娈婂鐞嗭紝鏈湴鍙瓨浜嗙鐐�1锛屽叾浣�2锝�5绔偣閮戒笉瀛�
+                    deviceEpoint = 1;
+                }
             }
             //澶勭悊缃戝叧涓婃姤鐨勬暟鎹�,鐒跺悗鍙樻洿鏈湴缂撳瓨
             var locadevice = Common.LocalDevice.Current.GetDevice(deviceAddr, deviceEpoint);
@@ -358,6 +361,20 @@
                             ((LightBase)locadevice).OnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData;
                             //宸茬粡鎺ユ敹鍒扮姸鎬�
                             locadevice.HadReadDeviceStatu = true;
+                        }
+
+                        if (locadevice is TemperatureSensor)
+                        {
+                            //鑾峰彇璁惧绫诲瀷
+                            var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { locadevice });
+                            //绌烘皵璐ㄩ噺浼犳劅鍣�
+                            if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.AirQualitySensor)
+                            {
+                                locadevice.DeviceStatusReport = report.DeviceStatusReport;
+                                ((TemperatureSensor)locadevice).OnOffStatus = report.DeviceStatusReport.AttriBute[0].AttriButeData;
+                                //宸茬粡鎺ユ敹鍒扮姸鎬�
+                                locadevice.HadReadDeviceStatu = true;
+                            }
                         }
                     }
                 }
@@ -628,7 +645,7 @@
                                 //灏忔暟鐐归渶瑕佷竴浣�
                                 string strValue = Convert.ToInt16(receiptData, 16).ToString();
                                 strValue = strValue.Substring(0, strValue.Length - 1);
-                                temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+                                temperatrue = strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                             }
                             //鏃犵鍙�(涓嶄細鍑虹幇璐熸暟)
                             else if (attData.AttriButeDataType == 32 || attData.AttriButeDataType == 33)
@@ -640,14 +657,14 @@
                                     string strValue = (shortData - 65536).ToString();
                                     //灏忔暟鐐归渶瑕佷竴浣�
                                     strValue = strValue.Substring(0, strValue.Length - 1);
-                                    temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+                                    temperatrue = strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                 }
                                 else
                                 {
                                     //灏忔暟鐐归渶瑕佷竴浣�
                                     string strValue = shortData.ToString();
                                     strValue = strValue.Substring(0, strValue.Length - 1);
-                                    temperatrue = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+                                    temperatrue = strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                                 }
                             }
 
@@ -692,7 +709,7 @@
                                 //灏忔暟鐐归渶瑕佷竴浣�
                                 string strValue = Convert.ToInt16(receiptData, 16).ToString();
                                 strValue = strValue.Substring(0, strValue.Length - 1);
-                                humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+                                humidity = strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                             }
                             //鏃犵鍙�(涓嶄細鍑虹幇璐熸暟)
                             else if (attData.AttriButeDataType == 32 || attData.AttriButeDataType == 33)
@@ -700,7 +717,7 @@
                                 //灏忔暟鐐归渶瑕佷竴浣� 婀垮害涓嶄細鍑虹幇璐熸暟
                                 string strValue = Convert.ToUInt16(receiptData, 16).ToString();
                                 strValue = strValue.Substring(0, strValue.Length - 1);
-                                humidity = Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
+                                humidity = strValue == string.Empty ? 0m : Convert.ToDecimal(strValue.Insert(strValue.Length - 1, "."));
                             }
                             //婀垮害浼犳劅鍣�
                             if (locadevice is TemperatureSensor)
@@ -735,10 +752,19 @@
                         //PM2.5
                         if (attData.AttributeId == (int)AttriButeId.MeasuredValue)
                         {
-
                             if (attData.AttriButeDataType == 57)
                             {
-                                ((PMSensor)locadevice).currentPmData = attData.AttriButeData;
+                                //鑾峰彇璁惧绫诲瀷
+                                var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { locadevice });
+                                //绌烘皵璐ㄩ噺浼犳劅鍣�
+                                if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.AirQualitySensor)
+                                {
+                                    ((TemperatureSensor)locadevice).currentPmData = attData.AttriButeData;
+                                }
+                                else
+                                {
+                                    ((PMSensor)locadevice).currentPmData = attData.AttriButeData;
+                                }
                             }
                         }
                         //宸茬粡鎺ユ敹鍒扮姸鎬�
@@ -748,6 +774,30 @@
 
                 #endregion
 
+                #region 鈻� CO2鏁版嵁
+                else if (report.DeviceStatusReport.CluterID == 1037)
+                {
+                    foreach (var attData in report.DeviceStatusReport.AttriBute)
+                    {
+                        if (attData.AttributeId == (int)AttriButeId.MeasuredValue)
+                        {
+                            if (attData.AttriButeDataType == 57)
+                            {
+                                //鑾峰彇璁惧绫诲瀷
+                                var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { locadevice });
+                                //绌烘皵璐ㄩ噺浼犳劅鍣�
+                                if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.AirQualitySensor)
+                                {
+                                    ((TemperatureSensor)locadevice).currentCO2 = attData.AttriButeData;
+                                }
+                            }
+                        }
+                        //宸茬粡鎺ユ敹鍒扮姸鎬�
+                        locadevice.HadReadDeviceStatu = true;
+                    }
+                }
+                #endregion
+
                 #region 鈻� 璁惧鍩虹淇℃伅
 
                 else if (report.DeviceStatusReport.CluterID == 0)

--
Gitblit v1.8.0