wxr
2022-06-22 9299395475a27a1da2d7e5d3b61c9346738b3153
备份
1个文件已添加
1个文件已删除
3个文件已修改
333 ■■■■■ 已修改文件
Crabtree/ON/Assets/FW_MCIP-L1_RF.01_V03.01_210712_STM32F107VCT6_U2_india_beta.bin 补丁 | 查看 | 原始文档 | blame | 历史
Crabtree/ON/Assets/india_beta.bin 补丁 | 查看 | 原始文档 | blame | 历史
Crabtree/ON/Properties/AndroidManifest.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Crabtree/SmartHome/UI/SimpleControl/Phone/Register/ManualUpgradeDialog.cs 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs 287 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Crabtree/ON/Assets/FW_MCIP-L1_RF.01_V03.01_210712_STM32F107VCT6_U2_india_beta.bin
Binary files differ
Crabtree/ON/Assets/india_beta.bin
Binary files differ
Crabtree/ON/Properties/AndroidManifest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.crabtree" android:versionCode="202206131" android:versionName="2.706131">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.crabtree" android:versionCode="202206201" android:versionName="2.706201">
    <uses-sdk android:minSdkVersion="26" android:targetSdkVersion="28" />
    <!-- 在安卓P版本之后,必须要授予FOREGROUND_SERVICE权限,才能够使用前台服务 -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
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 ("india_beta.bin");
            int length = 0;
            try {
                while ((length = stream.Read (buffer, 0, buffer.Length)) != 0) {
Crabtree/SmartHome/UI/SimpleControl/Phone/Register/MigrationServer.cs
@@ -6,6 +6,11 @@
namespace Shared.SimpleControl.Phone
{
    public class DeviceSecret
    {
        public string deviceSecret;
    }
    public class MigrationServer
    {
        /// <summary>
@@ -13,8 +18,8 @@
        /// </summary>
        private bool finish = false;
        //private string SeverAddr = "https://bahrain-gateway.hdlcontrol.com";
        private string SeverAddr = "https://test-gz.hdlcontrol.com";
        private string SeverAddr = "https://bahrain-gateway.hdlcontrol.com";
        //private string SeverAddr = "https://test-gz.hdlcontrol.com";
        FrameLayout contentView;
@@ -157,6 +162,8 @@
                }
#if DEBUG
                //SetGateWayMqttUrlAddress (1, 0);
                //WriteSecretKey (1, 0, new byte [] {1,1,2,3,2,3,4,5,2,3,5,6 });
                //CheckGateway ();
@@ -331,7 +338,8 @@
            var requestJson = HttpUtil.GetSignRequestJson (dic);
            //var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (dic);
            var revertObj = MainPage.RequestHttps ("/smart-open/third/device/authByMac", requestJson, false, false, SeverAddr);
            var revertObj = MainPage.RequestHttps ("/home-wisdom/program/device/secret/applyDeviceSecret", requestJson, false, false, SeverAddr);
            //var revertObj = MainPage.RequestHttps ("/smart-open/third/device/authByMac", requestJson, false, false, SeverAddr);
            if (revertObj.code == "0") {
                return revertObj.data.ToString ();
            } else { }
@@ -342,16 +350,15 @@
        /// 迁移备份
        /// </summary>
        /// <param name="newHomeId"></param>
        /// <param name="newUserId"></param>
        /// <returns></returns>
        private string moveFolder2New (string newHomeId,string newUserId)
        private string moveFolder2New (string newHomeId)
        {
            Dictionary<string, object> dic = new Dictionary<string, object> ();
            dic.Add ("backupDataType", "HDL_ON");
            dic.Add ("homeId",newHomeId);
            dic.Add ("userId",newUserId);
            dic.Add ("backupClassify", "USER_DEFINED_BACKUP");
            dic.Add ("folderName", "迁移备份" + DateTime.Now.ToString ());
            dic.Add ("folderName", "MigrateBackup" + DateTime.Now.ToString ());
            dic.Add ("tenantId", "202106");
            var requestJson = HttpUtil.GetSignRequestJson (dic);
            var revertObj = MainPage.RequestHttps ("/home-wisdom/data/move/folder/save", requestJson, false, false, SeverAddr);
@@ -362,15 +369,11 @@
                    return resultObj.id;
                }
            }
            Application.RunOnMainThread (() => {
                btnTipTitle.Text = "备份迁移失败.";
                btnTipTitle.TextColor = SkinStyle.Current.DelColor;
            });
            return "";
        }
        private string MoveFile2New(string newHomeId, string newUserId,string backupId)
        private string MoveFile2New(string newHomeId,string backupId)
        {
            Dictionary<string, object> dic = new Dictionary<string, object> ();
            dic.Add ("backupId", backupId);//1534728347497418754//1534728860322385922
@@ -397,8 +400,6 @@
                if(fileObjs.Count > 9) {
                    if (!dic.ContainsKey ("list")) {
                        dic.Add ("list", fileObjs);
                    //} else {
                    //    dic ["list"] = fileObjs;
                    }
                    var json = HttpUtil.GetSignRequestJson (dic);
                    var revertObj_foreach = MainPage.RequestHttps ("/home-wisdom/data/move/file/save", json, false, false, SeverAddr);
@@ -425,25 +426,87 @@
            return "";
        }
        /// <summary>
        /// 标记2.0平台数据
        /// 获取定时器列表
        /// </summary>
        /// <param name="newHomeId"></param>
        private List<BackupFileObj> GetTimer (string newHomeId)
        {
            var requestObj = new Timer () { RegionID = UserConfig.Instance.CurrentRegion.RegionID };
            var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj);
            var revertObj = MainPage.RequestHttps ("GetTimerList", requestJson);
            if (revertObj.StateCode == "SUCCESS") {
                var timers = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Timer>> (revertObj.ResponseData.ToString ());
                if(timers.Count > 0) {
                    List<BackupFileObj> backups = new List<BackupFileObj> ();
                    foreach (var timer in timers) {
                        var timerContent = System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (timer));
                        BackupFileObj backupFileObj = new BackupFileObj () {
                            fileName = timer.TimerName,
                            content = timerContent
                        };
                        backups.Add (backupFileObj);
                    }
                    return backups;
                }
            } else {
                return null;
            }
            return new List<BackupFileObj> ();
        }
        /// <summary>
        /// 定时器备份
        /// </summary>
        /// <returns></returns>
        private bool Mark(string newHomeId)
        private string BackupSchedule (string newHomeId, List<BackupFileObj> backups)
        {
            Dictionary<string, object> dic = new Dictionary<string, object> ();
            dic.Add ("backupDataType", "HDL_ON");
            dic.Add ("homeId", newHomeId);
            dic.Add ("mark", false);
            dic.Add ("userId", newUserId);
            dic.Add ("backupClassify", "CUSTOM_PROJECT_BACKUP");
            dic.Add ("folderName", "ScheduleBackup" + DateTime.Now.ToString ());
            dic.Add ("tenantId", "202106");
            var requestJson = HttpUtil.GetSignRequestJson (dic);
            var revertObj = MainPage.RequestHttps ("/home-wisdom/app/home/markVoice", requestJson, false, false, SeverAddr);
            var revertObj = MainPage.RequestHttps ("/home-wisdom/data/move/folder/save", requestJson, false, false, SeverAddr);
            if (revertObj != null) {
                if(revertObj.code == "0") {
                    if(revertObj.data.ToString() == "true") {
                        return true;
                    var resultObj = Newtonsoft.Json.JsonConvert.DeserializeObject<FolderObj> (revertObj.data.ToString ());
                    var ddd =  MoveTimerFileData (newHomeId,resultObj.id, backups);
                    return ddd;
                    }
                }
            return "";
            }
            return false;
        /// <summary>
        /// 保存定时器数据
        /// </summary>
        /// <param name="newHomeId"></param>
        /// <param name="backupId"></param>
        /// <param name="fileObjs"></param>
        /// <returns></returns>
        private string MoveTimerFileData (string newHomeId, string backupId, List<BackupFileObj> fileObjs)
        {
            Dictionary<string, object> dic = new Dictionary<string, object> ();
            dic.Add ("backupId", backupId);
            dic.Add ("homeId", newHomeId);
            dic.Add ("userId", newUserId);
            dic.Add ("backupClassify", "CUSTOM_PROJECT_BACKUP");
            dic.Add ("tenantId", "202106");
            dic.Add ("list", fileObjs);
            var requestJson = HttpUtil.GetSignRequestJson (dic);
            var revertObj = MainPage.RequestHttps ("/home-wisdom/data/move/file/save", requestJson, false, false, SeverAddr);
            if (revertObj != null) {
                if (revertObj.code == "0") {
                    return "true";
        }
            }
            return "";
        }
        #endregion
@@ -470,6 +533,8 @@
                GatewayBase common = null;
                string gateWayString = "";
                if (gateWayList.Count > 0) {
                    foreach (var gatewayFileName in gateWayList) {
                        var tempStrings = gatewayFileName.Split ('_');
                        if (tempStrings [1].ToString () == DeviceType.OnePortBus.ToString () || tempStrings [1].ToString () == DeviceType.RCU.ToString () ||
@@ -498,7 +563,7 @@
                            int result = -99;
                            if (visionString.Contains( "Ind_V03.01U_2021/07/12")) {//FW_MCIP-L1_RF.01_V03.01_210712_STM32F107VCT6_U2_india_beta") {
                            if (visionString.Contains("Ind_V03.01U_2021/07/12")) {
                                Application.RunOnMainThread (() => {
                                    btnTipMsg.Text = "Gateway firmware has been upgraded, initializing gateway.";
                                    btnTipMsg.TextColor = SkinStyle.Current.TextColor;
@@ -520,8 +585,6 @@
                                arrayTemp [1] = Convert.ToByte ((upgradeData.Count & 0xFF0000) >> 16);
                                arrayTemp [2] = Convert.ToByte ((upgradeData.Count & 0xFF00) >> 8);
                                arrayTemp [3] = Convert.ToByte (upgradeData.Count & 0xFF);
                                //丢失次数
                                int lostCount = 0;
                                while (true) {
                                    var ub = MainPage.GatewayStatus.Split ("_");
@@ -550,31 +613,6 @@
                                        });
                                        break;
                                    }
                                     //if (result == -1) {
                                     //    if (lostCount > 3) {
                                     //        Application.RunOnMainThread (() => {
                                     //            btnTipMsg.Text = "网关升级失败,请重试.";
                                     //            loading.Hide ();
                                     //        });
                                     //        return;
                                     //    }
                                     //} else if (result == -2) {
                                     //    if (lostCount > 3) {
                                     //        Application.RunOnMainThread (() => {
                                     //            btnTipMsg.Text = "网关无响应。";
                                     //            loading.Hide ();
                                     //        });
                                     //        return;
                                     //    }
                                     //} else if (result == 999999) {
                                     //    Application.RunOnMainThread (() => {
                                     //        btnTipMsg.Text = "网关升级成功.正在初始化网关";
                                     //        btnTipMsg.TextColor = SkinStyle.Current.TextColor;
                                     //    });
                                     //    break;
                                     //}
                                     else {
                                        if (upgradeData.Count >= result) {
                                            var listPack = upgradeData [result-1];//
@@ -608,14 +646,19 @@
                                initialBytes [11] = 0x00;
                                //初始化网关命令发送
                                InitializationGateway (common.SubnetID, common.DeviceID, initialBytes);
                                int initiaIndex = 0;
                                while (true) {
                                    if (MainPage.GatewayStatus != "Initialization_complete") {
                                        System.Threading.Thread.Sleep (100);
                                    } else {
                                    } else if (initiaIndex == 0) {
                                        Application.RunOnMainThread (() => {
                                            btnTipMsg.Text = "Successfully initialized the gateway. Opening the gateway remote configuration.";
                                            btnTipMsg.TextColor = SkinStyle.Current.TextColor;
                                        });
                                        break;
                                    }
                                    initiaIndex++;
                                    if(initiaIndex > 200) {
                                        break;
                                    }
                                }
@@ -630,6 +673,7 @@
                                    Application.RunOnMainThread (() => {
                                        btnTipMsg.Text = "Gateway remote opening failed. Please try again.";
                                        btnTipMsg.TextColor = SkinStyle.Current.DelColor;
                                        loading.Hide ();
                                    });
                                    return;
                                }
@@ -663,15 +707,9 @@
                                    btnTipMsg.TextColor = SkinStyle.Current.TextColor;
                                }
                                //写入homeId
                                var homeIdSendBytes = new byte [73];
                                var homeIdByte = new byte [36];
                                var homeStrs = newHomeId;// UserConfig.Instance.CurrentRegion.RegionID.ToString ();//需要使用新平台生成的homeId
                                for (int i = 0; i < UserConfig.Instance.CurrentRegion.RegionID.ToString ().Length; i++) {
                                    homeIdByte [i] = Convert.ToByte (homeStrs [i].ToString (), 16);
                                }
                                Array.Copy (homeIdByte, homeIdSendBytes, homeIdByte.Length);
                                var writeHomeIdResult = WriteHomeId (common.SubnetID, common.DeviceID, homeIdSendBytes);
                                var writeHomeIdResult = SetGateWayAdminInfo (common.SubnetID, newHomeId);
                                if (writeHomeIdResult) {
                                    Application.RunOnMainThread (() => {
                                        btnTipMsg.Text = "The gateway home information is configured successfully, and the Internet access key is being obtained.";
@@ -681,6 +719,8 @@
                                    Application.RunOnMainThread (() => {
                                        btnTipMsg.Text = "Gateway home information configuration failed. Please try again.";
                                        btnTipMsg.TextColor = SkinStyle.Current.DelColor;
                                        loading.Hide ();
                                        return;
                                    });
                                }
                                //获取上网秘钥
@@ -691,13 +731,17 @@
                                        btnTipMsg.Text = "The Internet access key was obtained successfully. It is being written.";
                                        btnTipMsg.TextColor = SkinStyle.Current.TextColor;
                                    });
                                    var secretkeySendBytes = new byte [netKet.Length + 1];
                                    var secretkeyByte = new byte [netKet.Length];
                                    for (int i = 0; i < netKet.Length; i++) {
                                        secretkeyByte [i] = Convert.ToByte (netKet [i].ToString (), 16);
                                    }
                                    Array.Copy (secretkeyByte, 0, secretkeySendBytes, 1, secretkeyByte.Length);
                                    var deviceSecret = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceSecret> (netKet);
                                    var secretkeyByte = Encoding.UTF8.GetBytes (deviceSecret.deviceSecret);
                                    var secretkeySendBytes = new byte [secretkeyByte.Length + 1];
                                    secretkeySendBytes [0] = 1;
                                    Array.Copy (secretkeyByte, 0, secretkeySendBytes, 1, secretkeyByte.Length);
                                    //for (int i = 0; i < netKet.Length; i++) {
                                    //    secretkeyByte [i] = Convert.ToByte (netKet [i].ToString (), 16);
                                    //}
                                    //Array.Copy (secretkeyByte, 0, secretkeySendBytes, 1, secretkeyByte.Length);
                                    //secretkeySendBytes [0] = 1;
                                    System.Threading.Thread.Sleep (10000);
                                    //写入上网秘钥
                                    var writeSecretKeyResult = WriteSecretKey (common.SubnetID, common.DeviceID, secretkeySendBytes);
                                    if (writeSecretKeyResult) {
@@ -708,6 +752,7 @@
                                        Application.RunOnMainThread (() => {
                                            btnTipMsg.Text = "Failed to write Internet secret key. Please try again.";
                                            btnTipMsg.TextColor = SkinStyle.Current.DelColor;
                                            loading.Hide ();
                                            return;
                                        });
                                    }
@@ -715,6 +760,7 @@
                                    Application.RunOnMainThread (() => {
                                        btnTipMsg.Text = "Failed to obtain the Internet secret key. Please try again.";
                                        btnTipMsg.TextColor = SkinStyle.Current.DelColor;
                                        return;
                                    });
                                }
                                //写入mqtt域名信息
@@ -737,10 +783,36 @@
                                    return;
                                }
                                //创建迁移备份文件夹
                                var backId = moveFolder2New (newHomeId, newUserId);
                                var backId = moveFolder2New (newHomeId);
                                //迁移备份文件
                                var moveFileResult = MoveFile2New (newHomeId, newUserId, backId);
                                var moveFileResult = MoveFile2New (newHomeId, backId);
                                if (moveFileResult == "true") {
                                    Application.RunOnMainThread (() => {
                                        btnTipMsg.Text = "Migration backup succeeded, migrating Schedule data.";
                                        btnTipMsg.TextColor = SkinStyle.Current.TextColor;
                                    });
                                    //迁移定时器
                                    var timerList = GetTimer (newHomeId);
                                    if (timerList == null) {
                                        Application.RunOnMainThread (() => {
                                            btnTipMsg.Text = "Schedule migration failed. Please try again.";
                                            btnTipMsg.TextColor = SkinStyle.Current.DelColor;
                                            loading.Hide ();
                                            return;
                                        });
                                    } else {
                                        if (timerList.Count > 0) {
                                            var backupTimerResult = BackupSchedule (newHomeId, timerList);
                                            if (string.IsNullOrEmpty (backupTimerResult)) {
                                                btnTipMsg.Text = "Schedule migration failed.. Please try again.";
                                                btnTipMsg.TextColor = SkinStyle.Current.DelColor;
                                                loading.Hide ();
                                                return;
                                            }
                                        }
                                    }
                                    //标记流程完成
                                    //var markResult = Mark (newHomeId);
                                    //if (markResult) {
@@ -790,7 +862,8 @@
        {
            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 ("india_beta.bin");
            //System.IO.Stream stream = Application.Activity.Assets.Open ("india_test.bin");
            int length = 0;
            try {
                while ((length = stream.Read (buffer, 0, buffer.Length)) != 0) {
@@ -854,38 +927,37 @@
            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) {
            if (result != null) {
                    return true;
                }
            }
            return false;
        }
        /// <summary>
        /// 写入homeId
        /// </summary>
        /// <param name="subnetId"></param>
        /// <param name="deviceId"></param>
        /// <param name="sendByets"></param>
        private bool WriteHomeId (byte subnetId, byte deviceId, byte [] sendByets)
        {
            var result = Control.ControlBytesSendHasReturn (Command.WriteHomeId, subnetId, deviceId, sendByets);
            if (result == null)
                return false;
            if (result.Length == 3) {
                if (result [2] == 0xF8) {
                    return true;
                }
            } else if (result.Length == 1) {
                if (result [0] == 0xF8) {
                    return true;
                }
            }
            return false;
        }
        ///// <summary>
        ///// 写入homeId
        ///// </summary>
        ///// <param name="subnetId"></param>
        ///// <param name="deviceId"></param>
        ///// <param name="sendByets"></param>
        //private bool WriteHomeId (byte subnetId, byte deviceId, byte [] sendByets)
        //{
        //    //var result = Control.ControlBytesSendHasReturn (Command.WriteHomeId, subnetId, deviceId, sendByets);
        //    //if (result == null)
        //    //    return false;
        //    //if (result.Length == 3) {
        //    //    if (result [2] == 0xF8) {
        //    //        return true;
        //    //    }
        //    //} else if (result.Length == 1) {
        //    //    if (result [0] == 0xF8) {
        //    //        return true;
        //    //    }
        //    //}
        //    //return false;
        //    return SetGateWayAdminInfo (subnetId, homeId);
        //}
        
        /// <summary>
@@ -956,5 +1028,34 @@
            //return CheckIsSuccessfulWithBytes (backBytes, "Failed to modify gateway remote address!");
        }
        /// <summary>
        /// 修改管理员信息
        /// </summary>
        /// <param name="adminBytes"></param>
        /// <returns></returns>
        private bool SetGateWayAdminInfo (byte subnetId,string homeId)
        {
            //byte [] name = CommonPage.MyEncodingGB2312.GetBytes (MainPage.LoginUser.AccountString);
            byte [] currentRegionIdBytes = CommonPage.MyEncodingGB2312.GetBytes (homeId);
            byte [] adminBytes = new byte [73];
            adminBytes [36] = 1;//住宅标志位
            Array.Copy (currentRegionIdBytes, 0, adminBytes, 37, 36 < currentRegionIdBytes.Length ? 36 : currentRegionIdBytes.Length);
            byte [] result = Control.ControlBytesSendHasReturn (Command.WriteHomeId, subnetId, 0, adminBytes);
            if (result == null)
                return false;
            if (result.Length == 3) {
                if (result [2] == 0xF8) {
                    return true;
    }
            } else if (result.Length == 1) {
                if (result [0] == 0xF8) {
                    return true;
                }
            }
            return false;
        }
    }
}