Пример #1
0
 public UwpGattCharacteristic(IGattService service,
                              Guid characteristicUuid,
                              CharacteristicProperties properties,
                              GattPermissions permissions) : base(service, characteristicUuid, properties, permissions)
 {
     this.nativeReady       = new Subject <GattLocalCharacteristic>();
     this.connectedDevices  = new List <IDevice>();
     this.SubscribedDevices = new ReadOnlyCollection <IDevice>(this.connectedDevices);
 }
        protected AbstractGattCharacteristic(IGattService service,
                                             Guid characteristicUuid,
                                             CharacteristicProperties properties,
                                             GattPermissions permissions)
        {
            this.Service     = service;
            this.Uuid        = characteristicUuid;
            this.Properties  = properties;
            this.Permissions = permissions;

            this.InternalDescriptors = new List <IGattDescriptor>();
            this.Descriptors         = new ReadOnlyCollection <IGattDescriptor>(this.InternalDescriptors);
        }
Пример #3
0
        public static Android.Bluetooth.GattPermission ToDroidGattPermission(this GattPermissions gattPermission)
        {
            int permissionCode = 0;

            if (gattPermission.Read)
            {
                permissionCode |= (int)Android.Bluetooth.GattPermission.Read;
            }
            if (gattPermission.Write)
            {
                permissionCode |= (int)Android.Bluetooth.GattPermission.Write;
            }
            return((Android.Bluetooth.GattPermission)permissionCode);
        }
Пример #4
0
        public static GattPermissions ToGattPermissions(this Android.Bluetooth.GattPermission self)
        {
            int             permissionsCode = (int)self;
            GattPermissions permissions     = new GattPermissions();

            if ((self &= Android.Bluetooth.GattPermission.Read) != 0)
            {
                permissions.Read = true;
            }
            if ((self &= Android.Bluetooth.GattPermission.Write) != 0)
            {
                permissions.Write = true;
            }
            return(permissions);
        }
Пример #5
0
        public GattCharacteristic(CBPeripheralManager manager,
                                  IGattService service,
                                  Guid characteristicUuid,
                                  CharacteristicProperties properties,
                                  GattPermissions permissions) : base(service, characteristicUuid, properties, permissions)
        {
            this.manager     = manager;
            this.subscribers = new ConcurrentDictionary <NSUuid, IDevice>();

            this.Native = new CBMutableCharacteristic(
                characteristicUuid.ToCBUuid(),
                properties.ToNative(),
                null,
                (CBAttributePermissions)(int)permissions   // TODO
                );
        }
Пример #6
0
        public GattCharacteristic(GattContext context,
                                  IGattService service,
                                  Guid uuid,
                                  CharacteristicProperties properties,
                                  GattPermissions permissions) : base(service, uuid, properties, permissions)
        {
            this.context     = context;
            this.subscribers = new Dictionary <string, IDevice>();
            this.Native      = new BluetoothGattCharacteristic(
                uuid.ToUuid(),
                properties.ToNative(),
                permissions.ToNative()
                );

            this.NotificationDescriptor = new BluetoothGattDescriptor(
                NotifyDescriptorId.ToUuid(),
                GattDescriptorPermission.Write | GattDescriptorPermission.Read
                );
            this.Native.AddDescriptor(this.NotificationDescriptor);
        }
Пример #7
0
 protected override IGattCharacteristic CreateNative(Guid uuid, CharacteristicProperties properties, GattPermissions permissions)
 {
     return(new GattCharacteristic(this.context, this, uuid, properties, permissions));
 }
Пример #8
0
 public static GattPermission ToNative(this GattPermissions permissions)
 => (GattPermission)Enum.Parse(typeof(GattPermission), permissions.ToString());
Пример #9
0
 public GattServerCharacteristic(Guid uuid, GattCharacteristicProperties properties, GattPermissions permission)
 {
     DroidCharacteristic = new Android.Bluetooth.BluetoothGattCharacteristic(uuid.ToJavaUuid(), properties.ToDroidGattProperty(), permission.ToDroidGattPermission());
     _Descritptor        = new List <GattServerDescriptor>();
 }
 public IGattDescriptorBuilder SetPermissions(GattPermissions permissions)
 {
     Permissions = permissions;
     return(this);
 }
Пример #11
0
 protected override IGattCharacteristic CreateNative(Guid uuid, CharacteristicProperties properties, GattPermissions permissions)
 => new UwpGattCharacteristic(this, uuid, properties, permissions);
Пример #12
0
 public GattServerDescriptor(Guid uuid, GattPermissions permissions)
 {
     DroidDescriptor = new Android.Bluetooth.BluetoothGattDescriptor(uuid.ToJavaUuid(), permissions.ToDroidGattDescriptorPermission());
 }
Пример #13
0
 protected abstract IGattCharacteristic CreateNative(Guid uuid, CharacteristicProperties properties, GattPermissions permissions);
Пример #14
0
        public virtual IGattCharacteristic AddCharacteristic(Guid uuid, CharacteristicProperties properties, GattPermissions permissions)
        {
            var characteristic = this.CreateNative(uuid, properties, permissions);

            this.internalList.Add(characteristic);
            return(characteristic);
        }
Пример #15
0
 public IGattCharacteristicBuilder SetPermissions(GattPermissions permissions)
 {
     Permissions = permissions;
     return(this);
 }
Пример #16
0
        protected override IGattCharacteristic CreateNative(Guid uuid, CharacteristicProperties properties, GattPermissions permissions)
        {
            var ch = new GattCharacteristic(this.context, this, uuid, properties, permissions);

            this.Native.AddCharacteristic(ch.Native);
            return(ch);
        }