Ejemplo n.º 1
0
        public async Task <ICharacteristic> ReadAsync()
        {
            GattCharacteristicWithValue val = new GattCharacteristicWithValue
            {
                NativeCharacteristic = this.gattCharacteristicWithValue.NativeCharacteristic
            };

            if (!CanRead)
            {
                throw new InvalidOperationException("Characteristic does not support READ");
            }
            try
            {
                GattReadResult readResult = await this.gattCharacteristicWithValue.NativeCharacteristic.ReadValueAsync();

                if (readResult.Status == GattCommunicationStatus.Success)
                {
                    val.Value = new byte[readResult.Value.Length];
                    DataReader.FromBuffer(readResult.Value).ReadBytes(val.Value);
                }
            }
            catch { }
            return(new Characteristic(val));
        }
Ejemplo n.º 2
0
 public Characteristic(GattCharacteristic nativeCharacteristic)
 {
     this.gattCharacteristicWithValue = new GattCharacteristicWithValue(nativeCharacteristic);
 }
Ejemplo n.º 3
0
 public Characteristic(GattCharacteristicWithValue gattCharacteristicWithValue)
 {
     this.gattCharacteristicWithValue = gattCharacteristicWithValue;
 }