| Reply | « Previous Thread | Next Thread » |
|
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. |
| Kurt Johannes |
| View Public Profile |
| Find all posts by Kurt Johannes |
|
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? |
| Kurt Johannes |
| View Public Profile |
| Find all posts by Kurt Johannes |
|
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. |
| Kurt Johannes |
| View Public Profile |
| Find all posts by Kurt Johannes |
|
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... |
| Kurt Johannes |
| View Public Profile |
| Find all posts by Kurt Johannes |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| 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 |