BlueZ:不使用sdptool命令添加服务,属性和配置文件

时间:2018-10-30 17:15:07

标签: linux bluetooth bluez

在BlueZ 5之前,通过 sdptool 完成在Linux上添加/删除蓝牙服务/属性/配置文件的方法,如下所示:-

浏览本地记录

    018-10-31 00:45:28,583 [ 119986]   INFO - tartup.impl.StartupManagerImpl - Activity run in 109ms on UI thread 
2018-10-31 00:45:29,001 [ 120404]   INFO - j.ide.ui.OptionsTopHitProvider - 233 ms spent on EDT to cache options in project 
2018-10-31 00:45:29,585 [ 120988]   WARN - ution.rmi.RemoteProcessSupport - Unrecognized option: -d64 
2018-10-31 00:45:29,585 [ 120988]   WARN - ution.rmi.RemoteProcessSupport - Error: Could not create the Java Virtual Machine. 
2018-10-31 00:45:29,585 [ 120988]   WARN - ution.rmi.RemoteProcessSupport - Error: A fatal exception has occurred. Program will exit. 
2018-10-31 00:45:29,630 [ 121033]   WARN - ution.rmi.RemoteProcessSupport - Unrecognized option: -d64 
2018-10-31 00:45:29,630 [ 121033]   WARN - ution.rmi.RemoteProcessSupport - Error: Could not create the Java Virtual Machine. 
2018-10-31 00:45:29,630 [ 121033]   WARN - ution.rmi.RemoteProcessSupport - Error: A fatal exception has occurred. Program will exit. 
2018-10-31 00:45:29,632 [ 121035]  ERROR -      #org.jetbrains.idea.maven - Cannot reconnect. 
java.lang.RuntimeException: Cannot reconnect.
    at org.jetbrains.idea.maven.server.RemoteObjectWrapper.perform(RemoteObjectWrapper.java:82)
    at org.jetbrains.idea.maven.server.MavenServerManager.applyProfiles(MavenServerManager.java:526)
    at org.jetbrains.idea.maven.project.MavenProjectReader.applyProfiles(MavenProjectReader.java:394)
    at org.jetbrains.idea.maven.project.MavenProjectReader.doReadProjectModel(MavenProjectReader.java:103)
    at org.jetbrains.idea.maven.project.MavenProjectReader.readProject(MavenProjectReader.java:62)
    at org.jetbrains.idea.maven.project.MavenProject.read(MavenProject.java:655)
    at org.jetbrains.idea.maven.project.MavenProjectsTree.doUpdate(MavenProjectsTree.java:555)
    at org.jetbrains.idea.maven.project.MavenProjectsTree.doAdd(MavenProjectsTree.java:500)
    at org.jetbrains.idea.maven.project.MavenProjectsTree.update(MavenProjectsTree.java:461)
    at org.jetbrains.idea.maven.project.MavenProjectsTree.updateAll(MavenProjectsTree.java:432)
    at org.jetbrains.idea.maven.project.MavenProjectsProcessorReadingTask.perform(MavenProjectsProcessorReadingTask.java:60)
    at org.jetbrains.idea.maven.project.MavenProjectsProcessor.doProcessPendingTasks(MavenProjectsProcessor.java:132)
    at org.jetbrains.idea.maven.project.MavenProjectsProcessor.access$000(MavenProjectsProcessor.java:32)
    at org.jetbrains.idea.maven.project.MavenProjectsProcessor$2.run(MavenProjectsProcessor.java:107)
    at org.jetbrains.idea.maven.utils.MavenUtil.lambda$runInBackground$5(MavenUtil.java:449)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.rmi.RemoteException: Cannot start maven service; nested exception is: 
    com.intellij.execution.ExecutionException: Unrecognized option: -d64
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

    at org.jetbrains.idea.maven.server.MavenServerManager.create(MavenServerManager.java:161)
    at org.jetbrains.idea.maven.server.MavenServerManager.create(MavenServerManager.java:66)
    at org.jetbrains.idea.maven.server.RemoteObjectWrapper.getOrCreateWrappee(RemoteObjectWrapper.java:41)
    at org.jetbrains.idea.maven.server.MavenServerManager.lambda$applyProfiles$3(MavenServerManager.java:526)
    at org.jetbrains.idea.maven.server.RemoteObjectWrapper.perform(RemoteObjectWrapper.java:76)
    ... 20 more
Caused by: com.intellij.execution.ExecutionException: Unrecognized option: -d64
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

    at com.intellij.execution.rmi.RemoteProcessSupport.acquire(RemoteProcessSupport.java:159)
    at org.jetbrains.idea.maven.server.MavenServerManager.create(MavenServerManager.java:158)
    ... 24 more
2018-10-31 00:45:29,633 [ 121036]  ERROR -      #org.jetbrains.idea.maven - IntelliJ IDEA 2018.2.5  Build #IC-182.4892.20 
2018-10-31 00:45:29,633 [ 121036]  ERROR -      #org.jetbrains.idea.maven - JDK: 1.8.0_152-release 
2018-10-31 00:45:29,633 [ 121036]  ERROR -      #org.jetbrains.idea.maven - VM: OpenJDK 64-Bit Server VM 
2018-10-31 00:45:29,633 [ 121036]  ERROR -      #org.jetbrains.idea.maven - Vendor: JetBrains s.r.o 
2018-10-31 00:45:29,633 [ 121036]  ERROR -      #org.jetbrains.idea.maven - OS: Mac OS X 
2018-10-31 00:45:29,633 [ 121036]  ERROR -      #org.jetbrains.idea.maven - Last Action: EditorBackSpace 

添加服务

#sdptool browse local
Browsing FF:FF:FF:00:00:00 ...

删除服务

#sdptool add SP
Serial Port service registered

但是,不推荐使用 sdptool (以及 hciattach hciconfig hcitool hcidump < / strong>, rfcomm ciptool gatttool ),并已从BlueZ主版本中删除,如以下链接所示:-< / p>

幸运的是,大多数命令已被更新的命令(btattach,btmgmt和bluetoothctl)取代。但是,似乎没有任何替代sdptool的方法。

我的问题是:-我现在可以使用什么工具代替sdptool来浏览本地服务/配置文件以及添加或删除配置文件?

请注意,我知道sdptool可以重新构建并启用,但是我正在寻找该命令的替代品,而不是替代方法。

1 个答案:

答案 0 :(得分:3)

在Bluez 5中,这需要使用ProfileManager DBUS接口来完成。您需要使用此界面注册自定义/外部配置文件,而Bluez处理安全性和连接的所有方面。

一旦连接就绪,bluez将提供文件描述符以对外部配置文件进行操作。您可以在bluez-alsa中找到HFP配置文件的示例实现。

详细来说,您可以实现org.bluez.Profile1 interface的所有方法,并使用org.bluez.ProfileManager1 interface在Bluez上进行注册,您可以在其中指定UUID,auth(如果有的话)需要)。

在bluez-alsa中,

  1. 注册完成here
  2. 方法已实现here

建立此配置文件的连接后,NewConnection API将是called,且参数为fd。

但是AFAIK,没有任何直接方法可以使用现有工具(例如bluetoothctl)来实现这一目标。