Skip to main content

File transfer from PC to BT device (like a phone)

1 reply [Last post]
cospell
Offline
Joined: 2009-02-02
Points: 0

Hello!
I should develop an application that runs on a PC for sendig files to bluetooth devices within range.
I hope you'll help me.
I installed Windows XP SP2, I downloaded NetBeans with the JDK included and bluecove-2.1.0.jar (da http://code.google.com/p/bluecove/downloads/list).

I managed to do discoverd a device and service that interests me.

Not knowing what service to check for, I tried both with
UUID[] uuidSet = {new UUID(0x1105)};
and I get a ServiceName "Object Push"

and with
UUID[] uuidSet = {new UUID(0x1106)};
and I get a ServiceName "Obex File Transfer"

Obviously, not knowing which one to use well I tried to send the file by trying both, but nothing!

My class for sending files is:

public class ObjectPusher extends Thread
{
String connectionURL = null;
Connection connection = null;
File file = new File("test.txt";
FileClient client = null;

public ObjectPusher(FileClient client, String connectionURL)
{
this.connectionURL = connectionURL;
this.client = client;
}

public void run()
{
try
{
ClientSession clientSession = (ClientSession) Connector.open(connectionURL);

HeaderSet hsConnectReply = clientSession.connect(null) ;

if (hsConnectReply.getResponseCode() != ResponseCodes.OBEX_HTTP_OK) {
System.out.println("Failed to connect";
return;
}

//....

}
catch (IOException e)
{
System.out.println("Error :"+e.toString());
client.updateStatus("Error :"+e.toString());
}
}
}

When I do:
ClientSession clientSession = (ClientSession) Connector.open(connectionURL);
appears on the phone "exchange object with "Friendly Name del PC"?"

When I answer YES, the software crash
HeaderSet hsConnectReply = clientSession.connect(null) ;

Url is
btgoep://"ID_REMOTO":7;authenticate=false;encrypt=false;master=false

Obviously I tried all combinations with master = true, authenticate=true...but nothing

But what may be the reason? Maybe my Bluesoleil USB BT adapter don't work correctly?! I don't know...

Someone (on some forums) writes
ClientSession cs;
cs = (ClientSession) OBEXConnector.open(adr);

But my application don't recognize any OBEXConnector...

Some help?

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sfitzjava
Offline
Joined: 2003-06-15
Points: 0

Have you paired the devices? I believe without doing that they are not going to talk to one another. It's been a few years since I did any BT, maybe Bruce Hopkins is watching and will join in, I know he's really good at the BT stuff. :)

-Shawn