Beispiel #1
0
        public string BuildBluetoothConnectionChannelsString(string macAddress)
        {
            BluetoothConnection connection = new BluetoothConnection(macAddress);

            connection.Open(); // Check connection

            try
            {
                ServiceDiscoveryHandlerImplementation serviceDiscoveryHandler = new ServiceDiscoveryHandlerImplementation();
                BluetoothDiscoverer.FindServices(global::Android.App.Application.Context, macAddress, serviceDiscoveryHandler);

                while (!serviceDiscoveryHandler.Finished)
                {
                    Task.Delay(100);
                }

                StringBuilder sb = new StringBuilder();
                foreach (ConnectionChannel connectionChannel in serviceDiscoveryHandler.ConnectionChannels)
                {
                    sb.AppendLine(connectionChannel.ToString());
                }
                return(sb.ToString());
            }
            finally
            {
                try
                {
                    connection?.Close();
                }
                catch (ConnectionException) { }
            }
        }
Beispiel #2
0
 public void Close()
 {
     BluetoothConnection.Close();
 }