修改断线重连自动开始问题

This commit is contained in:
Caiyanpeng committed 2022-06-07 11:32:23 +08:00
1 parent bfc56dded5
commit ff878d5d50
9 files changed
+193 -182

No files matched your search

@@ -155,7 +155,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
/// 平均划桨频率
/// </summary>
public int AverageStrokeRate { get; set; } = 0;
private UInt32 _totalDistance = 0;
private UInt32 _totalDistance = 1;
public UInt32 TotalDistance
{
get => _totalDistance;
@@ -25,7 +25,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
/// </summary>
public int AverageStrokeRate { get; set; } = 0;
private UInt32 _totalDistance = 0;
private UInt32 _totalDistance = 1;
public UInt32 TotalDistance
{
get => _totalDistance;
@@ -113,6 +113,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
return this.Flags.HasFlag(RowerDataFlag.MoreData);
}
}
private string[] deviceNamePool = new string[] {"Think","PF" };
public void HandleAttributeReceived(byte[] data)
{
@@ -127,7 +128,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
//}
var output = "";
output += "收到消息:" + string.Join(",", data);
Debug.Log(output);
this.Flags = (RowerDataFlag)BitConverter.ToUInt16(data, 0);
int b = 2;
if (!this.MoreDataFlag)
@@ -191,7 +192,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
{
this.commonRes = BitConvertHelper.ToInt16(data, b);
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
if (device != null && !device.Name.Contains("Think") && RowerResChanged != null)
if (device != null && deviceNamePool.FirstOrDefault(x => device.Name.ToLower().Contains(x.ToLower())) == null && RowerResChanged != null)
{
RowerResChanged.Invoke(this.commonRes, null);
}
@@ -230,7 +231,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
{
this.thinkRes = BitConvertHelper.ToInt16(data, b + 1);
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
if (device != null && device.Name.Contains("Think") && RowerResChanged != null)
if (device != null && deviceNamePool.FirstOrDefault(x=>device.Name.ToLower().Contains(x.ToLower()))!=null && RowerResChanged != null)
{
RowerResChanged.Invoke(this.thinkRes, null);
}
@@ -263,6 +264,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
}
//Debug.Log("拉力:" + string.Join(",",list));
}
//Debug.Log(output);
}
List<ushort> pullList;
public void Reset()