Ejemplo n.º 1
0
        internal static async Task <GattService> CreateInstanceAsync(Device device, ObjectPath path)
        {
            var instance = new GattService(device, path);

            instance.watcher = await instance.proxy.WatchPropertiesAsync(instance.OnPropertiesChanged);

            instance.properties = await instance.proxy.GetAllAsync();

            return(instance);
        }
Ejemplo n.º 2
0
        internal static async Task <GattCharacteristic> CreateInstanceAsync(GattService service, ObjectPath path)
        {
            var instance = new GattCharacteristic(service, path);

            instance.propertyWatcher = await instance.proxy.WatchPropertiesAsync(x => instance.HandlePropertyChanges(x.Changed));

            instance.HandlePropertyChanges(await instance.proxy.GetAllAsync());

            return(instance);
        }
Ejemplo n.º 3
0
        async Task <IReadOnlyList <GattService> > _GetGattServicesAsync(Guid uuid)
        {
            while (!(bool)properties["ServicesResolved"])
            {
                await Task.Delay(10);

                // TODO: need a timeout here!
            }

            var manager = Connection.System.CreateProxy <IObjectManager>("org.bluez", ObjectPath.Root);
            var objs    = await manager.GetManagedObjectsAsync();

            var services = new List <GattService>();

            foreach (var service in objs.Where(x => x.Key.StartsWith(proxy.ObjectPath) && x.Value.ContainsKey("org.bluez.GattService1")))
            {
                services.Add(await GattService.CreateInstanceAsync(this, service.Key));
            }

            return(services.AsReadOnly());
        }
Ejemplo n.º 4
0
 internal GattCharacteristic(GattService service, Win.GattCharacteristic characteristic)
 {
     this.service                 = service ?? throw new ArgumentNullException(nameof(service));
     this.characteristic          = characteristic ?? throw new ArgumentNullException(nameof(characteristic));
     characteristic.ValueChanged += Characteristic_ValueChanged;
 }
Ejemplo n.º 5
0
 GattCharacteristic(GattService service, ObjectPath path)
 {
     this.service = service ?? throw new System.ArgumentNullException(nameof(service));
     proxy        = Connection.System.CreateProxy <IGattCharacteristic1>("org.bluez", path);
     properties   = new Dictionary <string, object>();
 }