Task <List <GattService> > DoGetPrimaryServices(BluetoothUuid?service)
        {
            return(Task.Run(() =>
            {
                var services = new List <GattService>();

                EventWaitHandle handle = new EventWaitHandle(false, EventResetMode.AutoReset);

                GattService matchingService = null;

                ((CBPeripheral)Device).DiscoveredService += (sender, args) =>
                {
                    handle.Set();
                };

                if (service.HasValue)
                {
                    ((CBPeripheral)Device).DiscoverServices(new CBUUID[] { service });
                }
                else
                {
                    ((CBPeripheral)Device).DiscoverServices();
                }

                handle.WaitOne();

                foreach (CBService cbservice in ((CBPeripheral)Device).Services)
                {
                    services.Add(new GattService(Device, cbservice));
                }

                return services;
            }));
        }
        Task <GattService> DoGetPrimaryService(BluetoothUuid service)
        {
            return(Task.Run(() =>
            {
                EventWaitHandle handle = new EventWaitHandle(false, EventResetMode.AutoReset);

                GattService matchingService = null;

                ((CBPeripheral)Device).DiscoveredService += (sender, args) =>
                {
                    handle.Set();
                };

                ((CBPeripheral)Device).DiscoverServices(new CBUUID[] { service });

                handle.WaitOne();

                foreach (CBService cbservice in ((CBPeripheral)Device).Services)
                {
                    if ((BluetoothUuid)cbservice.UUID == service)
                    {
                        matchingService = new GattService(Device, cbservice);
                    }
                }

                return matchingService;
            }));
        }
Пример #3
0
 internal GattCharacteristic(GattService service)
 {
     Service = service;
 }
Пример #4
0
 internal GattCharacteristic(GattService service, Android.Bluetooth.BluetoothGattCharacteristic characteristic) : this(service)
 {
     _characteristic = characteristic;
 }
Пример #5
0
 internal GattCharacteristic(GattService service, Uap.GattCharacteristic characteristic) : this(service)
 {
     _characteristic = characteristic;
 }