Ejemplo n.º 1
0
        internal BluetoothGattCharacteristic GetCharacteristic(BluetoothGattService service, string uuid)
        {
            BluetoothGattAttributeHandle attributeHandle;
            int err = Interop.Bluetooth.BtGattServiceGetCharacteristic(_handle, uuid, out attributeHandle);

            if (err.IsFailed())
            {
                GattUtil.Error(err, string.Format("Failed to get Characteristic with UUID ({0})", uuid));
                return(null);
            }

            BluetoothGattCharacteristic Characteristic = BluetoothGattCharacteristicImpl.CreateBluetoothGattGattCharacteristic(attributeHandle, uuid);

            Characteristic.SetParent(service);
            return(Characteristic);
        }
Ejemplo n.º 2
0
        internal static BluetoothGattCharacteristic CreateBluetoothGattGattCharacteristic(BluetoothGattAttributeHandle handle, string uuid)
        {
            int permission;
            int err = Interop.Bluetooth.BtGattCharacteristicGetPermissions(handle, out permission);

            GattUtil.ThrowForError(err, "Failed to get permissions");

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

            BluetoothGattCharacteristicImpl impl = new BluetoothGattCharacteristicImpl(handle);

            return(new BluetoothGattCharacteristic(impl, uuid, (BluetoothGattPermission)permission));
        }
Ejemplo n.º 3
0
        internal IEnumerable <BluetoothGattCharacteristic> GetCharacteristics(BluetoothGattService service)
        {
            List <BluetoothGattCharacteristic> attribututeList = new List <BluetoothGattCharacteristic>();

            Interop.Bluetooth.BtGattForeachCallback cb = (total, index, attributeHandle, userData) =>
            {
                BluetoothGattAttributeHandle handle         = new BluetoothGattAttributeHandle(attributeHandle, false);
                BluetoothGattCharacteristic  Characteristic = BluetoothGattCharacteristicImpl.CreateBluetoothGattGattCharacteristic(handle, "");
                if (Characteristic != null)
                {
                    Characteristic.SetParent(service);
                    attribututeList.Add(Characteristic);
                }
                return(true);
            };

            int err = Interop.Bluetooth.BtGattServiceForeachCharacteristics(service.GetHandle(), cb, IntPtr.Zero);

            GattUtil.Error(err, "Failed to get all Characteristic");

            return(attribututeList);
        }
Ejemplo n.º 4
0
 internal BluetoothGattCharacteristic(BluetoothGattCharacteristicImpl impl, string uuid, BluetoothGattPermission permission) : base(uuid, permission)
 {
     _impl = impl;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// The constructor.
 /// </summary>
 /// <param name="uuid">The UUID of the characterstic.</param>
 /// <param name="permissions">Permissions for the characterstic.</param>
 /// <param name="properties">Properties set for the characterstic.</param>
 /// <param name="value">The value associated with the characterstic.</param>
 /// <remarks>throws in case of internal error.</remarks>
 /// <exception cref="InvalidOperationException">Thrown when the create GATT characteristics procedure fails.</exception>
 /// <since_tizen> 3 </since_tizen>
 public BluetoothGattCharacteristic(string uuid, BluetoothGattPermission permissions, BluetoothGattProperty properties, byte[] value) : base(uuid, permissions)
 {
     _impl = new BluetoothGattCharacteristicImpl(uuid, permissions, properties, value);
 }