internal BluetoothGattCharacteristic(IGattCharacteristic1 gattCharacteristic1, GattCharacteristic1Properties properties) { _gattCharacteristic1Proxy = gattCharacteristic1; UUID = properties.UUID; Notifying = properties.Notifying; Descriptors = new List <IBluetoothGattDescriptor>(); }
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); }
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); }
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>(); }