JLChen
2020-02-28 9137222ece9b978eb97b5598f2eee6e070bcf9d6
Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs
@@ -279,7 +279,14 @@
                                    hadBeUpdate = false;
                                (common as LightDimming).CurrentBrightness = usefullBytes [2];
                            } else if (common.Type == DeviceType.FanModule) {
                                //if ((common as FanModule).Switch == usefullBytes [2]) {
                                //    hadBeUpdate = false;
                                //}
                                (common as FanModule).Switch = usefullBytes [2];
                                if (usefullBytes [2] != 0)
                                    (common as FanModule).WindSpeed = usefullBytes [2];
                                //(common as FanModule).Switch = usefullBytes [2];
                            } else if (common.Type == DeviceType.LightMixSwitch) {
                                if ((common as LightMixSwitch).CurrentBrightness == usefullBytes [2])
                                    hadBeUpdate = false;
@@ -350,7 +357,7 @@
                                int dddd = usefullBytes [0] & 0x3F;
                            int dddd = usefullBytes [0] & 0x3F;
                            // 0xXX:公司内部协议对应的序号
                            // common.Type:对应的是编辑软件的序号(没有一一对应,是为了将相近的调整在一起,方便客户使用)
@@ -966,7 +973,56 @@
                        //});
                        #endregion
                        break;
                    case DeviceType.OnePortMqttFR:
                        #region
                        OnePortMqttFR onePortMqttFR = new OnePortMqttFR ();
                        string mqttFRPath = "Equipment_" + typeof (OnePortMqttFR).Name + "_" + subnetID + "_" + deviceID;
                        var bytesmqttFR = IO.FileUtils.ReadFile (mqttFRPath);
                        if (bytesmqttFR.Length > 1) {
                            onePortMqttFR = Newtonsoft.Json.JsonConvert.DeserializeObject<OnePortMqttFR> (MyEncodingUTF8.GetString (bytesmqttFR));
                        }
                        onePortMqttFR.SubnetID = subnetID;
                        onePortMqttFR.DeviceID = deviceID;
                        onePortMqttFR.ChNumberCount = usefullBytes [4];
                        onePortMqttFR.MAC = byteToHex16 (usefullBytes [5]) + "." + byteToHex16 (usefullBytes [6]) + "." + byteToHex16 (usefullBytes [7]) + "." + byteToHex16 (usefullBytes [8]) + "." + byteToHex16 (usefullBytes [9]) + "." + byteToHex16 (usefullBytes [10]) + "." + byteToHex16 (usefullBytes [11]) + "." + byteToHex16 (usefullBytes [12]);
                        onePortMqttFR.Name = MyEncodingGB2312.GetString (usefullBytes, 13, 20).Trim ('\0');//=============
                        onePortMqttFR.IPAddress = usefullBytes [33] + "." + usefullBytes [34] + "." + usefullBytes [35] + "." + usefullBytes [36];
                        onePortMqttFR.RouteIPAddress = usefullBytes [37] + "." + usefullBytes [38] + "." + usefullBytes [39] + "." + usefullBytes [40];
                        onePortMqttFR.IPMAC = usefullBytes [41] + "." + usefullBytes [42] + "." + usefullBytes [43] + "." + usefullBytes [44] + "." + usefullBytes [45] + "." + usefullBytes [46];
                        onePortMqttFR.SubnetMask = usefullBytes [47] + "." + usefullBytes [48] + "." + usefullBytes [49] + "." + usefullBytes [50];
                        onePortMqttFR.DHCP = usefullBytes [51] == 0 ? false : true;
                        if (usefullBytes.Length == 97) {
                            onePortMqttFR.AESEnable = usefullBytes [53] == 0 ? false : true;
                            onePortMqttFR.AESPassword = MyEncodingGB2312.GetString (usefullBytes, 54, 16).Trim ('\0');
                            onePortMqttFR.DNSEnable = usefullBytes [70] == 0 ? false : true;
                            onePortMqttFR.DNSAddress = usefullBytes [71] + "." + usefullBytes [72] + "." + usefullBytes [73] + "." + usefullBytes [74];
                            onePortMqttFR.DNSAlternateAddress = usefullBytes [75] + "." + usefullBytes [76] + "." + usefullBytes [77] + "." + usefullBytes [78];
                            onePortMqttFR.WirelessBand = usefullBytes [79];
                            onePortMqttFR.WirelessChannel = usefullBytes [80];
                            onePortMqttFR.WirelessPassword = MyEncodingGB2312.GetString (usefullBytes, 81, 16).Trim ('\0');
                        }
                        GateWayList.Add (onePortMqttFR);
                        if (onePortMqttFR.Name == "") {
                            onePortMqttFR.Name = onePortMqttFR.CommonLoopID.ToString ();
                        }
                        Application.RunOnMainThread (() => {
                            GuideAddGateway.InitGatewayRowView (onePortMqttFR);
                        });
                        //IO.FileUtils.SaveEquipmentMessage (onePortWirelessFR);
                        //System.Threading.Tasks.Task.Run (() => {
                        //    if (string.IsNullOrEmpty (UserConfig.Current.RemoteModeFile)) {
                        //        var gatewayBytes = Control.ControlBytesSendHasReturn (Command.ReadGateWayModelInfo, onePortWirelessFR.SubnetID, onePortWirelessFR.DeviceID, new byte [] { });
                        //        if (gatewayBytes!=null&&gatewayBytes [0] == 2) {
                        //            UserConfig.Current.RemoteModeFile = "Equipment_" + onePortWirelessFR.Type.ToString () + "_" + onePortWirelessFR.SubnetID.ToString () + "_" + onePortWirelessFR.DeviceID.ToString ();
                        //            UserConfig.Current.SaveUserConfig ();
                        //        }
                        //    }
                        //});
                        #endregion
                        break;
                    case DeviceType.OnePortWirelessFR:
                        #region
                        OnePortWirelessFR onePortWirelessFR = new OnePortWirelessFR ();
                        string wirelessPath = "Equipment_" + typeof (OnePortWirelessFR).Name + "_" + subnetID + "_" + deviceID;