Android应用程序蓝牙确定配对设备之间的距离
所以今年夏天我正在尝试 Android 开发。当一对连接的设备超出彼此的范围时,我试图制作一种警报应用程序。
通过查看互联网/堆栈溢出,似乎查看 RSSI 值将帮助我实现这一目标。
然而,RSSI值似乎只能在与设备连接时读取,也就是说它不会自行更新(或者没有方法这样做)。
- RSSI 值是实现我的目标的唯一方法吗?
- 是否可以使用 RemoteDevice 和 RemoteDeviceHelper?有人试过这个吗?
- 任何其他建议和提示将不胜感激
so I'm trying my hand at android developing this summer. I was trying to make a sort of alarm app when a pair of connected devices go out of range of each other.
From looking around on the internet / stack overflow, it seems that looking at the RSSI value will help me achieve this.
However, it seems that the RSSI value can only be read at the time of connection with the device, that is it doesn't update itself (or there is no method to do so).
- Is the RSSI value the only way to achieve my goal?
- Would it be possible to use RemoteDevice and RemoteDeviceHelper? Has anyone tried this?
- Any other suggestions and hints would be much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以与设备建立连接并与设备交换心跳信息,您可以使用有效心跳信息的接收来检测设备是否在范围内和/或超出范围。
您的算法可以结合使用此信息和连接丢失来检测设备是否超出范围并引发警报。
Android 中的 RSSI 仅在发现过程中通过公共 API 可用,读取 RSSI 的其他非公共方式(如 RemoteDeviceHelper)也应该是可能的,但 RSSI 本身并不能很好地指示距离。
You could establish a connection with the device and exchange heartbeat information with the device , you can use the reception of valid heartbeat information to detect device being in range and or going out of range..
Your algorithm can use this information in conjunction with the connection loss to detect device being out of range and set off the alarm.
RSSI in Android available via public APIs is only during the discovery process, the other non public means of reading the RSSI (like in RemoteDeviceHelper) should also be possible , but RSSI by itself is not a good indication of distance.