c2同步课程命令
This commit is contained in:
parent
701ec3069b
commit
06b9051b3c
@ -70,7 +70,6 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
|||||||
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 1)) / 100);
|
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 1)) / 100);
|
||||||
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 4)) / 10);
|
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 4)) / 10);
|
||||||
StrokeCount = BitConvertHelper.ToUInt16(data, 19);
|
StrokeCount = BitConvertHelper.ToUInt16(data, 19);
|
||||||
Debug.Log("数据" + string.Join(",", data) +$" | {ElapsedTime}-{TotalDistance}");
|
|
||||||
}
|
}
|
||||||
else if (data[0] == 0x3d)
|
else if (data[0] == 0x3d)
|
||||||
{
|
{
|
||||||
@ -140,10 +139,11 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
|||||||
}
|
}
|
||||||
else if (data[0] == 0x39)
|
else if (data[0] == 0x39)
|
||||||
{
|
{
|
||||||
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 1)) / 100);
|
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 5)) / 100);
|
||||||
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 4)) / 10);
|
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 8)) / 10);
|
||||||
CompleteEvent?.Invoke(this, null);
|
CompleteEvent?.Invoke(this, null);
|
||||||
}
|
}
|
||||||
|
Debug.Log("数据" + string.Join(",", data) + $" | {ElapsedTime}-{TotalDistance}");
|
||||||
//else if (data[0] == 34)
|
//else if (data[0] == 34)
|
||||||
//{
|
//{
|
||||||
// isReadyStatus = data[2] == 1 || data[2] == 129;
|
// isReadyStatus = data[2] == 1 || data[2] == 129;
|
||||||
|
|||||||
@ -229,11 +229,13 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
|||||||
checkSum = GetChecksumHexString(data);
|
checkSum = GetChecksumHexString(data);
|
||||||
data = BitConvertHelper.HexToByteArray($"F1 76 03 01 01 {typeHex} {checkSum} F2");
|
data = BitConvertHelper.HexToByteArray($"F1 76 03 01 01 {typeHex} {checkSum} F2");
|
||||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||||
|
Thread.Sleep(5);
|
||||||
}
|
}
|
||||||
public void SetConfigureWorkout()
|
public void SetConfigureWorkout()
|
||||||
{
|
{
|
||||||
var data = BitConvertHelper.HexToByteArray("F1 76 03 14 01 01 61 F2"); //03?
|
var data = BitConvertHelper.HexToByteArray("F1 76 03 14 01 01 61 F2"); //03?
|
||||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||||
|
Thread.Sleep(5);
|
||||||
}
|
}
|
||||||
public void SetScreenState()
|
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");
|
var data = BitConvertHelper.HexToByteArray("F1 76 07 01 01 01 13 02 01 01 61 F2");
|
||||||
Debug.Log($"SetJustRow:{string.Join(",", data)}");
|
Debug.Log($"SetJustRow:{string.Join(",", data)}");
|
||||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||||
|
Thread.Sleep(5);
|
||||||
SetScreenState();
|
SetScreenState();
|
||||||
}
|
}
|
||||||
public void SetFixedDistance(int distance)
|
public void SetFixedDistance(int distance)
|
||||||
@ -258,16 +261,19 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SetWorkoutType(3);
|
SetWorkoutType(3);
|
||||||
|
|
||||||
var hexditance = distance.ToString("X4");
|
var hexditance = distance.ToString("X4");
|
||||||
var checkSum = "00";
|
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
|
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);
|
checkSum = GetChecksumHexString(data);
|
||||||
data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 80 00 00 {hexditance} {checkSum} F2");//07?
|
data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 80 00 00 {hexditance} {checkSum} F2");//07?
|
||||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||||
|
Thread.Sleep(5);
|
||||||
|
|
||||||
SetConfigureWorkout();
|
SetConfigureWorkout();
|
||||||
|
|
||||||
SetScreenState();
|
SetScreenState();
|
||||||
|
|
||||||
}
|
}
|
||||||
private string GetChecksumHexString(byte[] data)
|
private string GetChecksumHexString(byte[] data)
|
||||||
{
|
{
|
||||||
@ -281,15 +287,16 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
|||||||
public void SetFixedTime(int mins)
|
public void SetFixedTime(int mins)
|
||||||
{
|
{
|
||||||
SetWorkoutType(5);
|
SetWorkoutType(5);
|
||||||
|
Thread.Sleep(5);
|
||||||
var timeHex = (mins * 100).ToString("X6");
|
var timeHex = (mins * 100).ToString("X6");
|
||||||
var checkNum = "00";
|
var checkNum = "00";
|
||||||
var data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 00 00 {timeHex} {checkNum} F2");
|
var data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 00 00 {timeHex} {checkNum} F2");
|
||||||
checkNum = GetChecksumHexString(data);
|
checkNum = GetChecksumHexString(data);
|
||||||
data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 00 00 {timeHex} {checkNum} F2");
|
data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 00 00 {timeHex} {checkNum} F2");
|
||||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||||
|
Thread.Sleep(5);
|
||||||
SetConfigureWorkout();
|
SetConfigureWorkout();
|
||||||
|
Thread.Sleep(5);
|
||||||
SetScreenState();
|
SetScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -413,10 +414,11 @@ namespace Assets.Scripts.Ble
|
|||||||
{
|
{
|
||||||
this.characteristicNotificationCallbacks.Add(characteristic.Peripheral, callback);
|
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)=>
|
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) =>
|
}, (deviceAddress, characteristric, bytes) =>
|
||||||
{
|
{
|
||||||
if (characteristicReadEvent != null)
|
if (characteristicReadEvent != null)
|
||||||
|
|||||||
@ -98,14 +98,15 @@ public class ActivityController : PFUIPanel
|
|||||||
webView.SetUserAgent($"UniWebView {Application.platform} {Application.version}");
|
webView.SetUserAgent($"UniWebView {Application.platform} {Application.version}");
|
||||||
webView.BackgroundColor = Utils.HexToColorHtml("#23232d");
|
webView.BackgroundColor = Utils.HexToColorHtml("#23232d");
|
||||||
//webView.CleanCache();
|
//webView.CleanCache();
|
||||||
if (action == null)
|
webView.Load(url);
|
||||||
{
|
//if (action == null)
|
||||||
webView.Load(url);
|
//{
|
||||||
}
|
// webView.Load(url);
|
||||||
else
|
//}
|
||||||
{
|
//else
|
||||||
action.Invoke();
|
//{
|
||||||
}
|
// action.Invoke();
|
||||||
|
//}
|
||||||
// Show it.
|
// Show it.
|
||||||
webView.Show();
|
webView.Show();
|
||||||
webView.OnMessageReceived -= FromJs;
|
webView.OnMessageReceived -= FromJs;
|
||||||
|
|||||||
@ -508,7 +508,7 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
if (rowdata != RowerData)
|
if (rowdata != RowerData)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Debug.Log($"开始了:{openTimer}");
|
Debug.Log($"开始了:{openTimer}-{DateTime.Now}");
|
||||||
if (UIManager.Instance.confirm != null && UIManager.Instance.confirm.IsActive())
|
if (UIManager.Instance.confirm != null && UIManager.Instance.confirm.IsActive())
|
||||||
{
|
{
|
||||||
print("当前有弹窗");
|
print("当前有弹窗");
|
||||||
@ -561,9 +561,19 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
var power = RowerData.InstantaneousPower;
|
var power = RowerData.InstantaneousPower;
|
||||||
var rate = RowerData.StrokeRate;
|
var rate = RowerData.StrokeRate;
|
||||||
|
|
||||||
KMText.text = "0";
|
if (rowerType.type == 1)
|
||||||
records.Add($"{strokeCount},{RowerData.ElapsedTime},{rowerType.value},{RowerData.InstantaneousPower},{RowerData.InstantaneousPace},{RowerData.StrokeRate},{RowerData.ResistanceLevel},{heartRate},{energy},{RowerData.AveragePower},{RowerData.ElapsedTime}");
|
{
|
||||||
var tmpdata = new TempRowerCalc() { strokeCount = strokeCount, pace = RowerData.InstantaneousPace, power = power, rate = rate, heartRate = heartRate, distance = (int)rowerType.value, energy = energy };
|
TimeText.text = $"{RowerData.ElapsedTime}";
|
||||||
|
KMText.text = "0";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TimeText.text = TimeSpan.FromSeconds(0).ToPFString();
|
||||||
|
KMText.text = $"{RowerData.TotalDistance}";
|
||||||
|
}
|
||||||
|
|
||||||
|
records.Add($"{strokeCount},{RowerData.ElapsedTime},{RowerData.TotalDistance},{RowerData.InstantaneousPower},{RowerData.InstantaneousPace},{RowerData.StrokeRate},{RowerData.ResistanceLevel},{heartRate},{energy},{RowerData.AveragePower},{RowerData.ElapsedTime}");
|
||||||
|
var tmpdata = new TempRowerCalc() { strokeCount = strokeCount, pace = RowerData.InstantaneousPace, power = power, rate = rate, heartRate = heartRate, distance = (int)RowerData.TotalDistance, energy = energy };
|
||||||
values.Add(tmpdata);
|
values.Add(tmpdata);
|
||||||
SendDataToRace(tmpdata);
|
SendDataToRace(tmpdata);
|
||||||
HandleSaveDirect();
|
HandleSaveDirect();
|
||||||
@ -920,7 +930,7 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
TempRowerCalc tmpdata = null;
|
TempRowerCalc tmpdata = null;
|
||||||
|
|
||||||
//解决C2里程训练无法结束的问题
|
//解决C2里程训练无法结束的问题
|
||||||
var c2notStop = C2RowerData.IsEnabled && rowerType.type == 1 && (rowerType.value-totalDistance) <= 5;
|
var c2notStop = C2RowerData.IsEnabled && rowerType!=null && rowerType.type !=0 && (rowerType.value-totalDistance) <= 5;
|
||||||
//里程停止逻辑
|
//里程停止逻辑
|
||||||
if (totalDistance == RowerData.TotalDistance && !c2notStop)
|
if (totalDistance == RowerData.TotalDistance && !c2notStop)
|
||||||
{
|
{
|
||||||
@ -934,6 +944,7 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
}
|
}
|
||||||
if (stopSeconds >= 2)
|
if (stopSeconds >= 2)
|
||||||
{
|
{
|
||||||
|
Debug.Log($"stopSeconds:{RowerData.TotalDistance}");
|
||||||
if (UIManager.Instance.confirm != null && UIManager.Instance.confirm.IsActive()) {
|
if (UIManager.Instance.confirm != null && UIManager.Instance.confirm.IsActive()) {
|
||||||
Debug.Log("stopSeconds >= 2");
|
Debug.Log("stopSeconds >= 2");
|
||||||
transform.Find("Stopped").gameObject.SetActive(false);
|
transform.Find("Stopped").gameObject.SetActive(false);
|
||||||
|
|||||||
@ -294,6 +294,8 @@ public class UniWebView: MonoBehaviour {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void UpdateFrame() {
|
public void UpdateFrame() {
|
||||||
Rect rect = NextFrameRect();
|
Rect rect = NextFrameRect();
|
||||||
|
if (listener == null)
|
||||||
|
return;
|
||||||
UniWebViewInterface.SetFrame(listener.Name, (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
|
UniWebViewInterface.SetFrame(listener.Name, (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user