From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码
---
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