适配C2划船机课程和menu

This commit is contained in:
Caiyanpeng committed 2022-03-30 18:25:51 +08:00
1 parent e0649f7ea1
commit 06aefb93c4
6 files changed
+162 -77

No files matched your search

@@ -23,7 +23,7 @@ namespace Assets.Scripts.Devices.Ble.Devices
private BleCharacteristicInfo controlPointCharacteristic;
private BleCharacteristicInfo c2Control;
public FtmsRower(BlePeripheralInfo peripheralInfo, IBleWinHwInterface bleWinHwInterface) :base(peripheralInfo, bleWinHwInterface, Ant.SensorType.Rower)
public FtmsRower(BlePeripheralInfo peripheralInfo, IBleWinHwInterface bleWinHwInterface) : base(peripheralInfo, bleWinHwInterface, Ant.SensorType.Rower)
{
Debug.Log(24);
base.Characteristics.Add(new FtmsFitnessMachineFeature());
@@ -44,7 +44,7 @@ namespace Assets.Scripts.Devices.Ble.Devices
{
hwInterface.DiscoverCharacteristic(service, (hwInterface, service1, response) =>
{
foreach (var character in response.Data)
{
//Debug.Log(character.Id.ToString());
@@ -70,13 +70,19 @@ namespace Assets.Scripts.Devices.Ble.Devices
//C2RowerData.IsEnabled = true;
this.hwInterface.SubscribeCharacteristic(character, null);
}
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerStatus))
//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);
Debug.Log("c2划船机课程数据" + service.Id);
//C2RowerData.IsEnabled = true;
this.hwInterface.SubscribeCharacteristic(character, null);
}
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerControl))
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerControl))
{
Debug.Log("c2划船机控制台");
this.c2Control = character;
@@ -97,7 +103,7 @@ namespace Assets.Scripts.Devices.Ble.Devices
var c = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.RowerData);
c.HandleAttributeReceived(response.Data);
}
else
else
{
var c = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.C2RowerData);
var data = new byte[] { characteristic.Id.ToByteArray()[0] }.Concat(response.Data).ToArray();
@@ -121,6 +127,27 @@ namespace Assets.Scripts.Devices.Ble.Devices
// }
//}
}
public void C2GetStatus()
{
if (C2RowerData.IsEnabled == true)
{
//等对csafe协议研究透彻后写
//if (this.c2Control != null)
//{
// var cmd = new byte[] { 0x80, 0xe8 };
// 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 Reset()
{