Exemplo n.º 1
0
        private static async Task MainAsync(string[] args)
        {
            async Task ReadDevInfo(string mac)
            {
                var gatt = new Gatt(mac);
                await gatt.ConnectAsync();

                string[] uuids = new string[] {
                    "00002a26-0000-1000-8000-00805f9b34fb",
                    "00002a24-0000-1000-8000-00805f9b34fb",
                    "00002a27-0000-1000-8000-00805f9b34fb",
                    "00002a29-0000-1000-8000-00805f9b34fb",
                    "00002a25-0000-1000-8000-00805f9b34fb"
                };

                foreach (var id in uuids)
                {
                    var gattchar = gatt.FindCharacteristic(id);

                    Console.Write(mac + " -> ");
                    if (gattchar == null)
                    {
                        Console.Write(id);
                        Console.WriteLine(": Does not exist");
                    }
                    else
                    {
                        Console.Write(gattchar.Uuid);
                        Console.WriteLine(string.Format(": {0}", System.Text.Encoding.ASCII.GetString(await gattchar.ReadAsync())));
                    }
                }
            }

            await Task.WhenAll(args.Select(_ => ReadDevInfo(_)));
        }
Exemplo n.º 2
0
        private static async Task MainAsync(string[] args)
        {
            var gatt = new Gatt(args[0]);

            for (int i = 0; i < 3; i++)
            {
                await gatt.ConnectAsync();

                Console.WriteLine("Connected");

                await Task.Delay(5000);

                gatt.Disconnect();

                Console.WriteLine("Am I connected? " + gatt.IsConnected);
            }
        }
 public async Task DiscoverServicesAsync()
 {
     await WarbleGatt.ConnectAsync();
 }