接入蓝牙基本结构
This commit is contained in:
1 parent
84e8b50bbf
commit
2f84f70a5f
152 files changed
+6426
-56
No files matched your search
@@ -10,6 +10,7 @@ using Assets.Scripts.Devices.Ant.Interfaces;
|
||||
using Assets.Scripts.UI.Control;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.UI.Prefab.Device;
|
||||
using Assets.Scripts.Devices;
|
||||
|
||||
public class ConnectDeviceModal : PFUIPanel
|
||||
{
|
||||
@@ -126,26 +127,26 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
{
|
||||
//Debug.Log(AntConnector.Instance().discoveredDevices.Count(d => d.Sensor == SensorType));
|
||||
|
||||
var devices = new List<AbstractAntDevice>();
|
||||
var a = AntConnector.Instance().discoveredDevices;
|
||||
var devices = new List<AbstractDevice>();
|
||||
//var a = AntConnector.Instance().discoveredDevices;
|
||||
switch (SensorType)
|
||||
{
|
||||
case SensorType.Cadence:
|
||||
devices = AntConnector.Instance().discoveredDevices.Where(d => d.Sensor == SensorType || (d is ICadenceDevice && d.State == DeviceState.Connected)).OrderBy(d=>d.Priority).ToList();
|
||||
devices = App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType || (d is ICadenceDevice && d.State == DeviceState.Connected)).OrderBy(d=>d.Priority).ToList();
|
||||
break;
|
||||
case SensorType.HeartRate:
|
||||
devices = AntConnector.Instance().discoveredDevices.Where(d => d.Sensor == SensorType || (d is IHeartRateDevice && d.State == DeviceState.Connected)).OrderBy(d => d.Priority).ToList();
|
||||
devices = App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType || (d is IHeartRateDevice && d.State == DeviceState.Connected)).OrderBy(d => d.Priority).ToList();
|
||||
break;
|
||||
case SensorType.Power:
|
||||
devices = AntConnector.Instance().discoveredDevices.Where(d => d.Sensor == SensorType || (d is IPowerDevice && d.State == DeviceState.Connected)).OrderBy(d=>d.Priority).ToList();
|
||||
devices = App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType || (d is IPowerDevice && d.State == DeviceState.Connected)).OrderBy(d=>d.Priority).ToList();
|
||||
break;
|
||||
case SensorType.Speed:
|
||||
break;
|
||||
case SensorType.SpeedCadence:
|
||||
devices = AntConnector.Instance().discoveredDevices.Where(d => d.Sensor == SensorType || (d is ISpeedDevice && d.State == DeviceState.Connected)).OrderBy(d => d.Priority).ToList();
|
||||
devices = App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType || (d is ISpeedDevice && d.State == DeviceState.Connected)).OrderBy(d => d.Priority).ToList();
|
||||
break;
|
||||
case SensorType.Trainer:
|
||||
devices = AntConnector.Instance().discoveredDevices.Where(d => d.Sensor == SensorType).ToList();
|
||||
devices = App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType).ToList();
|
||||
break;
|
||||
case SensorType.VirtualPower:
|
||||
break;
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using System.Collections.Concurrent;
|
||||
using UnityEngine;
|
||||
using Newtonsoft.Json;
|
||||
using Assets.Scripts.Devices;
|
||||
|
||||
namespace Assets.Scripts.UI.Prefab.Device
|
||||
{
|
||||
@@ -36,7 +37,7 @@ namespace Assets.Scripts.UI.Prefab.Device
|
||||
}
|
||||
}
|
||||
|
||||
public static void Add(AbstractAntDevice antDevice)
|
||||
public static void Add(AbstractDevice antDevice)
|
||||
{
|
||||
|
||||
Debug.Log("添加设备" + antDevice.DeviceNumber);
|
||||
@@ -52,7 +53,7 @@ namespace Assets.Scripts.UI.Prefab.Device
|
||||
Write();
|
||||
}
|
||||
|
||||
public static bool Exist(AbstractAntDevice antDevice)
|
||||
public static bool Exist(AbstractDevice antDevice)
|
||||
{
|
||||
ushort a;
|
||||
if(dict.TryGetValue(antDevice.Sensor.ToString(), out a))
|
||||
@@ -63,7 +64,7 @@ namespace Assets.Scripts.UI.Prefab.Device
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void Remove(AbstractAntDevice antDevice)
|
||||
public static void Remove(AbstractDevice antDevice)
|
||||
{
|
||||
if(dict == null)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Assets.Scripts.Devices.Ant;
|
||||
using Assets.Scripts.Devices;
|
||||
using Assets.Scripts.Devices.Ant;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -9,7 +10,7 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
|
||||
{
|
||||
private bool isOn;
|
||||
private Text mText;
|
||||
public AbstractAntDevice DeviceInfo
|
||||
public AbstractDevice DeviceInfo
|
||||
{
|
||||
get;set;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ using Assets.Scripts.UI.UIEffect;
|
||||
using Assets.Scripts;
|
||||
using DG.Tweening;
|
||||
using Assets.Scripts.UI.Prefab.Device;
|
||||
using Assets.Scripts.Devices;
|
||||
|
||||
public class DeviceView : MonoBehaviour
|
||||
{
|
||||
@@ -225,7 +226,7 @@ public class DeviceView : MonoBehaviour
|
||||
|
||||
title.text = GetTitle();
|
||||
|
||||
var hasDevice = AntConnector.Instance().discoveredDevices.Any(d => d.Sensor == SensorType);
|
||||
var hasDevice = App.MainDeviceAdapter.GetDevices().Any(d => d.Sensor == SensorType);
|
||||
if (hasDevice)
|
||||
{
|
||||
mSearchButton.SetActive(false);
|
||||
@@ -309,7 +310,7 @@ public class DeviceView : MonoBehaviour
|
||||
}
|
||||
|
||||
|
||||
string GetValue(AbstractAntDevice connectedDevice)
|
||||
string GetValue(AbstractDevice connectedDevice)
|
||||
{
|
||||
switch (SensorType)
|
||||
{
|
||||
@@ -338,19 +339,20 @@ public class DeviceView : MonoBehaviour
|
||||
}
|
||||
return "";
|
||||
}
|
||||
AbstractAntDevice GetCurrentDevice()
|
||||
AbstractDevice GetCurrentDevice()
|
||||
{
|
||||
return AntConnector.Instance().discoveredDevices.FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType);
|
||||
//return AntConnector.Instance().discoveredDevices.FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType);
|
||||
return App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取已经连接的设备
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
AbstractAntDevice GetDevice()
|
||||
AbstractDevice GetDevice()
|
||||
{
|
||||
//return AntConnector.Instance().discoveredDevices.FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType);
|
||||
var devices = AntConnector.Instance().discoveredDevices.Where(d => (d.State == DeviceState.Connected));
|
||||
var devices = App.MainDeviceAdapter.GetDevices().Where(d => (d.State == DeviceState.Connected));
|
||||
switch (SensorType)
|
||||
{
|
||||
case SensorType.None:
|
||||
|
||||
Reference in new issue
Block a user