From d87400af518ebc9274f4447f06476959c3aa5102 Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期二, 14 七月 2020 16:29:42 +0800 Subject: [PATCH] Merge branch 'dev-tzy' into dev-2020xm --- ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs | 56 ++++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 38 insertions(+), 18 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs b/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs index e229871..2a5e850 100644 --- a/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Common/Application.cs @@ -31,7 +31,10 @@ { return; } - isInited = true; + isInited = true; + + //鍒濆鍖朣ocket + FindGateWaySocket.Start(); new System.Threading.Thread(async () => { @@ -93,8 +96,8 @@ } } - var broadcastIpAddress = new Shared.Net.NetWiFi().BroadcastIpAddress; - + var broadcastIpAddress = new Shared.Net.NetWiFi().BroadcastIpAddress; + if (Shared.Application.IsWifi) { if (0 < gateWayList.Count) @@ -149,11 +152,7 @@ FindGateWaySocket.BeginSend(new System.Net.IPEndPoint(broadcastIpAddress, 7624), broadBytes); } } - catch - { - //鍏抽棴Socket,涓嬫鍙戦�佷細鑷姩杩炴帴 - FindGateWaySocket.Stop(); - } + catch{} System.Threading.Thread.Sleep(500); } }) @@ -171,7 +170,6 @@ var bytes = new byte[1024]; var len = FindGateWaySocket.busSocket.Receive(bytes, bytes.Length, System.Net.Sockets.SocketFlags.None); - if (bytes[43] == 0xA2) { //骞挎挱鍥炲缃戝叧鐨勫熀鏈俊鎭鐞� @@ -279,12 +277,17 @@ } } } + else + { + //璋冭瘯鐢� + if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSocketReceiveDataToFile == 1) + { + var data33 = Encoding.UTF8.GetString(bytes).Replace("锟�)", string.Empty).TrimStart('\0').TrimEnd('\0'); + Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(3, data33); + } + } } - catch - { - //鍏抽棴Socket,涓嬫鍙戦�佷細鑷姩杩炴帴 - FindGateWaySocket.Stop(); - } + catch{} } #endregion } @@ -385,10 +388,20 @@ { try { - Start(7624); - busSocket.BeginSendTo(bytes, 0, bytes.Length, SocketFlags.None, iPEndPoint, new AsyncCallback(asyncEndSend), null); + if (IsRunning) + { + busSocket.BeginSendTo(bytes, 0, bytes.Length, SocketFlags.None, iPEndPoint, new AsyncCallback(asyncEndSend), null); + } + } - catch { } + catch (Exception ex) + { + //璋冭瘯鐢� + if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSocketReceiveDataToFile == 1) + { + Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(3, "鍙戦�佸紓甯�(BeginSendTo)\r\n" + ex.Message); + } + } } /// <summary> @@ -401,7 +414,14 @@ { int bytesSent = busSocket.EndSendTo(iar); } - catch { } + catch(Exception ex) + { + //璋冭瘯鐢� + if (Shared.Phone.UserCenter.UserCenterResourse.HideOption.WriteSocketReceiveDataToFile == 1) + { + Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(3, "寮傛鍙戦�佺粨鏉熷紓甯�(asyncEndSend)\r\n" + ex.Message); + } + } } } } -- Gitblit v1.8.0