安卓2.1:怎样查询现有的蓝牙连接的RSSI值? [英] Android 2.1: How do I poll the RSSI value of an existing Bluetooth connection?

查看:205
本文介绍了安卓2.1:怎样查询现有的蓝牙连接的RSSI值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要了解蓝牙连接到远程设备,我让我的Andr​​oid 2.1手机的信号强度。从SDK,我可以看到,我可以的时候我发现远端设备确定RSSI。但我不能看到如何随着时间的推移更新RSSI值。

I need to know the signal strength of a Bluetooth connection to a remote device that I make with my Android 2.1 phone. From the SDK, I can see that I can determine the RSSI at the time I discover the remote device. But I can't see how to update that RSSI value over time.

有人可以给我个忙吗?谢谢!

Can someone give me a hand? Thanks!!

推荐答案

从SDK是获得RSSI的唯一途径。这是一个有点不方便,因为它是没有用的,如果你只是想定期监测配对设备的信号强度。

From the SDK it is the only way to obtain RSSI. It is a little bit inconvenient, since it is not useful if you only want to periodically monitor the strength of the signal of a paired device.

但有一种方法,但出来的SDK。您可以使用本机API(由NDK的方式)和通话功能由配合bluez API ,在Android的底层蓝牙框架(和几乎所有的linux系统)。有问题的功能是 hci_read_rssi() libbluetooth.so 规定(配合bluez堆栈的一部分)。为了学习如何使用它,你可以看看 Hcidump工具来源(附带配合bluez)。你可以写一个JNI包装code到你的功能,让你可以得到配对设备的信号强度。

However there is a way, but out of SDK. You can use native API (by means of NDK) and call functions provided by Bluez API, the underlying bluetooth framework in Android (and almost any linux system). The function in question is hci_read_rssi() provided by libbluetooth.so (part of Bluez stack). In order to learn how to use it, you can take a look at Hcidump tool sources (that comes with Bluez). You could write a JNI wrapper code to your function, so you could get the signal strength of paired device.

有使用这种方法的两个缺点:

There are two drawbacks of using this method:

  • 要测量的RSSI您必须首先连接到远程设备,至少在较低水平(需要这方面无身份验证),并调用后 hci_read_rssi()释放连接。这不仅仅是RSSI测量从信标慢,其他的无线通信手段提供(GSM或WiFi)
  • 低级别连接到远程蓝牙设备要求对Android的超级用户的权利。所以,不要担心写作和应用程序,它可以在非侵入的手机上运行(他们通常都没有root权限,有的像摩托罗拉Droid /里程碑,甚至失去质保,如果你尝试获得它)。
  • To measure RSSI you must first connect to remote device, at least at low level (no authentication is required for this connection) and release connection after calling hci_read_rssi(). This is slower than just measuring RSSI from beacons, as other wireless communication means provide (GSM or WIFI)
  • Low level connection to remote bluetooth devices requires on Android superuser rights. So forget about writing and application that can be run on non hacked phones (they usually come with no root access, and some like Motorola Droid/Milestone even void warranty if you try to gain it).

这篇关于安卓2.1:怎样查询现有的蓝牙连接的RSSI值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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