| Tobias Küster 2005-08-15, 11:48 pm |
| Hello,
we are encountering some problems connecting us to the WRAP THOR
evaluation kit using a mobile. Actually, we are encountering some
problems connecting several mobiles among each other as well. Maybe you
can help me.
I wrote a J2ME program that can act as a server and as a client. You can
find the essential parts of the code below. The server is intended to
open a conection using a given UUID (e.g. 1101 for SPP), then an
outputstream is opened. The client in connecting to this stream and is
reading data in a loop, until the stop-command is sent.
For testing we are using a Motorola A1000 as well as a Nokia 6320. On
the Nokia the Server doesn't work at all. The program gets stuck as soon
as the server is started and not even one of the debugging messages are
given to the screen. On the Motorola the Server works only when opening
an Inputstream (for reading data from, but not for writing). It seems to
get stuck when trying to open the outputstream (unfortunately debugging
is quite hard when the program is running on the mobile...).
The client is working well on the Nokia. We managed to conect to a PC
and send data from the pc to the mobile using the BlueGiga WRAP THOR TTY
program and a BT keyboard dongle. Still, the same thing doesn't work on
the Motorola...
And for some reason the getFriendlyName is causing an exection on the
okia while working perfectly on the Motorola, but that's not so
important - just interesting. We are very deranged since some parts of
the program seem only to work on the one phone and the rest only on the
other...
Here's some of the code. I hope you can help, and thanks in advance.
Tobias
The server:
----------------------------------------------
LocalDevice device = LocalDevice.getLocalDevice();
device. setDiscoverable(Disc
overyAgent.GIAC);
// build URL string
String url= "btspp://localhost:" + uuid + ";name=BTTestServer";
// connect to url
StreamConnectionNoti
fier notifier =
(StreamConnectionNot
ifier)Connector.open(url);
// wait for client and open stream then
StreamConnection conn = notifier.acceptAndOpen();
DataOutputStream out= conn. openDataOutputStream
();
--------------------------------------------------
The client: (the essentaial part of the
DiscoveryListener.serviceDiscovered()-method)
--------------------------------------------------
//get URL string from the service record found
String url=
servRecord[i]. getConnectionURL(Ser
viceRecord. NOAUTHENTICATE_NOENC
RYPT,false);
StreamConnection conn= (StreamConnection) Connector.open(url);
DataInputStream in= conn. openDataInputStream(
);
while (stop==false) {
int number= in.read();
form.append(number+"");
}
---------------------------------------------------
|