Exemplo n.º 1
0
 internal BluetoothGattCharacteristic(IGattCharacteristic1 gattCharacteristic1,
                                      GattCharacteristic1Properties properties)
 {
     _gattCharacteristic1Proxy = gattCharacteristic1;
     UUID        = properties.UUID;
     Notifying   = properties.Notifying;
     Descriptors = new List <IBluetoothGattDescriptor>();
 }
Exemplo n.º 2
0
        internal static async Task <GattCharacteristic> CreateAsync(IGattCharacteristic1 proxy)
        {
            var characteristic = new GattCharacteristic
            {
                m_proxy = proxy,
            };

            characteristic.m_propertyWatcher = await proxy.WatchPropertiesAsync(characteristic.OnPropertyChanges);

            return(characteristic);
        }
Exemplo n.º 3
0
        public static async Task <byte[]> ReadValueAsync(this IGattCharacteristic1 characteristic, TimeSpan timeout)
        {
            var options     = new Dictionary <string, object>();
            var readTask    = characteristic.ReadValueAsync(options);
            var timeoutTask = Task.Delay(timeout);

            await Task.WhenAny(new Task[] { readTask, timeoutTask });

            if (!readTask.IsCompleted)
            {
                throw new TimeoutException("Timed out waiting to read characteristic value.");
            }

            return(await readTask);
        }
Exemplo n.º 4
0
 GattCharacteristic(GattService service, ObjectPath path)
 {
     this.service = service ?? throw new System.ArgumentNullException(nameof(service));
     proxy        = Connection.System.CreateProxy <IGattCharacteristic1>("org.bluez", path);
     properties   = new Dictionary <string, object>();
 }