带 Bluez 卡盘的 BlueCove "Can not open SDP session. [2] No such file or directory"
BlueCove with Bluez chucks "Can not open SDP session. [2] No such file or directory"
我正在尝试编写一个简单的蓝牙服务器,它接受来自我的心率设备(蓝牙 LE)的连接,但它总是引发异常
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-ARCH #1 SMP PREEMPT”。
Java 是 1.8 版的 OpenJDK。0_45 和 Bluecove 是 2.1.1-SNAPSHOT-63 版。我已经安装了以下 BlueZ 工件:
- bluez 5.30-1
- bluez 固件 1.2-8
- bluez-libs 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;
}
有什么想法吗?
首先:我知道这是一个相当老的 post,但我经常通过 Google 来到这里,我终于让它在我的机器上工作了。
为了让它工作,我们需要使用 -C
(或 --compat
)选项启动蓝牙守护进程。这是通过进行以下更改来完成的:
打开终端并输入
sudo nano /etc/systemd/system/bluetooth.target.wants/bluetooth.service
然后换行
ExecStart=/usr/lib/bluetooth/bluetoothd
到
ExecStart=/usr/lib/bluetooth/bluetoothd -C
(只需添加 -C
选项)
现在您需要重新启动系统守护进程:
sudo systemctl daemon-reload
最后重启蓝牙服务:
sudo systemctl restart bluetooth
我在这里找到了这个解决方案:RaspberryPi Forum: Bluetooth RFCOMM - Jessie
希望我还能帮到别人!
几天来我遇到了同样的问题,我按照 Cyphargs 的说明进行操作,但后来我遇到了新问题,它说权限被拒绝而不是说没有这样的文件或目录,然后我在 Arch Linux forum :
chmod 777 /var/run/sdp # this line has done the magic
我正在尝试编写一个简单的蓝牙服务器,它接受来自我的心率设备(蓝牙 LE)的连接,但它总是引发异常
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-ARCH #1 SMP PREEMPT”。
Java 是 1.8 版的 OpenJDK。0_45 和 Bluecove 是 2.1.1-SNAPSHOT-63 版。我已经安装了以下 BlueZ 工件:
- bluez 5.30-1
- bluez 固件 1.2-8
- bluez-libs 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;
}
有什么想法吗?
首先:我知道这是一个相当老的 post,但我经常通过 Google 来到这里,我终于让它在我的机器上工作了。
为了让它工作,我们需要使用 -C
(或 --compat
)选项启动蓝牙守护进程。这是通过进行以下更改来完成的:
打开终端并输入
sudo nano /etc/systemd/system/bluetooth.target.wants/bluetooth.service
然后换行
ExecStart=/usr/lib/bluetooth/bluetoothd
到
ExecStart=/usr/lib/bluetooth/bluetoothd -C
(只需添加 -C
选项)
现在您需要重新启动系统守护进程:
sudo systemctl daemon-reload
最后重启蓝牙服务:
sudo systemctl restart bluetooth
我在这里找到了这个解决方案:RaspberryPi Forum: Bluetooth RFCOMM - Jessie
希望我还能帮到别人!
几天来我遇到了同样的问题,我按照 Cyphargs 的说明进行操作,但后来我遇到了新问题,它说权限被拒绝而不是说没有这样的文件或目录,然后我在 Arch Linux forum :
chmod 777 /var/run/sdp # this line has done the magic