移除划船机相关内容
This commit is contained in:
1 parent
29625182c3
commit
4d0a383a88
316 files changed
+730
-69567
No files matched your search
@@ -110,18 +110,6 @@ namespace Assets.Scripts.Devices.Ble
|
||||
var device1 = new SpeedCadence(device.Peripheral, hwInterface);
|
||||
discoveredDevices.Add(device.Peripheral.Address, device1);
|
||||
}
|
||||
else if (device.SensorType == Ant.SensorType.Rower)
|
||||
{
|
||||
var device1 = new FtmsRower(device.Peripheral, hwInterface);
|
||||
if (discoveredDevices.ContainsKey(device.Peripheral.Address))
|
||||
{
|
||||
discoveredDevices[device.Peripheral.Address] = device1;
|
||||
}
|
||||
else
|
||||
{
|
||||
discoveredDevices.Add(device.Peripheral.Address, device1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -1,224 +0,0 @@
|
||||
using Assets.Scripts.Ble;
|
||||
using Assets.Scripts.Devices.Ble.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ble.Characteristic
|
||||
{
|
||||
public class C2RowerData : ICharacteristic, IRowerCommonData
|
||||
{
|
||||
public Guid Uuid => ServiceUuids.Characteristics.C2RowerData35;
|
||||
|
||||
public Guid ServiceUuid => ServiceUuids.Characteristics.C2Service;
|
||||
|
||||
public bool IsOptional => false;
|
||||
|
||||
public static event EventHandler EnableChanged;
|
||||
public static event EventHandler RowerTypeChanged;
|
||||
private static bool _isEnabled;
|
||||
public static bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set
|
||||
{
|
||||
_isEnabled = value;
|
||||
if (EnableChanged != null)
|
||||
{
|
||||
EnableChanged(_isEnabled, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//0.1 lbs of force, max=6553.5m 单位0.1磅
|
||||
public double PeakDriveForce { get; set; }
|
||||
public double AverageDriveForce { get; set; }
|
||||
|
||||
public event EventHandler PullChanged;
|
||||
private ushort _pullValue;
|
||||
public ushort PullValue
|
||||
{
|
||||
get { return _pullValue; }
|
||||
set
|
||||
{
|
||||
_pullValue = value;
|
||||
if (this.PullChanged != null)
|
||||
{
|
||||
this.PullChanged(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool isReadyStatus { get; private set; }
|
||||
public static RowerTaskPanel.RowerType rowerType = new RowerTaskPanel.RowerType() { type = 0 ,value = 0};
|
||||
public void HandleAttributeReceived(byte[] data)
|
||||
{
|
||||
|
||||
if (data[0] == 0x35)
|
||||
{
|
||||
PeakDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 13)) / 10, true);
|
||||
AverageDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 15)) / 10, true);
|
||||
StrokeCount = BitConvertHelper.ToUInt16(data, 19);
|
||||
}
|
||||
else if (data[0] == 0x3d)
|
||||
{
|
||||
if (data[2] == 0)
|
||||
{
|
||||
PullValue = 0;
|
||||
}
|
||||
//老款表头不支持
|
||||
//List<ushort> r = new List<ushort>();
|
||||
for (int i = 3; i < data.Length; i += 2)
|
||||
{
|
||||
ushort pull = Convert.ToUInt16(Math.Round(LbsToNewton(data[i], true)));
|
||||
//r.Add(pull);
|
||||
PullValue = pull;
|
||||
}
|
||||
|
||||
// Debug.Log("拉力曲线:" + string.Join(",", r));
|
||||
}
|
||||
else if (data[0] == 0x31)
|
||||
{
|
||||
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 1)) / 100);
|
||||
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 4)) / 10);
|
||||
|
||||
int status = (int)data[7];
|
||||
int value = (data[17] << 16) + (data[16] << 8) + data[15];
|
||||
|
||||
int type = 0;
|
||||
//3 里程 5 时间 1直接划船
|
||||
if (status == 3)
|
||||
{
|
||||
type = 1;
|
||||
}
|
||||
if (status == 5)
|
||||
{
|
||||
type = 2;
|
||||
value /= 100;
|
||||
}
|
||||
//如果课程发生变化
|
||||
if (status != 0 && type > 0 && ( rowerType.type != type || rowerType.value != value))
|
||||
{
|
||||
Debug.Log($"status{status}-type{type}-value{value}");
|
||||
rowerType.type = type;
|
||||
rowerType.value = value;
|
||||
RowerTypeChanged?.Invoke(this,null);
|
||||
}
|
||||
|
||||
var time = ((data[3] << 16) + (data[2] << 8) + data[1]) / 100;
|
||||
Debug.Log("划船时间" + time);
|
||||
isReadyStatus = data[9] == 0;
|
||||
var hasChanged = data[19] != ResistanceLevel;
|
||||
ResistanceLevel = data[19];
|
||||
if (RowerResChanged != null && hasChanged)
|
||||
{
|
||||
RowerResChanged.Invoke(this, null);
|
||||
}
|
||||
//isReadyStatus = data[2] == 1 || data[2] == 129;
|
||||
}
|
||||
else if (data[0] == 0x32)
|
||||
{
|
||||
InstantaneousPace = (ushort)(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 8)) / 100);
|
||||
AveragePace = (ushort)(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 10)) / 100);
|
||||
//AveragePower = BitConvertHelper.ToUInt16(data, 17);
|
||||
StrokeRate = (uint)data[6];
|
||||
}
|
||||
else if (data[0] == 0x33)
|
||||
{
|
||||
TotalEnergy = BitConvertHelper.ToUInt16(data, 7);
|
||||
AveragePower = BitConvertHelper.ToUInt16(data, 5);
|
||||
}
|
||||
else if (data[0] == 0x36)
|
||||
{
|
||||
InstantaneousPower = BitConvertHelper.ToUInt16(data, 4);
|
||||
//TotalEnergy = BitConvertHelper.ToUInt16(data, 6);
|
||||
}
|
||||
else if (data[0] == 0x39)
|
||||
{
|
||||
TrainingTime = (Convert.ToDouble(BitConvertHelper.ToUInt24(data, 5)) / 100);
|
||||
ElapsedTime = (int)TrainingTime;
|
||||
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 8)) / 10);
|
||||
CompleteEvent?.Invoke(this, null);
|
||||
}
|
||||
Debug.Log("数据" + string.Join(",", data) + $" | {ElapsedTime}-{TotalDistance}");
|
||||
//else if (data[0] == 34)
|
||||
//{
|
||||
// isReadyStatus = data[2] == 1 || data[2] == 129;
|
||||
//}
|
||||
}
|
||||
public event EventHandler StartEvent;
|
||||
public event EventHandler CompleteEvent;
|
||||
private double LbsToNewton(double lbs,bool isKg = false) => 4.4482216 * lbs * (isKg ? (1f / 9.8f) : 1f);
|
||||
public void SetUnavailable()
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 划桨频率
|
||||
/// </summary>
|
||||
public uint StrokeRate { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 划桨次数
|
||||
/// </summary>
|
||||
public UInt16 StrokeCount { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 平均划桨频率
|
||||
/// </summary>
|
||||
public int AverageStrokeRate { get; set; } = 0;
|
||||
private UInt32 _totalDistance = 1;
|
||||
public UInt32 TotalDistance
|
||||
{
|
||||
get => _totalDistance;
|
||||
set
|
||||
{
|
||||
if (_totalDistance == 0 && value != 0 && StartEvent != null)
|
||||
{
|
||||
StartEvent.Invoke(this, null);
|
||||
}
|
||||
_totalDistance = value;
|
||||
}
|
||||
}
|
||||
//private UInt16 _instantaneousPace = 0;
|
||||
/// <summary>
|
||||
/// 即时配速
|
||||
/// </summary>
|
||||
public UInt16 InstantaneousPace { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 平均配速
|
||||
/// </summary>
|
||||
public UInt16 AveragePace { get; set; } = 0;
|
||||
|
||||
public int InstantaneousPower { get; set; } = 0;
|
||||
|
||||
public int AveragePower { get; set; } = 0;
|
||||
public int ElapsedTime { get; set; } = 0;
|
||||
public double TrainingTime { get; set; } = 0;
|
||||
public int TotalEnergy { get; set; } = 0;
|
||||
public int EnergyPerHour { get; set; } = 0;
|
||||
public int EnergyPerMinute { get; set; } = 0;
|
||||
public event EventHandler RowerResChanged;
|
||||
public int ResistanceLevel { get; set; } = 0;
|
||||
public void Reset()
|
||||
{
|
||||
this.StrokeRate = 0;
|
||||
this.StrokeCount = 0;
|
||||
this.AverageStrokeRate = 0;
|
||||
this.TotalDistance = 0;
|
||||
this.InstantaneousPace = 0;
|
||||
this.AveragePace = 0;
|
||||
this.InstantaneousPower = 0;
|
||||
this.AveragePower = 0;
|
||||
this.ResistanceLevel = 0;
|
||||
this.TotalEnergy = 0;
|
||||
this.EnergyPerHour = 0;
|
||||
this.EnergyPerMinute = 0;
|
||||
this.ElapsedTime = 0;
|
||||
this.TrainingTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64ae3a6d26480b04c8fed17cc833d179
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,435 +0,0 @@
|
||||
using Assets.Scripts.Ble;
|
||||
using Assets.Scripts.Devices.Ant;
|
||||
using Assets.Scripts.Devices.Ble.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ble.Characteristic
|
||||
{
|
||||
public class FtmsRowerData : ICharacteristic, IRowerCommonData
|
||||
{
|
||||
/// <summary>
|
||||
/// 划桨频率
|
||||
/// </summary>
|
||||
public uint StrokeRate { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 划桨次数
|
||||
/// </summary>
|
||||
public UInt16 StrokeCount { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 平均划桨频率
|
||||
/// </summary>
|
||||
public int AverageStrokeRate { get; set; } = 0;
|
||||
|
||||
private UInt32 _totalDistance = 1;
|
||||
public UInt32 TotalDistance
|
||||
{
|
||||
get => _totalDistance;
|
||||
set
|
||||
{
|
||||
if (_totalDistance == 0 && value != 0 && StartEvent != null)
|
||||
{
|
||||
StartEvent.Invoke(this, null);
|
||||
}
|
||||
_totalDistance = value;
|
||||
}
|
||||
}
|
||||
//private UInt16 _instantaneousPace = 1;
|
||||
/// <summary>
|
||||
/// 即时配速
|
||||
/// </summary>
|
||||
public UInt16 InstantaneousPace { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 平均配速
|
||||
/// </summary>
|
||||
public UInt16 AveragePace { get; set; } = 0;
|
||||
|
||||
public int InstantaneousPower { get; set; } = 0;
|
||||
|
||||
public int AveragePower { get; set; } = 0;
|
||||
public event EventHandler RowerResChanged;
|
||||
private int commonRes = 50;
|
||||
private int thinkRes = 50;
|
||||
|
||||
public int ResistanceLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
|
||||
if (device == null) return 0;
|
||||
if (device.Name.Contains("Think") || device.Name.Contains("PF"))
|
||||
{
|
||||
return thinkRes;
|
||||
}
|
||||
else
|
||||
{
|
||||
return commonRes;
|
||||
}
|
||||
}
|
||||
set { }
|
||||
}
|
||||
/// <summary>
|
||||
/// 运行时间
|
||||
/// </summary>
|
||||
public int ElapsedTime { get; set; } = 0;
|
||||
public double TrainingTime { get; set; } = 0;
|
||||
public int TotalEnergy { get; set; } = 0;
|
||||
public int EnergyPerHour { get; set; } = 0;
|
||||
public int EnergyPerMinute { get; set; } = 0;
|
||||
public double PeakDriveForce { get; set; } = 0;
|
||||
public double AverageDriveForce { get; set; } = 0;
|
||||
|
||||
public Guid Uuid => ServiceUuids.Characteristics.RowerData;
|
||||
|
||||
public Guid ServiceUuid => ServiceUuids.Get(ServiceUuids.Ftms).IdGuid;
|
||||
|
||||
public bool IsOptional => false;
|
||||
|
||||
public RowerDataFlag Flags;
|
||||
//拉力相关
|
||||
public event EventHandler PullChanged;
|
||||
//开始事件
|
||||
public event EventHandler StartEvent;
|
||||
//结束事件
|
||||
public event EventHandler CompleteEvent;
|
||||
//日志事件
|
||||
public event EventHandler LogEvent;
|
||||
private ushort _pullValue;
|
||||
public ushort PullValue
|
||||
{
|
||||
get { return _pullValue; }
|
||||
set
|
||||
{
|
||||
_pullValue = value;
|
||||
if (this.PullChanged != null)
|
||||
{
|
||||
this.PullChanged(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool MoreDataFlag
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Flags.HasFlag(RowerDataFlag.MoreData);
|
||||
}
|
||||
}
|
||||
private string[] deviceNamePool = new string[] {"Think","PF" };
|
||||
private List<ushort> tempPullList = new List<ushort>();
|
||||
|
||||
public void HandleAttributeReceived(byte[] data)
|
||||
{
|
||||
if (data == null || data.Length < 2)
|
||||
{
|
||||
throw new ArgumentException("数据异常" + string.Join(",", data));
|
||||
}
|
||||
//throw new NotImplementedException();
|
||||
//if(data[0] == 1)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
var output = "";
|
||||
output += "收到消息:" + string.Join(",", data);
|
||||
|
||||
this.Flags = (RowerDataFlag)BitConverter.ToUInt16(data, 0);
|
||||
int b = 2;
|
||||
if (!this.MoreDataFlag)
|
||||
{
|
||||
//this.instantSpeed = new double?((double)BitConverter.ToUInt16(data, (int)b) * 0.01);
|
||||
this.StrokeRate = (uint)Math.Round(BitConvertHelper.ToUInt8(data, b) / 2d);
|
||||
b += 1;
|
||||
this.StrokeCount = BitConvertHelper.ToUInt16(data, b);
|
||||
b += 2;
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.MoreData);
|
||||
}
|
||||
//平均浆频
|
||||
if (this.Flags.HasFlag(RowerDataFlag.AverageStrokeRate))
|
||||
{
|
||||
var vvv = BitConvertHelper.ToUInt8(data, (int)b) / 2;
|
||||
//Debug.WriteLine($"平均浆频:{ vvv }");
|
||||
output += $" 平均浆频:{ vvv }";
|
||||
this.AverageStrokeRate = vvv;
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.AverageStrokeRate);
|
||||
|
||||
//output += $" 次数:{ BitConvertHelper.ToUInt16(data, b) }";
|
||||
//b += 3;
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.TotalDistance))
|
||||
{
|
||||
var vvv = BitConvertHelper.ToUInt24(data, (int)b);
|
||||
output += $" 总距离{ vvv }米";
|
||||
if (vvv < 10)
|
||||
{
|
||||
LogEvent?.Invoke(DateTime.Now.ToString() + ":" + output,null);
|
||||
//App.cacheList.Add(DateTime.Now.ToString() + ":" + output);
|
||||
}
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.TotalDistance);
|
||||
|
||||
this.TotalDistance = vvv;
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.InstantaneousPace))
|
||||
{
|
||||
//this.InstantCadence = new int?((int)(BitConvertHelper.ToUInt16(data, (int)b) / 2));
|
||||
this.InstantaneousPace = BitConvertHelper.ToUInt16(data, b);
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.InstantaneousPace);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.AveragePace))
|
||||
{
|
||||
this.AveragePace = BitConvertHelper.ToUInt16(data, b);
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.AveragePace);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.InstantPower))
|
||||
{
|
||||
var power = new int?((int)BitConvertHelper.ToInt16(data, (int)b));
|
||||
output += $" 功率:{ power }";
|
||||
this.InstantaneousPower = power.GetValueOrDefault(0);
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.InstantPower);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.AveragePower))
|
||||
{
|
||||
//var power = new int?((int)BitConverter.ToInt16(data, (int)b));
|
||||
this.AveragePower = BitConvertHelper.ToInt16(data, b);
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.AveragePower);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.ResistanceLevel))
|
||||
{
|
||||
var newRes = BitConvertHelper.ToInt16(data, b);
|
||||
var resChanged = newRes != this.commonRes;
|
||||
this.commonRes = newRes;
|
||||
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
|
||||
if (resChanged && device != null && deviceNamePool.FirstOrDefault(x => device.Name.ToLower().Contains(x.ToLower())) == null && RowerResChanged != null)
|
||||
{
|
||||
RowerResChanged.Invoke(this, null);
|
||||
}
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.ResistanceLevel);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.ExpendedEnergy))
|
||||
{
|
||||
this.TotalEnergy = BitConvertHelper.ToInt16(data, b);
|
||||
b += 2;
|
||||
this.EnergyPerHour = BitConvertHelper.ToInt16(data, b);
|
||||
b += 2;
|
||||
this.EnergyPerMinute = data[b];
|
||||
b += 1;
|
||||
//b += this.SizeOfDataForFlag(RowerDataFlag.ExpendedEnergy);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.HeartRate))
|
||||
{
|
||||
//this.HeartRate = new int?((int)BitConverter.ToUInt8(data, (int)b));
|
||||
//(int)data[(int)b];
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.HeartRate);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.MetabolicEquivalent))
|
||||
{
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.MetabolicEquivalent);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.ElapsedTime))
|
||||
{
|
||||
this.ElapsedTime = BitConvertHelper.ToInt16(data, b);
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.ElapsedTime);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.RemainingTime))
|
||||
{
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.RemainingTime);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.ThinkDragFactor))
|
||||
{
|
||||
var originRes = BitConvertHelper.ToInt16(data, b + 1);
|
||||
var thinkResChanged = originRes != this.thinkRes;
|
||||
this.thinkRes = BitConvertHelper.ToInt16(data, b + 1);
|
||||
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
|
||||
if (thinkResChanged && device != null && deviceNamePool.FirstOrDefault(x=>device.Name.ToLower().Contains(x.ToLower()))!=null && RowerResChanged != null)
|
||||
{
|
||||
RowerResChanged.Invoke(this, null);
|
||||
}
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.ThinkDragFactor);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.Pull))
|
||||
{
|
||||
for (int pullB = 4; pullB < data.Length; pullB += 2)
|
||||
{
|
||||
var val = BitConverter.ToUInt16(data, pullB);
|
||||
val = Convert.ToUInt16(((double)val) /9.8f);
|
||||
tempPullList.Add(val);
|
||||
PullValue = val;
|
||||
}
|
||||
Debug.Log("拉力列表:" + string.Join(",", tempPullList));
|
||||
|
||||
if (pullList == null) pullList = new List<ushort>();
|
||||
foreach (var pull in tempPullList)
|
||||
{
|
||||
if (pull == 0)
|
||||
{
|
||||
if (pullList.Count != 0)
|
||||
{
|
||||
PeakDriveForce = pullList.Max();
|
||||
AverageDriveForce = (double)pullList.Average(x=>x);
|
||||
}
|
||||
pullList.Clear();
|
||||
}
|
||||
pullList.Add(pull);
|
||||
}
|
||||
tempPullList.Clear();
|
||||
|
||||
}
|
||||
}
|
||||
List<ushort> pullList { get; set; }
|
||||
public void Reset()
|
||||
{
|
||||
this.StrokeRate = 0;
|
||||
this.StrokeCount = 0;
|
||||
this.AverageStrokeRate = 0;
|
||||
//this.TotalDistance = 0;
|
||||
this.InstantaneousPace = 0;
|
||||
this.AveragePace = 0;
|
||||
this.InstantaneousPower = 0;
|
||||
this.AveragePower = 0;
|
||||
//this.commonRes = 50;
|
||||
//this.thinkRes = 50;
|
||||
//this.ResistanceLevel = 0;
|
||||
this.TotalEnergy = 0;
|
||||
this.EnergyPerHour = 0;
|
||||
this.EnergyPerMinute = 0;
|
||||
this.ElapsedTime = 0;
|
||||
this.TrainingTime = 0;
|
||||
}
|
||||
|
||||
public int SizeOfDataForFlag(RowerDataFlag flag)
|
||||
{
|
||||
int num = 0;
|
||||
switch (flag)
|
||||
{
|
||||
//case RowerDataFlag.MoreData:
|
||||
// break;
|
||||
case RowerDataFlag.AverageStrokeRate:
|
||||
num = 1;
|
||||
break;
|
||||
case RowerDataFlag.TotalDistance:
|
||||
num = 3;
|
||||
break;
|
||||
case RowerDataFlag.InstantaneousPace:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.AveragePace:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.InstantPower:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.AveragePower:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.ResistanceLevel:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.ExpendedEnergy:
|
||||
num = 5;
|
||||
break;
|
||||
case RowerDataFlag.HeartRate:
|
||||
num = 1;
|
||||
break;
|
||||
case RowerDataFlag.MetabolicEquivalent:
|
||||
num = 1;
|
||||
break;
|
||||
case RowerDataFlag.ElapsedTime:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.RemainingTime:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.ThinkDragFactor:
|
||||
num = 5;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public void SetUnavailable()
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
//254 0是前七字節 1 41是第二包 1 64是拉力
|
||||
[Flags]
|
||||
public enum RowerDataFlag
|
||||
{
|
||||
MoreData = 1,
|
||||
AverageStrokeRate = 2,
|
||||
TotalDistance = 4,
|
||||
InstantaneousPace = 8,
|
||||
AveragePace = 16,
|
||||
InstantPower = 32,
|
||||
AveragePower = 64,
|
||||
ResistanceLevel = 128,
|
||||
ExpendedEnergy = 256,
|
||||
HeartRate = 512,
|
||||
MetabolicEquivalent = 1024,
|
||||
ElapsedTime = 2048,
|
||||
RemainingTime = 4096,
|
||||
//单周期能耗
|
||||
SingleEnergy = 8192,
|
||||
//拉力曲綫
|
||||
Pull = 16384,
|
||||
//Think 阻力
|
||||
ThinkDragFactor = 32768
|
||||
}
|
||||
|
||||
|
||||
|
||||
private byte SizeOfDataForFlag1(RowerDataFlag flag)
|
||||
{
|
||||
if (flag <= RowerDataFlag.InstantPower)
|
||||
{
|
||||
//if (flag <= RowerDataFlag.AverageCadence)
|
||||
//{
|
||||
// if (flag - RowerDataFlag.MoreData > 1 && flag != RowerDataFlag.InstantCadence && flag != RowerDataFlag.AverageCadence)
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
{
|
||||
if (flag == RowerDataFlag.TotalDistance)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if (flag != RowerDataFlag.ResistanceLevel && flag != RowerDataFlag.InstantPower)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (flag <= RowerDataFlag.HeartRate)
|
||||
{
|
||||
if (flag != RowerDataFlag.AveragePower)
|
||||
{
|
||||
if (flag == RowerDataFlag.ExpendedEnergy)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
if (flag != RowerDataFlag.HeartRate)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flag != RowerDataFlag.MetabolicEquivalent && flag != RowerDataFlag.ElapsedTime && flag != RowerDataFlag.RemainingTime)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87207b21c4f11ef4b866ac490a88620f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,9 +4,6 @@ using Assets.Scripts.Devices.Ble.Characteristic;
|
||||
using Assets.Scripts.Devices.Ble.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ble.Devices
|
||||
@@ -17,8 +14,6 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
public int Power { get => _ftmsIndoorBikeData.InstantPower.GetValueOrDefault(0); set => throw new NotImplementedException(); }
|
||||
public double Speed { get => _ftmsIndoorBikeData.InstantSpeed.GetValueOrDefault(0); set => throw new NotImplementedException(); }
|
||||
public int Cadence { get => _ftmsIndoorBikeData.InstantCadence.GetValueOrDefault(0); set => throw new NotImplementedException(); }
|
||||
private FtmsRowerData _rowerData;
|
||||
public FtmsRowerData rowerData { get => _rowerData; }
|
||||
|
||||
private FtmsIndoorBikeData _ftmsIndoorBikeData;
|
||||
|
||||
@@ -29,9 +24,6 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
this._ftmsIndoorBikeData = new FtmsIndoorBikeData();
|
||||
base.Characteristics.Add(this._ftmsIndoorBikeData);
|
||||
base.Characteristics.Add(new FtmsFitnessMachineFeature());
|
||||
//划船机
|
||||
this._rowerData = new FtmsRowerData();
|
||||
base.Characteristics.Add(rowerData);
|
||||
bleWinHwInterface.CharacteristicReadEvent += CharacteristicReadMainCallback;
|
||||
}
|
||||
|
||||
@@ -58,17 +50,6 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
{
|
||||
this.controlPointCharacteristic = character;
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.RowerData))
|
||||
{
|
||||
Debug.Log("划船机");
|
||||
this.hwInterface.SubscribeCharacteristic(character, (hw, cha, res) =>
|
||||
{
|
||||
//Debug.Log("1111111111111111111111");
|
||||
//Debug.WriteLine(res.ToString());
|
||||
var res1 = (res as BleResponse<byte[]>);
|
||||
Debug.Log("收到消息划船机:" + string.Join(",", res1));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,333 +0,0 @@
|
||||
using Assets.Scripts.Ble;
|
||||
using Assets.Scripts.Ble.Commands;
|
||||
using Assets.Scripts.Devices.Ant.Interfaces;
|
||||
using Assets.Scripts.Devices.Ble.Characteristic;
|
||||
using Assets.Scripts.Devices.Ble.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ble.Devices
|
||||
{
|
||||
public class FtmsRower : BleDevice, IRowerDevice
|
||||
{
|
||||
private FtmsRowerData _rowerData;
|
||||
public FtmsRowerData rowerData { get => _rowerData; }
|
||||
|
||||
C2RowerData _c2RowerData;
|
||||
public C2RowerData c2RowerData { get => _c2RowerData; }
|
||||
private List<BleServiceInfo> Services;
|
||||
private BleCharacteristicInfo controlPointCharacteristic;
|
||||
private BleCharacteristicInfo c2Control { get; set; }
|
||||
|
||||
public FtmsRower(BlePeripheralInfo peripheralInfo, IBleWinHwInterface bleWinHwInterface) : base(peripheralInfo, bleWinHwInterface, Ant.SensorType.Rower)
|
||||
{
|
||||
Debug.Log(24);
|
||||
base.Characteristics.Add(new FtmsFitnessMachineFeature());
|
||||
//划船机
|
||||
this._rowerData = new FtmsRowerData();
|
||||
base.Characteristics.Add(rowerData);
|
||||
this._c2RowerData = new C2RowerData();
|
||||
base.Characteristics.Add(c2RowerData);
|
||||
bleWinHwInterface.CharacteristicReadEvent -= CharacteristicReadMainCallback;
|
||||
bleWinHwInterface.CharacteristicReadEvent += CharacteristicReadMainCallback;
|
||||
}
|
||||
|
||||
protected override void CreateServices(List<BleServiceInfo> discoveredServices)
|
||||
{
|
||||
this.Services = discoveredServices;
|
||||
Debug.Log("服务+" + string.Join(",", Services.Select(x => x.Id.ToString())));
|
||||
foreach (var service in this.Services)
|
||||
{
|
||||
hwInterface.DiscoverCharacteristic(service, (hwInterface, service1, response) =>
|
||||
{
|
||||
|
||||
foreach (var character in response.Data)
|
||||
{
|
||||
//Debug.Log(character.Id.ToString());
|
||||
if (character.MatchGuid(ServiceUuids.Characteristics.FitnessMachineControlPoint))
|
||||
{
|
||||
Debug.Log("中控台获取");
|
||||
this.controlPointCharacteristic = character;
|
||||
C2RowerData.IsEnabled = false;
|
||||
//Thread.Sleep(100);
|
||||
//Reset();
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.RowerData))
|
||||
{
|
||||
Debug.Log("ftms划船机" + service.Id);
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData35))
|
||||
{
|
||||
Debug.Log("c2划船机基本数据" + service.Id);
|
||||
//C2RowerData.IsEnabled = true;
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData3d))
|
||||
{
|
||||
Debug.Log("c2划船机拉力数据" + service.Id);
|
||||
//C2RowerData.IsEnabled = true;
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData32))
|
||||
{
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData33))
|
||||
{
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData36))
|
||||
{
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData39))
|
||||
{
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
//else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerStatus))
|
||||
//{
|
||||
// Debug.Log("c2划船机响应数据" + service.Id);
|
||||
// //C2RowerData.IsEnabled = true;
|
||||
// this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
//}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerCourse))
|
||||
{
|
||||
Debug.Log("c2划船机课程数据" + service.Id);
|
||||
C2RowerData.IsEnabled = true;
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerControl))
|
||||
{
|
||||
Debug.Log($"c2划船机控制台{character.Id}");
|
||||
this.c2Control = character;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void CharacteristicReadMainCallback(IBleWinHwInterface hwInterface, BleCharacteristicInfo characteristic, BleResponse<byte[]> response)
|
||||
{
|
||||
|
||||
//var tc = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.C2RowerData);
|
||||
//tc.HandleAttributeReceived(new byte[] { 61, 89, 0, 0, 0, 33, 0, 33, 0, 46, 0, 46, 0, 53, 0, 60, 0, 60, 0, 68, 0, 68, 0, 0, 0 });
|
||||
//tc.HandleAttributeReceived(new byte[] { 53, 223, 211, 0, 162, 57, 0, 82, 62, 96, 0, 94, 2, 183, 3, 125, 2, 208, 7, 203, 0 });
|
||||
if (characteristic.MatchGuid(ServiceUuids.Characteristics.RowerData))
|
||||
{
|
||||
var c = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.RowerData);
|
||||
if (c != null && !C2RowerData.IsEnabled)
|
||||
{
|
||||
c.HandleAttributeReceived(response.Data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var c = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.C2RowerData35);
|
||||
if (c != null)
|
||||
{
|
||||
var data = new byte[] { characteristic.Id.ToByteArray()[0] }.Concat(response.Data).ToArray();
|
||||
c.HandleAttributeReceived(data);
|
||||
}
|
||||
}
|
||||
//foreach (var item in base.Characteristics)
|
||||
//{
|
||||
// if (characteristic.MatchGuid(item.Uuid) || characteristic.Id == ServiceUuids.Characteristics.C2RowerData1)
|
||||
// {
|
||||
// if (item.Uuid == ServiceUuids.Characteristics.C2RowerData1)
|
||||
// {
|
||||
// Debug.Log("c2");
|
||||
// var data = new byte[] { item.Uuid.ToByteArray()[0] }.Concat(response.Data).ToArray();
|
||||
// item.HandleAttributeReceived(data);
|
||||
// }
|
||||
// else if (item.Uuid == ServiceUuids.Characteristics.RowerData)
|
||||
// {
|
||||
// Debug.Log("ftms");
|
||||
// item.HandleAttributeReceived(response.Data);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
public void C2GetStatus(byte[] bs)
|
||||
{
|
||||
if (C2RowerData.IsEnabled == true)
|
||||
{
|
||||
//等对csafe协议研究透彻后写
|
||||
if (this.c2Control != null)
|
||||
{
|
||||
var cmd = bs;
|
||||
byte a = cmd[0];
|
||||
for (int i = 1; i < cmd.Length; i++)
|
||||
{
|
||||
a ^= cmd[i];
|
||||
}
|
||||
cmd = new byte[] { 0xf1 }.Concat(cmd).Concat(new byte[] { a, 0xf2 }).ToArray();
|
||||
Debug.Log("发送获取命令" + string.Join(",", cmd));
|
||||
hwInterface.WriteCharacteristic(this.c2Control, cmd);
|
||||
//hwInterface.WriteCharacteristic(this.c2Control, new byte[] { 0xF1, 0x81, 0x81, 0xF2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SendCommand(RowerCommand command,int data = 0)
|
||||
{
|
||||
if (!C2RowerData.IsEnabled)
|
||||
return;
|
||||
switch (command)
|
||||
{
|
||||
case RowerCommand.JustRow:
|
||||
SetJustRow();
|
||||
break;
|
||||
case RowerCommand.FixedDistance:
|
||||
SetFixedDistance(data);
|
||||
break;
|
||||
case RowerCommand.FixedTime:
|
||||
SetFixedTime(data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (C2RowerData.IsEnabled == true)
|
||||
{
|
||||
////等对csafe协议研究透彻后写
|
||||
//if (this.c2Control != null)
|
||||
//{
|
||||
// Debug.Log("发送重置命令" + this.c2Control.ToString());
|
||||
// hwInterface.WriteCharacteristic(this.c2Control, new byte[] { 0xF1, 0x80, 0x80, 0xF2 });
|
||||
// //hwInterface.WriteCharacteristic(this.c2Control, new byte[] { 0xF1, 0x81, 0x81, 0xF2 });
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.controlPointCharacteristic != null)
|
||||
{
|
||||
Debug.Log("发送重置命令" + this.controlPointCharacteristic.ToString());
|
||||
//App.cacheList.Add(DateTime.Now.ToString() + ":发送重置命令" + this.controlPointCharacteristic.ToString());
|
||||
hwInterface.WriteCharacteristic(this.controlPointCharacteristic, new byte[] { 0x01 });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="workoutType">训练类型:0,1,2(里程不分段),3(里程分段),4(时间不分段),5,6,7,8~13</param>
|
||||
public void SetWorkoutType(int workoutType)
|
||||
{
|
||||
var typeHex = workoutType.ToString("X2");
|
||||
var checkSum = "00";
|
||||
var data = BitConvertHelper.HexToByteArray($"F1 76 03 01 01 {typeHex} {checkSum} F2");//"F1 76 03 01 01 03 76 F2"//03?
|
||||
checkSum = GetChecksumHexString(data);
|
||||
data = BitConvertHelper.HexToByteArray($"F1 76 03 01 01 {typeHex} {checkSum} F2");
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
Thread.Sleep(5);
|
||||
}
|
||||
public void SetConfigureWorkout()
|
||||
{
|
||||
var data = BitConvertHelper.HexToByteArray("F1 76 03 14 01 01 61 F2"); //03?
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
Thread.Sleep(5);
|
||||
}
|
||||
public void SetScreenState()
|
||||
{
|
||||
var data = BitConvertHelper.HexToByteArray("F1 76 04 13 02 01 01 63 F2"); //04?
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
}
|
||||
public void SetPoll()
|
||||
{
|
||||
var data = BitConvertHelper.HexToByteArray($"F1 76 07 8D 93 A3 A0 A8 B3 B6 C1 F2");
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
}
|
||||
public void SetJustRow()
|
||||
{
|
||||
var data = BitConvertHelper.HexToByteArray("F1 76 07 01 01 01 13 02 01 01 61 F2");
|
||||
Debug.Log($"SetJustRow:{string.Join(",", data)}");
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
Thread.Sleep(5);
|
||||
SetScreenState();
|
||||
}
|
||||
public void SetFixedDistance(int distance)
|
||||
{
|
||||
if (distance < 100)
|
||||
return;
|
||||
|
||||
SetWorkoutType(3);
|
||||
|
||||
var hexditance = distance.ToString("X4");
|
||||
var checkSum = "00";
|
||||
var data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 80 00 00 {hexditance} {checkSum} F2");//F1 76 07 03 05 80 00 00 {hexditance} {checkSum} F2
|
||||
checkSum = GetChecksumHexString(data);
|
||||
data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 80 00 00 {hexditance} {checkSum} F2");//07?
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
Thread.Sleep(5);
|
||||
|
||||
SetConfigureWorkout();
|
||||
|
||||
SetScreenState();
|
||||
|
||||
}
|
||||
private string GetChecksumHexString(byte[] data)
|
||||
{
|
||||
var res = data[1];
|
||||
for (int i = 2; i < data.Length-2; i++)
|
||||
{
|
||||
res ^= data[i];
|
||||
}
|
||||
return res.ToString("X2");
|
||||
}
|
||||
public void SetFixedTime(int mins)
|
||||
{
|
||||
SetWorkoutType(5);
|
||||
Thread.Sleep(5);
|
||||
var timeHex = (mins * 100).ToString("X6");
|
||||
var checkNum = "00";
|
||||
var data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 00 00 {timeHex} {checkNum} F2");
|
||||
checkNum = GetChecksumHexString(data);
|
||||
data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 00 00 {timeHex} {checkNum} F2");
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
Thread.Sleep(5);
|
||||
SetConfigureWorkout();
|
||||
Thread.Sleep(5);
|
||||
SetScreenState();
|
||||
}
|
||||
|
||||
public void SetResistanceLevel(ushort v)
|
||||
{
|
||||
if (C2RowerData.IsEnabled == true)
|
||||
{
|
||||
////等对csafe协议研究透彻后写
|
||||
//if (this.c2Control != null)
|
||||
//{
|
||||
//02312131 = > 03010103
|
||||
//var data = new byte[] { 0x76 }.Concat(BitConverter.GetBytes(v)).ToArray();
|
||||
//byte checksum = (byte)((byte)(data[0] ^ data[1]) ^ data[2]);
|
||||
//var r = new byte[] { 0xF1 }.Concat(data).Concat(new byte[] { checksum, 0xf2 }).ToArray();
|
||||
//Debug.Log($"设置阻力{v}, {string.Join(",", r)}");
|
||||
//
|
||||
// var data = BitConvertHelper.HexToByteArray("F1 76 07 01 01 01 13 02 01 01 61 F2");
|
||||
// hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.controlPointCharacteristic != null)
|
||||
{
|
||||
//特注:81是think专有指令,后期可能需要兼容其他设备
|
||||
var r = new byte[] { 0x81 }.Concat(BitConverter.GetBytes((ushort)(50 + v))).ToArray();
|
||||
Debug.Log($"设置阻力{v}, {string.Join(",", r)}");
|
||||
hwInterface.WriteCharacteristic(this.controlPointCharacteristic, r);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e62cf4fc3378d5c4eb76643a9d3ca528
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,52 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ble.Interfaces
|
||||
{
|
||||
interface IRowerCommonData
|
||||
{
|
||||
event EventHandler PullChanged;
|
||||
ushort PullValue { get; set; }
|
||||
double PeakDriveForce { get; set; }
|
||||
double AverageDriveForce { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 划桨频率
|
||||
/// </summary>
|
||||
uint StrokeRate { get; set; }
|
||||
/// <summary>
|
||||
/// 划桨次数
|
||||
/// </summary>
|
||||
UInt16 StrokeCount { get; set;}
|
||||
/// <summary>
|
||||
/// 平均划桨频率
|
||||
/// </summary>
|
||||
int AverageStrokeRate { get; set; }
|
||||
UInt32 TotalDistance { get; set; }
|
||||
/// <summary>
|
||||
/// 即时配速
|
||||
/// </summary>
|
||||
UInt16 InstantaneousPace { get; set; }
|
||||
/// <summary>
|
||||
/// 平均配速
|
||||
/// </summary>
|
||||
UInt16 AveragePace { get; set; }
|
||||
int InstantaneousPower { get; set; }
|
||||
int AveragePower { get; set; }
|
||||
int ElapsedTime { get; set; }
|
||||
double TrainingTime { get; set; }
|
||||
int TotalEnergy { get; set; }
|
||||
|
||||
int EnergyPerHour { get; set; }
|
||||
|
||||
int EnergyPerMinute { get; set; }
|
||||
int ResistanceLevel { get; set; }
|
||||
void Reset();
|
||||
event EventHandler StartEvent;
|
||||
event EventHandler CompleteEvent;//结束事件
|
||||
event EventHandler RowerResChanged;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b9b93075aa03cf4587d75a49b2bfaa8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -44,10 +44,7 @@ namespace Assets.Scripts.Ble
|
||||
(byte) 24,
|
||||
(byte) 38
|
||||
};
|
||||
public static readonly byte[] C2Rower = new byte[]
|
||||
{
|
||||
(byte)206,(byte)6
|
||||
};
|
||||
|
||||
public static readonly byte[] KineticInRide = new byte[16]
|
||||
{
|
||||
(byte) 233,
|
||||
@@ -168,8 +165,7 @@ namespace Assets.Scripts.Ble
|
||||
new ServiceUuid(new Guid("6e40fec1-b5a3-f393-e0a9-e50e24dcca9e"), ServiceUuids.TacxBle, true),
|
||||
new ServiceUuid(new Guid("01007b34-3576-8b40-8918-8ff3949ce592"), ServiceUuids.Elite, true),
|
||||
new ServiceUuid(new Guid("3a01f4c0-37a8-6541-bab9-654ef70747c6"), ServiceUuids.PowerBeam, true),
|
||||
new ServiceUuid(new Guid("CE060000-43E5-11E4-916C-0800200C9A66"), ServiceUuids.C2Rower,true),
|
||||
};
|
||||
};
|
||||
public static readonly IReadOnlyList<ServiceUuid> CyclingServices = ServiceUuids.Services.Where(s => s.IsCycling).ToList();
|
||||
|
||||
public static List<string> GetServiceUuidList()
|
||||
@@ -370,26 +366,6 @@ namespace Assets.Scripts.Ble
|
||||
|
||||
// Token: 0x04002908 RID: 10504
|
||||
public static Guid WahooFitnessSensorMeasurementInput = new Guid("A026E016-0A7D-4AB3-97FA-F1500F9FEB8B");
|
||||
|
||||
public static Guid RowerData = new Guid("00002AD1-0000-1000-8000-00805F9B34FB");
|
||||
|
||||
|
||||
public static Guid C2RowerControl = new Guid("ce060021-43e5-11e4-916c-0800200c9a66");
|
||||
//0x35 有峰力值和均力值
|
||||
public static Guid C2RowerData35 = new Guid("ce060035-43e5-11e4-916c-0800200c9a66");
|
||||
//拉力曲线
|
||||
public static Guid C2RowerData3d = new Guid("ce06003D-43e5-11e4-916c-0800200c9a66");
|
||||
//c2划船机状态
|
||||
public static Guid C2RowerStatus = new Guid("ce060022-43e5-11e4-916c-0800200c9a66");
|
||||
//c2划船机课程
|
||||
public static Guid C2RowerCourse = new Guid("CE060031-43E5-11E4-916C-0800200C9A66");
|
||||
public static Guid C2RowerData32 = new Guid("CE060032-43E5-11E4-916C-0800200C9A66");
|
||||
public static Guid C2RowerData33 = new Guid("CE060033-43E5-11E4-916C-0800200C9A66");
|
||||
public static Guid C2RowerData36 = new Guid("CE060036-43E5-11E4-916C-0800200C9A66");
|
||||
public static Guid C2RowerData39 = new Guid("CE060039-43E5-11E4-916C-0800200C9A66");
|
||||
public static Guid C2Service = new Guid("CE060030-43E5-11E4-916C-0800200C9A66");
|
||||
//ce060030-43e5-11e4-916c-0800200c9a66
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -140,15 +140,6 @@ namespace Assets.Scripts.Ble
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//Debug.Log($"設備{App.IsRowerMode}信息,{item.IdGuid},{string.Join(";", item.IdByteArray)}");
|
||||
if (item.IdByteArray == ServiceUuids.Ftms || item.IdByteArray == ServiceUuids.C2Rower)
|
||||
{
|
||||
sensor = SensorType.Rower;
|
||||
//else
|
||||
//{
|
||||
// sensor = SensorType.FtmsTrainer;
|
||||
//}
|
||||
}
|
||||
else if (item.IdByteArray == ServiceUuids.HeartRate)
|
||||
{
|
||||
sensor = SensorType.HeartRate;
|
||||
@@ -156,7 +147,6 @@ namespace Assets.Scripts.Ble
|
||||
else if (item.IdByteArray == ServiceUuids.CyclingPower)
|
||||
{
|
||||
sensor = SensorType.Power;
|
||||
//sensor = SensorType.Trainer;
|
||||
}
|
||||
else if (item.IdByteArray == ServiceUuids.CyclingSpeedCadence)
|
||||
{
|
||||
@@ -185,8 +175,6 @@ namespace Assets.Scripts.Ble
|
||||
}
|
||||
pCache[addressStr].SensorType = sensor;
|
||||
pCache[addressStr].Rssi = rssi;
|
||||
//Debug.Log(sensor);
|
||||
//pCache[address.ToString()].SensorType = sensor;
|
||||
|
||||
foreach (var item in uuids)
|
||||
{
|
||||
@@ -197,7 +185,6 @@ namespace Assets.Scripts.Ble
|
||||
if (pCache[addressStr].SensorType == SensorType.Power && pCache[addressStr].Services.Any(s => s.Equals(ServiceUuids.Get(ServiceUuids.TacxBle).IdGuid)))
|
||||
{
|
||||
pCache[addressStr].SensorType = SensorType.Trainer;
|
||||
//Debug.Log("纠正为trainer, "+ pCache[address.ToString()].Index);
|
||||
}
|
||||
|
||||
|
||||
@@ -214,9 +201,6 @@ namespace Assets.Scripts.Ble
|
||||
}
|
||||
}
|
||||
|
||||
List<BleServiceInfo> servicelist = new List<BleServiceInfo>();
|
||||
List<BleCharacteristicInfo> characteristilist = new List<BleCharacteristicInfo>();
|
||||
|
||||
public void ConnectPeripheral(BlePeripheralInfo info, Action<IBleWinHwInterface, BlePeripheralInfo, BleResponse> callback)
|
||||
{
|
||||
var exsit = this.callbacks.Where(c => c.Key.Address == info.Address).Any();
|
||||
|
||||
Reference in new issue
Block a user