| | |
| | | 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 () |
| | | { |
| | |
| | | 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, |
| | | }; |
| | |
| | | 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]; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | }) { IsBackground = true }.Start (); |
| | | |
| | | #endregion |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 读取固件数据 |
| | | /// </summary> |
| | |
| | | { |
| | | 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) { |