WiFi Direct the right choice? Trying to make chat app - Android - android

I'm trying to make a simple chat app on Android for learning purposes. I would like it to have the following features: Different "rooms" which people can create/join. Working of Bluetooth/WiFi Direct (Preferably WiFi direct). Passwords on rooms.
I'm having a number of problems however. I don't fully understand WiFi Direct. I've read and re-read the guides and references on developer.android.com and I've asked multiple times on #android-dev on freenode to no avail. Would someone be able to explain if what I outlined is even possible using WiFi direct and if not, what should I use?
TL;DR: Explain WiFi Direct's network structure and capabilities and provide resources for learning if possible.

It is possible using WiFi direct.A room can be considerd a P2P group(1 group owner+ one or more clients) .The person who starts a "room" becomes a P2P group owner and whoever wants to join a group has to undergo the authenticatio process.A client can directly communicate with owner but to communicate with other clients in the group it has to go through the owner.
For detailed understanding of wifi direct better go through the wifi p2p tecnical specification v1.2 which can be found in WiFi alliance website under published specs. Or for a overview Click [here] (http://enjambre.it.uc3m.es/~agsaaved/papers/2012_camps_wircommag.pdf).

It is possible in theory but currently the framework of wifi-direct is too unreliable..
I have tried it and the connection is very unreliable ,it breaks abruptly for no reason. Also beyond 3 devices it doesn't scale very well ,though i tested it on tablets having very less processing power (maybe on good phones it might allow one or two more connections).
So i would recommend you use wifi for communication . it would be the best suited for your needs and easier to work with as well

Related

How to make several mobile devices (both iOS and Android) communicate without using internet

I am currently trying to develop a mobile application for both iOS and Android. It basically will be a game buzzer app, determining which of the players is granted a right to answer a specific questions.
The problem is that I struggle to determine which technology / framework I should use for that. Now, some details:
In this app there will be a "base" - it is the phone that gives
"start" signal for all the other players. Each buzzer pressed before this signal corresponds to a false start. Eventually, information
about which player is granted a right to answer or is penalized due
to false start should be displayed on the base device.
App is done for people who have no access to the internet. All the
communication should exists given ONLY mobile phones with no data
plan.
Max number of communicating devices is 9 (1 base and 8 players)
I investigated a lot of resources and this is what I discovered:
Regular WLAN with TCP sockets and etc won't help, since it assumes that all devices are connected to same wireless access point - it violates my requirements.
Regular bluetooth won't help either. This would work across a specific platform, but making Android talk to iOS is impossible.
Situation with Wi-Fi direct is same as with regular bluetooth. Both platforms support this, but Apple's MultipeerConnectivity framework works only with iOS devices.
Now the last option I am left with is BLE. Both platforms support this and are able to intercommunicate (acting both as central or peripheral devices). However, due to my requirements for an app, I assume that base device should act as peripheral, and according to (sometimes conflicting) articles on Internet, one can't connect several central devices to single peripheral.
Now, my questions:
I still assume I might have done some mistakes in the bullet points above, so please, correct me if I am somewhere wrong.
Now when I am left only with BLE option, are there any possible solutions to the above issue? Maybe it is possible to use all devices as centrals (?). I recently saw this example, where everything works cool. Sorry in advance, if I said something stupid.
Of course, there is a counterexample - FireChat, which employs OpenGarden's MeshKit. But the framework is not available. I tried communicating OpenGarden people, but no response. Does anyone know if it is planned to go opensource soon, or maybe there exists any analog of this?
Try the Hype SDK by Hype Labs. It's a multi-transport, multi-hop mesh SDK. It supports interoperable Bluetooth Low Energy (and other transports as well). The SDK is currently in private beta but will be made available upon approval of the subscription.

Android Multiplayer Game with Socket Programming

I have been searching if it is possible to develop a multiplayer game with socket programming on android platform over WiFi but I couldn't come across with a certain answer.
As I found out, there are ServerSocket and Socket classes in android sdk.
Can I use those to establish communication between 2 devices, over WiFi?
Also if I can make 2 devices connected somehow, how should I combine this with my game architecture?
Any advice will greatly appreciated. This is my first try on Android and Socket Programming. I heard about Skiller, WiFi Direct and some other stuffs but It has to be done with Sockets.
I am actually from Skiller and I will try to address at least some of your points:
Why do you need sockets for your game? It will help a lot if you will explain what exactly you are trying to achieve. Maybe there are other, less complicated, ways you can achieve the same thing. And integrating the communication solution with your game logic relies directly on that.
Directly connecting two devices, whether they are connected using wifi or 3G is a very complicated task. In order to do so you need to know the IPs of the devices and it varies from difficult (wifi - depends on the wifi you are connecting to) to almost impossible (3g - you can not see the ip of the device behind operators proxy) unless you implement couple different techniques or use intermediate servers to do that job. These solutions of course will cost you because of a hardware resources and the most important time resource. From my experience in that field I strongly recommend to use existing solutions if it matches your needs (and I am really trying to be objective ;))
Hope it helps to further investigate what you need for your game. If you want to check out Skiller SDK you are more than welcome to do that in our wiki: http://wiki.skiller-games.com/ or send an email to developers#skiller-games.com
Michael

examples of implementation of NAT traversal techniques in (android ?) p2p applications

