[mono-android] Bluetooth rfcomm

ledz goncalo at minkan.net
Tue Feb 7 16:19:27 UTC 2012


Just to make some closure on this matter, as it might help others; I managed
to make this work.

first I tried using the "reflection" technique mentioned in a few places.


IntPtr createRfcommSocket = JNIEnv.GetMethodID( device.Class.Handle,
"createRfcommSocket", "(I)Landroid/bluetooth/BluetoothSocket;" );
IntPtr socketHandle = JNIEnv.CallObjectMethod( device.Handle,
createRfcommSocket, new JValue( 1 ) );

socket = Java.Lang.Object.GetObject<BluetoothSocket>( socketHandle,
JniHandleOwnership.TransferLocalRef );

This seems to be the one that works bests. In my tests, never once I got the
discovery error mentioned by some.


Afterwards, I tried the other method in the BluetoothSocket

socket = device.CreateInsecureRfcommSocketToServiceRecord( ServiceUUID );

This also seemed to work, even though it fails sometimes while connecting.

--
View this message in context: http://mono-for-android.1047100.n5.nabble.com/Bluetooth-rfcomm-tp5463305p5463679.html
Sent from the Mono for Android mailing list archive at Nabble.com.


More information about the Monodroid mailing list