我想写一个简单的蓝牙服务器,接受来自我的HeartRate设备(蓝牙LE)的连接,但它总是会引发例外BlueCove with Bluez chucks“无法打开SDP会话[2]没有这样的文件或目录”
javax.bluetooth.ServiceRegistrationException: Can not open SDP session. [2] No such file or directory
at com.intel.bluetooth.BluetoothStackBlueZ.openSDPSessionImpl(Native Method) ~[bluecove-gpl-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.intel.bluetooth.BluetoothStackBlueZ.getSDPSession(BluetoothStackBlueZ.java:518) ~[bluecove-gpl-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.intel.bluetooth.BluetoothStackBlueZ.registerSDPRecord(BluetoothStackBlueZ.java:543) ~[bluecove-gpl-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.intel.bluetooth.BluetoothStackBlueZ.rfServerOpen(BluetoothStackBlueZ.java:607) ~[bluecove-gpl-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.intel.bluetooth.BluetoothRFCommConnectionNotifier.<init>(BluetoothRFCommConnectionNotifier.java:42) ~[bluecove-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.intel.bluetooth.MicroeditionConnector.openImpl(MicroeditionConnector.java:389) ~[bluecove-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.intel.bluetooth.MicroeditionConnector.open(MicroeditionConnector.java:156) ~[bluecove-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at javax.microedition.io.Connector.open(Connector.java:83) ~[bluecove-2.1.1-SNAPSHOT-63.jar:2.1.1-SNAPSHOT]
at com.mmazurcz.bluetoothserver.WaitThread.waitForConnection(WaitThread.java:39) [classes/:na]
at com.mmazurcz.bluetoothserver.WaitThread.run(WaitThread.java:60) [classes/:na]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
我正在我的代码的Arch Linux的计算机上,使用内核 “4.0.5-1拱#1 SMP PREEMPT”。 Java是OpenJDK的1.8.0_45版本,Bluecove的版本是2.1.1-SNAPSHOT-63。我已经安装了下列文物的BlueZ:
- 的bluez 5.30-1
- 的bluez固件1.2-8
- 的bluez-库5.30-1
- 的bluez-utils的5.30-1
我正在使用的蓝牙适配器已启动并运行,我可以使用“hcitool -i hci0 lescan”扫描我的心率设备。我也以root用户身份运行我的代码。
所以,这里是给我带来麻烦的一段代码:
StreamConnectionNotifier notifier;
StreamConnection connection = null;
// setup the server to listen for connection
try {
local = LocalDevice.getLocalDevice();
log.info("Set up local device with BT address: " + local.getBluetoothAddress());
local.setDiscoverable(DiscoveryAgent.GIAC);
log.info("Set local device to GIAC discovery mode");
UUID uuid = new UUID("1101", true);
String url = "btspp://localhost:" + uuid.toString() + ";name=RemoteBluetooth";
notifier = (StreamConnectionNotifier) Connector.open(url);
} catch (Exception e) {
log.error("Exception in WaitThread.waitForConnection", e);
return;
}
任何想法?
您是否检查并完成了此处描述的要求? http://www.bluecove.org/bluecove-gpl/index.html –