You Are Here:

Community: Developer Discussion Boards

#1 Old L2CAP sending - 2006-09-26, 18:01

Join Date: Apr 2005
Posts: 75
Kurt Johannes
Offline
Regular Contributor
Hi,

I'm using a L2CAP connection between my cell-phone and a PC.
My problem is, that I have to connect twice until I receive data from my cell-phone on my server (PC).
The first time I receive nothing. Then I have to close my mobile application and start it again. Then the data is transferred to the PC.

Here is my code:

/***CLIENT***/
public void requestData() {
Logger.setLogger("request data");
try {
Logger.setLogger(serverURL);
connection = (L2CAPConnection) Connector.open(serverURL);
}
catch(IOException e) {
}
// open a stream and write message ID
try {
byte[] sendData = null;
String messageID = "0";
sendData = messageID.getBytes();

// send message
connection.send(sendData);

} catch (Exception e) {
}

}

/***SERVER***/
public void run() {
while (true) {
try {
//wait until a client has connected
System.out.println("Wait for clients...");
connection = (L2CAPConnection)notifier.acceptAndOpen();
System.out.println("Client has connected...");
}
catch (Exception e) {
System.err.println(e);
}
receiveData();
}
}

public void receiveData() {
String messageID = new String();
try {
byte[] buffer = new byte[1];
//Read only one byte
connection.receive(buffer);
messageID = new String(buffer);
System.out.println("messageID " + messageID);
} catch (IOException e) {
System.err.println(e);
}
}

I'm just sending a 0 or 1 as String.

What's wrong here?

Thanks.
Reply With Quote

#2 Old Re: L2CAP sending - 2006-09-26, 20:32

Join Date: Apr 2005
Posts: 75
Kurt Johannes
Offline
Regular Contributor
Furthermore when I call connection.ready() on server side for the first time, it returns false.
The main problem is here that when I execute the client the second time and I send data to the server, then not the current data is received by the server but the data that should be send the first time. And it goes on like this. When I send data a third time from the client the server receives the data from the second time.

It's really weird.

Can somebody help?
Reply With Quote

#3 Old Re: L2CAP sending - 2006-09-27, 11:56

Join Date: Apr 2005
Posts: 75
Kurt Johannes
Offline
Regular Contributor
Does no one know?

What could be the reason that when I establish a connection the connection.ready() call on server side returns false?

Does anyone has a BT-Server implemented on a PC for testing?


Thanks.
Reply With Quote

#4 Old Re: L2CAP sending - 2006-09-28, 00:31

Join Date: Apr 2005
Posts: 75
Kurt Johannes
Offline
Regular Contributor
I still couldn't figure out what is wrong.
So I changed my application so that I'm using now RFCOMM.
This works at least...
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Using L2cap sockets and Receiving Com Ports satya3050 Symbian Networking & Messaging 2 2006-09-25 06:08
BIP problem for nokia 6682 fafou Bluetooth Technology 0 2006-09-19 15:11
Sending 50 Kb data using BT L2Cap satya3050 Bluetooth Technology 0 2006-08-28 13:45
Sending long message njoandy1 Smart Messaging 2 2005-02-06 10:38
Error sending SMS jorge_c Multimodecards 0 2003-10-07 12:53

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia