小调整
This commit is contained in:
1 parent
a7ea02f70a
commit
53ec9c60ac
10 files changed
+42
-73
No files matched your search
@@ -4,8 +4,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ANT_Managed_Library;
|
||||
using Assets.Scripts.UI.Prefab.Device;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ant
|
||||
{
|
||||
@@ -36,6 +34,9 @@ namespace Assets.Scripts.Devices.Ant
|
||||
private bool IsBackgroundScanning { get; set; }
|
||||
//int searchingDeviceIndex = -1;
|
||||
|
||||
/// <summary>
|
||||
/// 可以搜索的设备
|
||||
/// </summary>
|
||||
private List<AbstractAntDevice> deviceList = new List<AbstractAntDevice>();
|
||||
|
||||
public bool IsAvailable = false;
|
||||
@@ -43,17 +44,28 @@ namespace Assets.Scripts.Devices.Ant
|
||||
/// 设备号,频道编号
|
||||
/// </summary>
|
||||
public readonly List<UserdChannel> usedChannels = new List<UserdChannel>();
|
||||
|
||||
/// <summary>
|
||||
/// 搜索到的设备
|
||||
/// </summary>
|
||||
public readonly List<AbstractAntDevice> discoveredDevices = new List<AbstractAntDevice>();
|
||||
|
||||
private Action<AbstractAntDevice> _action;
|
||||
private static AntConnector _antConnector;
|
||||
public static AntConnector Instance(Action<AbstractAntDevice> action = null)
|
||||
private Action<object> _log;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="action">探索到新的设备</param>
|
||||
/// <returns></returns>
|
||||
public static AntConnector Instance(Action<AbstractAntDevice> action = null,
|
||||
Action<object> log = null)
|
||||
{
|
||||
if (_antConnector == null)
|
||||
{
|
||||
_antConnector = new AntConnector();
|
||||
_antConnector._action = action;
|
||||
_antConnector._log = log;
|
||||
}
|
||||
|
||||
return _antConnector;
|
||||
@@ -226,7 +238,7 @@ namespace Assets.Scripts.Devices.Ant
|
||||
//设备断开连接
|
||||
else if (antEventId == ANT_ReferenceLibrary.ANTEventID.EVENT_RX_FAIL_GO_TO_SEARCH_0x08)
|
||||
{
|
||||
Debug.Log(antEventId.ToString() + ", " + string.Join(",", response.messageContents));
|
||||
_log?.Invoke(antEventId.ToString() + ", " + string.Join(",", response.messageContents));
|
||||
|
||||
var cc1 = usedChannels.Where(d => d.Index == channelIndex).FirstOrDefault();
|
||||
var dd1 = discoveredDevices.SingleOrDefault(d => d.searchProfile.deviceNumber.ToString() == cc1.DeviceNumber && d.searchProfile.deviceType.ToString() == cc1.DeviceTypeId);
|
||||
@@ -300,24 +312,20 @@ namespace Assets.Scripts.Devices.Ant
|
||||
if (device2 != null)
|
||||
{
|
||||
//ReSearch();
|
||||
_action?.Invoke(device2);
|
||||
if (device2.State == DeviceState.Connected)
|
||||
{
|
||||
device2.handleChannelResponse(response);
|
||||
return;
|
||||
}
|
||||
else if (device2.State == DeviceState.Disconnected)
|
||||
{
|
||||
//else if (device2.State == DeviceState.Disconnected)
|
||||
//{
|
||||
//var deviceInfo = deviceService.Get(App.CurrentUser.Id, $"{ device2.searchProfile.deviceNumber }:{ device2.searchProfile.deviceType }");
|
||||
//if (deviceInfo != null && deviceInfo.Paired)
|
||||
//{
|
||||
// device2.Connect();
|
||||
//}
|
||||
|
||||
if(_action != null)
|
||||
{
|
||||
_action(device2);
|
||||
}
|
||||
}
|
||||
//}
|
||||
//}
|
||||
return;
|
||||
}
|
||||
var device1 = deviceList.SingleOrDefault(d => d.searchProfile.deviceType == deviceTypeId);
|
||||
|
||||
Reference in new issue
Block a user