Android WiFi (sending and receiving data without specifying recipient) - android

I want to make an application is via WiFi would send and receive data without sending them to a specific recipient. I explained to the example of a simple chat: The user sends a message via WiFi, but without a specific destination. As a result, his report available to all users nearby. Similarly other users can receive and send messages. I also want to realize the function of repeater, where each user's device not only receives a message from the other devices, and retransmits them to others allowing increase the coverage area of WiFi connection.
But at the moment it is not possible to send data without a specific recipient. The same WiFi Direct necessarily require pairing before data transfer. Can not specify that the recipient is unknown.
Recently I heard the news about the technology WiFi Aware, which involves greater interaction between WiFI devices. Please reply, WiFi Aware allows to do what I described above? Namely - the transfer of data and we will without a clear indication of the recipient and the need to do additional work (eg preliminary pairing between devices).
If WiFi Aware allows to do what I described - when it is expected to release its API? In particular, for Android devices. And if not - you can tell me how to implement what I need? And in general - it is technically possible?
Thank you for your time and sorry for my bad English.

You should try to look into nsd via wifi-direct. This Network Service discovery via Wifi-Direct. What this helps you to achieve is broadcast information to all listening devices.
On the device which wants to convey the information you addLocalService and on the other devices you should discoverServices. In the ServiceInfo object you can the pass the information you want to communicate to the other devices who are listening for services. Please try to study from the link attached above.
I am not very sure about how repeater will work with this.

Related

Android Broadcasting / Receiving Data without Wifi Hotspot or Wifi Direct

My question is that is it possible to send and receive data between multiple android devices via broadcasting over wifi without establishing p2p connection?
Our professor asked us to design a wireless network system in which you broadcast a message within your android phone, and the other android phones nearby receive it and broadcast it again so that the other phones can receive it and it continues like that. In this way, for example, when someone writes a message in a classroom or café everyone will be able to receive it and broadcast it again. (like an adhoc network system). And although my professor believes it can be achievable, I didn't find anything online like this kind of android network system. So my question is again is it possible to do something like that?
Any helpful leads and references will be appreciated.
Edit: I had to change the title of the question.
I couldn't find a proper solution so I tried the following method so far: I set up a UDP messaging app using Wifi hotspot (it works perfectly for multi clients). The phone who turns on the hotspot is the server and others who connect to it are the clients. Then, I decided to turn this system into an adhoc-like system where there would be more than one hotspot and the clients would connect to them in cycling order and serve as a bridge among these servers.(every second, they will switch to other hotspot and vice versa.) So, they will carry the messages from one network to another. (I know it is very inefficient and prone to time delays; but it is the only idea I have come up with so far.)
When I told this system to my professor, he said that it is too complicated and I just need to broadcast a message from a device to a common channel(without setting up a network connection), and other devices will listen to this broadcast channel(without connecting to a network system), receive the message and broadcast their own messages along with received ones to this channel again as I described in the question body. (he never mentions hotspot, Wifi direct, and etc.) He even told me that the only thing I need to do was to think simpler and use the properties of 802.11. But, I do not think it is that easy to set up such a wireless system, at least for Android where ad hoc systems are not supported yet. So any help will be greatly appreciated. Thanks!
The Nearby Connections API in Google Play Services released last week uses WiFi multicast: https://developers.google.com/games/services/android/nearby
It works for devices already on the same WiFi network. However, it uses a host/clients model, and doesn't work with WiFi direct or a tethered hotspot connection.
You could also use the WiFi direct APIs from ICS: https://developer.android.com/guide/topics/connectivity/wifip2p.html
You can have multiple devices connected together via WiFi direct, so firing UDP packets as #willis suggests would seem the way to go
It is implementable. Do you know the aircrack? similarly, you can receive all packets even not sent to you, and you can send any kinds of packets even not sent by you.

Is it possible to make two-way communication between two devices via NFC?

I am trying to provide an application which sends multiple data between two different devices via NFC. For ex: device1 sends "date" comment and device2 gets the comment via NFC communication and then device2 checks the comment coming from device1. For device2, "date" means date of today and then device2 sends response message (such as 23.05.2013 14:21:45) at the same time. Not only "date" comment, but also the other comments should be used for the communication. For ex: when device1 sends "who are you" comment via NFC, device2 should send "i am Alice's device" at the same time. Is it possible? Can i make such a communication between two different devices at the same time? Thank you for your help.
Sending data via Android Beam in response to a received NDEF message transfered via Android Beam is not possible.
Technically the protocol Android Beam is built upon (LLCP) allows bi-directional data exchange on roughly 240 logical channels at the same time. This capability is just not exposed to Android applications.
You can hope for an API update, but I wouldn't wait for it. A hidden API for this existed in Android 2.3.3 but was later removed for some reason.
As Nils said - via NFC alone, this is not possible due the the limited Android API.
However, I am aware of one way of achieving it by using connection handover. Essentially, the NFC communication is used to send some credentials to the other device that allow the two of them to connect over Bluetooth.
The EasyNFC library claims to achieve this bluetooth functionality. I gave it a try and I think I was able to set up a socket, but never properly tested it. I didn't find it too reliable and I did not want the addition of bluetooth in my application, nor the use of the "Touch-to-beam" UI.

