最新打包配置;适配wahoo

This commit is contained in:
CaiYanPeng 2022-08-25 18:00:33 +08:00
parent 74bdd26924
commit b830b5961a
20 changed files with 280 additions and 189 deletions

View File

@ -1,33 +1,32 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: a70633e155d144f5da10d40c35d9c832 guid: a70633e155d144f5da10d40c35d9c832
timeCreated: 1528980533
licenseType: Store
PluginImporter: PluginImporter:
externalObjects: {}
serializedVersion: 2 serializedVersion: 2
iconMap: {} iconMap: {}
executionOrder: {} executionOrder: {}
defineConstraints: []
isPreloaded: 0 isPreloaded: 0
isOverridable: 0 isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData: platformData:
data: - first:
first: Android: Android
Android: Android second:
second: enabled: 1
enabled: 1 settings: {}
settings: {} - first:
data: Any:
first: second:
Any: enabled: 0
second: settings: {}
enabled: 0 - first:
settings: {} Editor: Editor
data: second:
first: enabled: 0
Editor: Editor settings:
second: DefaultValueInitialized: true
enabled: 0
settings:
DefaultValueInitialized: true
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View File

@ -12,7 +12,7 @@ allprojects {
// See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html // See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
// See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle // See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
// To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version // To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
classpath 'com.android.tools.build:gradle:3.4.3' classpath 'com.android.tools.build:gradle:4.1.0'
**BUILD_SCRIPT_DEPS** **BUILD_SCRIPT_DEPS**
} }
} }

View File

@ -0,0 +1,73 @@
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
apply plugin: 'com.android.application'
dependencies {
implementation project(':unityLibrary')
}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
applicationId '**APPLICATIONID**'
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
}
aaptOptions {
noCompress = ['.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**]
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**SIGN**
lintOptions {
abortOnError false
}
buildTypes {
debug {
minifyEnabled **MINIFY_DEBUG**
useProguard **PROGUARD_DEBUG**
proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
jniDebuggable true
}
release {
minifyEnabled **MINIFY_RELEASE**
useProguard **PROGUARD_RELEASE**
proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
}
}**PACKAGING_OPTIONS****PLAY_ASSET_PACKS****SPLITS**
**BUILT_APK_LOCATION**
bundle {
language {
enableSplit = false
}
density {
enableSplit = false
}
abi {
enableSplit = true
}
}
}**SPLITS_VERSION_CODE****LAUNCHER_SOURCE_BUILD_SETUP**
task localizeAppName(type: Copy) {
from("${project.rootDir}/unityLibrary/unity-android-resources/res/") {
include "**/strings.xml"
}
into "${project.rootDir}/launcher/src/main/res"
}
preBuild.dependsOn(localizeAppName)

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 90b16fb413bf03d44bf5dcf31fd8c8f5
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -46,12 +46,3 @@ android {
}**PACKAGING_OPTIONS** }**PACKAGING_OPTIONS**
}**REPOSITORIES****SOURCE_BUILD_SETUP** }**REPOSITORIES****SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES** **EXTERNAL_SOURCES**
task localizeAppName(type: Copy) {
from("${project.rootDir}/unityLibrary/unity-android-resources/res/") {
include "**/strings.xml"
}
into "${project.rootDir}/launcher/src/main/res"
}
preBuild.dependsOn(localizeAppName)

View File

