Google Nearby Connections set limit on connection distance like Nearby Messages

纵饮孤独 提交于 2021-02-07 09:47:13

问题


I'm working on an app at the moment for Android and iOS that uses Nearby Connections to communicate small amounts of data (like a string, character, or int) to other devices. I was originally looking into Nearby Messages but noticed that it needed an internet connection at all times to be able to send the messages to the google server and then to the targeted devices(s). That was not the functionality I wanted and saw that Nearby Connections was more appropriate.

However, unlike Nearby Messages, I could not find a way to limit the range at which the data can be sent like using DISTANCE_TYPE_EARSHOT. Currently, I believe it is always 100m which is ridiculously large and want to reduce it down to possibly a couple feet (maybe 5-10ft). Is this possible somehow with Nearby Connections or would I have to just work with Nearby Messages?

Thank you.


回答1:


There is no way to limit the range.

Nearby Messages uses ultrasonic to exchange IDs in EARSHOT mode and there is a physical limitation of this kind of exchange.

But Nearby Connections uses radio and only way (very inaccurate) to limit is by signal strength, but Nearby Connection does not expose signal strength via its API.

But don't rely on ~100 meters you see in Nearby docs. As far as I know Nearby Connections only use Bluetooth for initial discovery, and this type of radio is often limited by ~30 meters.



来源:https://stackoverflow.com/questions/54153355/google-nearby-connections-set-limit-on-connection-distance-like-nearby-messages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!