蓝牙问题

This commit is contained in:
CaiYanPeng 2021-09-30 09:06:35 +08:00
parent 561ad993b8
commit 9511e30e50
3 changed files with 27 additions and 6 deletions

View File

@ -1,6 +1,8 @@
using Assets.Scenes.Ride.Scripts;
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using Assets.Scripts.Ble.Service;
using Assets.Scripts.Devices;
using Assets.Scripts.Devices.Ant;
using Assets.Scripts.Devices.Ant.Interfaces;
using Assets.Scripts.Devices.Ble;
@ -40,6 +42,11 @@ public class RowerHomeScript : PFUIPanel
return null;
}
}
protected override void OnDestroy()
{
Debug.Log("銷毀");
}
private IRowerDevice Rower
{
get
@ -81,6 +88,7 @@ public class RowerHomeScript : PFUIPanel
bool isPause = false;
protected override void Awake()
{
spriteDict = new Dictionary<object, Sprite>()
{
{"Start",Resources.Load<Sprite>("Images/Rower/System_play")},
@ -122,9 +130,21 @@ public class RowerHomeScript : PFUIPanel
var mainNav = this.transform.Find("MainNav").GetComponent<MainNav>();
mainNav.ShowRowerTab();
transform.MyDOFade();
App.MainDeviceAdapter.StartScan();
Init();
//transform.Find("Left/Rower").GetComponent<RowerAnimation>().StartAnimation();
}
void Disconnect()
{
foreach(var d in App.MainDeviceAdapter.GetDevices())
{
if ((d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && (d.Sensor == SensorType.Rower || d.Sensor == SensorType.HeartRate))
{
d.Disconnect();
}
}
App.MainDeviceAdapter.StopScan();
}
private void HandleStartOrPause()
{
//UIManager.ShowRowerResult();
@ -244,6 +264,7 @@ public class RowerHomeScript : PFUIPanel
Debug.Log(ex.Message);
}
UIManager.ShowRowerWelldone(model);
Disconnect();
Task.Run(()=>
{
var res = ConfigHelper.rowerApi.Add(model, files);
@ -294,6 +315,7 @@ public class RowerHomeScript : PFUIPanel
Utils.showToast(null, "Please end this training.");
return;
}
Disconnect();
UIManager.ShowHomePanel();
}
@ -416,5 +438,4 @@ public class RowerHomeScript : PFUIPanel
}
}
}
}

View File

@ -95,7 +95,7 @@ public class RouteItem : MonoBehaviour
row1.Find("Distance").GetComponent<Text>().text = $"<color=#5c5c6e>Distance:</color>{result.TotalDistance}M";
row2.Find("Device").GetComponent<Text>().text = $"<color=#5c5c6e>Rowing equipment:</color>{result.ManufacturerName}";
left.Find("Progress").gameObject.SetActive(false);
left.Find("Main/Name").GetComponent<Text>().text = "Free rowing";
left.Find("Main/Name").GetComponent<Text>().text = $"{result.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")} Free rowing";
left.Find("Main/Time").GetComponent<Text>().text = $"{result.StartTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")} ~ {result.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")}";
var rect = left.Find("Main").GetComponent<RectTransform>();
rect.sizeDelta = new Vector2(399,rect.sizeDelta.y);

View File

@ -224,10 +224,10 @@ public class UIManager : MonoBehaviour
public static void ShowRowerPanel()
{
App.IsRowerMode = true;
App.MainDeviceAdapter.ClearDevice();
#if UNITY_ANDROID || UNITY_IOS
App.MainDeviceAdapter.StartScan();
#endif
// App.MainDeviceAdapter.ClearDevice();
//#if UNITY_ANDROID || UNITY_IOS
// App.MainDeviceAdapter.StartScan();
//#endif
stack.Clear();
UIManager.Show(UIManager.Instance.RowerHomeScript, UIManager.Instance.MainPanel);
}