internal BluetoothGattDescriptor GetDescriptor(BluetoothGattCharacteristic characteristic, string uuid) { BluetoothGattAttributeHandle handle; int err = Interop.Bluetooth.BtGattCharacteristicGetDescriptor(_handle, uuid, out handle); if (err.IsFailed()) { GattUtil.Error(err, string.Format("Failed to get descriptor with UUID ({0})", uuid)); return(null); } BluetoothGattDescriptor descriptor = BluetoothGattDescriptorImpl.CreateBluetoothGattDescriptor(handle, uuid); descriptor.SetParent(characteristic); return(descriptor); }
/// <summary> /// Adds a descriptor to this characteristic. /// </summary> /// <param name="descriptor">The descriptor to be added.</param> /// <returns>true on success, false otherwise.</returns> /// <exception cref="InvalidOperationException">Thrown when the add GATT descriptor procedure fails.</exception> /// <since_tizen> 3 </since_tizen> public void AddDescriptor(BluetoothGattDescriptor descriptor) { if (Client != null) { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotSupported); } if (descriptor.GetCharacteristic() != null) { BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.InvalidParameter); } _impl.AddDescriptor(descriptor); descriptor.SetParent(this); }
internal IEnumerable <BluetoothGattDescriptor> GetDescriptors(BluetoothGattCharacteristic characteristic) { List <BluetoothGattDescriptor> attribututeList = new List <BluetoothGattDescriptor>(); Interop.Bluetooth.BtGattForeachCallback cb = (total, index, attributeHandle, userData) => { BluetoothGattAttributeHandle handle = new BluetoothGattAttributeHandle(attributeHandle, false); BluetoothGattDescriptor descriptor = BluetoothGattDescriptorImpl.CreateBluetoothGattDescriptor(handle, ""); if (descriptor != null) { descriptor.SetParent(characteristic); attribututeList.Add(descriptor); } return(true); }; int err = Interop.Bluetooth.BtGattCharacteristicForeachDescriptors(characteristic.GetHandle(), cb, IntPtr.Zero); GattUtil.Error(err, "Failed to get all descriptor"); return(attribututeList); }
internal void AddDescriptor(BluetoothGattDescriptor descriptor) { int err = Interop.Bluetooth.BtGattCharacteristicAddDescriptor(_handle, descriptor.GetHandle()); GattUtil.ThrowForError(err, string.Format("Failed to add descriptor with UUID ({0})", descriptor.Uuid)); }
/// <summary> /// Writes the value of the given descriptor to the remote device asynchronously. /// </summary> /// <param name="descriptor">The descriptor to be written.</param> /// <returns>true on success, false otherwise.</returns> /// <exception cref="InvalidOperationException">Thrown when the BT/BTLE is not enabled /// or when the remote device is disconnected, or when the write attribute value fails.</exception> /// <since_tizen> 3 </since_tizen> public async Task <bool> WriteValueAsync(BluetoothGattDescriptor descriptor) { return(await _impl.WriteValueAsyncTask(descriptor.GetHandle())); }