67 lines
1.8 KiB
C#
67 lines
1.8 KiB
C#
using Assets.Scripts.Devices.Ant.Interfaces;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Assets.Scripts.Devices.Ant
|
|
{
|
|
public class HeartRateDevice : AbstractAntDevice, IHeartRateDevice
|
|
{
|
|
//public const int MAX_NO_EVENT_STOP_COUNT = 12;
|
|
|
|
private int _HeartRate;
|
|
public int HeartRate
|
|
{
|
|
get
|
|
{
|
|
return _HeartRate;
|
|
}
|
|
set
|
|
{
|
|
_HeartRate = DeviceValueFilter.HeartRate(value);
|
|
}
|
|
}
|
|
|
|
//ds_AntPlus_BikeSpd speedSensor;
|
|
|
|
public HeartRateDevice(string id)
|
|
: base(id, "Ant+ HeartRate", racerSportType.Unknown, SensorType.HeartRate)
|
|
{
|
|
Priority = 2;
|
|
}
|
|
|
|
protected override AntChannelProfile getDefaultSearchProfile()
|
|
{
|
|
return new AntChannelProfile()
|
|
{
|
|
rfOffset = 57,
|
|
transType = 0,
|
|
deviceType = 120,
|
|
deviceNumber = 0,
|
|
messagePeriod = 8070,
|
|
pairingEnabled = false,
|
|
};
|
|
}
|
|
|
|
public override void handleChannelResponse(ANT_Managed_Library.ANT_Response response)
|
|
{
|
|
//Console.WriteLine(string.Join(",", response.messageContents));
|
|
//商品Manufacturer Information
|
|
if (response.messageContents[1] == 2)
|
|
{
|
|
base.ManufacturerId = response.messageContents[2];
|
|
}
|
|
|
|
if (response.responseID == (byte)ANT_Managed_Library.ANT_ReferenceLibrary.ANTMessageID.BROADCAST_DATA_0x4E)
|
|
{
|
|
var num = response.messageContents[8];
|
|
|
|
//PubCommData.HeartRate = num;
|
|
HeartRate = num;
|
|
}
|
|
}
|
|
}
|
|
}
|