I'm trying to add support for a bluetooth device in one of our applications
based on the code from the latest Bluetooth Chat example on GitHub. On every
attempt to perform socket.Connect() I get the Java.IO.IOException "Service
discovery failed".
 
This happens both in my application and when I try to run the Bluetooth Chat
sample with two separate devices (Printer and RFID reader). I have used both
devices in a 3rd party apps and all works fine. I have used both a Galaxy
Tab 
 
Thanks for any help.
 
This is the most stripped down version of the test code.
 
  string mac = "00:17:51:04:6E:C4";
//  static UUID MY_UUID = UUID.FromString(
"00001101-0000-1000-8000-00805F9B34FB" );
  static UUID MY_UUID = UUID.FromString(
"fa87c0d0-afac-11de-8a39-0800200c9a66" );
  
  const int btEnableID = 1;
  BluetoothAdapter bluetoothAdapter = null;
  BluetoothDevice device = null;
  BluetoothSocket socket = null;
 
  void testBtn_Click( object sender, EventArgs e )
  {
   bluetoothAdapter = BluetoothAdapter.DefaultAdapter;
   if( bluetoothAdapter == null )
   {
    Toast.MakeText( this, "Bluetooth is not available", ToastLength.Long
).Show();
    return;
   }
 
   if (!bluetoothAdapter.IsEnabled)
   {
    Intent enableIntent = new Intent (BluetoothAdapter.ActionRequestEnable);
    StartActivityForResult (enableIntent, btEnableID );
   }
   else BluetoothIsEnabled();
  }
 
  void BluetoothIsEnabled()
  {
   device = bluetoothAdapter.GetRemoteDevice( mac );
   if( device == null )
   {
    Toast.MakeText( this, "Cannot get Bluetooth Device", ToastLength.Long
).Show();
    return;
   }
   try
   {
    bluetoothAdapter.CancelDiscovery();
    socket = device.CreateRfcommSocketToServiceRecord( MY_UUID );
   }
   catch( Java.IO.IOException e )
   {
    Toast.MakeText( this, "Cannot Create Socket", ToastLength.Long ).Show();
    return;
   }
   if ( socket == null )
   {
    Toast.MakeText( this, "Null Socket", ToastLength.Long ).Show();
    return;
   }
 
   try
   {
    socket.Connect();
   }
   catch( Java.IO.IOException e )
   {
    Toast.MakeText( this, "Cannot Connect Socket", ToastLength.Long
).Show();
    Utl.ShowError( e.Message, "Connect Error" );
    return;
   }
 
   Toast.MakeText( this, "Success Connect", ToastLength.Long ).Show();
  }

 
Steve Sharrock
Architecture/Design/Programming
www.sharkcode.com <blocked::http://www.sharkcode.com/> 
 
_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to