Simplest way to pass information between the same application installed on different phones

As the topic name suggests, what I am looking for is to add my android app the option to send data to a different phone running the same application so the receiving phone will process it accordingly.
The obvious option for me was to use app engine and use push notification with the phone number acting as the identifier.
Does a simpler solution exist?
Thanks ahead :)
The best and most robust solution is to have something like your messaging clients, in which Device A sends data to the server, which pushes it to Device B. Device B sends a reply to the server, which pushes it to Device A.
This process has the advantage of retrying the sending without requiring your users to stay connected, as may be required if Device B is offline when A sends a message.
A less foolproof solution is to have a server work as a middle man, and get each device's IP Address, and then open up a direct socket between them. In this solution, you'll lose any data that doesn't make it through.
If the devices are on the same network or in Bluetooth range, you could try Bluetooth or WiFi direct.

Is there a way for automatic/programatic pairing of 2 bluetooth devices in android?

I am developing an application which connects devices over bluetooth and exchanges messages. It works fine for paired devices, but I would also like it to automatically pair devices that are not paired. Like for example it could store and use the same PIN for pairing requests, I just dont know how to manage this request programatically in my applciation, how to automatically set and send the PIN when you get a pairing request and how to initiate such a request with the predefined PIN code.
Any snippets or thoughts would be highly appreciated! :)
EDIT:
I know its risky, I am developing this app for emergency situations only where no other means but bluetooth is available. Also is there maybe a way of premature pairing with devices without even connecting to them? Like lets say there is a list of MAC Addresses of those devices and I can use them to generate a bond with that devices so that they appear paired on my device?
You can't do this. To do what you want to do would create a huge security risk. Think about it, my device just comes anywhere in bluetooth range of yours and now I can send you anything I want without you knowing? You can't really do this and I highly recommend not trying to subvert it.
Reflecting the setPin method allowed me to send the pin automatically to the other device. I had to implement it in a broadcast receiver that is listening for pairing requests. Although I cant get rid of the dialog it just stucks there on the screen and I dont know how to close it (programatically) and continue the bonding procedure since this dialog is called from inside connect() which is a blocking method. I am not giving up on it yet though :)
With Bluetooth version 2.1 and above there is a method of pairing called the 'just works' association model. This is the lowest security method of pairing and has no protection against man-in-the-middle attacks.
However, this will provide a secure, encrypted link without the need to exchange pin numbers or verify device ID.
The API on different platforms may differ but the underlying HCI messages require that you indicate that your device (or one of the devices) has the following IO capabilities:
No Keyboard, No Display.
As you might have guessed, this is a mode for very
simple devices that use Bluetooth, such as a speaker or headphones.
If you can find the API to configure that, then the 'just works' association mode of Secure Simple Pairing will be used for pairing.
The next step is to store the link keys e.g. bonding. Many devices e.g. mobile phones, will still create a dialogue box to the user to ask if they want to 'remember this device', as user authorisation is specified by the BT specifications... but that's another problem.

Android P2P idea

I've been looking around for some way to simulate Peer 2 Peer for games on the android and the best way I've been able to come up with is connected an android to a server and then routing through that server. I'm just looking for some thoughts on my way of solving the solution so that you could literally type in someones phone number and try and connect to them.
By use of a service module to check incoming text messages, which would be properly formatted for detection, it would interpret that another phone is trying to request a connection to another one of the androids applications. If the application is found it would then prompt the user as to if they wished to connect to the other person. If yes, their phone would send back a text message to the original phones, which also has the messaging system installed on it, which states it would like to connect and that this is my current IP address. The original phone, or host phone, would then open a connection with the other users phone via the Internet at which point the newly made connection could be used to transfer information back and forth.
Basic list layout
Service module:
- Writes/Receives formatted text messages to alert/verify someone is trying to connect to an application of theirs
- Sender attempts to make a connection with the recipient phone, which takes connection and passes to desired application along with sending back a confirmation package
- On confirmation Sender phone passes connection to original desired application.
Any thoughts, ideas, constructive criticism would be helpful.
* srry for bold, but I hope you understand why.
the best way I've been able to come up with is connected an android to a server and then routing through that server
This is called TURN P2P implementation. You want to read about STUNT implementations too. You'll probably be interested in the JXTA P2P framework.

Categories

Resources