From 9ebd6edb9beddf1a6881b2ca924ed43bf5cedfbe Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期五, 30 十二月 2022 11:24:03 +0800
Subject: [PATCH] 1
---
ON.Ios/ON.Ios.csproj | 2
.vs/SmartHome/xs/UserPrefs.xml | 53 +--
SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs | 137 +++++++-
SmartHome/UI/SimpleControl/CommonPage.cs | 88 ++---
ON/Resources/.DS_Store | 0
ON/.DS_Store | 0
SmartHome/.DS_Store | 0
SmartHome/HDL/Operation/Control.cs | 21
SmartHome/UI/SimpleControl/Phone/System/SystemMiddle.cs | 231 +++++++++++-----
SmartHome/HDL/Operation/Device/GatewayBase.cs | 6
SmartHome/UI/SimpleControl/Phone/System/RemoteOnePort.cs | 233 +++++++++++-----
ON.Ios/.DS_Store | 0
SmartHome/HDL/Operation/Packet.cs | 4
ON.Ios/Info.plist | 6
ON/Properties/AndroidManifest.xml | 2
ON/ON.Droid.csproj | 3
16 files changed, 510 insertions(+), 276 deletions(-)
diff --git a/.vs/SmartHome/xs/UserPrefs.xml b/.vs/SmartHome/xs/UserPrefs.xml
index 9e5c60d..6030cbc 100644
--- a/.vs/SmartHome/xs/UserPrefs.xml
+++ b/.vs/SmartHome/xs/UserPrefs.xml
@@ -1,45 +1,24 @@
-锘�<Properties StartupConfiguration="{9D9EF20B-6E65-4A65-92BF-567EBF1E1443}|Default">
+锘�<Properties StartupConfiguration="{1D83BF28-BA88-4152-BA41-D7EFE90A5437}|Default">
<MonoDevelop.Ide.ItemProperties.ON.Droid PreferredExecutionTarget="Android.364c4b3158493098" />
<MonoDevelop.Ide.Workbench>
<Files>
- <File FileName="SmartHome/HDL/Operation/Packet.cs" Line="93" Column="8" />
- <File FileName="SmartHome/HDL/Operation/Device/Common.cs" Line="80" Column="20" />
- <File FileName="SmartHome/UI/SimpleControl/Phone/System/SystemMiddle.cs" Line="15" Column="22" />
- <File FileName="SmartHome/UI/SimpleControl/Phone/System/RemoteOnePort.cs" Line="39" Column="36" />
- <File FileName="SmartHome/HDL/Operation/Control.cs" Line="194" Column="45" />
+ <File FileName="SmartHome/UI/SimpleControl/Phone/System/SystemMiddle.cs" Line="146" Column="28" />
+ <File FileName="SmartHome/UI/SimpleControl/Phone/System/RemoteOnePort.cs" />
+ <File FileName="SmartHome/UI/SimpleControl/Phone/System/SystemHomePage.cs" />
+ <File FileName="SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs" Line="233" Column="53" />
+ <File FileName="SmartHome/UI/SimpleControl/Phone/System/SystemRemote.cs" />
+ <File FileName="SmartHome/HDL/Operation/Packet.cs" />
+ <File FileName="SmartHome/HDL/Operation/BusSocket.cs" />
+ <File FileName="SmartHome/HDL/Operation/Control.cs" />
+ <File FileName="ON.Ios/ViewController.cs" />
<File FileName="ON.Ios/Info.plist" />
- <File FileName="SmartHome/UI/SimpleControl/Phone/System/SystemHomePage.cs" Line="84" Column="61" />
- <File FileName="SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs" Line="189" Column="1" />
- <File FileName="SmartHome/UI/SimpleControl/CommonPage.cs" Line="81" Column="30" />
- <File FileName="SmartHome/UI/SimpleControl/Phone/System/SystemRemote.cs" Line="1" Column="1" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State name="__root__">
- <Node name="SmartHome" expanded="True">
- <Node name="ON.Droid" selected="True" />
+ <Node name="SmartHome" expanded="True" selected="True">
<Node name="ON.Ios" expanded="True" />
- <Node name="Shared" expanded="True">
- <Node name="HDL" expanded="True">
- <Node name="Operation" expanded="True">
- <Node name="Device" expanded="True" />
- </Node>
- </Node>
- <Node name="UI" expanded="True">
- <Node name="SimpleControl" expanded="True">
- <Node name="Phone" expanded="True">
- <Node name="System" expanded="True" />
- </Node>
- </Node>
- </Node>
- </Node>
</Node>
- </State>
- </Pad>
- <Pad Id="MonoDevelop.Debugger.WatchPad">
- <State>
- <Value>command</Value>
- <Value>MyEncodingGB2312.GetString (usefullBytes, 0, 20).Trim ('\0');</Value>
</State>
</Pad>
</Pads>
@@ -50,12 +29,14 @@
<String>DroidService/DroidService.csproj</String>
<String>IosService/IosService.csproj</String>
</DisabledProjects>
- <MonoDevelop.Ide.Workspace ActiveConfiguration="Release" />
- <MonoDevelop.Ide.ItemProperties.ON.Ios PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.00008020-000404163432002E" />
+ <MonoDevelop.Ide.Workspace ActiveConfiguration="Release|iPhone" />
+ <MonoDevelop.Ide.ItemProperties.ON.Ios PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget" />
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore>
- <Breakpoint file="/Users/kaede/Desktop/MigrationWidget/SmartHome/UI/SimpleControl/Phone/System/SystemMiddle.cs" relfile="SmartHome/UI/SimpleControl/Phone/System/SystemMiddle.cs" line="246" column="1" />
- <Breakpoint file="/Users/kaede/Desktop/MigrationWidget/SmartHome/UI/SimpleControl/Phone/System/SystemHomePage.cs" relfile="SmartHome/UI/SimpleControl/Phone/System/SystemHomePage.cs" line="84" column="1" />
+ <Breakpoint file="/Users/kaede/Desktop/MigrationWidget/SmartHome/UI/SimpleControl/Phone/System/SystemMiddle.cs" relfile="SmartHome/UI/SimpleControl/Phone/System/SystemMiddle.cs" line="329" column="1" />
+ <Breakpoint file="/Users/kaede/Desktop/MigrationWidget/SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs" relfile="SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs" line="456" column="1" />
+ <Breakpoint file="/Users/kaede/Desktop/MigrationWidget/SmartHome/UI/SimpleControl/CommonPage.cs" relfile="SmartHome/UI/SimpleControl/CommonPage.cs" line="120" column="1" />
+ <Breakpoint file="/Users/kaede/Desktop/MigrationWidget/SmartHome/UI/SimpleControl/CommonPage.cs" relfile="SmartHome/UI/SimpleControl/CommonPage.cs" line="112" column="1" />
</BreakpointStore>
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MultiItemStartupConfigurations />
diff --git a/ON.Ios/.DS_Store b/ON.Ios/.DS_Store
index afde5cd..52e00ab 100644
--- a/ON.Ios/.DS_Store
+++ b/ON.Ios/.DS_Store
Binary files differ
diff --git a/ON.Ios/Info.plist b/ON.Ios/Info.plist
index 18f84bd..fe9347d 100755
--- a/ON.Ios/Info.plist
+++ b/ON.Ios/Info.plist
@@ -17,9 +17,9 @@
<key>CFBundleIdentifier</key>
<string>com.hdl.moveserver</string>
<key>CFBundleShortVersionString</key>
- <string>1.0.5</string>
+ <string>1.0.9</string>
<key>CFBundleVersion</key>
- <string>1.0.5</string>
+ <string>1.0.9</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
@@ -69,5 +69,7 @@
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>CFBundleDisplayName</key>
<string>Migration Tools</string>
+ <key>NSLocalNetworkUsageDescription</key>
+ <string>App wants to use local network access rights to find local smart home devices.</string>
</dict>
</plist>
diff --git a/ON.Ios/ON.Ios.csproj b/ON.Ios/ON.Ios.csproj
index a797af8..deb0b24 100644
--- a/ON.Ios/ON.Ios.csproj
+++ b/ON.Ios/ON.Ios.csproj
@@ -73,7 +73,7 @@
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
- <DefineConstants>__IOS__;__MOBILE__;__UNIFIED__;DEBUG;ENABLE_TEST_CLOUD;HDL;HDLVideo;</DefineConstants>
+ <DefineConstants>__IOS__;__MOBILE__;__UNIFIED__;DEBUG1;ENABLE_TEST_CLOUD;HDL;HDLVideo;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
diff --git a/ON/.DS_Store b/ON/.DS_Store
index 3f40f9e..dc3ed2d 100644
--- a/ON/.DS_Store
+++ b/ON/.DS_Store
Binary files differ
diff --git a/ON/ON.Droid.csproj b/ON/ON.Droid.csproj
index f4128ad..e53e318 100644
--- a/ON/ON.Droid.csproj
+++ b/ON/ON.Droid.csproj
@@ -32,6 +32,7 @@
<AndroidSupportedAbis>armeabi-v7a</AndroidSupportedAbis>
<AndroidDexTool>d8</AndroidDexTool>
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
+ <AndroidPackageFormat>apk</AndroidPackageFormat>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugSymbols>false</DebugSymbols>
@@ -49,7 +50,7 @@
<NoWarn></NoWarn>
<AndroidDexTool>d8</AndroidDexTool>
<AndroidSupportedAbis>armeabi-v7a;arm64-v8a</AndroidSupportedAbis>
-<AndroidPackageFormat>aab</AndroidPackageFormat>
+<AndroidPackageFormat>apk</AndroidPackageFormat>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
diff --git a/ON/Properties/AndroidManifest.xml b/ON/Properties/AndroidManifest.xml
index 56b7d4a..917d10e 100644
--- a/ON/Properties/AndroidManifest.xml
+++ b/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.moveserver" android:versionCode="202212141" android:versionName="1.2212141">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.moveserver" android:versionCode="202212261" android:versionName="1.2212261">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="31" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
diff --git a/ON/Resources/.DS_Store b/ON/Resources/.DS_Store
index 7bd3015..4feeecc 100644
--- a/ON/Resources/.DS_Store
+++ b/ON/Resources/.DS_Store
Binary files differ
diff --git a/SmartHome/.DS_Store b/SmartHome/.DS_Store
index 6a022e3..d4c1feb 100644
--- a/SmartHome/.DS_Store
+++ b/SmartHome/.DS_Store
Binary files differ
diff --git a/SmartHome/HDL/Operation/Control.cs b/SmartHome/HDL/Operation/Control.cs
index a2b60c0..35e9033 100644
--- a/SmartHome/HDL/Operation/Control.cs
+++ b/SmartHome/HDL/Operation/Control.cs
@@ -8,7 +8,6 @@
{
public class Control
{
- public bool IsCanShowTip;
public System.DateTime LatestDateTime = System.DateTime.Now;
/// <summary>
@@ -20,18 +19,20 @@
/// 鍙戦�佹暟鎹紝绛夊緟鏈夊弽棣�
/// </summary>
/// <returns>The bytes send has return.</returns>
- public static byte [] ControlBytesSendHasReturn (Command command, byte subnetID, byte deviceID, byte [] gatewayBytes, bool isShow = true)
+ public static byte [] ControlBytesSendHasReturn (Command command, byte subnetID, byte deviceID, byte [] gatewayBytes, string ip = "")
{
-
- Control control = new Control () { IsCanShowTip = isShow };
+ Control control = new Control ();
+ var sendIp = CommonPage.EndPoint;
+ if (!string.IsNullOrEmpty (ip)) {
+ sendIp = new System.Net.IPEndPoint (System.Net.IPAddress.Parse (ip), 9999);
+ }
control.Send (new Target () {
- IPEndPoint = CommonPage.EndPoint,
+ IPEndPoint = sendIp,
Command = command,
SubnetID = subnetID,
DeviceID = deviceID,
AddData = gatewayBytes,
}, SendCount.Three, true);
-
return control.UsefulBytes;
}
@@ -41,7 +42,7 @@
public static void ControlBytesSend (Command command, byte subnetID, byte deviceID, byte [] gatewayBytes, SendCount sendCount = SendCount.Three, System.Net.IPEndPoint ipEndpoint = null, bool isShowTip = true)
{
- Control control = new Control () { IsCanShowTip = isShowTip };
+ Control control = new Control ();
control.Send (new Target () {
IPEndPoint = ipEndpoint == null ? CommonPage.EndPoint : ipEndpoint,//new System.Net.IPEndPoint (System.Net.IPAddress.Parse (new Net.NetWiFi ().BroadcastIpAddress.ToString ()), 6000),
Command = command,
@@ -265,7 +266,8 @@
for (int i = 0; i < controlList.Count; i++) {
try {
Control control = controlList [i];
- if (control.SendFlag == receiveFlag) {
+ if (control.SendFlag == receiveFlag && (control.Packet.RemoteEndPoint.ToString() == remoteEndPoint.ToString()||
+ control.Packet.RemoteEndPoint.ToString().Contains("6000"))) {
control.LatestDateTime = System.DateTime.Now;
control.UsefulBytes = usefulBytes;//
control.run ();
@@ -378,9 +380,6 @@
Console.WriteLine ("managerSendCount:" + ex.ToString ());
} finally {
allDone.Set ();
- if (Packet.HaveSendCount == 3 && IsCanShowTip) {
- //MainPage.AddTip (Language.StringByID (SimpleControl.R.MyInternationalizationString.OperationFailed));
- }
}
return;
//if (Shared.SimpleControl.CommonPage.IsRemote && !isLocal) {
diff --git a/SmartHome/HDL/Operation/Device/GatewayBase.cs b/SmartHome/HDL/Operation/Device/GatewayBase.cs
index 2bb7ab7..08cc2d5 100644
--- a/SmartHome/HDL/Operation/Device/GatewayBase.cs
+++ b/SmartHome/HDL/Operation/Device/GatewayBase.cs
@@ -36,5 +36,11 @@
public string Remote_IP2 = string.Empty;
public string Remote_IP2_Prot = string.Empty;
+ public bool isOnline = false;
+ /// <summary>
+ /// 宸茬粡杩佺Щ鍒版柊鏈嶅姟鍣�
+ /// </summary>
+ public bool isMoveToNewServer = false;
+
}
}
diff --git a/SmartHome/HDL/Operation/Packet.cs b/SmartHome/HDL/Operation/Packet.cs
index 298a6e0..5724c00 100644
--- a/SmartHome/HDL/Operation/Packet.cs
+++ b/SmartHome/HDL/Operation/Packet.cs
@@ -47,7 +47,7 @@
/// </summary>
public int HaveSendCount;
- public delegate void DelegateReceive (byte subnetID, byte deviceID, Command command, byte [] usefullBytes, int deviceType);
+ public delegate void DelegateReceive (byte subnetID, byte deviceID, Command command, byte [] usefullBytes, int deviceType, System.Net.IPEndPoint remoteIp);
public static event DelegateReceive ReceiveEvent;
/// <summary>
/// 鎺ユ敹鍒扮殑鎵�鏈夋暟鎹�
@@ -92,7 +92,7 @@
if (ReceiveEvent != null) {
try {
- ReceiveEvent (subnetID, deviceID, command, usefulBytes, deviceType);
+ ReceiveEvent (subnetID, deviceID, command, usefulBytes, deviceType,(System.Net.IPEndPoint)RemoteEndPoint);
} catch (Exception ex) {
Console.WriteLine (ex.Message);
}
diff --git a/SmartHome/UI/SimpleControl/CommonPage.cs b/SmartHome/UI/SimpleControl/CommonPage.cs
index eb54f2d..f422a89 100644
--- a/SmartHome/UI/SimpleControl/CommonPage.cs
+++ b/SmartHome/UI/SimpleControl/CommonPage.cs
@@ -10,13 +10,8 @@
{
public static class CommonPage
{
- //public static AirQuality AirQuality;
- //public static Action RefreshAir;
public static bool IsRemote = false;
- //public static bool FindGateway = false;
- public static bool FindGatewayChilren = false;
public static string FindGatewayChilrenIPAddress = new Net.NetWiFi ().BroadcastIpAddress.ToString ();
- public static bool LocalPhoneFindDevice = false;
public static int searchTotal = 0;
public static int newDevice = 0;
private static string ip= "115.29.251.24";
@@ -81,63 +76,55 @@
36865,9600,19600,
1099,1163,3501,3502,3503,3504,3505,3506,
3508,3509,3516,3517,3521,3527,3528,3530,3532,3533,3534,3536,3538,
- 3539,3541,3543,3550,3559,3600,3601,3605,4599,4601,4602,
+ 3539,3541,3543,3550,3559,3600,3601,3605,4601,4602,
30001,63479,65282,65532,65534,
};
- static void Packet_ReceiveEvent (byte subnetID, byte deviceID, Command command, byte [] usefullBytes,int deviceTypeNumber)
+ static void Packet_ReceiveEvent (byte subnetID, byte deviceID, Command command, byte [] usefullBytes,int deviceTypeNumber, System.Net.IPEndPoint remoteIp)
{
try {
List<byte> ButtonBkeyModelList = new List<byte> ();
switch (command) {
case Command.ReadRemarkACK:
if(supportList.Contains(deviceTypeNumber)) {
- lock (GateWayList) {
- if (GateWayList.Find ((l) => { return l.SubnetID == subnetID && l.DeviceID == deviceID; }) != null) {
- return;
+ //if (IsRemote) {
+ // if (remoteIp.ToString().Contains("118.31.3.103") || remoteIp.ToString ().Contains ("157.175.231.123"))
+ // lock (GateWayList_NewServer) {
+ // if (GateWayList_NewServer.Find ((l) => { return l.SubnetID == subnetID && l.DeviceID == deviceID; }) != null) {
+ // return;
+ // }
+ // DeviceType deviceType = (DeviceType)(usefullBytes [2] * 256 + usefullBytes [3]);
+ // GatewayBase gatewayBase = new GatewayBase ();
+ // gatewayBase.DeviceTypeNumber = deviceTypeNumber;
+ // gatewayBase.SubnetID = subnetID;
+ // gatewayBase.DeviceID = deviceID;
+ // gatewayBase.Type = deviceType;
+ // gatewayBase.Name = MyEncodingGB2312.GetString (usefullBytes, 0, 20).Trim ('\0');//=============
+ // GateWayList_NewServer.Add (gatewayBase);
+ // Console.WriteLine ($"name:{gatewayBase.Name}++{deviceTypeNumber}");
+ // }
+ //} else
+ {
+ lock (GateWayList) {
+ if (GateWayList.Find ((l) => { return l.SubnetID == subnetID && l.DeviceID == deviceID; }) != null) {
+ return;
+ }
+ DeviceType deviceType = (DeviceType)(usefullBytes [2] * 256 + usefullBytes [3]);
+ GatewayBase gatewayBase = new GatewayBase ();
+ gatewayBase.DeviceTypeNumber = deviceTypeNumber;
+ gatewayBase.SubnetID = subnetID;
+ gatewayBase.DeviceID = deviceID;
+ gatewayBase.Type = deviceType;
+ gatewayBase.Name = MyEncodingGB2312.GetString (usefullBytes, 0, 20).Trim ('\0');//=============
+ var name = Encoding.Default.GetString (usefullBytes, 0, 20).Trim ('\0');
+ GateWayList.Add (gatewayBase);
+
+ Console.WriteLine ($"name:{gatewayBase.Name}++{deviceTypeNumber}");
}
- DeviceType deviceType = (DeviceType)(usefullBytes [2] * 256 + usefullBytes [3]);
- GatewayBase gatewayBase = new GatewayBase ();
- gatewayBase.DeviceTypeNumber = deviceTypeNumber;
- gatewayBase.SubnetID = subnetID;
- gatewayBase.DeviceID = deviceID;
- gatewayBase.Type = deviceType;
- gatewayBase.Name = MyEncodingGB2312.GetString (usefullBytes, 0, 20).Trim ('\0');//=============
- GateWayList.Add (gatewayBase);
}
}
break;
- //璇诲彇缃戝叧璁惧鍥炲
- case Command.ReadGatewayACK:
- if (usefullBytes [0] != RandomHigh | usefullBytes [1] != RandomLow) {
- return;
- }
- lock (GateWayList) {
- if (GateWayList.Find ((l) => { return l.SubnetID == subnetID && l.DeviceID == deviceID; }) != null) {
- return;
- }
- DeviceType deviceType = (DeviceType)(usefullBytes [2] * 256 + usefullBytes [3]);
- if (usefullBytes [2] == 254 && usefullBytes [3] < 8) {
- GatewayBase gatewayBase = new GatewayBase ();
- gatewayBase.DeviceTypeNumber = deviceTypeNumber;
- gatewayBase.SubnetID = subnetID;
- gatewayBase.DeviceID = deviceID; gatewayBase.Type = deviceType;
- gatewayBase.LoopID = usefullBytes [4];
- gatewayBase.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]);
- gatewayBase.Name = MyEncodingGB2312.GetString (usefullBytes, 13, 20).Trim ('\0');//=============
- gatewayBase.IPAddress = usefullBytes [33] + "." + usefullBytes [34] + "." + usefullBytes [35] + "." + usefullBytes [36];
- gatewayBase.RouteIPAddress = usefullBytes [37] + "." + usefullBytes [38] + "." + usefullBytes [39] + "." + usefullBytes [40];
- gatewayBase.IPMAC = usefullBytes [41] + "." + usefullBytes [42] + "." + usefullBytes [43] + "." + usefullBytes [44] + "." + usefullBytes [45] + "." + usefullBytes [46];
- gatewayBase.SubnetMask = usefullBytes [47] + "." + usefullBytes [48] + "." + usefullBytes [49] + "." + usefullBytes [50];
- gatewayBase.DHCP = usefullBytes [51] == 0 ? false : true;
- GateWayList.Add (gatewayBase);
- if (gatewayBase.Name == "") {
- gatewayBase.Name = gatewayBase.CommonLoopID.ToString ();
- }
- }
- }
- break;
case Command.WriteWirelessPanelButtonKey:
//01 01 59(+30) 02 0D 03 64 00 01
break;
@@ -187,5 +174,10 @@
/// </summary>
public static List<GatewayBase> GateWayList = new List<GatewayBase> ();
+
+ public static List<GatewayBase> GateWayList_NewServer = new List<GatewayBase> ();
+
+
+
}
}
\ No newline at end of file
diff --git a/SmartHome/UI/SimpleControl/Phone/System/RemoteOnePort.cs b/SmartHome/UI/SimpleControl/Phone/System/RemoteOnePort.cs
index 75324e4..fd8fd62 100644
--- a/SmartHome/UI/SimpleControl/Phone/System/RemoteOnePort.cs
+++ b/SmartHome/UI/SimpleControl/Phone/System/RemoteOnePort.cs
@@ -318,7 +318,6 @@
try {
#region 鎼滅储璁惧
- CommonPage.LocalPhoneFindDevice = true;
CommonPage.RandomHigh = (byte)new Random ().Next (255);
CommonPage.RandomLow = (byte)new Random ().Next (255);
CommonPage.GateWayList.Clear ();
@@ -346,7 +345,7 @@
Control control = new Control ();
control.Send (new Target () {
IPEndPoint = CommonPage.EndPoint,
- Command = Command.ReadGateway,
+ Command = Command.ReadRemark,
SubnetID = 0xFF,
DeviceID = 0xFF,
AddData = ms.ToArray ()
@@ -365,7 +364,6 @@
ShowGateWayView ();
});
- CommonPage.LocalPhoneFindDevice = false;
#endregion
} catch (Exception ex) {
Console.WriteLine (ex.ToString ());
@@ -450,7 +448,6 @@
Button rightButton1 = new Button () {
X = Application.GetRealWidth (480),
Width = Application.GetRealWidth (100),
- Height = Application.GetRealHeight (40),
Gravity = Gravity.CenterVertical,
TextAlignment = TextAlignment.CenterLeft,
TextColor = SkinStyle.Current.TextColor1,
@@ -460,87 +457,177 @@
};
wirelessView.AddChidren (rightButton1);
- new System.Threading.Thread (() => {
- var serverIPBytes = Control.ControlBytesSendHasReturn (Command.ReadGatewayServerIP, common.SubnetID, common.DeviceID, new byte [] { });
- if (serverIPBytes != null) {
- try {
- string serverIP1 = serverIPBytes [0].ToString () + "." + serverIPBytes [1].ToString () + "." +
- serverIPBytes [2].ToString () + "." + serverIPBytes [3].ToString ();
- string serverIP1Point = ((serverIPBytes [4] * 256) + serverIPBytes [5]).ToString ();
- string serverIP2 = serverIPBytes [6].ToString () + "." + serverIPBytes [7].ToString () + "." +
- serverIPBytes [8].ToString () + "." + serverIPBytes [9].ToString ();
- string serverIP2Point = ((serverIPBytes [10] * 256) + serverIPBytes [11]).ToString ();
- if (serverIP1 == "118.31.3.103" || serverIP2 == "118.31.3.103") {
- Application.RunOnMainThread (() => {
- rightButton1.Text = text_Upgraded;
- rightButton1.TextColor = 0xFF00FF00;
- return;
- });
- } else if (serverIP1 != "115.29.251.24" && serverIP2 != "115.29.251.24") {
- Application.RunOnMainThread (() => {
- rightButton1.Text = text_UnknownVersion;
- rightButton1.TextColor = 0xFF00FF00;
- return;
- });
- } else {
- Application.RunOnMainThread (() => {
- rightButton1.Text = text_Upgrading;
- rightButton1.TextColor = 0xFF0000FF;
- });
- if (serverIP1 == "115.29.251.24") {
- serverIP1 = "118.31.3.103";
- serverIP1Point = "9999";
+ if (Language.CurrentLanguage != "Chinese") {
+ //淇敼鍥藉鏈嶅姟鍣�
+ new System.Threading.Thread (() => {
+ var serverIPBytes = Control.ControlBytesSendHasReturn (Command.ReadGatewayServerIP, common.SubnetID, common.DeviceID, new byte [] { });
+ if (serverIPBytes != null) {
+ try {
+ string serverIP1 = serverIPBytes [0].ToString () + "." + serverIPBytes [1].ToString () + "." +
+ serverIPBytes [2].ToString () + "." + serverIPBytes [3].ToString ();
+ string serverIP1Point = ((serverIPBytes [4] * 256) + serverIPBytes [5]).ToString ();
+ string serverIP2 = serverIPBytes [6].ToString () + "." + serverIPBytes [7].ToString () + "." +
+ serverIPBytes [8].ToString () + "." + serverIPBytes [9].ToString ();
+ string serverIP2Point = ((serverIPBytes [10] * 256) + serverIPBytes [11]).ToString ();
- serverIPBytes [0] = 118;
- serverIPBytes [1] = 31;
- serverIPBytes [2] = 3;
- serverIPBytes [3] = 103;
- serverIPBytes [4] = Convert.ToByte (9999 / 256);
- serverIPBytes [5] = Convert.ToByte (9999 % 256);
-
- }
- if (serverIP2 == "115.29.251.24") {
- serverIP2 = "118.31.3.103";
- serverIP2Point = "9999";
-
- serverIPBytes [0 + 6] = 118;
- serverIPBytes [1 + 6] = 31;
- serverIPBytes [2 + 6] = 3;
- serverIPBytes [3 + 6] = 103;
- serverIPBytes [4 + 6] = Convert.ToByte (9999 / 256);
- serverIPBytes [5 + 6] = Convert.ToByte (9999 % 256);
-
- }
-
-
- var mobytes = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInternetInfo, common.SubnetID, common.DeviceID, serverIPBytes);
- if (mobytes == null || mobytes [0] == 0xF5) {
+ if (serverIP1 == "157.175.231.123" || serverIP2 == "157.175.231.123") {//宸存灄鏈嶅姟鍣�
Application.RunOnMainThread (() => {
+ rightButton1.Text = text_Upgraded;
+ rightButton1.TextColor = 0xFF00FF00;
+ });
+ }
+ else if (serverIP1 == "115.29.251.24" || serverIP2 == "115.29.251.24"//鏃ф湇鍔″櫒
+ || serverIP1 == "118.31.3.103" || serverIP2 == "118.31.3.103") {//鏂板浗鍐呮湇鍔″櫒
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_Upgrading;
+ rightButton1.TextColor = 0xFF0000FF;
+ });
+ if (serverIP1 == "115.29.251.24" || serverIP1 == "118.31.3.103") {//鏃ф湇鍔″櫒//鏂板浗鍐呮湇鍔″櫒
+ serverIP1 = "157.175.231.123";//宸存灄鏈嶅姟鍣�
+ serverIP1Point = "9999";
+
+ serverIPBytes [0] = 157;
+ serverIPBytes [1] = 175;
+ serverIPBytes [2] = 231;
+ serverIPBytes [3] = 123;
+ serverIPBytes [4] = Convert.ToByte (9999 / 256);
+ serverIPBytes [5] = Convert.ToByte (9999 % 256);
+
+ }
+ if (serverIP2 == "115.29.251.24" || serverIP2 == "118.31.3.103") {//鏃ф湇鍔″櫒//鏂板浗鍐呮湇鍔″櫒
+ serverIP2 = "157.175.231.123";//宸存灄鏈嶅姟鍣�
+ serverIP2Point = "9999";
+
+ serverIPBytes [0 + 6] = 157;
+ serverIPBytes [1 + 6] = 175;
+ serverIPBytes [2 + 6] = 231;
+ serverIPBytes [3 + 6] = 123;
+ serverIPBytes [4 + 6] = Convert.ToByte (9999 / 256);
+ serverIPBytes [5 + 6] = Convert.ToByte (9999 % 256);
+
+ }
+
+
+ var mobytes = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInternetInfo, common.SubnetID, common.DeviceID, serverIPBytes);
+ if (mobytes == null || mobytes [0] == 0xF5) {
Application.RunOnMainThread (() => {
- rightButton1.Text = text_UpgradeFailed;
- rightButton1.TextColor = 0x99ff0000;
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_UpgradeFailed;
+ rightButton1.TextColor = 0x99ff0000;
+ });
});
+ } else {
+ Application.RunOnMainThread (() => {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_Upgraded;
+ rightButton1.TextColor = 0xFF00FF00;
+ });
+ });
+ }
+ }
+ else {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_UnknownVersion;
+ rightButton1.TextColor = 0xFF00FF00;
+ });
+ }
+
+
+ } catch (Exception ex) {
+ Console.WriteLine ("涓�绔彛杩滅▼ip淇℃伅杞瘧澶辫触.");
+ }
+ } else {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_readFailure;
+ rightButton1.TextColor = 0x99ff0000;
+ });
+ }
+ }) { IsBackground = true }.Start ();
+ } else {
+ //淇敼鍥藉唴鏈嶅姟鍣�
+ new System.Threading.Thread (() => {
+ var serverIPBytes = Control.ControlBytesSendHasReturn (Command.ReadGatewayServerIP, common.SubnetID, common.DeviceID, new byte [] { });
+ if (serverIPBytes != null) {
+ try {
+ string serverIP1 = serverIPBytes [0].ToString () + "." + serverIPBytes [1].ToString () + "." +
+ serverIPBytes [2].ToString () + "." + serverIPBytes [3].ToString ();
+ string serverIP1Point = ((serverIPBytes [4] * 256) + serverIPBytes [5]).ToString ();
+ string serverIP2 = serverIPBytes [6].ToString () + "." + serverIPBytes [7].ToString () + "." +
+ serverIPBytes [8].ToString () + "." + serverIPBytes [9].ToString ();
+ string serverIP2Point = ((serverIPBytes [10] * 256) + serverIPBytes [11]).ToString ();
+
+ if (serverIP1 == "118.31.3.103" || serverIP2 == "118.31.3.103") {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_Upgraded;
+ rightButton1.TextColor = 0xFF00FF00;
+ return;
+ });
+ } else if (serverIP1 != "115.29.251.24" && serverIP2 != "115.29.251.24") {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_UnknownVersion;
+ rightButton1.TextColor = 0xFF00FF00;
+ return;
});
} else {
Application.RunOnMainThread (() => {
- Application.RunOnMainThread (() => {
- rightButton1.Text = text_Upgraded;
- rightButton1.TextColor = 0xFF00FF00;
- });
+ rightButton1.Text = text_Upgrading;
+ rightButton1.TextColor = 0xFF0000FF;
});
+ if (serverIP1 == "115.29.251.24") {
+ serverIP1 = "118.31.3.103";
+ serverIP1Point = "9999";
+
+ serverIPBytes [0] = 118;
+ serverIPBytes [1] = 31;
+ serverIPBytes [2] = 3;
+ serverIPBytes [3] = 103;
+ serverIPBytes [4] = Convert.ToByte (9999 / 256);
+ serverIPBytes [5] = Convert.ToByte (9999 % 256);
+
+ }
+ if (serverIP2 == "115.29.251.24") {
+ serverIP2 = "118.31.3.103";
+ serverIP2Point = "9999";
+
+ serverIPBytes [0 + 6] = 118;
+ serverIPBytes [1 + 6] = 31;
+ serverIPBytes [2 + 6] = 3;
+ serverIPBytes [3 + 6] = 103;
+ serverIPBytes [4 + 6] = Convert.ToByte (9999 / 256);
+ serverIPBytes [5 + 6] = Convert.ToByte (9999 % 256);
+
+ }
+
+
+ var mobytes = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInternetInfo, common.SubnetID, common.DeviceID, serverIPBytes);
+ if (mobytes == null || mobytes [0] == 0xF5) {
+ Application.RunOnMainThread (() => {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_UpgradeFailed;
+ rightButton1.TextColor = 0x99ff0000;
+ });
+ });
+ } else {
+ Application.RunOnMainThread (() => {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_Upgraded;
+ rightButton1.TextColor = 0xFF00FF00;
+ });
+ });
+ }
}
+ } catch (Exception ex) {
+ Console.WriteLine ("涓�绔彛杩滅▼ip淇℃伅杞瘧澶辫触.");
}
- } catch (Exception ex) {
- Console.WriteLine ("涓�绔彛杩滅▼ip淇℃伅杞瘧澶辫触.");
+ } else {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_UnknownVersion;
+ rightButton1.TextColor = 0xFF00FF00;
+ });
}
- } else {
- Application.RunOnMainThread (() => {
- rightButton1.Text = text_UnknownVersion;
- rightButton1.TextColor = 0xFF00FF00;
- });
- }
- }) { IsBackground = true }.Start ();
+ }) { IsBackground = true }.Start ();
+ }
}
}
}
diff --git a/SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs b/SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs
index 9b7c4ab..eb37042 100644
--- a/SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs
+++ b/SmartHome/UI/SimpleControl/Phone/System/SearchServerOnePortListPage.cs
@@ -1,5 +1,6 @@
锘�
using System;
+using System.Collections.Generic;
using Shared;
using Shared.SimpleControl;
@@ -77,7 +78,7 @@
text_Upgraded = "Upgraded";
text_Upgrading = "Upgrading";
text_UpgradeFailed = "Upgrade failed";
- text_UnknownVersion = "Unknown version";
+ text_UnknownVersion = "Other version";
text_readFailure = "Read failure";
text_back = "Back";
text_link = "Link";
@@ -229,10 +230,15 @@
CommonPage.IsRemote = true;
var sendBytes = new byte [29];
- var b1 = System.Text.Encoding.UTF8.GetBytes (userName);
+ var b1 = CommonPage.MyEncodingGB2312.GetBytes (userName);
byte [] ggn = new byte [20];
Array.Copy (b1, 0, ggn, 0, 20 < b1.Length ? 20 : b1.Length);
Array.Copy (ggn, 0, sendBytes, 9, 20);
+
+ string newIp = "118.31.3.103";
+ if(Language.CurrentLanguage!= "Chinese") {
+ newIp = "157.175.231.123";
+ }
new System.Threading.Thread (() => {
@@ -241,11 +247,12 @@
MainPage.Loading.Start ();
});
try {
+ //璇诲彇鏃ф湇鍔″櫒涓婄殑宸ョ▼鍒楄〃
var sss = Control.ControlBytesSendHasReturn (Command.GetRemoteOnePortListInfo, 0xFB, 0xFB, sendBytes);
+ var oldGatewayList = new List<GatewayBase> ();
if (sss != null) {
try {
if (sss [1] == 248) {
-
Application.RunOnMainThread (() => {
MainPage.Loading.Start ();
rightButton1.Text = txt_connectionSucceeded;
@@ -253,6 +260,7 @@
});
var count = sss [2] * 256 + sss [3];
+
for (int i = 1; i <= count; i++) {
byte [] arayImp = new byte [23];
if (b1.Length <= 20)
@@ -264,19 +272,20 @@
var oneProtData = Control.ControlBytesSendHasReturn (Command.GetRemoteOnePortInfo, 0xFB, 0xFB, arayImp);
if (oneProtData != null) {
try {
- var groupName = System.Text.Encoding.UTF8.GetString (oneProtData, 1, 20).Trim ('\0');//=============
- var projectName22 = System.Text.Encoding.UTF8.GetString (oneProtData, 23, 20).Trim ('\0');//=============
- var userName22 = System.Text.Encoding.UTF8.GetString (oneProtData, 43, 8).Trim ('\0');//=============
+ var groupName = CommonPage.MyEncodingGB2312.GetString (oneProtData, 1, 20).Trim ('\0');
+ var projectName22 = CommonPage.MyEncodingGB2312.GetString (oneProtData, 23, 20).Trim ('\0');
+ var userName22 = CommonPage.MyEncodingGB2312.GetString (oneProtData, 43, 8).Trim ('\0');
var isOnline = oneProtData [57] == 1;
- Application.RunOnMainThread (() => {
- RowLayout wirelessView = new RowLayout () {
- Height = Application.GetRealHeight (93),
- BackgroundColor = SkinStyle.Current.ViewColor,
- };
- listView.AddChidren (wirelessView);
- showGatewayRow (userName22,projectName22, wirelessView,isOnline);
- });
+ GatewayBase gatewayBase = new GatewayBase () {
+ Remote_GroupName = groupName,
+ Remote_ProjectName = projectName22,
+ Remote_UserName = userName22,
+ isOnline = isOnline,
+ };
+ oldGatewayList.Add (gatewayBase);
+
+
}catch (Exception ex) {
}
@@ -284,8 +293,77 @@
}
}
- }
- else if(sss[1] == 245) {
+
+
+
+
+ //璇诲彇鏂版湇鍔″櫒涓婄殑宸ョ▼鍒楄〃
+ var sss2 = Control.ControlBytesSendHasReturn (Command.GetRemoteOnePortListInfo, 0xFB, 0xFB, sendBytes, newIp);
+ var newGatewayList = new List<GatewayBase> ();
+ try {
+ if (sss [1] == 248) {
+ var countNew = sss [2] * 256 + sss [3];
+
+ for (int i = 1; i <= countNew; i++) {
+ byte [] arayImp = new byte [23];
+ if (b1.Length <= 20)
+ Array.Copy (b1, 0, arayImp, 1, b1.Length);
+ else
+ Array.Copy (b1, 0, arayImp, 1, 20);
+ arayImp [21] = (byte)(i / 256);
+ arayImp [22] = (byte)(i % 256);
+ var oneProtData = Control.ControlBytesSendHasReturn (Command.GetRemoteOnePortInfo, 0xFB, 0xFB, arayImp, newIp);
+ if (oneProtData != null) {
+ try {
+ var groupName = CommonPage.MyEncodingGB2312.GetString (oneProtData, 1, 20).Trim ('\0');
+ var projectName22 = CommonPage.MyEncodingGB2312.GetString (oneProtData, 23, 20).Trim ('\0');
+ var userName22 = CommonPage.MyEncodingGB2312.GetString (oneProtData, 43, 8).Trim ('\0');
+
+ var oldGateway = oldGatewayList.Find ((obj) => obj.Remote_GroupName == groupName &&
+ obj.Remote_ProjectName == projectName22 && obj.Remote_UserName == userName22);
+ if (oldGateway != null) {
+ oldGateway.isMoveToNewServer = true;
+ }
+ } catch (Exception ex) {
+
+ }
+ } else {
+
+ }
+ }
+ } else if (sss [1] == 245) {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = txt_NoData;
+ rightButton1.TextColor = 0x99FF0000;
+ });
+ } else {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = txt_QueryFailed;
+ rightButton1.TextColor = 0x99FF0000;
+ });
+ }
+ } catch (Exception ex) {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = txt_DataError;
+ rightButton1.TextColor = 0x99FF0000;
+ });
+ } finally {
+
+ }
+
+
+ Application.RunOnMainThread (() => {
+ foreach (var one in oldGatewayList) {
+ RowLayout wirelessView = new RowLayout () {
+ Height = Application.GetRealHeight (93),
+ BackgroundColor = SkinStyle.Current.ViewColor,
+ };
+ listView.AddChidren (wirelessView);
+ showGatewayRow (one,wirelessView);
+ }
+ });
+
+ } else if(sss[1] == 245) {
Application.RunOnMainThread (() => {
rightButton1.Text = txt_NoData;
rightButton1.TextColor = 0x99FF0000;
@@ -338,7 +416,7 @@
/// <summary>
/// 鏄剧ず
/// </summary>
- void showGatewayRow (string userName,string projectName, RowLayout wirelessView,bool isOnline)
+ void showGatewayRow (GatewayBase gatewayBase, RowLayout wirelessView)
{
Button pointButton1 = new Button () {
@@ -347,7 +425,7 @@
X = Application.GetRealWidth (60),
Radius = (uint)Application.GetRealHeight (7),
Gravity = Gravity.CenterVertical,
- BackgroundColor = isOnline ? 0xFF00FF00: 0xFF000000
+ BackgroundColor = gatewayBase.isOnline ? 0xFF00FF00: 0xFF000000
};
wirelessView.AddChidren (pointButton1);
@@ -355,7 +433,7 @@
Button nameButton1 = new Button () {
Width = Application.GetRealWidth (342),
Height = LayoutParams.MatchParent,
- Text = projectName,
+ Text = gatewayBase.Remote_ProjectName,
TextAlignment = TextAlignment.CenterLeft,
X = pointButton1.Right + Application.GetRealWidth (20),
TextColor = SkinStyle.Current.TextColor1,
@@ -373,15 +451,20 @@
TextSize = 12,
Text = text_link,
};
- if (isOnline)
- wirelessView.AddChidren (rightButton1);
- EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
- LinkOnePort (userName,projectName);
- };
- nameButton1.MouseUpEventHandler = eventHandler;
- rightButton1.MouseUpEventHandler = eventHandler;
- wirelessView.MouseUpEventHandler = eventHandler;
+ if (gatewayBase.isMoveToNewServer && !gatewayBase.isOnline) {
+ wirelessView.AddChidren (rightButton1);
+ rightButton1.Text = text_Upgraded;
+ } else {
+ if (gatewayBase.isOnline)
+ wirelessView.AddChidren (rightButton1);
+ EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
+ LinkOnePort (gatewayBase.Remote_UserName, gatewayBase.Remote_ProjectName);
+ };
+ nameButton1.MouseUpEventHandler = eventHandler;
+ rightButton1.MouseUpEventHandler = eventHandler;
+ wirelessView.MouseUpEventHandler = eventHandler;
+ }
}
void LinkOnePort (string userName, string projectName) {
diff --git a/SmartHome/UI/SimpleControl/Phone/System/SystemMiddle.cs b/SmartHome/UI/SimpleControl/Phone/System/SystemMiddle.cs
index ed97bf6..bdaaecd 100644
--- a/SmartHome/UI/SimpleControl/Phone/System/SystemMiddle.cs
+++ b/SmartHome/UI/SimpleControl/Phone/System/SystemMiddle.cs
@@ -90,7 +90,6 @@
System.Threading.Tasks.Task.Run (() => {
try {
#region 鎼滅储璁惧
- CommonPage.LocalPhoneFindDevice = true;
CommonPage.RandomHigh = (byte)new Random ().Next (255);
CommonPage.RandomLow = (byte)new Random ().Next (255);
CommonPage.GateWayList.Clear ();
@@ -146,7 +145,6 @@
ShowGateWayView ();
});
- CommonPage.LocalPhoneFindDevice = false;
#endregion
} catch (Exception ex) {
Console.WriteLine (ex.ToString ());
@@ -209,7 +207,6 @@
Button rightButton1 = new Button () {
X = Application.GetRealWidth (480),
Width = Application.GetRealWidth (150),
- Height = Application.GetRealHeight (40),
Gravity = Gravity.CenterVertical,
TextAlignment = TextAlignment.CenterLeft,
TextColor = SkinStyle.Current.TextColor1,
@@ -219,87 +216,173 @@
};
wirelessView.AddChidren (rightButton1);
- new System.Threading.Thread (() => {
- var serverIPBytes = Control.ControlBytesSendHasReturn (Command.ReadGatewayServerIP, common.SubnetID, common.DeviceID, new byte [] { });
- if (serverIPBytes != null) {
- try {
- string serverIP1 = serverIPBytes [0].ToString () + "." + serverIPBytes [1].ToString () + "." +
- serverIPBytes [2].ToString () + "." + serverIPBytes [3].ToString ();
- string serverIP1Point = ((serverIPBytes [4] * 256) + serverIPBytes [5]).ToString ();
- string serverIP2 = serverIPBytes [6].ToString () + "." + serverIPBytes [7].ToString () + "." +
- serverIPBytes [8].ToString () + "." + serverIPBytes [9].ToString ();
- string serverIP2Point = ((serverIPBytes [10] * 256) + serverIPBytes [11]).ToString ();
- if (serverIP1 == "118.31.3.103" || serverIP2 == "118.31.3.103") {
- Application.RunOnMainThread (() => {
- rightButton1.Text = text_Upgraded;
- rightButton1.TextColor = 0xFF00FF00;
- return;
- });
- } else if (serverIP1 != "115.29.251.24" && serverIP2 != "115.29.251.24") {
- Application.RunOnMainThread (() => {
- rightButton1.Text = text_UnknownVersion;
- rightButton1.TextColor = 0xFF00FF00;
- return;
- });
- } else {
- Application.RunOnMainThread (() => {
- rightButton1.Text = text_Upgrading;
- rightButton1.TextColor = 0xFF0000FF;
- });
- if (serverIP1 == "115.29.251.24") {
- serverIP1 = "118.31.3.103";
- serverIP1Point = "9999";
+ if (Language.CurrentLanguage != "Chinese" ) {
+ //淇敼鍥藉鏈嶅姟鍣�
+ new System.Threading.Thread (() => {
+ var serverIPBytes = Control.ControlBytesSendHasReturn (Command.ReadGatewayServerIP, common.SubnetID, common.DeviceID, new byte [] { });
+ if (serverIPBytes != null) {
+ try {
+ string serverIP1 = serverIPBytes [0].ToString () + "." + serverIPBytes [1].ToString () + "." +
+ serverIPBytes [2].ToString () + "." + serverIPBytes [3].ToString ();
+ string serverIP1Point = ((serverIPBytes [4] * 256) + serverIPBytes [5]).ToString ();
+ string serverIP2 = serverIPBytes [6].ToString () + "." + serverIPBytes [7].ToString () + "." +
+ serverIPBytes [8].ToString () + "." + serverIPBytes [9].ToString ();
+ string serverIP2Point = ((serverIPBytes [10] * 256) + serverIPBytes [11]).ToString ();
- serverIPBytes [0] = 118;
- serverIPBytes [1] = 31;
- serverIPBytes [2] = 3;
- serverIPBytes [3] = 103;
- serverIPBytes [4] = Convert.ToByte (9999 / 256);
- serverIPBytes [5] = Convert.ToByte (9999 % 256);
-
- }
- if (serverIP2 == "115.29.251.24") {
- serverIP2 = "118.31.3.103";
- serverIP2Point = "9999";
-
- serverIPBytes [0 + 6] = 118;
- serverIPBytes [1 + 6] = 31;
- serverIPBytes [2 + 6] = 3;
- serverIPBytes [3 + 6] = 103;
- serverIPBytes [4 + 6] = Convert.ToByte (9999 / 256);
- serverIPBytes [5 + 6] = Convert.ToByte (9999 % 256);
-
- }
- var mobytes = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInternetInfo, common.SubnetID, common.DeviceID, serverIPBytes);
- if (mobytes == null || mobytes [0] == 0xF5) {
+ if (serverIP1 == "157.175.231.123" || serverIP2 == "157.175.231.123") {//宸存灄鏈嶅姟鍣�
Application.RunOnMainThread (() => {
+ rightButton1.Text = text_Upgraded;
+ rightButton1.TextColor = 0xFF00FF00;
+ });
+ } else if (serverIP1 == "115.29.251.24" || serverIP2 == "115.29.251.24"//鏃ф湇鍔″櫒
+ || serverIP1 == "118.31.3.103" || serverIP2 == "118.31.3.103") {//鏂板浗鍐呮湇鍔″櫒
+
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_Upgrading;
+ rightButton1.TextColor = 0xFF0000FF;
+ });
+ if (serverIP1 == "115.29.251.24" || serverIP1 == "118.31.3.103") {//鏃ф湇鍔″櫒//鏂板浗鍐呮湇鍔″櫒
+ serverIP1 = "157.175.231.123";//宸存灄鏈嶅姟鍣�
+ serverIP1Point = "9999";
+
+ serverIPBytes [0] = 157;
+ serverIPBytes [1] = 175;
+ serverIPBytes [2] = 231;
+ serverIPBytes [3] = 123;
+ serverIPBytes [4] = Convert.ToByte (9999 / 256);
+ serverIPBytes [5] = Convert.ToByte (9999 % 256);
+
+ }
+ if (serverIP2 == "115.29.251.24" || serverIP2 == "118.31.3.103") {//鏃ф湇鍔″櫒//鏂板浗鍐呮湇鍔″櫒
+ serverIP2 = "157.175.231.123";//宸存灄鏈嶅姟鍣�
+ serverIP2Point = "9999";
+
+ serverIPBytes [0 + 6] = 157;
+ serverIPBytes [1 + 6] = 175;
+ serverIPBytes [2 + 6] = 231;
+ serverIPBytes [3 + 6] = 123;
+ serverIPBytes [4 + 6] = Convert.ToByte (9999 / 256);
+ serverIPBytes [5 + 6] = Convert.ToByte (9999 % 256);
+
+ }
+ var mobytes = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInternetInfo, common.SubnetID, common.DeviceID, serverIPBytes);
+ if (mobytes == null || mobytes [0] == 0xF5) {
Application.RunOnMainThread (() => {
- rightButton1.Text = text_UpgradeFailed;
- rightButton1.TextColor = 0x99ff0000;
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_UpgradeFailed;
+ rightButton1.TextColor = 0x99ff0000;
+ });
});
+ } else {
+ Application.RunOnMainThread (() => {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_Upgraded;
+ rightButton1.TextColor = 0xFF00FF00;
+ });
+ });
+ }
+ } else {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_UnknownVersion;
+ rightButton1.TextColor = 0xFF00FF00;
+ });
+ }
+
+
+ } catch (Exception ex) {
+ Console.WriteLine ("涓�绔彛杩滅▼ip淇℃伅杞瘧澶辫触.");
+ }
+ } else {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_readFailure;
+ rightButton1.TextColor = 0x99FF0000;
+ });
+ }
+ }) { IsBackground = true }.Start ();
+
+ } else {
+ new System.Threading.Thread (() => {
+ var serverIPBytes = Control.ControlBytesSendHasReturn (Command.ReadGatewayServerIP, common.SubnetID, common.DeviceID, new byte [] { });
+ if (serverIPBytes != null) {
+ try {
+ string serverIP1 = serverIPBytes [0].ToString () + "." + serverIPBytes [1].ToString () + "." +
+ serverIPBytes [2].ToString () + "." + serverIPBytes [3].ToString ();
+ string serverIP1Point = ((serverIPBytes [4] * 256) + serverIPBytes [5]).ToString ();
+ string serverIP2 = serverIPBytes [6].ToString () + "." + serverIPBytes [7].ToString () + "." +
+ serverIPBytes [8].ToString () + "." + serverIPBytes [9].ToString ();
+ string serverIP2Point = ((serverIPBytes [10] * 256) + serverIPBytes [11]).ToString ();
+
+ if (serverIP1 == "118.31.3.103" || serverIP2 == "118.31.3.103") {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_Upgraded;
+ rightButton1.TextColor = 0xFF00FF00;
+ return;
+ });
+ } else if (serverIP1 != "115.29.251.24" && serverIP2 != "115.29.251.24") {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_UnknownVersion;
+ rightButton1.TextColor = 0xFF00FF00;
+ return;
});
} else {
Application.RunOnMainThread (() => {
- Application.RunOnMainThread (() => {
- rightButton1.Text = text_Upgraded;
- rightButton1.TextColor = 0xFF00FF00;
- });
+ rightButton1.Text = text_Upgrading;
+ rightButton1.TextColor = 0xFF0000FF;
});
- }
- }
- } catch (Exception ex) {
- Console.WriteLine ("涓�绔彛杩滅▼ip淇℃伅杞瘧澶辫触.");
- }
- } else {
- Application.RunOnMainThread (() => {
- rightButton1.Text = text_UnknownVersion;
- rightButton1.TextColor = 0xFF00FF00;
- });
- }
- }) { IsBackground = true }.Start ();
- }
+ if (serverIP1 == "115.29.251.24") {
+ serverIP1 = "118.31.3.103";
+ serverIP1Point = "9999";
+ serverIPBytes [0] = 118;
+ serverIPBytes [1] = 31;
+ serverIPBytes [2] = 3;
+ serverIPBytes [3] = 103;
+ serverIPBytes [4] = Convert.ToByte (9999 / 256);
+ serverIPBytes [5] = Convert.ToByte (9999 % 256);
+
+ }
+ if (serverIP2 == "115.29.251.24") {
+ serverIP2 = "118.31.3.103";
+ serverIP2Point = "9999";
+
+ serverIPBytes [0 + 6] = 118;
+ serverIPBytes [1 + 6] = 31;
+ serverIPBytes [2 + 6] = 3;
+ serverIPBytes [3 + 6] = 103;
+ serverIPBytes [4 + 6] = Convert.ToByte (9999 / 256);
+ serverIPBytes [5 + 6] = Convert.ToByte (9999 % 256);
+
+ }
+ var mobytes = Control.ControlBytesSendHasReturn (Command.SetGateWayModelInternetInfo, common.SubnetID, common.DeviceID, serverIPBytes);
+ if (mobytes == null || mobytes [0] == 0xF5) {
+ Application.RunOnMainThread (() => {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_UpgradeFailed;
+ rightButton1.TextColor = 0x99ff0000;
+ });
+ });
+ } else {
+ Application.RunOnMainThread (() => {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_Upgraded;
+ rightButton1.TextColor = 0xFF00FF00;
+ });
+ });
+ }
+ }
+ } catch (Exception ex) {
+ Console.WriteLine ("涓�绔彛杩滅▼ip淇℃伅杞瘧澶辫触.");
+ }
+ } else {
+ Application.RunOnMainThread (() => {
+ rightButton1.Text = text_readFailure;
+ rightButton1.TextColor = 0x99ff0000;
+ });
+ }
+ }) { IsBackground = true }.Start ();
+ }
+ }
}
--
Gitblit v1.8.0