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/Device/DeviceMacInfoEditorForm.cs |  136 ++++++++++++++++++++++++++++++++------------
 1 files changed, 98 insertions(+), 38 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs
old mode 100755
new mode 100644
index 402b3a6..20b9eea
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs
@@ -227,7 +227,7 @@
                     }
                 }
                 //淇濆瓨璁惧鎴块棿绱㈠紩
-                Common.LocalDevice.Current.SaveRealDeviceRoomId(this.listNewDevice, roomKeys);
+                HdlRoomLogic.Current.SaveRealDeviceRoomId(this.listNewDevice, roomKeys);
             };
 
             //娣诲姞鍏ㄩ儴鑿滃崟
@@ -462,7 +462,13 @@
                 //搴曠嚎
                 btnRow.AddBottomLine();
 
-                var doorLock = (ZigBee.Device.DoorLock)listNewDevice[0];
+                var doorLock = (ZigBee.Device.DoorLock)listNewDevice[0];
+                ///鍊间负绌哄啀鍘昏鍙栨湰鍦�
+                if (string.IsNullOrEmpty(doorLock.RemoteUnlockPassword))
+                {
+                    ///璇诲彇鏈湴杩滅▼寮�閿佸瘑鐮侊紝鐪嬬湅涔嬪墠鏄惁閰嶇疆杩�
+                    doorLock.RemoteUnlockPassword = ReadLocalPassword();
+                }
                 if (string.IsNullOrEmpty(doorLock.RemoteUnlockPassword) == false)
                 {
                     btnswitch.IsSelected = true;
@@ -518,7 +524,24 @@
                  };
             }
         }
-
+        /// <summary>
+        /// 淇濆瓨杩滅▼闂ㄩ攣瀵嗙爜
+        /// </summary>
+        /// <param name="password">瀵嗙爜</param>
+        public void SaveLocalPassword(string password) {
+            var bytes = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(password));
+            IO.FileUtils.WriteFileByBytes(Config.Instance.HomeId + "_" + Config.Instance.Guid, bytes);
+        }
+        /// <summary>
+        /// 璇诲彇杩滅▼闂ㄩ攣瀵嗙爜
+        /// </summary>
+        /// <returns></returns>
+        public string ReadLocalPassword()
+        {
+            var str = System.Text.Encoding.UTF8.GetString(IO.FileUtils.ReadFile(Config.Instance.HomeId + "_" + Config.Instance.Guid));
+            //Newtonsoft.Json.JsonConvert.DeserializeObject<瀵瑰儚>(str);
+            return str;
+        }
         #endregion
 
         #region 鈻� 闂ㄩ攣鏃堕棿(闂ㄩ攣)_____________________
@@ -784,8 +807,30 @@
             //鍙湁鍥炶矾鏁板ぇ浜�1鎵嶈兘鏈夎繖涓彍鍗�
             if (Common.LocalDevice.Current.GetDevicesCountByMac(listNewDevice[0].DeviceAddr) == 1)
             {
-                //鏂伴灏忔ā鍧楀彧鏈変竴涓洖璺紝浣嗚姹傛柊椋庡皬妯″潡鐨勬柊椋庢湁鍔熻兘璁剧疆
-                if (deviceEnumInfo.ConcreteType != DeviceConcreteType.Relay_FangyueFreshAirModul)
+                //绌烘皵璐ㄩ噺浼犳劅鍣ㄥ拰鏂伴灏忔ā鍧楀彧鏈変竴涓洖璺紝浣嗚姹傛柊椋庡皬妯″潡鐨勬柊椋庢湁鍔熻兘璁剧疆
+                //鏅捐。鏋堕粯璁ゅ彧瀛樺偍绗竴鍥炶矾锛屽叾浠栧洖璺杩囨护浜�
+                bool isSpecial = false;
+                if (deviceEnumInfo.ConcreteType == DeviceConcreteType.Relay_FangyueFreshAirModul ||
+                    deviceEnumInfo.ConcreteType == DeviceConcreteType.AirQualitySensor)
+                {
+                    isSpecial = true;
+                }
+                if (deviceEnumInfo.ConcreteType == DeviceConcreteType.Airer)
+                {
+                    isSpecial = true;
+                    var dev = listNewDevice[0];
+                    //鏅捐。鏋堕粯璁ゅ彧瀛樺偍绗竴鍥炶矾锛屽叾浠栧洖璺湪鍔熻兘鐣岄潰闇�瑕佽鍙栨椂闂达紝鎵�浠ユ彁鍓嶄竴涓晫闈㈣幏鍙�
+                    //绗竴鐗堟椂闂村姛鑳界敱浜庤澶囦笉鏀寔锛屾殏鏃跺幓鎺夛紝鍚庢湡鎵嶅姞涓�
+                    //for (int i = 3; i < 6; i++)
+                    //{
+                    //  //娉ㄦ剰锛岃。鏋朵腑鐨勭姸鎬佺敱涓嶅悓绔偣鑾峰彇
+                    //  //鍥炶矾3:璇诲彇椋庡共寮�鍏崇姸鎬佸拰鏃堕棿鍊� 
+                    //  //鍥炶矾4:璇诲彇鐑樺共寮�鍏崇姸鎬佸拰鏃堕棿鍊�
+                    //  //鍥炶矾5:璇诲彇娑堟瘨寮�鍏崇姸鎬佸拰鏃堕棿鍊�
+                    //  HdlDeviceAttributeLogic.Current.SendAirerComand(dev, i);
+                    //}
+                }
+                if (!isSpecial)
                 {
                     return;
                 }
@@ -831,14 +876,19 @@
                     var form = new DevicePanel.PanelFangyueFunctionSettionForm();
                     form.AddForm(listNewDevice[0], deviceEnumInfo);
                 }
