wxr
2023-08-04 20f70e3446df19bf5d0faaae9f7bd58fd0fc4bcc
Crabtree/SmartHome/UI/SimpleControl/Phone/Register/ManualUpgradeDialog.cs
@@ -14,20 +14,6 @@
            bodyView = this;
        }
        public static void UpdataInfo(byte inId,byte devId)
        {
            Application.RunOnMainThread (() => {
                if (bodyView == null) {
                    return;
                }
                bodyView.subnetId = inId;
                if (devId > 0) {
                    return;
                }
            });
        }
        public void ShowDialog ()
        {
@@ -67,7 +53,7 @@
                Y = Application.GetRealHeight (20),
                Width = Application.GetRealWidth (400),
                Height = Application.GetRealHeight (80),
                Text = "正在等待网关升级",
                Text = "Waiting for gateway upgrade",
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = SkinStyle.Current.TextColor,
            };
@@ -121,43 +107,35 @@
                arrayTemp [3] = Convert.ToByte (upgradeData.Count & 0xFF);
                while (true) {
                    var ub = MainPage.GatewayStatus.Split ("_");
                    if (ub.Length > 3) {
                        subnetId = Convert.ToByte( ub [2]);
                    }
                    if(subnetId == 0) {
                        System.Threading.Thread.Sleep (100);
                        continue;
                    }
                    if (ub.Length > 1) {
                        result = Convert.ToInt32 (ub [1]);
                        //if (result < result0 && result0 < 100)
                        {
                            //result = result0;
                            Application.RunOnMainThread (() => {
                                btnTipMsg.Text = "正在升级网关 " + result + "/" + upgradeData.Count;
                                btnTipMsg.Text = "Upgrading gateway " + result + "/" + upgradeData.Count;
                            });
                        }
                    }
                    if (ub.Length > 3) {
                        byte.TryParse (ub [2], out subnetId);
                    }
                    if (MainPage.GatewayStatus.Contains ("upgrading") && result == 0) {
                        SendUpgradeData (subnetId, 0, arrayTemp);
                        Application.RunOnMainThread (() => {
                            btnTipMsg.Text = "正在升级网关 " + result + "/" + upgradeData.Count;
                            btnTipMsg.Text = "Upgrading gateway " + result + "/" + upgradeData.Count;
                        });
                    } else if (result == -99) {
                        System.Threading.Thread.Sleep (100);
                        continue;
                    } else if (result == 100) {
                        Application.RunOnMainThread (() => {
                            btnTipMsg.Text = "网关升级成功.正在初始化网关";
                            btnTipMsg.Text = "Gateway upgrade succeeded. Initializing gateway.";
                            btnTipMsg.TextColor = SkinStyle.Current.TextColor;
                            MainPage.GatewayStatus = "";
                        });
                        break;
                    }
                     else {
                    } else {
                        if (upgradeData.Count >= result) {
                            var listPack = upgradeData [result - 1];//
                            byte [] packData = new byte [2 + listPack.Count];
@@ -171,12 +149,12 @@
                    }
                }
            }) { IsBackground = true }.Start ();
            #endregion
        }
        /// <summary>
        /// 读取固件数据
        /// </summary>
@@ -185,7 +163,7 @@
        {
            byte [] buffer = new byte [1024];
            List<List<byte>> upgradeData = new List<List<byte>> ();
            System.IO.Stream stream = Application.Activity.Assets.Open ("FW_MCIP-L1_RF.01_V03.01_210712_STM32F107VCT6_U2_india_beta.bin");
            System.IO.Stream stream = Application.Activity.Assets.Open ("ind_C03.02U_2022-06-22.bin");
            int length = 0;
            try {
                while ((length = stream.Read (buffer, 0, buffer.Length)) != 0) {