Bluetooth-Communication J2SE <--> J2ME

R

Rainer

Hello NG,

i'm trying to write a small programm transfering some data between a pc
(J2SE) and my mobile (Nokia 6270). I decided to use BlueCove on the pc
side because of the identical api's.

The pc should act as the server where the clients connects to. But the
client (mobile) can't find the server (pc).

At first, here is the code for the j2se side:

ld = LocalDevice.getLocalDevice();
String ServiceURL =
"btspp://localhost:10203040607040A1B1C1DE100;name=SPPServer1";
// create a server connection
StreamConnectionNotifier notifier =
(StreamConnectionNotifier) Connector.open(ServiceURL);
// accept client connections
StreamConnection connection = notifier.acceptAndOpen();
// prepare to send/receive data
byte buffer[] = new byte[100];
String msg = "hello there, client";
InputStream is = connection.openInputStream();
OutputStream os = connection.openOutputStream();
// send data to the client
os.write(msg.getBytes());
// read data from client
is.read(buffer);
connection.close();

I've taken this code from a sun tutorial. In the method call
notifier.acceptAndOpen the thread waits for a incoming connection, as
expected.

Now the mobile tries to find the RFCOMM-Service of the Server. Here is
the code for the mobile:

LocalDevice ld = LocalDevice.getLocalDevice();
ld.setDiscoverable(DiscoveryAgent.GIAC);
m_discoveryAgent = ld.getDiscoveryAgent();
if (!m_discoveryAgent.startInquiry(DiscoveryAgent.GIAC, this)) {
return;
}
m_devices =
m_discoveryAgent.retrieveDevices(DiscoveryAgent.PREKNOWN);

The class containing this source code also implements the
DiscoveryListener-Interface. In the moment only the method
inquiryCompleted gets called. And after the inquiryCompleted-Method has
been called, the
m_discoveryAgent.retrieveDevices(DiscoveryAgent.PREKNOWN)
method call still returns null.

Does anyone knows why my mobile can't find the service, provided by the
pc.

Thanks in advice

Best Regards

Rainer Blickle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top