适配v1表头,性能优化一波

This commit is contained in:
Caiyanpeng committed 2022-05-11 17:11:48 +08:00
1 parent edc629ed75
commit be687d6b77
10 files changed
+282 -162

No files matched your search

+33 -18
View File
@@ -59,18 +59,34 @@ namespace Assets.Scripts.Devices.Ble.Devices
Debug.Log("ftms划船机" + service.Id);
this.hwInterface.SubscribeCharacteristic(character, null);
}
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData))
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.C2RowerData1))
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);
@@ -109,7 +125,7 @@ namespace Assets.Scripts.Devices.Ble.Devices
}
else
{
var c = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.C2RowerData);
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();
@@ -134,25 +150,24 @@ namespace Assets.Scripts.Devices.Ble.Devices
// }
//}
}
public void C2GetStatus()
public void C2GetStatus(byte[] bs)
{
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 });
//}
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 });
}
}
}