Пример #1
0
        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);
        }
Пример #2
0
        internal static BluetoothGattDescriptor CreateBluetoothGattDescriptor(BluetoothGattAttributeHandle handle, string uuid)
        {
            int permission;
            int err = Interop.Bluetooth.BtGattDescriptorGetPermissions(handle, out permission);

            GattUtil.ThrowForError(err, string.Format("Failed to get permissions with UUID ({0})", uuid));

            if (uuid == "")
            {
                int ret = Interop.Bluetooth.BtGattGetUuid(handle, out uuid);
                GattUtil.ThrowForError(ret, "Failed to get UUID");
            }

            BluetoothGattDescriptorImpl impl = new BluetoothGattDescriptorImpl(handle);

            return(new BluetoothGattDescriptor(impl, uuid, (BluetoothGattPermission)permission));
        }
Пример #3
0
        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);
        }
Пример #4
0
 internal BluetoothGattDescriptor(BluetoothGattDescriptorImpl impl, string uuid, BluetoothGattPermission permission) : base(uuid, permission)
 {
     _impl = impl;
 }
Пример #5
0
 /// <summary>
 /// The constructor.
 /// </summary>
 /// <param name="uuid">The UUID of the descriptor.</param>
 /// <param name="permisions">Permissions for the descriptor.</param>
 /// <param name="value">The value associated with the descriptor.</param>
 /// <remarks>throws in case of internal error.</remarks>
 /// <exception cref="InvalidOperationException">Thrown when the create GATT descriptor procedure fails.</exception>
 /// <since_tizen> 3 </since_tizen>
 public BluetoothGattDescriptor(string uuid, BluetoothGattPermission permisions, byte[] value) : base(uuid, permisions)
 {
     _impl = new BluetoothGattDescriptorImpl(uuid, permisions, value);
 }