JSR-82 L2CAP

  • Thread starter Mart? Bayo Alemany
  • Start date
M

Mart? Bayo Alemany

Hi I am trying to communicate with a L2CAP service in a bluetooth device.

I can discover the service and I can get the attributes from them.
However wherever I use the getConnectionUrl to open a connector I only get
null.
Any idea ?

Here is the code...

public void doAClient/*L2CAP*/ ( ServiceRecord aRecord )

{


String url =
aRecord.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
System.out.println("\t\t\t\t\t|url: " + url);
System.out.println("\t\t\t\t\t|------------------------------------");


try {
L2CAPConnection conn = (L2CAPConnection)Connector.open(url);

int ReceiveBufferSize = conn.getReceiveMTU();
int SendBufferSize = conn.getTransmitMTU();

String message = "Hello World !";

byte[] receiveBuf = new byte[ReceiveBufferSize];
conn.send(message.getBytes());
conn.receive(receiveBuf);
conn.close();
}
catch(IOException e)
{

System.out.println("Error with that url " + url);

e.printStackTrace();

}



Here is the description of the service...

Service Name: Ambiesense
Service Description: Ambiesense
Service RecHandle: 0x10002
Service Class ID List:
"Serial Port" (0x1101)
Protocol Descriptor List:
"L2CAP" (0x0100)
uint8: 0x7

sh-2.03# sdptool get --tree --bdaddr 00:02:72:01:0E:16 0x10002
Attribute Identifier : 0x0 - ServiceRecordHandle
Integer : 0x10002
Attribute Identifier : 0x1 - ServiceClassIDList
Data Sequence
UUID16 : 0x1101 - SerialPort
Attribute Identifier : 0x2 - ServiceRecordState
Integer : 0x8
Attribute Identifier : 0x3 - ServiceID
UUID16 : 0x1500
Attribute Identifier : 0x4 - ProtocolDescriptorList
Data Sequence
Data Sequence
UUID16 : 0x0100 - L2CAP
Channel/Port (Integer) : 0x7
Attribute Identifier : 0x5 - BrowseGroupList
UUID16 : 0x1002 - PublicBrowseGroup (SDP)
Attribute Identifier : 0x8 - ServiceAvailability
Integer : 0xff
Attribute Identifier : 0x100
Text : "Ambiesense"
Attribute Identifier : 0x101
Text : "Ambiesense"
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top