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) { } } }
public void Close() { BluetoothConnection.Close(); }