From b4d92451b2071c9762b519275601424e276db90d Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 16 三月 2021 13:59:49 +0800 Subject: [PATCH] Merge branch 'dev-tzy' into temp-wxr --- HDL_ON/UI/UI0-Stan/Logic/HdlBluetoothIOSLogic.cs | 114 +++++++++++++++++++++++++++----------------------------- 1 files changed, 55 insertions(+), 59 deletions(-) diff --git a/HDL_ON/UI/UI0-Stan/Logic/HdlBluetoothIOSLogic.cs b/HDL_ON/UI/UI0-Stan/Logic/HdlBluetoothIOSLogic.cs index 9ecd110..8900504 100644 --- a/HDL_ON/UI/UI0-Stan/Logic/HdlBluetoothIOSLogic.cs +++ b/HDL_ON/UI/UI0-Stan/Logic/HdlBluetoothIOSLogic.cs @@ -151,17 +151,20 @@ /// <param name="FinishEvent">鎼滅储缁撴潫鐨勪簨浠�</param> public void ScanBluetooth(int waitTime, Action<List<BluetoothInfo>> FinishEvent) { - //鍐嶆妫�娴嬫槸鍚﹁兘澶熸悳绱㈣摑鐗� - this.CheckCanScanBluetooth((result) => + HdlThreadLogic.Current.RunMain(() => { - if (result == true) + //鍐嶆妫�娴嬫槸鍚﹁兘澶熸悳绱㈣摑鐗� + this.CheckCanScanBluetooth((result) => { - HdlThreadLogic.Current.RunThread(() => + if (result == true) { - //寮�濮嬫悳绱㈣摑鐗� - this.DoScanBluetooth(waitTime, FinishEvent); - }); - } + HdlThreadLogic.Current.RunThread(() => + { + //寮�濮嬫悳绱㈣摑鐗� + this.DoScanBluetooth(waitTime, FinishEvent); + }); + } + }); }); } @@ -218,45 +221,48 @@ /// <param name="connectEvent">鍥犱负闇�瑕佸鏂瑰弽棣�,鎵�浠ヤ娇鐢ㄥ洖璋�(閾炬帴缁撴灉 false:杩炴帴澶辫触 true:杩炴帴鎴愬姛)</param> public void ContectBluetooth(BluetoothInfo bluetooth, Action<bool> connectEvent) { - try + HdlThreadLogic.Current.RunMain(() => { - //娣诲姞浜嬩欢 - ((BlueWifiDelegate)blufiClient.BlufiDelegate).StateEvent += (div, data) => + try { - //-1:寮傚父 1:姝e父 2:鍙戦�佹暟鎹垚鍔� 3:鍙戦�佹暟鎹け璐� - if (div == StatuEnum.A寮傚父) + //娣诲姞浜嬩欢 + ((BlueWifiDelegate)blufiClient.BlufiDelegate).StateEvent += (div, data) => { - //鍏抽棴閾炬帴 - this.DisContectBluetooth(); - connectEvent?.Invoke(false); - //鍙�氱煡涓�娆� - connectEvent = null; - } - else if (div == StatuEnum.A姝e父) - { - //閾炬帴寤虹珛鎴愬姛 - connectEvent?.Invoke(true); - //鍙�氱煡涓�娆� - connectEvent = null; - } - else if (div == StatuEnum.A鍙戦�佹垚鍔� || div == StatuEnum.A鍙戦�佸け璐�) - { - sendStatuValue = div == StatuEnum.A鍙戦�佹垚鍔� ? 1 : 0; - } - else if (div == StatuEnum.A钃濈墮鍙嶉) - { - //钃濈墮杩斿洖鐨勭粨鏋� - this.ReceiveEvent?.Invoke(data); - } - }; - //鎵ц閾炬帴 - this.blufiClient.Connect(bluetooth.Address); - } - catch - { - connectEvent?.Invoke(false); - connectEvent = null; - } + //-1:寮傚父 1:姝e父 2:鍙戦�佹暟鎹垚鍔� 3:鍙戦�佹暟鎹け璐� + if (div == StatuEnum.A寮傚父) + { + //鍏抽棴閾炬帴 + this.DisContectBluetooth(); + connectEvent?.Invoke(false); + //鍙�氱煡涓�娆� + connectEvent = null; + } + else if (div == StatuEnum.A姝e父) + { + //閾炬帴寤虹珛鎴愬姛 + connectEvent?.Invoke(true); + //鍙�氱煡涓�娆� + connectEvent = null; + } + else if (div == StatuEnum.A鍙戦�佹垚鍔� || div == StatuEnum.A鍙戦�佸け璐�) + { + sendStatuValue = div == StatuEnum.A鍙戦�佹垚鍔� ? 1 : 0; + } + else if (div == StatuEnum.A钃濈墮鍙嶉) + { + //钃濈墮杩斿洖鐨勭粨鏋� + this.ReceiveEvent?.Invoke(data); + } + }; + //鎵ц閾炬帴 + this.blufiClient.Connect(bluetooth.Address); + } + catch + { + connectEvent?.Invoke(false); + connectEvent = null; + } + }); } #endregion @@ -307,27 +313,17 @@ try { this.sendStatuValue = -1; - if (waiTime == 0) + HdlThreadLogic.Current.RunMain(() => { //鍙戦�佹暟鎹� var data = new Foundation.NSData(); data = i_data; blufiClient.PostCustomData(data); - //鐩存帴杩斿洖鎴愬姛 - return true; - } - else - { - //鎴栬浠栫敤鐨勬槸绾跨▼鏉ヨ皟鐢� - HdlThreadLogic.Current.RunMain(() => - { - //鍙戦�佹暟鎹� - var data = new Foundation.NSData(); - data = i_data; - blufiClient.PostCustomData(data); - }, ShowErrorMode.NO); - } + }, ShowErrorMode.NO); + + if (waiTime == 0) { return true; } + waiTime *= 5; while (this.sendStatuValue == -1 && waiTime > 0) { -- Gitblit v1.8.0