Sampreeth / android-bluetooth

Automatically exported from code.google.com/p/android-bluetooth
0 stars 0 forks source link

Pairing and using setPin #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. setPin will always return false.

What is the expected output? What do you see instead?
I've expected it to set the PIN and afterwords when I pair, the pairing
request with the remote device will start automatically without user interface.

What version of the product are you using? On what operating system?
0.2 and 0.3. On 1.5.

Please provide any additional information below.
What I really wanted to do is:

remoteBluetoothDevice.pair("123");

However, this function is not implemented. (Throws
UnsupportedOperationException )

So I thought I can do:
Boolean b = remoteBluetoothDevice.setPin("123");
remoteBluetoothDevice.pair();

However, it seems that setPin doesn't work hence, when I pair() the
function notifies the user that a pairing request is initiated and request PIN.

Am I doing something wrong?

Original issue reported on code.google.com by eran.kir...@gmail.com on 6 Oct 2009 at 9:33

GoogleCodeExporter commented 9 years ago
I'm sorry. My mistake. I didn't realize that I need to set the pin in 
pinRequested().
If someone else has this problem, the solution is to set the pin in the
RemoteBluetoothDeviceListener in the event: pinRequested. (Read about this 
event in
java doc - it's really clear)

Original comment by eran.kir...@gmail.com on 6 Oct 2009 at 11:30

GoogleCodeExporter commented 9 years ago

Original comment by gerda...@gmail.com on 18 Oct 2009 at 7:02

GoogleCodeExporter commented 9 years ago
Hello,

 I'm also having problems with this issue. I try to open a BluetoothSocket to another
device, and when I try to do this, I received the pinRequested event. At this 
point I
do remoteDevice.setPin("0000");. What is the next step? If I try to open the 
socket
again it throws an exception, and I don´t receive the paired event.

Thanks.

Original comment by fquinhoy...@gmail.com on 19 Oct 2009 at 3:32

GoogleCodeExporter commented 9 years ago
Hi,

Same thing is here also. I am using following code as mentioned in the doc. But 
the pinRequested() method has been never called up. Any help or clue would be 
appreciated. If there is any other way to set PIN please respond.
----------------------------------------------------------------------
private class RemoteBluetoothDeviceEventHandler implements 
RemoteBluetoothDeviceListener {
    RemoteBluetoothDevice device ;
    public void paired() {
       try {
        if (D) Log.i(TAG, "BS paired 1.");
        mmSocket = device.openSocket(1);
       } catch (BluetoothException e) {
        if (D) Log.i(TAG, "BS paired() BluetoothException.");
        e.printStackTrace();
        connectionFailed();
        }       
    }
    public void pinRequested() {
        if (D) Log.i(TAG, "pinRequested()*************************");
        try {
        device.setPin("1234");
        } catch (BluetoothException e) {
        e.printStackTrace();
        }    
    }
    public void gotServiceChannel(int serviceID, int channel) {
        if (D) Log.i(TAG, "gotServiceChannel()");     
    }
    public void serviceChannelNotAvailable(int serviceID) {
        if (D) Log.i(TAG, "serviceChannelNotAvailable()");
    }
    }
----------------------------------------------------------------------
Thanx & Regds.

Original comment by santosh....@gmail.com on 30 Jun 2010 at 7:44

GoogleCodeExporter commented 9 years ago
In android standard API, i have never seen setPin() method.
Which version of android sdk do you using?
I checked 

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/and
roid/2.1_r2/android/bluetooth/BluetoothDevice.java#BluetoothDevice.setPin%28byte
%5B%5D%29

I downloaded android-2.2.1_r1.jar.
But i did not found the way how can i use the .jar file. Because the name space 
of the library is same with android standard api.
Please help me.

Original comment by ycm825@gmail.com on 21 May 2012 at 8:50