I made a google glass app which receives some data (wireless) from a laptop
and use the data to visualize something. The network connection is simple
UDP or TCP, but I noticed that google glass often miss some data and stop
visualization for a few or several second and continue.
So I'm wondering if Google Glass's wireless network connection is stable
and reliable. Did anyone experience similar or other network problem
with own apps (glassware)?
Thanks!
Not really. You cannot expect it to perform as your laptop or phone because instead of full-circuit card that supports 802.11 b/g/n with several antennas, Glass has only one wireless module on its board. That is from a Taiwanese company with module number WM-BN-BM-04 .
You can see the details about that module here or you can even buy it from Alibaba for $10 ;) . Thus in your case, you should minimize your data or use/implement an ACKing protocol. But a bigger problem about Glass Wifi is that it only supports WEP -hackable by high school students- and WPA/WPA2. No enterprise. You can have a WIFI connection at home but unfortunately not at university, work etc. So with this in mind, you should probably design only at-home applications with WIFI.
Related
There's a game called Pocket Tanks. What it offers is that 2 players can connect to same WiFi Network (like in home) and play the game together. Its different from internet multiplayer. It just needs common WiFi. I want to know how to implement such a system in my android game. I've tried to search it on Google but no helpful results. Any idea where do I even begin?
Thanks.
The app probably has a socket open listening on a certain port.
Then when it searches for other phones, it just tries to connect to other IP addresses on that port.
I am developing an p2p application in android for an educational project in which I want to form groups android phones of students nearby and exchange sensor data in a university campus.
Now there are some considerations :
Devices will automatically discover each other and upon discovering connect and exchange data.
The process runs for a long time maybe 4-8 hours per day. (process of periodically sensing data and exchanging )
Now the p2p groups can be formed using either Bluetooth or WiFi (Not WiFi Direct, simple UDP packets over WiFi considering phones are connected on campus WiFi).
What are pros and cons of using Bluetooth and WiFi in this scenario in terms of reliability, power usage of phones, scalability and any other you can suggest.
Among other answers and input, I would added this answer.
First of all, before we chose WiFi or Bluetooth we need to find out the difference between those two technologies.
I have made comparison chart that covers some of the important information you might need regarding your project.
Note: There are different versions of Bluetooth's and WiFi, this chart is to represent the the general picture of Standard Bluetooth,
Bluetooth v4 and WiFi. It is always suggested to refer to manufacture
specification of each technology.
From the chart we can conclude that Bluetooth has lower power consumption vs WiFi, but at the other hand WiFi has more bandwidth than Bluetooth.
Range in general is just approximation, a lot of things affecting range like human body, obstacles, location (inside or outside), if inside; structure type and materials used inside the building, noise from other sources and devices etc.
(*) Regarding scalability, I have tested WiFi and Bluetooth v4, both system with up to 8 devices, where one of those is host (group owner, server) device and 7 others are guest (clients). see the figure below.
What regards reliability, with Bluetooth v4 I have had some time connectivity problems, but when it works than every-thing is fine.
Note: Bluetooth v4 is not back compatible with older versions of Bluetooth, so if your host is Bluetooth v4 than all other clients
should have Bluetooth v4 or vice versa.
So I will not say which one is best, but if you need longer battery life and light data communication than Bluetooth is the way. Regardless if it is Bluetooth OR WiFi you might need to start with Bluetooth to and test it, if you are happy with it than keep it, otherwise switch to WiFi.
In case you want to build your own code, the code example I followed and used previously for another university research project. It is based on 8 phones (host and client) as seen in the figure above, we collected sensor information and send it to host phone using Bluetooth 4 connection. The source code we used for that can be found here. The same project has WiFi and other type of connections.
Android official google documentation has some information and code example regarding WiFi peer to peer connection, you can follow with example of the code as well.
Regarding collecting your sensor data and sending those to one device. You could added a method that starts collecting sensor or what ever data, and after connection is established successfully than start sending it over to the other device.
As others suggest https://developers.google.com/nearby is also a way to go.
As you can rely on campus Wifi, I would definitely go with the implementation of Google Nearby APIs in my App as it was designed for such use cases...
The way it works answers your question : it makes all the heavy stuff for you, including choice between wifi or Bluetooth for better performance...
Google Nearby is definitely a good choice. You don't have to tackle all the problems when working with WiFi or Bluetooth directly. But Google Nearby only works when both devices are online and have their screens on. For a more critical review of Nearby have a look at http://blog.p2pkit.io/how-google-nearby-really-works-and-what-else-it-does
If you can not accept these limitations, you should look into other frameworks like http://www.p2pkit.io.
Disclaimer: I work for Uepaa, developing p2pkit for Android and iOS.
Background
I have an idea for an app on vacation that needs to communicate to other phones with the same app. While on vacation those phones might not all have internet as roaming can be very expensive. The data is not a lot: like 500 kB max would suffice (in json).
Every phone has a bit of info that all the other phones would like to know, but if it helps the info can be stored on 1 phone (master phone from now on) and shared later to the other phones when back home over internet.
Phones
Android, iPhone and Windows Phone
We can't assume they have NFC, IR or zigbee. Just the hardware almost every phone has like bluetooth, camera, microphone etc.
My ideas
QR codes that changes, based on new info: If the first phone is scanned the second phones QR code has data from the 1st phone and itself and the 3rd phone has data from the 1st, 2nd and 3rd (itself) until it reaches that master phone that holds all data.
Data transmission trough sound that we can't hear (or we can). Con is that I don't know if something like this exists for mobile platforms and writing it is like a 3 year master thesis project.
http://nearbytes.com
https://applidium.com
https://developer.chirp.io/
Bluetooth. Can we connect like 8 devices? Would it work consistent (connecting even my headphones can be a hassle, what about 8 phones who try to connect simultaneously)
All of these ideas have big cons. Maybe I'm overlooking a better way.
I will add a bounty to the question for the best solution
An answer that explains it with a little bit of code reference (link is ok) is always better than just: "use bluetooth man"
TL;DR
The easiest (and most supported) way of getting multiple devices to connect to each other is using WiFi. Since your goal is to achieve data transfer with no internet, the most appealing solution would be to use a Peer-to-Peer network structure.
The two major smartphone OS's (Android and iOS) have API's and documentation on creating and transferring data over a Peer-to-Peer network.
Android WiFi P2P
Apple Multipeer Connectivity
These two also have a means to encrypt the data being transferred.
Windows doesn't seem to have an API to allow multiple peers connected, but their Proximity Class will work for one device at a time.
I can give a few outlines over the different options in each major OS:
Android
Android's WiFi P2P (peer-to-peer) API was created for transferring data without internet or another network.
From their documentation:
The Wi-Fi peer-to-peer (P2P) APIs allow applications to connect to nearby devices without needing to connect to a network or hotspot (Android's Wi-Fi P2P framework complies with the Wi-Fi Directâ„¢ certification program). Wi-Fi P2P allows your application to quickly find and interact with nearby devices, at a range beyond the capabilities of Bluetooth.
Google even has Documentation and training on this API.
iOS
Apple's Multipeer Connectivity.
Very similar to Android's P2P API, they claim:
The Multipeer Connectivity framework provides support for discovering services provided by nearby iOS devices using infrastructure Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks and subsequently communicating with those services by sending message-based data, streaming data, and resources (such as files).
Here is a decent looking tutorial on using Multipeer Connectivity.
--EDIT--
Another iOS way of doing this, which is a bit of a mis-utilization(?) of the tool, is by using GameKit.
However, I think that to get it to work for your purposes might result in a bit of a hack, since the "players" have to be using Game Center.
Windows
The only way (apparently) to connect phones in Windows Phone, is by using Proximity, however, that only gives you the option of connecting no more than two phones together.
They state:
Proximity is a great way to create a shared app experience between two instances of your app running on two different devices.
Those are options in each of the major mobile device OS's.
App usage could be something like:
Decide which device was going to be the "master", so that other devices can connect to it. It isn't required to know this before deploying the app, but there should be a way for the user to decide whether he is going to be a client (receiving data) or the server (pushing data).
Once it was decided between the group of devices which was going to be pushing data, that device would have to be registered as the server (in the Android P2P API, you can establish a "group owner"), and then start looking for peers by initializing the service.
Then, once the devices are connected to the master device, you can start pushing data. An additional bonus is that when using Android WiFi P2P, all communication is encrypted with WPA2, and with iOS, you can enable encryption using MCEnableEncryption (however they state that is slows down data transfer rate).
Now you would just have to pick one method to go with, and make sure that all the phones ran that OS. Because these three methods of connectivity won't work together.
All of the three methods listed are done programmatically, so there should be no strange or odd things that your user will have to do. Searching for other devices, connecting, and transferring data can all be done within your app.
More help can be provided if the question is narrowed down to specific problems, but this should be enough data to get you started.
Don't try QR or sound. I think it would be very painful to transmit 500kb of data.
Bluetooth seems like a good solution but maybe, as you already said, hard to configure.
What do you think about wifi?
At least every Android and iPhone device can create a mobile wifi hotspot. By using this, you can easily setup a environment where 8 devices are in the same LAN (without using the internet by any of your devices).
Now your "master phone" runs a simple server to synchronize data (just like an internet server would do). Every of the seven clients could receive the ip adress of you master by scanning a simple QR code or sending a short message and afterwards configure itself accordingly.
Have you checked Alljoyn?
As quoted:
"Developers can write applications for interoperability regardless of transport layer, manufacturer, and without the need for Internet access"
You can create a Wifi connection between your devices. Than after connection it creates local network between your devices. Inside this network you, of course, can interact between your devices using TCP/IP connection. It works both on Android and iOS. Simply lauch your app as server on the one device
EDIT
Note, you have to connect your devices using any network. It is possible to connect the devices by initializing your device as WiFi-router. It can be both Android and iOS. If it is possible, you can connect your devices to any wifi connection.
Than, launch your app as Server-socket, the others as clients.
for Android (java) server use this link:
https://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html
try (
ServerSocket serverSocket = new ServerSocket(portNumber);
Socket clientSocket = serverSocket.accept();
PrintWriter out =
new PrintWriter(clientSocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(
new InputStreamReader(clientSocket.getInputStream()));
) {
for android device client:
try (
Socket kkSocket = new Socket(hostName, portNumber);
PrintWriter out = new PrintWriter(kkSocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(
new InputStreamReader(kkSocket.getInputStream()));
)
The same idea is for iOS (Objective-C):
server
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/UsingSocketsandSocketStreams.html#//apple_ref/doc/uid/CH73-SW8
and client:
https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/UsingSocketsandSocketStreams.html#//apple_ref/doc/uid/CH73-SW4
A better way could be use Ble.
It's easiers to connect the phones because you don't need user confirmation.
Seems like you can connect up to 20 devices Maximum number of peripherals on CoreBluetooth?.
To transfer 500KB should require few minutes (may be between 2 and 5).
You can track an Android device without Internet via GPS.
Connection without The Internet:
SMS
USSD
DTMF (very slow)
How to design a tracking device on USSD is mentioned at
M2M IoT Cookbook
How to develop a device based on Wireless Wide Area Network modules
You also can use the Android phone as a data logger and store under the Micro SD Card and read the card by:
Replacing the SD card to your PC
Streaming the data local by Bluetooth
Forwarding the data at home by Wi-Fi
Or Possibly:
Your app can use SMS API to transmit the DATA or other SOURCES.
I am looking to implement a cloud application that allows one to save contacts and if the contact also has the app on, see on a map where the contact is (if in close proximity to you).
I've been looking around towards how to do so and the first step is to establish a connection.
For my purposes, a centralized server to which apps connect and fetch repeatedly updated database information about other users is unsatisfactory as this is too "centralized" for a cloud app.
I've some experience with Bluetooth but in my opinion and experience, bluetooth is not practical as the two devices must then be in very very close proximity with each other.
Thus my question is this, how do android phones connect p2p without the use of local wifi? If that is even possible?
Thank you for your time
Thus my question is this, how do android phones connect p2p without the use of local wifi? If that is even possible?
Yes, via Bluetooth where available, but it will probably not meet your needs. So, in practice, the answer to your question is no. You will need the local wifi.
That being said, you could attempt multicast on the LAN to detect other connected devices enabled with your application. If you want more than LAN, you will need a fully fledge solution including super peers and a P2P framework, like JXTA
I try to create an ad-hoc network between many Android devices, but I can't find documentation to do that.
I thought Wifi direct could work for what I want, but is it possible to have multiple connection on one device ? I saw that we could do a device acting like an access point and communicate with many devices, but can we communicate from one client device to two access point devices ?
I have for example 3 devices: A -> B -> C
The "A" device need to communicate with "C" device but he's too far away, so I want to have ad-hoc wifi direct connection between A&B and ad-hoc wifi direct connection between B&C, so A can communicate with C. It should also work with more than 3 devices.
Thanks !
Here is the link to the Wifi Direct Demo http://developer.android.com/resources/samples/WiFiDirectDemo/index.html
I have been working on establishing ad hoc communication over Android phones for a month. I am trying to create an app that could work without having 3G or access point. Main idea is to let the clients to be able transfer voice or data in a close range.
There are some guys implemented a basic system regarding almost the same topic. It basically works with Wi-Fi access point. So you need an access point in order to establish the connection. Although this is not what I am looking for, it might be helpful for others. You might need to contact them for more details.
https://sites.google.com/site/androidwalkietalkie/home
Android does not have support for ad-hoc WiFi at this time -- sorry!
Update (2019): Android has supported WiFi Direct for a while, and this answer has not been updated.
Your scenario would work. A would be able to connect with C as long as B (the group owner) is within range of both A and C.
See Android's developer documentation for more info:
https://developer.android.com/guide/topics/connectivity/wifip2p
At this time only Galaxy S 2 support Wi-Fi Direct
The wifi direct supports concurrent hosting and client capabilities on single interface. Which means, the device will act as an AP, allowing other devices to connect to it as clients, And also connect to another AP as a client. And can share internet connection by driving the internet traffic between the interfaces.
However, current implementations of wifi direct on android are specific to the phone and not part of andorid sdk. So there is not much clarity if they support concurrency. This capability is not limited by hardware.
Ad hoc wifi is disabled in Android. You need to ask Google why they have chosen to do so. If you have access to a device that allow you to install custom Android images, you will be able to patch Android to support it. Or you can root your device and reenable ad hoc Wifi, there are plenty of solutions on the web on how to enable ad hoc on rooted Android devices. This is a software issue, the hardware on every Android device that I know of has support for ad hoc Wifi.
The Serval Project, based in part on WiFi Tether, is the only place I've found this functionality. It's still alpha phase, but seems to be the forerunner in the field. The wiki is much more useful than the main project page linked above, with installation instructions and a bit of documentation.
Serval may or may not be right for your needs, but I felt it should be pointed out that ad-hoc networking is not impossible on Android. It might be better to wait until Google gets around to implementing it as standard API, though (if you believe they ever will :) ).
Well You might be interested in looking at AllJoyn. It is qualcoms SDK for android OS which includes wi-fi peer-to-peer implementations by creating adhoc connections. This is same as Wi-Fi Direct.