简体   繁体   English

Android NDK访问本机蓝牙功能bluedroid

[英]Android NDK accessing native bluetooth functions bluedroid

I'm trying to see what sort of native bluetooth functions i can access using JNI and Android NDK. 我正在尝试查看我可以使用JNI和Android NDK访问哪种本地蓝牙功能。 I've tried two different approaches: Using a prebuilt .so or building my own. 我尝试了两种不同的方法:使用预构建的.so或构建自己的.so。 As far as using a prebuilt .so I've pulled libbluetooth_jni.so off a Samsung Galaxy S4 using adb pull. 至于使用预构建的.so,我已使用adb pull将libbluetooth_jni.so从三星Galaxy S4中拉出。 However, I cannot find the source code for this (bluetooth_jni.c??) online and can't identify any accessible functions. 但是,我无法在线找到该源代码(bluetooth_jni.c ??),也无法识别任何可访问的功能。

Secondly, I tried to download the source for bluedroid from 其次,我尝试从以下位置下载bluedroid的源代码
https://android.googlesource.com/platform/external/bluetooth/bluedroid/ https://android.googlesource.com/platform/external/bluetooth/bluedroid/
However, I am having trouble building this. 但是,我在构建它时遇到了麻烦。

Currently when I try to run ndk-build, I get the following errors: 当前,当我尝试运行ndk-build时,出现以下错误:
undefined reference to '__android_log_print' 未定义对'__android_log_print'的引用
undefined reference to 'socket_local_client_connect' 未定义对“ socket_local_client_connect”的引用
undefined reference to 'str_parms_destroy' 未定义对“ str_parms_destroy”的引用

I added to this line: 我添加到此行:
LOCAL_LDLIBS := -llog LOCAL_LDLIBS:= -llog
and it got rid of the first error. 它摆脱了第一个错误。 However, I'm not sure how to get rid of the others. 但是,我不确定如何摆脱其他人。

Can anyone give me some advice on how to compile or otherwise get an .so in order to access native bluetooth functions?? 任何人都可以给我一些有关如何编译或以其他方式获得.so以便访问本地蓝牙功能的建议吗?

libbluedroid is specific for some hardware; libbluedroid是特定于某些硬件的。 on Samsung S4 you will find different bluetooth libraries. 在三星S4上,您会找到不同的蓝牙库。 If you need to go beyond the public bluetooth API, you will probably not find a common ground. 如果您需要超越公共蓝牙API,则可能找不到共同点。

Another problem that you face is that these libraries cannot work in app context, as @Chris explained in his comment. 您面临的另一个问题是这些库无法在应用程序上下文中运行,如@Chris在其评论中所解释。 They were designed to work with the media server with its special permissions. 它们旨在与具有特殊权限的媒体服务器一起使用。

Regarding the specific references, they are in libcutils.so . 关于特定参考,它们在libcutils.so The recent discussion about this non-public library is here . 关于这个非公共图书馆的最新讨论在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM