Example #1
0
        public override async void OnActivated(UIApplication uiApplication)
        {
            base.OnActivated(uiApplication);

            Bluetooth b = new Bluetooth();

            while (!await b.GetAvailability())
            {
                await Task.Delay(100);
            }

            /*var opts = new RequestDeviceOptions();
             * opts.AcceptAllDevices = true;
             * device = await b.RequestDevice(opts);
             * if (device != null)
             * {
             *  await device.Gatt.Connect();
             *  //device.AdvertisementReceived += Device_AdvertisementReceived;
             *  //await device.WatchAdvertisementsAsync();
             *  var service = await device.Gatt.GetPrimaryServiceAsync(new Guid(0x0000180F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB));
             *  var chars = await service.GetCharacteristicsAsync();
             *  foreach (var ch in chars)
             *  {
             *      System.Diagnostics.Debug.WriteLine(ch.Properties);
             *      var desc = await ch.GetDescriptorAsync(new Guid(0x00002902, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB));
             *      if (desc != null)
             *      {
             *          var descval = await desc.ReadValueAsync();
             *          System.Diagnostics.Debug.WriteLine(desc.Uuid);
             *      }
             *
             *      System.Diagnostics.Debug.WriteLine(ch.Uuid);
             *      byte[] val = await ch.ReadValueAsync();
             *      int ival = val[0];
             *  }
             * }*/
        }