From f77a3add1e7ab266e473da9128bbe5758ba3a890 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期日, 20 十二月 2020 19:29:03 +0800
Subject: [PATCH] Merge branch 'NewFilePath' into CJL
---
HDL_ON/DAL/DriverLayer/Control.cs | 82 ++++++++++++++++++++++++++++++-----------
1 files changed, 60 insertions(+), 22 deletions(-)
diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
old mode 100755
new mode 100644
index 1149ee5..2e8555f
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -25,6 +25,8 @@
public class Control
{
+
+
static Control _control;
public static Control Ins
{
@@ -58,6 +60,14 @@
return t.ToString();
}
+ /// <summary>
+ /// 鏄惁鎼滅储鏈湴缃戝叧鎴愬姛
+ /// </summary>
+ public bool IsSearchLocalGatewaySuccessful = false;
+
+ /// <summary>
+ ///
+ /// </summary>
bool _gatewayOnline = false;
/// <summary>
/// 缃戝叧鏄惁鍦ㄧ嚎
@@ -181,30 +191,56 @@
/// </summary>
public void SearchLoaclGateway()
{
- OpenUdp(DB_ResidenceData.Instance.GatewayType == 0 ? 6000 : 8585);
- new System.Threading.Thread(() =>
+ MainPage.Log($"鎼滅储鏈湴缃戝叧鍒楄〃锛岀綉鍏崇被鍨�:{DB_ResidenceData.Instance.GatewayType}");
+ if (MainPage.InternetStatus == 0)
{
- for (int i = 0; i < 5; i++)
- {
- if (GatewayOnline)
- break;
- if (DB_ResidenceData.Instance.GatewayType == 0)
- {
- new Control_Udp().ControlBytesSend(Command.ReadGateway, 255, 255, new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) });
- }
- else if (DB_ResidenceData.Instance.GatewayType == 1)
- {
- new Control_Udp().SearchLocalGateway();
- }
- System.Threading.Thread.Sleep(500);
- }
- })
- { IsBackground = true }.Start();
- if (!GatewayOnline)//缃戝叧涓嶅湪绾跨殑鏃跺�欐墠鍙皾璇曡繙绋嬭繛鎺�
- {
- Ins.IsRemote = true;
- DAL.Mqtt.MqttClient.InitState();
+ Ins.GatewayOnline = false;
+ return;
}
+ else if (MainPage.InternetStatus == 1)
+ {
+ if (!Ins.IsRemote)
+ {
+ Ins.IsRemote = true;
+ DAL.Mqtt.MqttClient.InitState();
+ }
+ }
+ else if (MainPage.InternetStatus == 2)
+ {
+ OpenUdp(DB_ResidenceData.Instance.GatewayType == 0 ? 6000 : 8585);
+ //閲嶇疆鎼滅储缃戝叧鏍囧織
+ IsSearchLocalGatewaySuccessful = false;
+
+ new System.Threading.Thread(() =>
+ {
+ for (int i = 0; i < 5; i++)
+ {
+ if (IsSearchLocalGatewaySuccessful)
+ break;
+ if (DB_ResidenceData.Instance.GatewayType == 0)
+ {
+ new Control_Udp().ControlBytesSend(Command.ReadGateway, 255, 255, new byte[] { (byte)new Random().Next(255), (byte)new Random().Next(255) });
+ }
+ else if (DB_ResidenceData.Instance.GatewayType == 1)
+ {
+ new Control_Udp().SearchLocalGateway();
+ }
+ System.Threading.Thread.Sleep(500);
+ }
+
+ if (!IsSearchLocalGatewaySuccessful)
+ {
+ //鏈湴鎼滅储涓嶅埌缃戝叧
+ if (!Ins.IsRemote)
+ {
+ Ins.IsRemote = true;
+ DAL.Mqtt.MqttClient.InitState();
+ }
+ }
+ })
+ { IsBackground = true }.Start();
+ }
+
}
/// <summary>
@@ -440,6 +476,8 @@
var device = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceModule>(bodyJObj.objects.ToString());
if (device.device_mac == DB_ResidenceData.Instance.residenceGatewayMAC)
{
+ //鏈湴鎼滅储缃戝叧鎴愬姛
+ Control.Ins.IsSearchLocalGatewaySuccessful = true;
Ins.GatewayOnline = true;
if (!string.IsNullOrEmpty(device.gatewayId))
{
--
Gitblit v1.8.0