From 23420922845c9e77019a55c3b3e3271eb1ec261e Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 13 七月 2020 11:42:18 +0800
Subject: [PATCH] 新版本
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlWifiLogic.cs | 155 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 148 insertions(+), 7 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlWifiLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlWifiLogic.cs
old mode 100644
new mode 100755
index d34f704..ce24a39
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlWifiLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlWifiLogic.cs
@@ -40,7 +40,24 @@
{
string myId = this.SSID;
- if (myId.StartsWith("hdlZigbeeGW") == true)
+ if (myId != null && myId.StartsWith("hdlZigbeeGW") == true)
+ {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ /// <summary>
+ /// 褰撳墠鏄惁鏄疢ini缃戝叧鐑偣
+ /// </summary>
+ public bool IsMiniGatewayHotspot
+ {
+ get
+ {
+ string myId = this.SSID;
+
+ if (myId != null && myId.StartsWith("hdlZigbeeGW-") == true)
{
return true;
}
@@ -54,12 +71,12 @@
public string SSID
{
get
- {
+ {
#if iOS
- string ssiD = Shared.WiimuUPnP.SSID;
- if (string.IsNullOrEmpty(ssiD) == false && ssiD.StartsWith("\"") && ssiD.EndsWith("\""))
- {
- ssiD = ssiD.Substring(1, ssiD.Length - 2);
+ string ssiD = Shared.WiimuUPnP.SSID;
+ if (string.IsNullOrEmpty(ssiD) == false && ssiD.StartsWith("\"") && ssiD.EndsWith("\""))
+ {
+ ssiD = ssiD.Substring(1, ssiD.Length - 2);
}
return ssiD;
#endif
@@ -97,7 +114,6 @@
/// </summary>
private Com.Mediatek.Elian.ElianNative hdlWiFi = null;
#endif
-
/// <summary>
/// TCP鍗忚
/// </summary>
@@ -110,6 +126,40 @@
/// Ap妯″紡缃戝叧杩斿洖鐨勭閽�
/// </summary>
private string randDesKey = null;
+ /// <summary>
+ /// 鏄惁宸茬粡娣诲姞缃戠粶鍙樺寲鐩戝惉
+ /// </summary>
+ private bool hadAddListenNetWork = false;
+
+ /// <summary>
+ /// 鑳藉惁璁块棶http
+ /// </summary>
+ private bool m_CanAccessHttp = true;
+ /// <summary>
+ /// 涓婁竴娆¤闂甴ttp鐨勬椂闂�
+ /// </summary>
+ private DateTime oldAccessHttpTime = DateTime.Now;
+ /// <summary>
+ /// 鑳藉惁璁块棶http
+ /// </summary>
+ public bool CanAccessHttp
+ {
+ set
+ {
+ m_CanAccessHttp = value;
+ oldAccessHttpTime = DateTime.Now;
+ }
+ get
+ {
+ //8绉掑悗鍏佽鍐嶆璁块棶
+ if (m_CanAccessHttp == true || (DateTime.Now - oldAccessHttpTime).TotalMilliseconds > 8 * 1000)
+ {
+ oldAccessHttpTime = DateTime.Now;
+ return true;
+ }
+ return false;
+ }
+ }
#endregion
@@ -269,6 +319,97 @@
#endregion
+ #region 鈻� 鐩戝惉缃戠粶鍙樺寲_______________________
+
+ /// <summary>
+ /// 寮�鍚洃鍚綉缁�
+ /// </summary>
+ public void StartListenNetWork()
+ {
+ if (hadAddListenNetWork == true)
+ {
+ return;
+ }
+ hadAddListenNetWork = true;
+
+#if Android
+ //寮�鍚洃鍚畨鍗撶綉缁滃彉鍖�
+ BaseActivity.NetworkStateChanged += (value) =>
+ {
+ //缃戠粶鍙樺寲
+ this.NetworkStateChanged(value);
+ };
+#endif
+
+#if iOS
+ //寮�鍚洃鍚琁OS缃戠粶鍙樺寲
+ GateWay.Ios.Reachability.ReachabilityChanged += (sender, e) =>
+ {
+ var internetStatus = GateWay.Ios.Reachability.InternetConnectionStatus();
+ if (internetStatus == GateWay.Ios.NetworkStatus.NotReachable)//娌℃湁缃戠粶杩炴帴 0
+ {
+ //缃戠粶鍙樺寲
+ this.NetworkStateChanged(0);
+ }
+ else if (internetStatus == GateWay.Ios.NetworkStatus.ReachableViaCarrierDataNetwork)//3,4G鐨勭綉缁滆繛鎺� 1
+ {
+ //缃戠粶鍙樺寲
+ this.NetworkStateChanged(1);
+ }
+ else if (internetStatus == GateWay.Ios.NetworkStatus.ReachableViaWiFiNetwork) //wifi鐨勭綉缁滆繛鎺� 2
+ {
+ //缃戠粶鍙樺寲
+ this.NetworkStateChanged(2);
+ }
+ };
+#endif
+ }
+
+ /// <summary>
+ /// 鐩戝惉瀹夊崜缃戠粶鍙樺寲
+ /// </summary>
+ /// <param name="value">0:娌℃湁缃戠粶 1:4G 2:wifi</param>
+ private void NetworkStateChanged(int value)
+ {
+ //娌℃湁缃戠粶
+ if (value == 0)
+ {
+ this.CanAccessHttp = false;
+ //鍏抽棴Socket
+ ZigBee.Common.Application.FindGateWaySocket.Stop();
+ }
+ //WIFI鎴栬��4G鏃�
+ if (value == 1 || value == 2)
+ {
+ //鍏佽鑱旂綉
+ this.CanAccessHttp = true;
+
+ //妫�娴嬫槸鍚﹀凡缁忓畬鎴愯处鍙蜂俊鎭垵濮嬪寲
+ if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false
+ && Common.Config.Instance.HomeId != string.Empty)
+ {
+ HdlThreadLogic.Current.RunThread(() =>
+ {
+ ProgressBar.Show();
+ //閲嶆柊鍒濆鍖栬处鍙蜂俊鎭�
+ UserCenterLogic.ReInitUserAccoutInfo();
+ ProgressBar.Close();
+
+ }, ShowErrorMode.NO);
+ }
+ //閲嶆柊鍒濆鍖朣ocket
+ ZigBee.Common.Application.FindGateWaySocket.Stop();
+ if (value == 2)
+ {
+ ZigBee.Common.Application.FindGateWaySocket.Start();
+ }
+ //鏂帀鏈湴杩炴帴
+ HdlGatewayLogic.Current.ClearAllRealGateway();
+ }
+ }
+
+ #endregion
+
#region 鈻� 涓�鑸柟娉昣__________________________
#if Android
--
Gitblit v1.8.0