public WellKnownCharacteristic(string name, ushort shortId, IPresentationFormat defaultPresentationFormat) : base(shortId) { Name = name; PresentationFormat = defaultPresentationFormat; }
public static object ToValue(this GattReadResult result, IPresentationFormat presentationFormat) { if (result == null) { throw new ArgumentNullException(nameof(result)); } if (result.Status != GattCommunicationStatus.Success) { throw new ArgumentException($"Unexpected status: {result.Status}", nameof(result)); } if (presentationFormat == null) { return(result.Value.ToUnknownFormat()); } byte[] data; CryptographicBuffer.CopyToByteArray(result.Value, out data); if (presentationFormat.TryGetValue(data, out object value)) { return(value); } throw new ArgumentException($"Unexpected format of result: {data}", nameof(result)); }
public static ICharacteristicInfo ToCharacteristicInfo(this GattCharacteristic characteristic) { var serviceInfo = characteristic.Service.ToServiceInfo(); IPresentationFormat preferedFormat = null; var properties = characteristic.CharacteristicProperties.ToContract(); // use default factory to recognize known services if (WellKnownCharacteristics.Default.TryCreate(characteristic.Uuid, out ICharacteristicTemplate template)) { return(new KnownCharacteristicInfo(template, serviceInfo, properties, preferedFormat)); } return(new GeneralCharacteristicInfo(serviceInfo, characteristic.Uuid, properties, preferedFormat)); }
protected DevicePollerBase(Guid service, Guid characteristic, IPresentationFormat defaultFormat) { Service = service; Characteristic = characteristic; DefaultPresentationFormat = defaultFormat; }
/// <summary> /// Constructor /// </summary> /// <param name="template">Requiered characteristic template</param> /// <param name="service">Required parent service</param> /// <param name="presentationFormat">Optional overriding of presentation format</param> public KnownCharacteristicInfo(ICharacteristicTemplate template, IServiceInfo service, CharacteristicProperties properties, IPresentationFormat presentationFormat) { Template = template ?? throw new ArgumentNullException(nameof(template)); Service = service ?? throw new ArgumentNullException(nameof(service)); PresentationFormat = presentationFormat ?? template.PresentationFormat; Properties = properties; }
public WellKnownCharacteristic(string name, Guid uuid, IPresentationFormat defaultPresentationFormat) : base(uuid) { Name = name; PresentationFormat = defaultPresentationFormat; }
public GeneralCharacteristicInfo(IServiceInfo service, Guid uuid, CharacteristicProperties properties, IPresentationFormat presentationFormat) : base(uuid) { Service = service ?? throw new ArgumentNullException(nameof(service)); PresentationFormat = presentationFormat ?? WellKnownPresentationFormats.Unknown; Properties = properties; // derive name from UUID Name = GetDefaultName(); }
public SimpleDevicePoller(Guid service, Guid characteristic, IPresentationFormat presentationFormat) : base(service, characteristic, presentationFormat) { }