蓝牙监听调整

This commit is contained in:
lishuo 2021-06-08 16:28:00 +08:00
parent 1020632757
commit 541aefe4dd
6 changed files with 25 additions and 10 deletions

View File

@ -498,6 +498,7 @@ public class CyclingController : DeviceServiceMonoBase
cyclingController.recorderData.EndDistance = totalDistance;
cyclingController.recorderData.AntModelId = AntModelId;
cyclingController.recorderData.ManufacturerId = ManufacturerId;
cyclingController.recorderData.ManufacturerName = ManufacturerName;
cyclingController.recorderData.DeviceNumber = DeviceNumber;
//显示骑行结果
resultPanel.SetActive(true);

View File

@ -46,6 +46,7 @@ namespace Assets.Scenes.Ride.Scripts
{
var bleDevice = _device as BleDevice;
DeviceNumber = $"{ Helper.FormateMacAddress(bleDevice.Address) },{ ServiceUuids.GetBySensor(bleDevice.Sensor) }";
ManufacturerName = bleDevice.Name + "," + bleDevice.Network + "," + bleDevice.Sensor;
}
}
@ -111,6 +112,7 @@ namespace Assets.Scenes.Ride.Scripts
protected AntConnector _antConnector;
public int? ManufacturerId { get; private set; }
public string ManufacturerName { get; private set; }
public string DeviceNumber { get; private set; }
public int? AntModelId { get; private set; }
@ -144,6 +146,7 @@ namespace Assets.Scenes.Ride.Scripts
{
var bleDevice =_device as BleDevice;
DeviceNumber = $"{ bleDevice.Address },{ bleDevice.Sensor }";
ManufacturerName = bleDevice.Name + " " + bleDevice.Network + " " + bleDevice.Sensor;
}
}

View File

@ -112,13 +112,21 @@ namespace Assets.Scenes.Ride.Scripts
{
try
{
var s = Convert.ToInt64(v).ToString("x8").ToUpperInvariant();
var array = s.ToCharArray();
//var s = Convert.ToInt64(v).ToString("x8").ToUpperInvariant();
var array = v.ToCharArray();
StringBuilder newLsit = new StringBuilder();
for (int i = array.Length - 1; i >= 0; i--)
List<string> li = new List<string>();
for (int i = 0; i < array.Length; i++)
{
newLsit.Append(array[i]);
if (i % 2 == 0 && i > 0)
if ((i+1) % 2 == 0 && i > 0)
{
li.Add(array[i-1].ToString()+ array[i].ToString());
}
}
for (int i = li.Count() -1 ; i >= 0 ; i--)
{
newLsit.Append(li[i]);
if (i > 0)
{
newLsit.Append(":");
}

View File

@ -64,6 +64,8 @@ namespace Assets.Scenes.Ride.Scripts.Model
/// </summary>
public int? ManufacturerId { get; set; }
public string ManufacturerName { get; set; }
public int? AntModelId { get; set; }
/// <summary>
/// 骑行数据
@ -154,7 +156,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
ContinueIndex = ContinueIndex,
IsDelete = false,
MapCompetitionId = Competitionid,
ManufacturerName = "",//manufacturer == null ? "" : manufacturer.Name,
ManufacturerName = ManufacturerName,//manufacturer == null ? "" : manufacturer.Name,
DeviceNumber = DeviceNumber,
IsRanking = IsNeedRanking,
CurrentRouteStartDistance = CurrentRouteStartDistance,

View File

@ -56,7 +56,7 @@ namespace Assets.Scenes.Ride.Scripts
bicycleWeight = App.CurrentUser.BicycleWeight;
//#if UNITY_EDITOR
System.Random rd = new System.Random();
power = 1000; //rd.Next(150, 300);//测试功率
//power = 1000; //rd.Next(150, 300);//测试功率
//#endif
mainController.TrackResistance(currentSlope * App.rideSetting.sensitivity / 100);
}

View File

@ -138,11 +138,12 @@ namespace Assets.Scripts.Devices.Ble.Win
public bool StartWatcher()
{
this.wclWatcher.StartScan(this.wclBleManager.Radio);
return true;
return base.EnqueueAction(() =>
{
this.wclWatcher.StartScan(this.wclBleManager.Radio);
});
}
public WclBleGattThread CreateGattThread(BlePeripheralInfo info)
{
lock (locker)