View Single Post
Old Feb 13th, 2008, 7:58 AM   #4
urip
Newbie
 
Join Date: Jan 2008
Posts: 3
Rep Power: 0 urip is on a distinguished road
Re: PC application with bluetooth

Quote:
Originally Posted by andro View Post
Here's a more helpful response...

http://sourceforge.net/projects/bluecove/
Thank you, your link was very helpful.
But now I have another question:

Using bluecove (jsr-82), I've succeeded in making a device discovery search, select a mobile phone, search for services and make a connection attempt..
So far so good, but when I try to connect the mobile, my cell demands a passkey (in order to pair itself to the PC).
So I have two questions (I've listed some code in the bottom):

1. Is it possible to send a message without the passkey and the pairing? (only by clicking yes/no to accept the connection by the cell) For instance, when I send a file from one mobile phone to another, it doesn't request a passkey, only an approval from the mobile user.

2. If it's not possible to connect without the passkey, how do I enter the pairing passkey back in the PC?

This is how I'm trying to initialize the connection:

    ...
    //after finding the remote device...
    int[] attrSet = new int[] { 0x0100};
    UUID uuidSet[] = new UUID[] { new UUID(0x1106) };
    int bl = _discoveryAgent.searchServices(attrSet, uuidSet, devices[i], this);
    ...
 
    public void serviceSearchCompleted(int transID, int respCode)
    {
            if(respCode == SERVICE_SEARCH_COMPLETED)
            {
                try
                {
                    //servRecord holds the found ServiceRecord
                    String connectionUrl = servRecord[0].getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
                    StreamConnection streamConnector = (StreamConnection) Connector.open(connectionUrl);
                    String msg = "Success.";
                    OutputStream os = streamConnector.openOutputStream();
                    os.write(msg.getBytes());
                    streamConnector.close();
                }
                catch(Exception exc)
                {
                    System.out.println("Error occured: " + exc);
                }
            }
    }

I hope I explained the code enough,
Thanks
urip is offline   Reply With Quote