wxr
2022-06-13 acf6f2bfdd9c4fa2500cc746e1064f375dc633d1
Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs
@@ -13,7 +13,8 @@
        /// </summary>
        private bool finish = false;
        private string SeverAddr = "https://test-gz.hdlcontrol.com";//"https://bahrain-gateway.hdlcontrol.com"
        private string SeverAddr = "https://bahrain-gateway.hdlcontrol.com";
        //private string SeverAddr = "https://test-gz.hdlcontrol.com";
        FrameLayout contentView;
@@ -27,6 +28,7 @@
        string newUserId;
        Button btnSave;
        public MigrationServer ()
        {
@@ -76,6 +78,7 @@
                Text = "请输入密码,确认迁移",
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = SkinStyle.Current.TextColor,
                IsMoreLines = true,
            };
            contentView.AddChidren (btnTipTitle);
@@ -152,7 +155,6 @@
                }
#if DEBUG
                //WriteSecretKey (1, 0, new byte [] {1,1,2,3,2,3,4,5,2,3,5,6 });
                //CheckGateway ();
@@ -608,12 +610,27 @@
                                        System.Threading.Thread.Sleep (100);
                                    } else {
                                        Application.RunOnMainThread (() => {
                                            btnTipMsg.Text = "初始化网关成功,正在迁移账号信息。";
                                            btnTipMsg.Text = "初始化网关成功,正在打开网关远程配置。";
                                            btnTipMsg.TextColor = SkinStyle.Current.TextColor;
                                        });
                                        break;
                                    }
                                }
                                //开启网关远程
                                var setRemoteResult = SetGatewayRemote (common.SubnetID, common.DeviceID);
                                if (setRemoteResult) {
                                    Application.RunOnMainThread (() => {
                                        btnTipMsg.Text = "网关远程已开启,正在迁移账号信息。";
                                        btnTipMsg.TextColor = SkinStyle.Current.TextColor;
                                    });
                                } else {
                                    Application.RunOnMainThread (() => {
                                        btnTipMsg.Text = "网关远程开启失败。";
                                        btnTipMsg.TextColor = SkinStyle.Current.DelColor;
                                    });
                                    return;
                                }
                                //迁移账号
                                var moveAccontResult = Account2New (pwd);
                                if (moveAccontResult) {
@@ -818,7 +835,25 @@
            Control.ControlBytesSend (Command.InitializationGateway, subnetId, deviceId, sendByets);
        }
        /// <summary>
        /// 设备网关开启远程
        /// </summary>
        private bool SetGatewayRemote(byte subnetId, byte deviceId)
        {
            var sendByte = new byte [67];
            sendByte [0] = 4;
            var result = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInfo, subnetId, deviceId, sendByte);
            if (result == null) {
            } else {
                if(result.Length>0 && result[0] == 248) {
                    return true;
                }
            }
            return false;
        }
        /// <summary>
        /// 写入homeId
        /// </summary>