问题
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