problem client-server l2cap

69 views
Skip to first unread message

Daniele

unread,
Dec 17, 2010, 1:54:13 PM12/17/10
to bluecove-users
Hi all,
i've got a problem with a simply client-server comunication when i try
to open a connection between them.this is my code when i try to open
it:

Client:
String url="btl2cap://localhost:" + Server.UUID;
L2CAPConnection conn = (L2CAPConnection) Connector.open(url);

Server:
public final static String UUID =
"7140b25b7bd741d6a3ad0426002febcd";
String url = "btl2cap://localhost:" + UUID +
";name=L2CAPExampleServer";
System.out.println("conn: "+Connector.open(url));
L2CAPConnectionNotifier
notifier=(L2CAPConnectionNotifier)Connector.open(url);
System.out.println("\nServer Started. Waiting for clients to
connect...");
L2CAPConnection client = notifier.acceptAndOpen( );

The server runs ok, but when i run the client i've got this exception:

BlueCove version 2.1.0 on widcomm
conn: com.intel.bluetooth.BluetoothL2CAPConnectionNotifier@13a328f
Exception in thread "main" java.lang.ClassCastException:
com.intel.bluetooth.BluetoothL2CAPConnectionNotifier cannot be cast to
javax.bluetooth.L2CAPConnection
at Client.startClient(Client.java:28)
at Client.main(Client.java:74)
BlueCove stack shutdown completed
Java Result: 1
Build Successfully (tempo totale: 2 secondi)

the second line is a println that i have put to see if client really
open a connector, but when try to open a L2CAPL2CAPConnectionNotifier
the compiler says to me that i cannot do a casting between
BluetoothL2CAPConnectionNotifier and L2CAPConnection, why? i have done
many researches in the web and find that all people follow this
procedure, so what i have to do?

Thanks in advantage to all how will help me ;)

Sebastian Brestin

unread,
Apr 27, 2014, 9:31:30 AM4/27/14
to bluecov...@googlegroups.com, d.ma...@gmail.com
When opening the connection from the client you shouldn't place localhost inside your url. Placing the word localhost inside the url makes the open() method open a server connection. For more details check com.intel.bluetooth.MicroeditionConnector.openImpl() method on line 205. you will see this cone isServer = host.equals("localhost");

For the client try btl2cap://0050CD00321B:1001;ReceiveMTU=512;TransmitMTU=512 as a url. modify it according to your needs.
Reply all
Reply to author
Forward
0 new messages