diff --git a/Assets/Plugins/Android/unityandroidbluetoothlelib.jar b/Assets/Plugins/Android/unityandroidbluetoothlelib.jar
index 8731dae3..55740ba1 100644
Binary files a/Assets/Plugins/Android/unityandroidbluetoothlelib.jar and b/Assets/Plugins/Android/unityandroidbluetoothlelib.jar differ
diff --git a/Assets/Scripts/Devices/Ant/AntConnector.cs b/Assets/Scripts/Devices/Ant/AntConnector.cs
index f2e63aaf..781bb005 100644
--- a/Assets/Scripts/Devices/Ant/AntConnector.cs
+++ b/Assets/Scripts/Devices/Ant/AntConnector.cs
@@ -544,5 +544,10 @@ namespace Assets.Scripts.Devices.Ant
channel.closeChannel(500);
channel.unassignChannel(500);
}
+
+ public void Remove(AbstractAntDevice device)
+ {
+ discoveredDevices.Remove(device);
+ }
}
}
diff --git a/Assets/Scripts/Devices/Ant/AntDeviceAdapter.cs b/Assets/Scripts/Devices/Ant/AntDeviceAdapter.cs
index 870d9cbf..83b5fecd 100644
--- a/Assets/Scripts/Devices/Ant/AntDeviceAdapter.cs
+++ b/Assets/Scripts/Devices/Ant/AntDeviceAdapter.cs
@@ -42,6 +42,18 @@ namespace Assets.Scripts.Devices.Ant
return AntConnector.Instance().discoveredDevices;
}
+ public override void Refresh()
+ {
+ var list = AntConnector.Instance().discoveredDevices.ToList();
+ foreach (var item in list)
+ {
+ if (item.State == Ant.DeviceState.Disconnected)
+ {
+ AntConnector.Instance().Remove(item);
+ }
+ }
+ }
+
public override void StartScan()
{
//throw new NotImplementedException();
diff --git a/Assets/Scripts/Devices/Ble/BleDeviceAdapter.cs b/Assets/Scripts/Devices/Ble/BleDeviceAdapter.cs
index 8cd6cb49..ec7df364 100644
--- a/Assets/Scripts/Devices/Ble/BleDeviceAdapter.cs
+++ b/Assets/Scripts/Devices/Ble/BleDeviceAdapter.cs
@@ -183,6 +183,19 @@ namespace Assets.Scripts.Devices.Ble
}
}
+ public override void Refresh()
+ {
+ var list = discoveredDevices.ToList();
+ foreach (var item in list)
+ {
+ if (item.Value.State == Ant.DeviceState.Disconnected)
+ {
+ item.Value.Dispose();
+ discoveredDevices.Remove(item.Key);
+ }
+ }
+ }
+
///
/// 清除未连接的设备
///
diff --git a/Assets/Scripts/Devices/DeviceAdapter.cs b/Assets/Scripts/Devices/DeviceAdapter.cs
index d38547e3..4a77ff78 100644
--- a/Assets/Scripts/Devices/DeviceAdapter.cs
+++ b/Assets/Scripts/Devices/DeviceAdapter.cs
@@ -24,7 +24,7 @@ namespace Assets.Scripts.Devices
{
}
-
+ public abstract void Refresh();
}
}
diff --git a/Assets/Scripts/UI/Prefab/Rower/RowerDeviceView.cs b/Assets/Scripts/UI/Prefab/Rower/RowerDeviceView.cs
index 93f74ddd..ff982fd9 100644
--- a/Assets/Scripts/UI/Prefab/Rower/RowerDeviceView.cs
+++ b/Assets/Scripts/UI/Prefab/Rower/RowerDeviceView.cs
@@ -129,14 +129,35 @@ public class RowerDeviceView : MonoBehaviour
UIManager.AddEvent(gameObject, EventTriggerType.PointerClick, b =>
{
if (!mPairButton.activeInHierarchy && !mDisconnectButton.activeInHierarchy) return;
- connectButtonClick();
+ var device = GetDevice();
+ if (device != null && device.State == DeviceState.Connected)
+ {
+ UIManager.ShowConfirm("警告", "是否断开该设备?", () =>
+ {
+ device.Disconnect(false);
+ UIManager.CloseConfirm();
+ }, 2, () => {
+ UIManager.CloseConfirm();
+ });
+ }
+ else
+ {
+ connectButtonClick();
+ }
});
UIManager.AddEvent(mDisconnectButton, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction(e => {
- //var device = GetDevice();
- //if(device != null && device.State == DeviceState.Connected)
- //{
- // device.Disconnect();
- //}
+ UIManager.ShowConfirm("警告", "是否断开该设备?", () =>
+ {
+ var device = GetDevice();
+ if (device != null && device.State == DeviceState.Connected)
+ {
+ device.Disconnect(false);
+ }
+ UIManager.CloseConfirm();
+ }, 2, () => {
+ UIManager.CloseConfirm();
+ });
+ return;
#if UNITY_IOS || UNITY_ANDROID
var obj = Resources.Load("UI/Prefab/Device/Mobile/ConnectDeviceModal");