-                //绠�绾︾幆澧冮潰鏉跨殑鎸夐敭閰嶇疆
+                //绠�绾﹀鍔熻兘闈㈡澘鐨勬寜閿厤缃�
                 else if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
                 {
-                    var form = new DeviceFunctionSettionForm();
-                    if (listNewDevice.Count > 62)
+                    foreach (var dev in listNewDevice)
                     {
-                        form.AddForm(listNewDevice[62], true);
+                        if (dev.Type == DeviceType.OnOffOutput && dev.DeviceEpoint == 62)
+                        {
+                            var form = new DeviceFunctionSettionForm();
+                            form.AddForm(dev, true);
+                            break;
+                        }
                     }
+
                 }
                 //娌充笢鐨勯潰鏉胯澶�
                 else if (deviceEnumInfo.BeloneType == DeviceBeloneType.A鎸夐敭闈㈡澘 && deviceEnumInfo.IsHdlDevice == true)
@@ -1174,6 +1224,7 @@
                         if (string.IsNullOrEmpty(bindName))
                         {
                             btnHumidityStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing);
+                            bindHumidityDev = null;
                         }
                         else
                         {
@@ -1225,6 +1276,7 @@
                         if (string.IsNullOrEmpty(bindName))
                         {
                             btnTemperatureStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing);
+                            bindTemperatureDev = null;
                         }
                         else
                         {
@@ -1308,47 +1360,54 @@
                     {
                         continue;
                     }
+                    //鑾峰彇璁惧绫诲瀷鐨�
+                    var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                     if (device.Type == DeviceType.TemperatureSensor)
                     {
                         var bD = device as TemperatureSensor;
                         if (bD.SensorDiv == 1 && bDev.BindCluster == 1026)
                         {
-                            if (string.IsNullOrEmpty(bDev.ESName))
-                            {
-                                bindTemperatureName = Common.LocalDevice.Current.GetDeviceEpointName(device);
-                            }
-                            else
-                            {
-                                bindTemperatureName = bDev.ESName;
-                            }
+                            bindTemperatureName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                             bindTemperatureDev = device;
                         }
                         if (bD.SensorDiv == 2 && bDev.BindCluster == 1029)
                         {
-                            if (string.IsNullOrEmpty(bDev.ESName))
-                            {
-                                bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device);
-                            }
-                            else
-                            {
-                                bindHumidityName = bDev.ESName;
-                            }
-
+                            bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                             bindHumidityDev = device;
+                        }
+
+                        //绌烘皵璐ㄩ噺浼犳劅鍣�
+                        if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.AirQualitySensor)
+                        {
+                            if (bDev.BindCluster == 1026)
+                            {
+                                bindTemperatureName = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
+                                bindTemperatureDev = device;
+                            }
+                            if (bDev.BindCluster == 1029)
+                            {
+                                bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
+                                bindHumidityDev = device;
+                            }
                         }
                     }
                     if (device.Type == DeviceType.FreshAirHumiditySensor)
                     {
-                        if (string.IsNullOrEmpty(bDev.ESName))
-                        {
-                            bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device);
-                        }
-                        else
-                        {
-                            bindHumidityName = bDev.ESName;
-                        }
-
+                        bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                         bindHumidityDev = device;
+                    }
+                    else if (device.Type == DeviceType.PMSensor)
+                    {
+                        if (bDev.BindCluster == 1026)
+                        {
+                            bindTemperatureName = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
+                            bindTemperatureDev = device;
+                        }
+                        if (bDev.BindCluster == 1029)
+                        {
+                            bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
+                            bindHumidityDev = device;
+                        }
                     }
                 }
                 result = true;
@@ -1377,7 +1436,8 @@
                     { 
                         return;
                     }
-                } catch (Exception ex)
+                }
+                catch (Exception ex)
                 {
                     var mess = ex.Message;
                 }
@@ -1598,7 +1658,7 @@
                         }
                     }, ShowErrorMode.NO);
                 }
-            });
+            }, ShowErrorMode.NO);
         }
 
         #endregion
@@ -1683,7 +1743,7 @@
                 frame.AddRowMenu(deviceMenu, "Item/FixedPosition.png", "Item/FixedPositionSelected.png", () =>
                 {
                     //鍙戦�佸畾浣嶅姛鑳�
-                    Common.LocalDevice.Current.SetFixedPositionCommand(listNewDevice[0]);
+                    Common.LocalDevice.Current.SetFixedPositionCommand(listNewDevice[0], true);
                 });
             }
 

--
Gitblit v1.8.0