Android NDK 访问原生蓝牙功能 bluedroid [英] Android NDK accessing native bluetooth functions bluedroid

查看:59
本文介绍了Android NDK 访问原生蓝牙功能 bluedroid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想看看我可以使用 JNI 和 Android NDK 访问什么样的原生蓝牙功能.我尝试了两种不同的方法:使用预构建的 .so 或构建我自己的.至于使用预构建的 .so,我已经使用 adb pull 从三星 Galaxy S4 中提取了 libbluetooth_jni.so.但是,我无法在网上找到此 (bluetooth_jni.c??) 的源代码,也无法识别任何可访问的功能.

I'm trying to see what sort of native bluetooth functions i can access using JNI and Android NDK. I've tried two different approaches: Using a prebuilt .so or building my own. As far as using a prebuilt .so I've pulled libbluetooth_jni.so off a Samsung Galaxy S4 using adb pull. However, I cannot find the source code for this (bluetooth_jni.c??) online and can't identify any accessible functions.

其次,我尝试从
下载bluedroid的源代码https://android.googlesource.com/platform/external/bluetooth/bluedroid/
但是,我在构建它时遇到了问题.

Secondly, I tried to download the source for bluedroid from
https://android.googlesource.com/platform/external/bluetooth/bluedroid/
However, I am having trouble building this.

目前,当我尝试运行 ndk-build 时,出现以下错误:
对__android_log_print"的未定义引用
对socket_local_client_connect"的未定义引用
对str_parms_destroy"的未定义引用

Currently when I try to run ndk-build, I get the following errors:
undefined reference to '__android_log_print'
undefined reference to 'socket_local_client_connect'
undefined reference to 'str_parms_destroy'

我添加到这一行:
LOCAL_LDLIBS := -llog
它摆脱了第一个错误.但是,我不确定如何摆脱其他人.

I added to this line:
LOCAL_LDLIBS := -llog
and it got rid of the first error. However, I'm not sure how to get rid of the others.

谁能给我一些关于如何编译或以其他方式获取 .so 以访问本机蓝牙功能的建议?

Can anyone give me some advice on how to compile or otherwise get an .so in order to access native bluetooth functions??

推荐答案

libbluedroid 特定于某些硬件;在三星 S4 上,您会发现不同的蓝牙库.如果您需要超越公共蓝牙 API,您可能找不到共同点.

libbluedroid is specific for some hardware; on Samsung S4 you will find different bluetooth libraries. If you need to go beyond the public bluetooth API, you will probably not find a common ground.

您面临的另一个问题是这些库无法在应用上下文中工作,正如 @Chris 在他的评论.它们旨在与具有特殊权限的媒体服务器一起使用.

Another problem that you face is that these libraries cannot work in app context, as @Chris explained in his comment. They were designed to work with the media server with its special permissions.

关于具体的引用,它们在libcutils.so中.最近关于这个非公共库的讨论是这里.

Regarding the specific references, they are in libcutils.so. The recent discussion about this non-public library is here.

这篇关于Android NDK 访问原生蓝牙功能 bluedroid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