I have been able to fix the problem by using this code:
IntPtr createRfcommSocket = JNIEnv.GetMethodID(item.Class.Handle,
"createInsecureRfcommSocket", "(I)Landroid/bluetooth/BluetoothSocket;");
IntPtr _socket =
JNIEnv.CallObjectMethod(item.Handle, createRfcommSocket, new
Android.Runtime.JValue(1));
ConnectionSock =
Java.Lang.Object.GetObject<BluetoothSocket>(_socket,
JniHandleOwnership.TransferLocalRef);
It seems that it was impossible to start a secure connection so a insecure
connection must be made.
Subject: [mono-android] Bluetooth problem
Hello,
I have a problem connecting to a bluetooth device on my
arduino(http://www.hobbycomponents.com/index.php?route=product/product&filter_name=bluetooth&product_id=116)
The problem is connecting to it with my phone(Alcatel OT-991)
I use the following code to try and connect to the bluetooth device but i get
this exeption: service discovery failed.
bluetoothAdapter.CancelDiscovery();
ConnectionSock = item.CreateRfcommSocketToServiceRecord(SPP_UUID);
ConnectionSock.Connect();
After some searching on Google i found this:
> 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".
I see you found the advice to call CancelDiscovery():
http://stackoverflow.com/a/8752294/83444
Now you probably need to try the "hack" solution:
http://stackoverflow.com/a/3397739/83444
> Method m = device.getClass().getMethod("createRfcommSocket", new Class[]
> {int.class});
> socket = (BluetoothSocket) m.invoke(device, 1);
Unfortunately that solution relies on Java reflection, which we don't currently
expose. It thus needs to be translated to JNI:
IntPtr createRfcommSocket = JNIEnv.GetMethodID(device.Class.Handle,
"createRfcommSocket", "(I)Landroid/bluetooth/BluetoothSocket;");
IntPtr _socket = JNIEnv.CallObjectMethod(device.Handle,
createRfcommSocket, new Android.Runtime.JValue(1));
socket = Java.Lang.Object.GetObject<BluetoothSocket>(_socket,
JniHandleOwnership.TransferLocalRef);
- Jon
(http://lists.ximian.com/pipermail/monodroid/2012-September/012376.html)
So i tried that but then i had the problem of getting infinite pair request no
matter how many i fill in it kept coming back.
now i am lost any one have a idea on how to make this work?
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid