我正在尝试在我的 J2ME 应用程序(使用 JSR-082 API)和我用 Python 编写的桌面应用程序(使用 pybluez 蓝牙 API)之间建立蓝牙连接。但是,我找不到合适的蓝牙通信协议来配对它们。
在pybluez中,连接服务器的方式如下:
addr, port = "01:23:45:67:89:AB", 1
sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
sock.connect((addr, port))
但是在 JSR-082 蓝牙 API 中,创建服务器的方式如下:
StreamConnectionNotifier connectionNotifier =
(StreamConnectionNotifier) Connector.open("btspp://localhost:" +
"0000000000000000000000000000ABCD;name=JSR82_ExampleService");
streamConnection = connectionNotifier.acceptAndOpen();
或如下:
L2CAPConnectionNotifier connectionNotifier =
(L2CAPConnectionNotifier) Connector.open("btl2cap://localhost:" +
"0000000000000000000000000000ABCD;name=JSR82_ExampleService");
streamConnection = connectionNotifier.acceptAndOpen();
在 pybluez API 中我们使用端口号,在 JSR-082 API 中我们使用 URL。那我该如何建立蓝牙连接呢?有没有办法使用 JSR-082 API 中的端口号创建服务器?