@ -211,6 +211,8 @@ public static class App
public static List<string> cacheList = new List<string>(); public static List<string> cacheList = new List<string>();
static App() static App()
{ {
Debug.Log((byte)(10.01548687 * 10));
//Debug.Log(BitConverter.ToUInt16(new byte[] {220,2 },0));
InitLanguage(); InitLanguage();
#if !UNITY_EDITOR #if !UNITY_EDITOR
//Host = "http://pf.juze.pro/"; //Host = "http://pf.juze.pro/";

View File

@ -294,6 +294,7 @@ namespace Assets.Scripts.Devices.Ant
void antChannel_channelResponse_FeSearch(ANT_Response response) void antChannel_channelResponse_FeSearch(ANT_Response response)
{ {
//删除扫描不到的设备 //删除扫描不到的设备
var now = DateTime.Now; var now = DateTime.Now;
var needRemoveList = discoveredDevices.Where(c => (now - c.LastActiveTime).TotalSeconds > 5 && c.State == DeviceState.Disconnected).ToList(); var needRemoveList = discoveredDevices.Where(c => (now - c.LastActiveTime).TotalSeconds > 5 && c.State == DeviceState.Disconnected).ToList();
@ -430,7 +431,7 @@ namespace Assets.Scripts.Devices.Ant
u.DeviceTypeId == device.searchProfile.deviceType.ToString())) u.DeviceTypeId == device.searchProfile.deviceType.ToString()))
return; return;
if (device.Sensor == SensorType.Trainer || device.Sensor == SensorType.Power) if (device.Sensor == SensorType.Trainer || device.Sensor == SensorType.FtmsTrainer || device.Sensor == SensorType.Power)
{ {
if (discoveredDevices.Any(s => s.Sensor == device.Sensor && (s.State == DeviceState.Connected || s.State == DeviceState.Connecting))) if (discoveredDevices.Any(s => s.Sensor == device.Sensor && (s.State == DeviceState.Connected || s.State == DeviceState.Connecting)))
{ {

View File

@ -5,48 +5,24 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine;
namespace Assets.Scripts.Devices.Ble.Characteristic namespace Assets.Scripts.Devices.Ble.Characteristic
{ {
[Flags]
public enum TrainerDataFlag
{
MoreData = 1,
Cadence = 4,
Power = 64
}
public class FtmsIndoorBikeData : ICharacteristic public class FtmsIndoorBikeData : ICharacteristic
{ {
private readonly ushort? _instantSpeedSubject = new ushort?();
private readonly ushort? _averageSpeedSubject = new ushort?();
private readonly ushort? _instantCadenceSubject = new ushort?();
private readonly ushort? _averageCadenceSubject = (new ushort?());
private readonly uint? _totalDistanceSubject = (new uint?());
private readonly short? _resistanceLevelSubject = (new short?());
private readonly short? _instantPowerSubject = (new short?());
private readonly short? _averagePowerSubject = (new short?());
private readonly ushort? _totalEnergySubject = (new ushort?());
private readonly ushort? _energyPerHourSubject = (new ushort?());
private readonly byte? _energyPerMinuteSubject = (new byte?());
private readonly byte? _heartRateSubject = (new byte?());
private readonly byte? _metabolicEquivalentSubject = (new byte?());
private readonly ushort? _elapsedTimeSubject = (new ushort?());
private readonly ushort? _remainingTimeSubject = (new ushort?());
public short? InstantPower public int? InstantPower { get; set; }
{ public int? InstantCadence { get; set; }
get public double? InstantSpeed { get; set; }
{
return this._instantPowerSubject;
}
}
public ushort? InstantCadence
{
get
{
return this._instantCadenceSubject;
}
}
public ushort? InstantSpeed
{
get
{
return this._instantSpeedSubject;
}
}
public Guid Uuid => ServiceUuids.Characteristics.IndoorBikeData; public Guid Uuid => ServiceUuids.Characteristics.IndoorBikeData;
@ -55,43 +31,27 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
public bool IsOptional => false; public bool IsOptional => false;
public TrainerDataFlag Flags;
public void HandleAttributeReceived(byte[] data) public void HandleAttributeReceived(byte[] data)
{ {
if(data.Length < 2) if(data.Length < 2)
{ {
return; return;
} }
this.Flags = (TrainerDataFlag)BitConverter.ToUInt16(data, 0);
List<FtmsIndoorBikeData.IndoorBikeDataField> list = new List<FtmsIndoorBikeData.IndoorBikeDataField>(); int b = 2;
if (!ByteExtensions.IsFlagSetAtPosition(data[0], (byte)0)) if (Flags.HasFlag(TrainerDataFlag.Cadence))
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.InstantaneousSpeed); {
if (ByteExtensions.IsFlagSetAtPosition(data[0], (byte)1)) this.InstantSpeed = BitConverter.ToUInt16(data, b) / 100f;
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.AverageSpeed); this.InstantCadence = (ushort)(BitConverter.ToUInt16(data, b + 2) / 2);
if (ByteExtensions.IsFlagSetAtPosition(data[0], (byte)2)) b += this.SizeOfDataForFlag(TrainerDataFlag.Cadence);
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.InstantaneousCadence); }
if (ByteExtensions.IsFlagSetAtPosition(data[0], (byte)3)) if (Flags.HasFlag(TrainerDataFlag.Power))
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.AverageCadence); {
if (ByteExtensions.IsFlagSetAtPosition(data[0], (byte)4)) this.InstantPower = BitConverter.ToUInt16(data, b);
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.TotalDistance); b += this.SizeOfDataForFlag(TrainerDataFlag.Power);
if (ByteExtensions.IsFlagSetAtPosition(data[0], (byte)5)) }
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.ResistanceLevel); //Debug.Log("速度:" + this.InstantSpeed + "踏频:" + this.InstantCadence + "功率:" + this.InstantPower);
if (ByteExtensions.IsFlagSetAtPosition(data[0], (byte)6))
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.InstantaneousPower);
if (ByteExtensions.IsFlagSetAtPosition(data[0], (byte)7))
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.AveragePower);
if (ByteExtensions.IsFlagSetAtPosition(data[1], (byte)0))
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.ExpendedEnergy);
if (ByteExtensions.IsFlagSetAtPosition(data[1], (byte)1))
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.HeartRate);
if (ByteExtensions.IsFlagSetAtPosition(data[1], (byte)2))
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.MetabolicEquivalent);
if (ByteExtensions.IsFlagSetAtPosition(data[1], (byte)3))
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.ElapsedTime);
if (ByteExtensions.IsFlagSetAtPosition(data[1], (byte)4))
list.Add(FtmsIndoorBikeData.IndoorBikeDataField.RemainingTime);
int offset = 2;
foreach (FtmsIndoorBikeData.IndoorBikeDataField field in list)
offset += this.ParseField(data, offset, field);
} }
public void SetUnavailable() public void SetUnavailable()
@ -99,58 +59,6 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
//throw new NotImplementedException(); //throw new NotImplementedException();
} }
private int ParseField(byte[] attribute, int offset, FtmsIndoorBikeData.IndoorBikeDataField field)
{
int fieldSize = FtmsIndoorBikeData.GetFieldSize(field);
if (attribute.Length < fieldSize + offset)
throw new ArgumentException("attribute");
switch (field)
{
case FtmsIndoorBikeData.IndoorBikeDataField.InstantaneousSpeed:
ICharacteristicExtensions.HandleUshortAttributeValue((ICharacteristic)this, attribute, offset, this._instantSpeedSubject);
break;
case FtmsIndoorBikeData.IndoorBikeDataField.AverageSpeed:
ICharacteristicExtensions.HandleUshortAttributeValue((ICharacteristic)this, attribute, offset, this._averageSpeedSubject);
break;
case FtmsIndoorBikeData.IndoorBikeDataField.InstantaneousCadence:
ICharacteristicExtensions.HandleUshortAttributeValue((ICharacteristic)this, attribute, offset, this._instantCadenceSubject);
break;
case FtmsIndoorBikeData.IndoorBikeDataField.AverageCadence:
ICharacteristicExtensions.HandleUshortAttributeValue((ICharacteristic)this, attribute, offset, this._averageCadenceSubject);
break;
case FtmsIndoorBikeData.IndoorBikeDataField.TotalDistance:
ICharacteristicExtensions.HandleUint24AttributeValue((ICharacteristic)this, attribute, offset, this._totalDistanceSubject);
break;
case FtmsIndoorBikeData.IndoorBikeDataField.ResistanceLevel:
ICharacteristicExtensions.HandleShortAttributeValue((ICharacteristic)this, attribute, offset, this._resistanceLevelSubject);
break;
case FtmsIndoorBikeData.IndoorBikeDataField.InstantaneousPower:
ICharacteristicExtensions.HandleShortAttributeValue((ICharacteristic)this, attribute, offset, this._instantPowerSubject);
break;
case FtmsIndoorBikeData.IndoorBikeDataField.AveragePower:
ICharacteristicExtensions.HandleShortAttributeValue((ICharacteristic)this, attribute, offset, this._averagePowerSubject);
break;
case FtmsIndoorBikeData.IndoorBikeDataField.ExpendedEnergy:
ICharacteristicExtensions.HandleUshortAttributeValue((ICharacteristic)this, attribute, offset, this._totalEnergySubject);
ICharacteristicExtensions.HandleUshortAttributeValue((ICharacteristic)this, attribute, offset + 2, this._energyPerHourSubject);
ICharacteristicExtensions.HandleByteAttributeValue((ICharacteristic)this, attribute, offset + 4, this._energyPerMinuteSubject);
break;
case FtmsIndoorBikeData.IndoorBikeDataField.HeartRate:
ICharacteristicExtensions.HandleByteAttributeValue((ICharacteristic)this, attribute, offset, this._heartRateSubject);
break;
case FtmsIndoorBikeData.IndoorBikeDataField.MetabolicEquivalent:
ICharacteristicExtensions.HandleByteAttributeValue((ICharacteristic)this, attribute, offset, this._metabolicEquivalentSubject);
break;
case FtmsIndoorBikeData.IndoorBikeDataField.ElapsedTime:
ICharacteristicExtensions.HandleUshortAttributeValue((ICharacteristic)this, attribute, offset, this._elapsedTimeSubject);
break;
case FtmsIndoorBikeData.IndoorBikeDataField.RemainingTime:
ICharacteristicExtensions.HandleUshortAttributeValue((ICharacteristic)this, attribute, offset, this._remainingTimeSubject);
break;
}
return fieldSize;
}
private static int GetFieldSize(FtmsIndoorBikeData.IndoorBikeDataField field) private static int GetFieldSize(FtmsIndoorBikeData.IndoorBikeDataField field)
{ {
int num = 0; int num = 0;
@ -216,5 +124,22 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
ElapsedTime, ElapsedTime,
RemainingTime, RemainingTime,
} }
public int SizeOfDataForFlag(TrainerDataFlag flag)
{
int num = 0;
switch (flag)
{
//case RowerDataFlag.MoreData:
// break;
case TrainerDataFlag.MoreData: num = 2; break;
case TrainerDataFlag.Power: num = 2; break;
case TrainerDataFlag.Cadence: num = 4; break;
default:
break;
}
return num;
}
} }
} }

