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.
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.
Related
So I am working with trying to transfer data between two phones with Google Nearby Connections.
For example, say I want to transfer a variable from each phone to another and then show a toast containing the text from the other phone.
I have been looking into the Connections API but I can't seem to limit it to when two phones are really close to each other. I have seen that the Nearby Messages API has an Earshot distance option.
But there isn't an option for earshot distance in the Nearby Connections API since the Nearby messages API doesn't seem to contain what I need to make something like the example above work.
Hope you can help me :)
There hadn't been a feature request for it until now, which is why there's no support in Nearby Connections.
I believe Nearby Messages would support your use case, though. It can exchange a few KB of data to other devices nearby. It's not a live bi-directional channel, like Nearby Connections is, but it doesn't sound like you need that.
Nearby connections uses bluetooth, BLE (Bluetooth Low Emissions) and WiFi. This signals can't be adjusted to reach a certain distance.
Nearby messages, on the other hand, also uses ultrasounds which can limit the phone's reach to a much shorter distance. See this video. It's also stated in the documentation of messages.
So your options are either fully offline connections without distance setting, or online messages with distance setting. Note that messages is not fully online, it only publishes the message to be shared in a google server. The key necessary to retrieve that message is sent offline between users.
I believe that your precise requirement for distance is what is being addressed in this Bluetooth Core Specification 5.1. Therefore, the solution is pending on:
Bluetooth hardware chips 5.1 will happen
Smartphone manufacturer will use these chips
Android Bluetooth library is updated to exploit the new feature of this chip
I'm starting to think about a near by group chat application in Android with the following prerequisites:
Have to be able to connect groups of users up to 250 without too much problems.
The messages sent by the users will be public and all the group members have to receive them.
The message will be the combination of a tiny profile image (no more than 20KB), a user identifier and a text message up to 250 characters.
The range of the messages should be around 100 meters (~300ft)
These are the base requirements, there are other ones that are also related to the way of connect but I want to keep it clear and simply by now.
I tried to look for information of both apis but I'm still doubitative about them.
I know that the connections api has a mesh P2P_CLUSTER strategy that probably could fit but I don't have information about other things such as stability, real distance and maximum number of users.
On the other hand, the messages api seems more suitable but It needs a permanent internet connection, which is something still in consideration for the moment.
I'm building a app to test Google Nearby Messages API. For that test, I'm using DISTANCE_TYPE_EARSHOT.
According to this thread Nearby API's Strategy.DISTANCE _TYPE_ EARSHOT doesn't seem to restrict message proximity , after the initial link between devices, they can receive messages for 10 minutes regardless of distance. I would like to know if this 10 minute limit can be interrupted (in order to prevent that a device can receive a message when its distance to another device is more than ~5ft - EARSHOT).
Alternatively, is there a way to get the distance between devices?
Thank you.
(I work on the Nearby API)
Today, Nearby doesn't expose distance directly nor does it provide a way to force "un-pairing" of devices programmatically. We've heard folks want both of these things, the features are on our radar, but we can't comment or commit beyond that.
As a manual hack, you can clear data on "Google Play Services" to un-pair devices.
You can get a rough approximation of distance by measuring BLE RSSI if one of the devices is capable of BLE advertising. This will be sensitive to how the device is held, antenna gain and environmental factors but better than random.
There's not a straight-forward "tape measure" API, though.
This question follows on from Unity3D -- Send message to other mobile phones in the same vicinity
However, I made mistake of restricting to Unity3D.
So I would like to re-ask the question without that constraint.
Let us say we have 20 mobile phone users in a cave (so no Wi-Fi networks / isGPS)
One user hits a button, and every other user's screen flashes, (within a few milliseconds)
How to accomplish this?
What if everyone is using an iPhone?
What if there is a mix of iPhone and android users?
Finally, is there any solution that would cover a wider range of phones?
You should have some network so that mobiles can share some data. Bluetooth can have maximum of 10 m distance coverage (depends upon devices though). Since, all mobile are running same app they should be linked to a network and communicate. Please Check:
http://developer.android.com/samples/BluetoothLeGatt/index.html
You can create one device as server and communicate among other devices.
https://github.com/polyclef/BluetoothChatMulti
If you have installed the app on all of the devices then in all probability yes, if the device supports push (pretty much any smartphone) then you can use the push service to synchronize the devices based on geofencing (ie, 10m from my location), there are some other discovery routes you could try to (without using the B word) pinging other devices
the app would need to be able to provide some sort of server service if it was to create its own private network based on the IP addresses of the devices it found nearby, as those devices would have to connect to that phone acting as a server. the network interface shouldn't be important, but connecting the satellite devices to the server should be. You could try doing it based on which device can provide data services, aka hotspot. You can easily connect devices to networks programmatically.
at that point your faced with the classic client server problem. There is going to be a huge amount of work to get devices configured, network creation, client server infrastructure if it has to be done without data, packet optimization. Very expensive and very high risk depending on how many restrictions there are.
Search for How to make a html5 group chat and then build on that example.
Possibly send commands to the chat delimited by a / character where a javascript could then execute the command.
Good Luck with your design.
Danny117
I am looking for a way to transmit data when two phones are close by. This needs to be cross platform so I cannot use NFC or iBeacon. I plan on using allJoyn to send information. I would only like to send data to others that are within a few feet of me.
Is there any way that I could get an accurate reading of distance on other phones? Or can I get an accurate distance on a master device that could be placed in the room?
Shot in the dark answer:
If both devices are on the same wireless WiFi network (same subnet), then any devices on same network are "close enough".
When on the celluar network (or when only one device is on Wifi), use the Location APIs of the platform to get GPS coordinates. Send your coordinates up to a web server that keeps track of the Latitude/Longitude coordinates of each device. The web service also allows the devices to poll for nearby devices (where the distance equation can be computed on the server).
So the best way that I found to do this is to use the accelerometer to tell when two devices bump then I get the bluetooth signal strength of the nearest device, if that falls into a certain value then they are touching.