首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用蓝牙HIDL?

如何使用蓝牙HIDL?
EN

Stack Overflow用户
提问于 2019-05-21 13:45:16
回答 1查看 1.7K关注 0票数 1

我正在开发一个AOSP应用程序,必须将HCI命令发送到蓝牙芯片组。

我发现我可以使用这个接口:https://source.android.com/reference/hidl/android/hardware/bluetooth/1.0/IBluetoothHci

要使用它,我尝试遵循以下页面:https://source.android.com/devices/architecture/hidl-java/index.html

如果我理解得很好,我必须创建一个Android.mk文件并将

代码语言:javascript
复制
LOCAL_STATIC_JAVA_LIBRARIES +=  android.hardware.bluetooth@1.0

但我不明白怎么回事?我还是AOSP开发中的新手,如何使用这个库?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-10 14:36:57

如果您是应用程序开发人员

您找到的IBluetoothHci定义了蓝牙硬件抽象层(HAL)的接口。HAL接口不能直接从应用程序访问,而是由框架服务使用,框架服务提供了可供应用程序使用的接口。我建议查看Android:https://developer.android.com/guide/topics/connectivity/bluetooth

如果您是platform developer

如果您计划编写一个具有更多权限的服务(您自己构建AOSP并闪现整个设备),您是正确的。IBluetoothHci是要使用的接口。您可能希望从使用Android.mk切换到Android.bp,因为不推荐使用Android.mk文件。在您的代码中,我希望看到这样的内容:

代码语言:javascript
复制
import android.hardware.bluetooth.V1_0.IBluetoothHci;
...
// retry to wait until the service starts up if it is in the manifest
IBluetoothHci bluetooth = IBluetoothHci.getService(true /* retry */); // throws NoSuchElementException if not available
bluetooth.initialize();

关于如何使用HAL接口的提示也可以在各自的VTS测试中找到(尽管它们是用C++编写的):0TargetTest.cpp

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56239716

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档