Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   PC application with bluetooth (http://www.programmingforums.org/showthread.php?t=15044)

urip Jan 26th, 2008 11:01 AM

PC application with bluetooth
 
Hello everybody,

I'm trying to develop a PC application with a Bluetooth connection using a USB dongle.
The application is supposed to search for devices in range, choose one of them, and then send him a file...


I have searched the net looking for a way to do it, but didn't find one. :icon_sad:
Is it possible to develop such application? If so, how can I do it? What should I look for? Is Java the ideal language for this application? (I don't care to use C# or C++ instead...)



Thanks.... :icon_wink:

Grich Jan 27th, 2008 5:51 AM

Re: PC application with bluetooth
 
Personally, use C++.

andro Jan 27th, 2008 8:21 PM

Re: PC application with bluetooth
 
Here's a more helpful response...

http://sourceforge.net/projects/bluecove/

urip Feb 13th, 2008 7:58 AM

Re: PC application with bluetooth
 
Quote:

Originally Posted by andro (Post 140396)
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

itgalary Feb 13th, 2008 9:08 AM

Re: PC application with bluetooth
 
Can be done with JSR with J2me

urip Feb 13th, 2008 12:15 PM

Re: PC application with bluetooth
 
In this case, I'm talking about J2SE only, due to the fact I'm programming this application for my computer...

I know this attributes determine the type of service we are looking for:
:

    int[] attrSet = new int[] { 0x0100};
    UUID uuidSet[] = new UUID[] { new UUID(0x1106) };

Those variables are later on passed to the discovery agent:
:

    _discoveryAgent.searchServices(attrSet, uuidSet, devices[i], this);

Maybe there are other properties except 0x0100 and 0x1106 that will do the work? I tried to learn more about those properties but found nothing about it.


All times are GMT -5. The time now is 4:21 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC