蓝牙断开重连相关逻辑优化
This commit is contained in:
1 parent
87a0e7fb6d
commit
f25d0b7b8c
11 files changed
+455
-27
No files matched your search
@@ -116,6 +116,10 @@ namespace Assets.Scripts.Ble
|
||||
private void ManagerStatusChanged(BleMobileThread sender, WclBleManagerStatus status)
|
||||
{
|
||||
this.BleState = BleMobileInterface.StateFromNativeState(status);
|
||||
if (this.BleState == BleState.Off)
|
||||
{
|
||||
ClearAllCallbacks();
|
||||
}
|
||||
}
|
||||
|
||||
private void WatcherScanInfoReceived(BleMobileThread sender, string address, string name, int rssi,string[] uuids)
|
||||
@@ -348,6 +352,7 @@ namespace Assets.Scripts.Ble
|
||||
BluetoothLEHardwareInterface.DisconnectPeripheral(peripheral.Address, (address) =>
|
||||
{
|
||||
Debug.Log("断开回调"+ address);
|
||||
PeripheralDisconnected(address,peripheral);
|
||||
peripheralDisconnectedEvent(this, peripheral, null, true);
|
||||
callback?.Invoke();
|
||||
});
|
||||
@@ -374,6 +379,17 @@ namespace Assets.Scripts.Ble
|
||||
{
|
||||
bleMobileThread?.Stop();
|
||||
}
|
||||
|
||||
public void ClearAllCallbacks()
|
||||
{
|
||||
callbacks?.Clear();
|
||||
servicesCallbacks?.Clear();
|
||||
characteristicNotificationCallbacks?.Clear();
|
||||
characteristicReadCallbacks?.Clear();
|
||||
characteristicsDiscoveredCallbacks?.Clear();
|
||||
_discoveredCallback = null;
|
||||
_pCache?.Clear();
|
||||
}
|
||||
|
||||
//发现服务列表
|
||||
public void DiscoverServices(BlePeripheralInfo peripheral, Action<IBleWinHwInterface, BlePeripheralInfo, BleResponse<List<BleServiceInfo>>> callback)
|
||||
|
||||
Reference in new issue
Block a user