划船机暂存
This commit is contained in:
1 parent
1c73701e73
commit
c73545d912
164 files changed
+38281
-2181
No files matched your search
@@ -7,6 +7,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ble.Devices
|
||||
{
|
||||
@@ -16,21 +17,22 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
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 int Cadence { get => _ftmsIndoorBikeData.InstantCadence.GetValueOrDefault(0); set => throw new NotImplementedException(); }
|
||||
private FtmsRowerData _rowerData;
|
||||
public FtmsRowerData rowerData { get => _rowerData; }
|
||||
|
||||
private FtmsIndoorBikeData _ftmsIndoorBikeData;
|
||||
|
||||
private List<BleServiceInfo> Services;
|
||||
private BleCharacteristicInfo controlPointCharacteristic;
|
||||
|
||||
public Ftms(BlePeripheralInfo peripheralInfo, IBleWinHwInterface bleWinHwInterface) :base(peripheralInfo, bleWinHwInterface, Ant.SensorType.Trainer)
|
||||
{
|
||||
this._ftmsIndoorBikeData = new FtmsIndoorBikeData();
|
||||
base.Characteristics.Add(this._ftmsIndoorBikeData);
|
||||
|
||||
base.Characteristics.Add(new FtmsFitnessMachineFeature());
|
||||
|
||||
//划船机
|
||||
this._rowerData = new FtmsRowerData();
|
||||
base.Characteristics.Add(rowerData);
|
||||
bleWinHwInterface.CharacteristicReadEvent += CharacteristicReadMainCallback;
|
||||
|
||||
}
|
||||
|
||||
protected override void CreateServices(List<BleServiceInfo> discoveredServices)
|
||||
@@ -56,6 +58,17 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
{
|
||||
this.controlPointCharacteristic = character;
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.RowerData))
|
||||
{
|
||||
Debug.Log("划船机");
|
||||
this.hwInterface.SubscribeCharacteristic(character, (hw, cha, res) =>
|
||||
{
|
||||
//Debug.Log("1111111111111111111111");
|
||||
//Debug.WriteLine(res.ToString());
|
||||
var res1 = (res as BleResponse<byte[]>);
|
||||
Debug.Log("收到消息划船机:" + string.Join(",", res1));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
using Assets.Scripts.Ble;
|
||||
using Assets.Scripts.Devices.Ant.Interfaces;
|
||||
using Assets.Scripts.Devices.Ble.Characteristic;
|
||||
using Assets.Scripts.Devices.Ble.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ble.Devices
|
||||
{
|
||||
public class FtmsRower : BleDevice, IRowerDevice
|
||||
{
|
||||
private FtmsRowerData _rowerData;
|
||||
public FtmsRowerData rowerData { get => _rowerData; }
|
||||
|
||||
|
||||
private List<BleServiceInfo> Services;
|
||||
private BleCharacteristicInfo controlPointCharacteristic;
|
||||
public FtmsRower(BlePeripheralInfo peripheralInfo, IBleWinHwInterface bleWinHwInterface) :base(peripheralInfo, bleWinHwInterface, Ant.SensorType.Rower)
|
||||
{
|
||||
Debug.Log(24);
|
||||
base.Characteristics.Add(new FtmsFitnessMachineFeature());
|
||||
//划船机
|
||||
this._rowerData = new FtmsRowerData();
|
||||
base.Characteristics.Add(rowerData);
|
||||
bleWinHwInterface.CharacteristicReadEvent += CharacteristicReadMainCallback;
|
||||
}
|
||||
|
||||
protected override void CreateServices(List<BleServiceInfo> discoveredServices)
|
||||
{
|
||||
this.Services = discoveredServices;
|
||||
|
||||
foreach (var service in this.Services)
|
||||
{
|
||||
hwInterface.DiscoverCharacteristic(service, (hwInterface, service1, response) =>
|
||||
{
|
||||
foreach (var character in response.Data)
|
||||
{
|
||||
if (character.MatchGuid(ServiceUuids.Characteristics.RowerData))
|
||||
{
|
||||
Debug.Log("划船机");
|
||||
this.hwInterface.SubscribeCharacteristic(character, (hw, cha, res) =>
|
||||
{
|
||||
//Debug.Log("1111111111111111111111");
|
||||
//Debug.WriteLine(res.ToString());
|
||||
var res1 = (res as BleResponse<byte[]>);
|
||||
Debug.Log("收到消息划船机:" + string.Join(",", res1));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void CharacteristicReadMainCallback(IBleWinHwInterface hwInterface, BleCharacteristicInfo characteristic, BleResponse<byte[]> response)
|
||||
{
|
||||
foreach (var item in base.Characteristics)
|
||||
{
|
||||
if (characteristic.MatchGuid(item.Uuid))
|
||||
{
|
||||
//Debug.Log(string.Join(",", response.Data));
|
||||
item.HandleAttributeReceived(response.Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e62cf4fc3378d5c4eb76643a9d3ca528
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user