修复ios蓝牙关闭功率不变的问题

This commit is contained in:
lishuo 2022-02-11 17:00:28 +08:00
parent c12df53c18
commit 5f0efe3995
7 changed files with 38 additions and 6 deletions

View File

@ -748,7 +748,8 @@ extern "C" {
{
NSLog(@"Central State: Powered Off");
NSString *message = [NSString stringWithFormat:@"Error~Bluetooth LE Powered Off"];
//NSString *message = [NSString stringWithFormat:@"Error~Bluetooth LE Powered Off"];
NSString *message = [NSString stringWithFormat:@"BleStatusChanged~13"];
UnitySendMessage ("BluetoothLEReceiver", "OnBluetoothMessage", [message UTF8String] );
} break;
@ -756,7 +757,14 @@ extern "C" {
{
NSLog(@"Central State: Powered On");
if (_isInitializing)
UnitySendMessage ("BluetoothLEReceiver", "OnBluetoothMessage", "Initialized");
{
UnitySendMessage ("BluetoothLEReceiver", "OnBluetoothMessage", "Initialized");
}
else
{
NSString *message = [NSString stringWithFormat:@"BleStatusChanged~11"];
UnitySendMessage ("BluetoothLEReceiver", "OnBluetoothMessage", [message UTF8String] );
}
_isInitializing = FALSE;
} break;

View File

@ -122,7 +122,7 @@ namespace Assets.Scripts.Apis
#else
defaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Unity", ConfigHelper.AppVersion));
#endif
defaultRequestHeaders.Add("deviceUniqueIdentifier", SystemInfo.deviceUniqueIdentifier);
defaultRequestHeaders.Add("deviceUniqueIdentifier", App.DeviceUniqueIdentifier);
defaultRequestHeaders.Remove("Language");
defaultRequestHeaders.Add("Language", App.GetLocalLanguage());
}
@ -558,6 +558,7 @@ namespace Assets.Scripts.Apis
request.UserAgent = httpClient.DefaultRequestHeaders.UserAgent.ToString();
request.Accept = "application/json";
request.Headers.Add("Language", App.GetLocalLanguage());
request.Headers.Add("deviceUniqueIdentifier", App.DeviceUniqueIdentifier);
request.CookieContainer = new CookieContainer();
foreach (Cookie item in cookies)
{

View File

@ -95,6 +95,15 @@ namespace Assets.Scripts.Apis
{
return Get<JsonResult<Dictionary<string, string>>>($"Map/GetServiceKey").data;
}
/// <summary>
/// 骑行场景轮询是否有新设备登录
/// </summary>
/// <returns></returns>
public async Task<JsonResult> GetPing()
{
var res = await GetAsync<JsonResult>($"/Map/v1/Ping");
return res;
}
/// <summary>
/// 获取在线用户的数据

View File

@ -8,6 +8,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
using Assets.Scenes.Ride.Scripts;
namespace Assets.Scripts.Apis
{
@ -62,6 +63,9 @@ namespace Assets.Scripts.Apis
}
IEnumerator LoadLogin(string msg)
{
//删除本地文件
Helper.DelectDir(PFConstants.MapWorkoutRecordTempFolder);
App.tempRecordData = null;
UnityEngine.SceneManagement.SceneManager.LoadScene(0);
yield return null;
}

View File

@ -20,7 +20,7 @@ public delegate void ChangeLanguageDelegate();
public static class App
{
public static string Host = "http://192.168.0.101:5084/";
public static string Host = "http://192.168.0.102:5082/";
public static string AppVersion = Application.version;
@ -174,6 +174,7 @@ public static class App
public static List<MapRoute> RouteList = new List<MapRoute>();
public static bool _currentPageIsHome = false;
public static event EventHandler isHomeChanged;
public static string DeviceUniqueIdentifier = SystemInfo.deviceUniqueIdentifier;
public static bool currentPageIsHome
{
get => _currentPageIsHome;

View File

@ -237,6 +237,7 @@ public class CyclingController : DeviceServiceMonoBase
SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
HandleTouchAndInput();
StartCoroutine(Ping());
//进入比赛
if (competitionId > 0)
{
@ -253,6 +254,14 @@ public class CyclingController : DeviceServiceMonoBase
}
private IEnumerator Ping()
{
while (true)
{
var result = ConfigHelper.mapApi.GetPing();
yield return new WaitForSeconds(5);
}
}
float timer = 1f;
bool clearLock = false;

View File

@ -79,9 +79,9 @@ public class LocalRouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterH
Name.text = record.RouteName;
Time.text = record.StartTime.ToLocalString("HH:mm:ss dd-MM-yyyy");
RidingTime.text = $"<color={titleColor}>{App.GetLocalString("Riding time")}:</color>{Helper.FormatTicks(record.Ticks)}";
RidingTime.text = $"<color={titleColor}>{App.GetLocalString("Riding Time")}:</color>{Helper.FormatTicks(record.Ticks)}";
RidingDistance.text = $"<color={titleColor}>{App.GetLocalString("Mileage")}:</color>{record.EndDistance.ToString("#0.00")}KM";
Device.text = $"<color={titleColor}>{App.GetLocalString("Cycling equipment")}:</color>{record.ManufacturerName}";
Device.text = $"<color={titleColor}>{App.GetLocalString("Cycling Equipment")}:</color>{record.ManufacturerName}";
}
else
{