View File

@ -8,18 +8,18 @@ using UnityEngine;
namespace Assets.Scripts.Devices.Ble.Devices namespace Assets.Scripts.Devices.Ble.Devices
{ {
public class Ftms : BleDevice, ISpeedDevice, IPowerDevice, ICadenceDevice, ITrainerDevice public class Ftms : BleDevice, ISpeedDevice, IPowerDevice, ICadenceDevice, ITrainerDevice, IRequiresRiderWeight
{ {
public int Power { get => _ftmsIndoorBikeData.InstantPower.GetValueOrDefault(0); set => throw new NotImplementedException(); } public int Power { get => _ftmsIndoorBikeData.InstantPower.GetValueOrDefault(0); set => throw new NotImplementedException(); }
public double Speed { get => _ftmsIndoorBikeData.InstantSpeed.GetValueOrDefault(0); set => throw new NotImplementedException(); } public double Speed { get => _ftmsIndoorBikeData.InstantSpeed.GetValueOrDefault(0); set => throw new NotImplementedException(); }
public int Cadence { get => _ftmsIndoorBikeData.InstantCadence.GetValueOrDefault(0); set => throw new NotImplementedException(); } public int Cadence { get => _ftmsIndoorBikeData.InstantCadence.GetValueOrDefault(0); set => throw new NotImplementedException(); }
public double RiderWeight { get; set; }
private FtmsIndoorBikeData _ftmsIndoorBikeData; private FtmsIndoorBikeData _ftmsIndoorBikeData;
private List<BleServiceInfo> Services; private List<BleServiceInfo> Services;
private BleCharacteristicInfo controlPointCharacteristic; private BleCharacteristicInfo controlPointCharacteristic;
public Ftms(BlePeripheralInfo peripheralInfo, IBleWinHwInterface bleWinHwInterface) :base(peripheralInfo, bleWinHwInterface, Ant.SensorType.Trainer) public Ftms(BlePeripheralInfo peripheralInfo, IBleWinHwInterface bleWinHwInterface) :base(peripheralInfo, bleWinHwInterface, Ant.SensorType.FtmsTrainer)
{ {
this._ftmsIndoorBikeData = new FtmsIndoorBikeData(); this._ftmsIndoorBikeData = new FtmsIndoorBikeData();
base.Characteristics.Add(this._ftmsIndoorBikeData); base.Characteristics.Add(this._ftmsIndoorBikeData);
@ -39,7 +39,7 @@ namespace Assets.Scripts.Devices.Ble.Devices
{ {
if (character.MatchGuid(ServiceUuids.Characteristics.IndoorBikeData)) if (character.MatchGuid(ServiceUuids.Characteristics.IndoorBikeData))
{ {
//Debug.Log("功率功能"); //Debug.Log("Ftms功率功能");
this.hwInterface.SubscribeCharacteristic(character, (hw, cha, res) => this.hwInterface.SubscribeCharacteristic(character, (hw, cha, res) =>
{ {
@ -80,11 +80,12 @@ namespace Assets.Scripts.Devices.Ble.Devices
public void SetResistanceMode(double value) public void SetResistanceMode(double value)
{ {
//throw new NotImplementedException(); //throw new NotImplementedException();
var data = new byte[] var data = new byte[]
{ {
(byte)4, (byte)4,
(byte)0.1 (byte)(value * 10)
}; };
} }
@ -99,24 +100,35 @@ namespace Assets.Scripts.Devices.Ble.Devices
/// <param name="grade"></param> /// <param name="grade"></param>
public void SetTrackResistance(double grade) public void SetTrackResistance(double grade)
{ {
if (this.State != Ant.DeviceState.Connected) if (grade < 0) grade = 0;
return; if (grade > 10) grade = 10;
if (controlPointCharacteristic == null) if (this.controlPointCharacteristic != null)
return; {
var data = new byte[]
{
(byte)4,
(byte)(grade * 10)
};
this.hwInterface.WriteCharacteristic(this.controlPointCharacteristic, data);
}
//if (this.State != Ant.DeviceState.Connected)
// return;
//if (controlPointCharacteristic == null)
// return;
short windSpeed = 0; //short windSpeed = 0;
short value2 = (short)(grade); //short value2 = (short)(grade);
byte rollingResistanceCoefficient = (byte)(0.004 * 10000); //byte rollingResistanceCoefficient = (byte)(0.004 * 10000);
byte windResistanceCoefficient = 0; //byte windResistanceCoefficient = 0;
var data = new List<byte>();// { 17, (byte)windSpeed, (byte)value2, rollingResistanceCoefficient, windResistanceCoefficient }; //var data = new List<byte>();// { 17, (byte)windSpeed, (byte)value2, rollingResistanceCoefficient, windResistanceCoefficient };
data.Add(17); //data.Add(17);
data.AddRange(BitConverter.GetBytes(windSpeed)); //data.AddRange(BitConverter.GetBytes(windSpeed));
data.AddRange(BitConverter.GetBytes(value2)); //data.AddRange(BitConverter.GetBytes(value2));
data.AddRange(BitConverter.GetBytes(rollingResistanceCoefficient)); //data.AddRange(BitConverter.GetBytes(rollingResistanceCoefficient));
data.AddRange(BitConverter.GetBytes(windResistanceCoefficient)); //data.AddRange(BitConverter.GetBytes(windResistanceCoefficient));
this.hwInterface.WriteCharacteristic(this.controlPointCharacteristic, data.ToArray()); //this.hwInterface.WriteCharacteristic(this.controlPointCharacteristic, data.ToArray());
} }
} }
} }

View File

@ -130,7 +130,7 @@ namespace Assets.Scripts.Ble
} }
if(item.IdByteArray == ServiceUuids.Ftms) if(item.IdByteArray == ServiceUuids.Ftms)
{ {
sensor = SensorType.Trainer; sensor = SensorType.FtmsTrainer;
} }
else if(item.IdByteArray == ServiceUuids.HeartRate) else if(item.IdByteArray == ServiceUuids.HeartRate)
{ {

View File

@ -195,6 +195,8 @@ namespace Assets.Scripts.Ble
return Get(ServiceUuids.PowerBeam).IdGuid; return Get(ServiceUuids.PowerBeam).IdGuid;
case SensorType.Trainer: case SensorType.Trainer:
return Get(ServiceUuids.TacxBle).IdGuid; return Get(ServiceUuids.TacxBle).IdGuid;
case SensorType.FtmsTrainer:
return Get(ServiceUuids.Ftms).IdGuid;
default: default:
return Guid.Empty; return Guid.Empty;
} }

View File

@ -151,6 +151,10 @@ namespace Assets.Scripts.Ble
{ {
sensor = SensorType.Trainer; sensor = SensorType.Trainer;
} }
else if (item.IdByteArray == ServiceUuids.Ftms)
{
sensor = SensorType.FtmsTrainer;
}
} }
}; };

View File

@ -28,11 +28,11 @@ namespace Assets.Scenes.Ride.Scripts
public AbstractDevice CurrentTrainer public AbstractDevice CurrentTrainer
{ {
get { get {
var devices = App.MainDeviceAdapter.GetDevices().Where(d => d.State == DeviceState.Connected && (d.Sensor == SensorType.Trainer)); var devices = App.MainDeviceAdapter.GetDevices().Where(d => d.State == DeviceState.Connected && (d.Sensor == SensorType.Trainer || d.Sensor == SensorType.FtmsTrainer));
_device = null;//重置设备状态 _device = null;//重置设备状态
if (devices.Count() > 0) if (devices.Count() > 0)
{ {
_device = devices.OrderByDescending(d => d.Sensor == SensorType.Trainer).First(); _device = devices.OrderByDescending(d => d.Sensor == SensorType.Trainer || d.Sensor == SensorType.FtmsTrainer).First();
var RiderWeight = (_device as IRequiresRiderWeight).RiderWeight; var RiderWeight = (_device as IRequiresRiderWeight).RiderWeight;
if (RiderWeight == 0) if (RiderWeight == 0)
{ {
@ -141,10 +141,10 @@ namespace Assets.Scenes.Ride.Scripts
public bool CheckAnt() public bool CheckAnt()
{ {
//_antConnector = AntConnector.Instance(); //_antConnector = AntConnector.Instance();
var devices = App.MainDeviceAdapter.GetDevices().Where(d => d.State == DeviceState.Connected && (d.Sensor == SensorType.Trainer || d.Sensor == SensorType.Power)); var devices = App.MainDeviceAdapter.GetDevices().Where(d => d.State == DeviceState.Connected && (d.Sensor == SensorType.Trainer || d.Sensor == SensorType.FtmsTrainer || d.Sensor == SensorType.Power));
if (devices.Count() > 0) if (devices.Count() > 0)
{ {
_device = devices.OrderByDescending(d => d.Sensor == SensorType.Trainer).First(); _device = devices.OrderByDescending(d => d.Sensor == SensorType.Trainer || d.Sensor == SensorType.FtmsTrainer).First();
if (_device != null && _device is IRequiresRiderWeight) if (_device != null && _device is IRequiresRiderWeight)
{ {
(_device as IRequiresRiderWeight).RiderWeight = App.CurrentUser.Weight; (_device as IRequiresRiderWeight).RiderWeight = App.CurrentUser.Weight;
@ -216,10 +216,9 @@ namespace Assets.Scenes.Ride.Scripts
{ {
return (IPowerDevice)power; return (IPowerDevice)power;
} }
if (powerDevices.Any()) if (powerDevices.Any())
{ {
return (IPowerDevice)powerDevices.FirstOrDefault(); return (IPowerDevice)powerDevices.FirstOrDefault(d=>d.Sensor == SensorType.Trainer || d.Sensor == SensorType.FtmsTrainer);
} }
return null; return null;

View File

@ -47,8 +47,8 @@ namespace Assets.Scenes.Ride.Scripts
/// </summary> /// </summary>
protected override void Compute() protected override void Compute()
{ {
//计算数据 //计算数据
//speed = mainController.UpDateSpeed(); speed = mainController.UpDateSpeed();
try try
{ {
heartRate = mainController.UpDateHeart(); heartRate = mainController.UpDateHeart();
@ -57,10 +57,10 @@ namespace Assets.Scenes.Ride.Scripts
weight = App.CurrentUser.Weight; weight = App.CurrentUser.Weight;
bicycleWeight = App.CurrentUser.BicycleWeight; bicycleWeight = App.CurrentUser.BicycleWeight;
#if UNITY_EDITOR #if UNITY_EDITOR
power = 300; power = 300;
#endif #endif
mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100); mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100);
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.Log(ex.Message); Debug.Log(ex.Message);

View File

@ -184,7 +184,8 @@ public class ConnectDeviceModal : PFUIPanel
devices = App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType || (d is ISpeedDevice && d.State == DeviceState.Connected)).OrderBy(d => d.Priority).ToList(); devices = App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType || (d is ISpeedDevice && d.State == DeviceState.Connected)).OrderBy(d => d.Priority).ToList();
break; break;
case SensorType.Trainer: case SensorType.Trainer:
devices = App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType && d is ITrainerDevice).ToList(); case SensorType.FtmsTrainer:
devices = App.MainDeviceAdapter.GetDevices().Where(d => (d.Sensor == SensorType || d.Sensor == SensorType.FtmsTrainer) && d is ITrainerDevice).ToList();
break; break;
case SensorType.VirtualPower: case SensorType.VirtualPower:
break; break;

View File

@ -230,7 +230,7 @@ public class DeviceView : MonoBehaviour
powerUnit.text = "BPM"; powerUnit.text = "BPM";
} }
else if (SensorType == SensorType.Trainer) else if (SensorType == SensorType.Trainer || SensorType == SensorType.FtmsTrainer)
{ {
sprite0 = Resources.Load<Sprite>("Images/Devices/Trainer_1"); sprite0 = Resources.Load<Sprite>("Images/Devices/Trainer_1");
sprite1 = Resources.Load<Sprite>("Images/Devices/Trainer_1"); sprite1 = Resources.Load<Sprite>("Images/Devices/Trainer_1");
@ -387,6 +387,7 @@ public class DeviceView : MonoBehaviour
case SensorType.Speed: case SensorType.Speed:
return App.GetLocalString("Speed Meter"); return App.GetLocalString("Speed Meter");
case SensorType.Trainer: case SensorType.Trainer:
case SensorType.FtmsTrainer:
return App.GetLocalString("Smart Trainer"); return App.GetLocalString("Smart Trainer");
case SensorType.VirtualPower: case SensorType.VirtualPower:
break; break;
@ -414,6 +415,7 @@ public class DeviceView : MonoBehaviour
case SensorType.Speed: case SensorType.Speed:
return (connectedDevice as ISpeedDevice).Speed.ToString("f1"); return (connectedDevice as ISpeedDevice).Speed.ToString("f1");
case SensorType.Trainer: case SensorType.Trainer:
case SensorType.FtmsTrainer:
//powerValue.text = (connectedDevice as IPowerDevice).Power.ToString(); //powerValue.text = (connectedDevice as IPowerDevice).Power.ToString();
//cadenceValue.GetComponent<Text>().text = (connectedDevice as ICadenceDevice).Cadence.ToString(); //cadenceValue.GetComponent<Text>().text = (connectedDevice as ICadenceDevice).Cadence.ToString();
//speedValue.GetComponent<Text>().text = (connectedDevice as ISpeedDevice).Speed.ToString(); //speedValue.GetComponent<Text>().text = (connectedDevice as ISpeedDevice).Speed.ToString();
@ -462,7 +464,8 @@ public class DeviceView : MonoBehaviour
case SensorType.Speed: case SensorType.Speed:
return devices.FirstOrDefault(d => d is ISpeedDevice); return devices.FirstOrDefault(d => d is ISpeedDevice);
case SensorType.Trainer: case SensorType.Trainer:
var item3 = devices.FirstOrDefault(d => d.Sensor == SensorType.Trainer); case SensorType.FtmsTrainer:
var item3 = devices.FirstOrDefault(d => d.Sensor == SensorType.Trainer || d.Sensor == SensorType.FtmsTrainer);
return item3; return item3;
case SensorType.VirtualPower: case SensorType.VirtualPower:
break; break;

View File

@ -0,0 +1,21 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1200 &1
AutoStreamingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
mSearchMode: 15
mCustomSearchFile:
mTextureSearchString:
mMeshSearchString:
mTextures: []
mAudios: []
mMeshes: []
mScenes: []
mConfigCCD:
useCCD: 0
cosKey:
projectGuid:
bucketUuid:
bucketName:
badgeName:

View File

@ -74,6 +74,12 @@ PlayerSettings:
androidRenderOutsideSafeArea: 1 androidRenderOutsideSafeArea: 1
androidUseSwappy: 0 androidUseSwappy: 0
androidBlitType: 0 androidBlitType: 0
androidResizableWindow: 0
androidDefaultWindowWidth: 1920
androidDefaultWindowHeight: 1080
androidMinimumWindowWidth: 400
androidMinimumWindowHeight: 300
androidFullscreenMode: 1
defaultIsNativeResolution: 1 defaultIsNativeResolution: 1
macRetinaSupport: 1 macRetinaSupport: 1
runInBackground: 1 runInBackground: 1
@ -85,6 +91,11 @@ PlayerSettings:
hideHomeButton: 0 hideHomeButton: 0
submitAnalytics: 1 submitAnalytics: 1
usePlayerLog: 1 usePlayerLog: 1
autoStreaming: 0
useAnimationStreaming: 0
useFontStreaming: 0
autoStreamingId:
instantGameAppId:
bakeCollisionMeshes: 0 bakeCollisionMeshes: 0
forceSingleInstance: 1 forceSingleInstance: 1
useFlipModelSwapchain: 1 useFlipModelSwapchain: 1
@ -180,7 +191,7 @@ PlayerSettings:
Android: com.ZhiXingPai.PowerFunUnity Android: com.ZhiXingPai.PowerFunUnity
buildNumber: buildNumber:
iPhone: 2.1.4.1 iPhone: 2.1.4.1
AndroidBundleVersionCode: 18 AndroidBundleVersionCode: 21
AndroidMinSdkVersion: 24 AndroidMinSdkVersion: 24
AndroidTargetSdkVersion: 30 AndroidTargetSdkVersion: 30
AndroidPreferredInstallLocation: 1 AndroidPreferredInstallLocation: 1
@ -257,6 +268,7 @@ PlayerSettings:
templatePackageId: com.unity.template.3d@4.2.8 templatePackageId: com.unity.template.3d@4.2.8
templateDefaultScene: Assets/Scenes/SampleScene.unity templateDefaultScene: Assets/Scenes/SampleScene.unity
AndroidTargetArchitectures: 1 AndroidTargetArchitectures: 1
AndroidTargetDevices: 0
AndroidSplashScreenScale: 0 AndroidSplashScreenScale: 0
androidSplashScreen: {fileID: 0} androidSplashScreen: {fileID: 0}
AndroidKeystoreName: '{inproject}: Assets/Plugins/Android/powerfun.keystore' AndroidKeystoreName: '{inproject}: Assets/Plugins/Android/powerfun.keystore'
@ -273,6 +285,7 @@ PlayerSettings:
height: 180 height: 180
banner: {fileID: 0} banner: {fileID: 0}
androidGamepadSupportLevel: 0 androidGamepadSupportLevel: 0
chromeosInputEmulation: 1
AndroidValidateAppBundleSize: 1 AndroidValidateAppBundleSize: 1
AndroidAppBundleSizeToValidate: 150 AndroidAppBundleSizeToValidate: 150
m_BuildTargetIcons: m_BuildTargetIcons:
@ -663,6 +676,7 @@ PlayerSettings:
switchTitleNames_12: switchTitleNames_12:
switchTitleNames_13: switchTitleNames_13:
switchTitleNames_14: switchTitleNames_14:
switchTitleNames_15:
switchPublisherNames_0: switchPublisherNames_0:
switchPublisherNames_1: switchPublisherNames_1:
switchPublisherNames_2: switchPublisherNames_2:
@ -678,6 +692,7 @@ PlayerSettings:
switchPublisherNames_12: switchPublisherNames_12:
switchPublisherNames_13: switchPublisherNames_13:
switchPublisherNames_14: switchPublisherNames_14:
switchPublisherNames_15:
switchIcons_0: {fileID: 0} switchIcons_0: {fileID: 0}
switchIcons_1: {fileID: 0} switchIcons_1: {fileID: 0}
switchIcons_2: {fileID: 0} switchIcons_2: {fileID: 0}
@ -693,6 +708,7 @@ PlayerSettings:
switchIcons_12: {fileID: 0} switchIcons_12: {fileID: 0}
switchIcons_13: {fileID: 0} switchIcons_13: {fileID: 0}
switchIcons_14: {fileID: 0} switchIcons_14: {fileID: 0}
switchIcons_15: {fileID: 0}
switchSmallIcons_0: {fileID: 0} switchSmallIcons_0: {fileID: 0}
switchSmallIcons_1: {fileID: 0} switchSmallIcons_1: {fileID: 0}
switchSmallIcons_2: {fileID: 0} switchSmallIcons_2: {fileID: 0}
@ -708,6 +724,7 @@ PlayerSettings:
switchSmallIcons_12: {fileID: 0} switchSmallIcons_12: {fileID: 0}
switchSmallIcons_13: {fileID: 0} switchSmallIcons_13: {fileID: 0}
switchSmallIcons_14: {fileID: 0} switchSmallIcons_14: {fileID: 0}
switchSmallIcons_15: {fileID: 0}
switchManualHTML: switchManualHTML:
switchAccessibleURLs: switchAccessibleURLs:
switchLegalInformation: switchLegalInformation:
@ -770,6 +787,10 @@ PlayerSettings:
switchSocketInitializeEnabled: 1 switchSocketInitializeEnabled: 1
switchNetworkInterfaceManagerInitializeEnabled: 1 switchNetworkInterfaceManagerInitializeEnabled: 1
switchPlayerConnectionEnabled: 1 switchPlayerConnectionEnabled: 1
switchUseMicroSleepForYield: 1
switchEnableRamDiskSupport: 0
switchMicroSleepForYieldTime: 25
switchRamDiskSpaceSize: 12
ps4NPAgeRating: 12 ps4NPAgeRating: 12
ps4NPTitleSecret: ps4NPTitleSecret:
ps4NPTrophyPackPath: ps4NPTrophyPackPath:
@ -840,10 +861,37 @@ PlayerSettings:
ps4videoRecordingFeaturesUsed: 0 ps4videoRecordingFeaturesUsed: 0
ps4contentSearchFeaturesUsed: 0 ps4contentSearchFeaturesUsed: 0
ps4CompatibilityPS5: 0 ps4CompatibilityPS5: 0
ps4AllowPS5Detection: 0
ps4GPU800MHz: 1 ps4GPU800MHz: 1
ps4attribEyeToEyeDistanceSettingVR: 0 ps4attribEyeToEyeDistanceSettingVR: 0
ps4IncludedModules: [] ps4IncludedModules: []
ps4attribVROutputEnabled: 0 ps4attribVROutputEnabled: 0
ps5ParamFilePath:
ps5VideoOutPixelFormat: 0
ps5VideoOutInitialWidth: 1920
ps5VideoOutOutputMode: 1
ps5BackgroundImagePath:
ps5StartupImagePath:
ps5Pic2Path:
ps5StartupImagesFolder:
ps5IconImagesFolder:
ps5SaveDataImagePath:
ps5SdkOverride:
ps5BGMPath:
ps5ShareOverlayImagePath:
ps5NPConfigZipPath:
ps5Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ
ps5UseResolutionFallback: 0
ps5UseAudio3dBackend: 0
ps5ScriptOptimizationLevel: 2
ps5Audio3dVirtualSpeakerCount: 14
ps5VrrSupport: 0
ps5UpdateReferencePackage:
ps5disableAutoHideSplash: 0
ps5OperatingSystemCanDisableSplashScreen: 0
ps5IncludedModules: []
ps5SharedBinaryContentLabels: []
ps5SharedBinarySystemFolders: []
monoEnv: monoEnv:
splashScreenBackgroundSourceLandscape: {fileID: 21300000, guid: d143ec26537fa4344801b2c6b9dc6277, splashScreenBackgroundSourceLandscape: {fileID: 21300000, guid: d143ec26537fa4344801b2c6b9dc6277,
type: 3} type: 3}
@ -868,12 +916,13 @@ PlayerSettings:
platformArchitecture: platformArchitecture:
iPhone: 1 iPhone: 1
scriptingBackend: scriptingBackend:
Android: 1 Android: 0
Standalone: 0 Standalone: 0
il2cppCompilerConfiguration: il2cppCompilerConfiguration:
Standalone: 0 Standalone: 0
managedStrippingLevel: {} managedStrippingLevel: {}
incrementalIl2cppBuild: {} incrementalIl2cppBuild: {}
suppressCommonWarnings: 1
allowUnsafeCode: 0 allowUnsafeCode: 0
additionalIl2CppArgs: additionalIl2CppArgs:
scriptingRuntimeVersion: 1 scriptingRuntimeVersion: 1

View File

@ -1,2 +1,2 @@
m_EditorVersion: 2019.4.22f1c1 m_EditorVersion: 2019.4.40f1c1
m_EditorVersionWithRevision: 2019.4.22f1c1 (ea76eba460f9) m_EditorVersionWithRevision: 2019.4.40f1c1 (bcafa7f80565)

View File

@ -9,6 +9,8 @@ UnityConnectSettings:
m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
m_EventUrl: https://cdp.cloud.unity3d.com/v1/events m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
m_ConfigUrl: https://config.uca.cloud.unity3d.com m_ConfigUrl: https://config.uca.cloud.unity3d.com
m_CNEventUrl: https://cdp.cloud.unity.cn/v1/events
m_CNConfigUrl: https://cdp.cloud.unity.cn/config
m_TestInitMode: 0 m_TestInitMode: 0
CrashReportingSettings: CrashReportingSettings:
m_EventUrl: https://perf-events.cloud.unity.cn m_EventUrl: https://perf-events.cloud.unity.cn