Read-only archive of the All About Symbian forum (2001–2013) · About this archive

problem connecting Java(J2SE) program on computer with Symbian C++ program on mobile

0 replies · 1,406 views · Started 25 March 2006

Hi

I have been trying to connect a program written in Java(J2SE) on my computer with program written in Symbian C++ on the mobile using bluetooth. My simple aim is to pass a string say "Hello World" from my mobile to computer. The Java part is complete and its basically like a server waiting for connection. Bluetooth settings are normal on my computer with microsoft bluetooth emulator, widcomm stack, bluecove and all that. For the mobile part I have used the bt point to point example given in the SDK documentation. But so far Im unable to connect both of them. Here is what I have done:

Firstly to confirm that the java server on computer is working correctly I used the btdiscover example given in sdk to see a list of services offered by my computer. And it works! I see the "MyBtService" (the human readable string name I have given to the java program) on the list with other info like UUID, Handle and other attributes. If u want I can give the exact record (with des and all that) which it showed upon discovery. So the java program works.

Now my logic is that if I can change the UUID to which the bt point to point example connects to....I can make it connect to my java program on the computer and send a simple hello world string. The device discovery part works well, but when I select my computers name from list of devices, I get "connection error".
Here are the changes I did in the source code:

I narrowed down to the CBTServiceSearcher::FindServiceL function in the bt point to point example code. FindServiceL sets up a record filter to filter out just the Serial Port service record. It calls SetRecordFilter on the CSdpAgent to register the filter with the agent .

in this code the iSdpSearchPattern variable contains the attribute (at least thats what I think) which contains the UUID to connect to.

void CBTServiceSearcher::FindServiceL(TRequestStatus& aObserverRequestStatus)
{
if (!iResponse().IsValidBDAddr())
{
User::Leave(KErrNotFound);
}
iHasFoundService = EFalse;

// delete any existing agent and search pattern
delete iSdpSearchPattern;
iSdpSearchPattern = NULL;

delete iAgent;
iAgent = NULL;

iAgent = CSdpAgent::NewL(*this, BTDevAddr());

iSdpSearchPattern = CSdpSearchPattern::NewL();

iSdpSearchPattern->AddL(ServiceClass());
// return code is the position in the list that the UUID is inserted at
// and is intentionally ignored

iAgent->SetRecordFilterL(*iSdpSearchPattern);

iStatusObserver = &aObserverRequestStatus;

iAgent->NextRecordRequestL();
}

So if you look at the code of the function above... this line iSdpSearchPattern->AddL(ServiceClass());
is putting the attribute in the variable. How am I suppose to change it to the UUID of my service on the computer?? I tried simply putting the UUID of my service but it gave a variable out of range warning and program didnt work by still showing connection error after selecting the computer from discovered device's list.

Is my logic correct? Then how can I change the UUID attribute?
If my logic is wrong then tell me another way to connect a symbian c++ program on mobile to a java(j2se) program on the computer. Thanks!