powerfun-unity/Assets/Scripts/Devices/Ble/Characteristic/FtmsFitnessMachineFeature.cs
2021-06-04 13:22:59 +08:00

46 lines
1.3 KiB
C#

using Assets.Scripts.Ble;
using Assets.Scripts.Devices.Ble.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts.Devices.Ble.Characteristic
{
public class FtmsFitnessMachineFeature : ICharacteristic
{
public Guid Uuid => ServiceUuids.Characteristics.FitnessMachineFeature;
public Guid ServiceUuid => ServiceUuids.Get(ServiceUuids.Ftms).IdGuid;
public bool IsOptional => false;
public bool IsInclinationSupported
{
get; private set;
}
public bool IsInclinationTargetSettingSupported
{
get; private set;
}
public void HandleAttributeReceived(byte[] data)
{
//throw new NotImplementedException();
if (data.Length != 8)
return;
this.IsInclinationSupported = ByteExtensions.IsFlagSet(data[0], (byte)8);
//this.ResistanceLevelSupported = ByteExtensions.IsFlagSet(data[0], sbyte.MinValue);
this.IsInclinationTargetSettingSupported = ByteExtensions.IsFlagSet(data[4], 2);
}
public void SetUnavailable()
{
//throw new NotImplementedException();
}
}
}