设备连接微调
This commit is contained in:
1 parent
afb8c358f5
commit
ad26419654
7 files changed
+55
-21
No files matched your search
@@ -211,6 +211,7 @@ namespace Assets.Scripts.Ble
|
||||
{
|
||||
this.callbacks.Add(info, callback);
|
||||
}
|
||||
Debug.Log("try connect device" + info.Name + this.callbacks.Count.ToString());
|
||||
if (this.callbacks.Count == 1)
|
||||
{
|
||||
BleResponse s = new BleResponse();
|
||||
@@ -221,6 +222,7 @@ namespace Assets.Scripts.Ble
|
||||
{
|
||||
callback?.Invoke(self, info, s);
|
||||
this.callbacks.Remove(info);
|
||||
Debug.Log("连接成功!");
|
||||
if (this.callbacks.Any())
|
||||
{
|
||||
this.ConnectPeripheral(this.callbacks.First().Key, this.callbacks.First().Value);
|
||||
@@ -233,6 +235,7 @@ namespace Assets.Scripts.Ble
|
||||
CharacteristicsDiscovered(address, service, characteristic);
|
||||
}, (address) =>
|
||||
{
|
||||
Debug.Log("disconnect device:" + address);
|
||||
PeripheralDisconnected(address, info);
|
||||
});
|
||||
}
|
||||
@@ -311,6 +314,7 @@ namespace Assets.Scripts.Ble
|
||||
{
|
||||
BluetoothLEHardwareInterface.DisconnectPeripheral(peripheral.Address, (address) =>
|
||||
{
|
||||
Debug.Log("断开回调"+ address);
|
||||
peripheralDisconnectedEvent(this, peripheral, null, true);
|
||||
callback?.Invoke();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user