I am currently working on an Android peer-to-peer application.
Of course, we soon realized that one of the most difficult tasks is to figure out how to traverse NATs to allow 2 devices (or more) to communicate with each other over the internet, regardless of the distance between them.
I have been doing some research, read about STUN(T), ICE, TURN and found some implementations including Ice4j, JStun,IcedJava,NUTSS...
Would you know about examples of practical use of at least one of these techniques, possibly in existing (android or other) peer to peer applications ?
The most useful for us would be the ones that don't need the app to use any additional relay server.
Other suggestions are welcome as well!
Thanks a lot in advance :)
Just to know a device Ip and Port by NAT, other device connect to the one.
IcedJava implementation RFC5389, JStun implementation RFC3489.
AFAIK It is impossible to avoid a relay server of some sort with Android applications: the IPs allocated to the mobile devices by the telcos are not fixed and not publicly accessible: there is no way you can establish a direct connection to a mobile device.

Android API for inter-device communication

I was wondering if there is an API that allows for direct communication between two or more Android devices, particularly for real-time multiplayer gaming. For example, is Bluetooth communication between two devices for the purpose of gaming?
EDIT: I do not have a (reliable) server so I cannot consider it as an option. I am looking for an API that strictly uses direct device communication (so no servers).
http://androidforums.com/android-games/57-mages-multiplayer-android-game-engine-chess-game-included.html
Here is one multiplayer engine i have run across when exploring networking options. I have not used it though so I cannot give any insightful opinion about it.
Generally I tend to lean towards creating my own tcp client / server solution. Of course the best choice for you depends on what type game / application you are looking to make. Generally if you plan to have a good number of users on at a single given time (more than 3+) P2P is strayed away from. That being said i have also yet to see a well working solution for a client / server application over bluetooth, which leaves you with traditional networking strategies.
Yes there are APIs for that now.
"Nearby Connections is a peer-to-peer networking API that allows apps to easily discover, connect to, and exchange data with nearby devices in real-time, regardless of network connectivity."
https://developers.google.com/nearby/connections/overview
Also see:
Wifi P2P
https://developer.android.com/guide/topics/connectivity/wifip2p
Overview on what to select:
https://developer.android.com/training/connect-devices-wirelessly
PS I know this is an old question but it still ranks very high on search engines, therefore I add this answer.
If you're doing Peer-2-Peer, then Bluetooth and/or NFC would be your best bets. I would suggest to using the "Internet" approach through Wifi as it offers more flexibility.

Make a mobile device a remote control for a tablet?

I'm trying to make an app on an Android device that will control an application on an iPad or Android tablet. (I'm testing with an Samsung Galaxy S2 and an iPad 2).
The application is pretty simple for now. When one selects a colour on the Android mobile, that colour displays on the tablet device.
The question is, how to connect the two devices. Just now I've verified that I can pair the two devices using Bluetooth. Also, the Samsung has a "Kies" Wifi Direct feature (which I don't understand fully), that allows the iPad to connect to the Galaxy as a wifi hotspot.
The connections are there, but I don't know if either protocol can be used to actually get the apps to talk to each other to get the control I'm looking for.
Should I be using Bluetooth, Wifi, or something else?
And in whichever case, how?
My opinion is that you should not stick so much around the physical medium used for connectivity either is WiFi or Bluetooth. You should abstract this aspect, in both cases you will be using sockets (I'm speaking about Android), if it's Bluetooth you will be using Bluetooth Sockets, if it's WiFi: TCP sockets. You could have a intermediate layer that abstracts the type of connection and through a factory to use either Bluetooth or TCP.
Bluetooth - http://developer.android.com/guide/topics/wireless/bluetooth.html
For WiFi you should study if P2P would help.
You will need two applications:
- one on the tablet - the server which listens for commands from the client (change color, do this or this)
- second on the smartphone - the client which sends commands.
I've built a few apps that do exactly that between iPhone and iPad. But the principle is the same. I used Bonjour networking. It's just a fancy name for ZeroConfig networking between devices. It's written originally by Apple but it's open source so there should be Android support out there for it too. Really simple and easy to work with.
If you already have a working connection then you already have the first half of your answer, that said you should really consider implementing a solution that uses a variety of connection types, WIFI, Bluetooth, etc.. The question I think you are really asking is how to pass data and messages between the apps once you have the connection.
There are a lot of ways to accomplish this. You could implement your own lightweight message passing system. If you haven't done this before it is more complicated than it originally seems, especially as you would be required to implement the system for each OS you end up using.
Should I be using Bluetooth, Wifi, or something else?
It depends on what situations you want your program to work in.
Bluetooth can provide a direct connection between your devices. A potential issue with bluetooth is that it has a limited range. If you're devices need to be far away from each other, you may want to go with wifi. Otherwise, bluetooth could work great.
If both devices are connected to the internet, you can make them talk to each other through there. The advantage of this approach is that it doesn't matter how far apart your devices are as long as they're both online. A disadvantage is that you'll have to figure out how to find the tablet's ip address before you can talk to it. This is actually a HUGE disadvantage because it can be quite problematic if both of your devices are not on the same wifi. You could have the user type in the destination ip address, but you'll have problems getting it to work if the user is behind a router (which will almost always be the case). The point is, it gets hairy.
If both of your devices are on the same wifi, you can use ZeroConf AKA bonjour (like Dancreek said) to figure out what ip address you need to send info to. I've previously used a library called jmdns (easy to find with google) to implement zero configuration networking. It's good because the user doesn't have to worry about ip addresses... it's intuitive for the user.
And in whichever case, how?
Networking is a pretty big topic, so I can't expand on this question to much. Short answer is, it depends on what method you choose. Search for some tutorials and start by getting one of your devices to send something as simple as an int to the other.

Categories

Resources