c2同步课程命令
This commit is contained in:
1 parent
701ec3069b
commit
06b9051b3c
6 files changed
+44
-21
No files matched your search
@@ -70,7 +70,6 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
||||
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 1)) / 100);
|
||||
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 4)) / 10);
|
||||
StrokeCount = BitConvertHelper.ToUInt16(data, 19);
|
||||
Debug.Log("数据" + string.Join(",", data) +$" | {ElapsedTime}-{TotalDistance}");
|
||||
}
|
||||
else if (data[0] == 0x3d)
|
||||
{
|
||||
@@ -140,10 +139,11 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
||||
}
|
||||
else if (data[0] == 0x39)
|
||||
{
|
||||
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 1)) / 100);
|
||||
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 4)) / 10);
|
||||
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 5)) / 100);
|
||||
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;
|
||||
|
||||
@@ -229,11 +229,13 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
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()
|
||||
{
|
||||
@@ -250,6 +252,7 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
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)
|
||||
@@ -258,16 +261,19 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
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)
|
||||
{
|
||||
@@ -281,15 +287,16 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using UnityEngine;
|
||||
@@ -413,10 +414,11 @@ namespace Assets.Scripts.Ble
|
||||
{
|
||||
this.characteristicNotificationCallbacks.Add(characteristic.Peripheral, callback);
|
||||
}
|
||||
Debug.Log("SubscribeCharacteristic" + characteristic.Peripheral.Name + characteristic.Service.ToString() + characteristic.Service.ToString());
|
||||
Thread.Sleep(50);
|
||||
Debug.Log("SubscribeCharacteristic" + characteristic.Peripheral.Name + characteristic.Service.ToString() + characteristic.Id.ToString());
|
||||
BluetoothLEHardwareInterface.SubscribeCharacteristicWithDeviceAddress(characteristic.Peripheral.Address, characteristic.Service.ToString(), characteristic.Id.ToString(), (a,b)=>
|
||||
{
|
||||
Debug.Log("返回特征值," + a + "," + b);
|
||||
Debug.Log("返回特征值," + a + "," + b+DateTime.Now.ToString());
|
||||
}, (deviceAddress, characteristric, bytes) =>
|
||||
{
|
||||
if (characteristicReadEvent != null)
|
||||
|
||||
Reference in new issue
Block a user