views:

14

answers:

0

I am trying to establish a bluetooth connection between my J2ME application (using JSR-082 API) and my desktop application written with Python (using pybluez bluetooth API). However, I could not find a suitable bluetooth communication protocols to pair them.

In pybluez, the way you connect to a server is as follows:

addr, port = "01:23:45:67:89:AB", 1
sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
sock.connect((addr, port))

However in JSR-082 bluetooth API, the way you create a server is as follows:

StreamConnectionNotifier connectionNotifier =
    (StreamConnectionNotifier) Connector.open("btspp://localhost:" + 
    "0000000000000000000000000000ABCD;name=JSR82_ExampleService");
streamConnection = connectionNotifier.acceptAndOpen();

or as follows:

L2CAPConnectionNotifier connectionNotifier = 
    (L2CAPConnectionNotifier) Connector.open("btl2cap://localhost:" + 
    "0000000000000000000000000000ABCD;name=JSR82_ExampleService");
streamConnection = connectionNotifier.acceptAndOpen();

In pybluez API we use port numbers, and in JSR-082 API we use URLs. How am I going to establish a bluetooth connection then? Is there a way to create a server using a port number in JSR-082 API?