Exemple #1
0
        public async Task <ICharacteristic> ReadAsync()
        {
            var val = new GattCharacteristicWithValue();

            val.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));
        }
Exemple #2
0
 public Characteristic(GattCharacteristic nativeCharacteristic)
 {
     this.gattCharacteristicWithValue = new GattCharacteristicWithValue(nativeCharacteristic);
 }
Exemple #3
0
 public Characteristic(GattCharacteristicWithValue gattCharacteristicWithValue)
 {
     this.gattCharacteristicWithValue = gattCharacteristicWithValue;
 }