Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone 3G / WiFi Connection

I like to make an application for iPhone where it uses a Wifi to collect some data and use 3G to send this data to internet. The Wifi connection would be adhoc and wouldn't offer any internet connectivity. So, in this case, wifi would be just a data collection interface.

Is this possible?

More technically: - iPhone connects to an adhoc network and picks an auto IP such as 169.254.x.x - Fetches the data from 169.254.1.1 (known ip of the sensor) - sends the data using web services to www.xyz.com/dataEntry

Also, I make this small test: - Make a P2P Access point on my Win7 - attach my iPhone to the P2P access point - try to browse a web site on the internet and this fails. I cannot open google.com for eg.

How about Android, albeit less important I would like to offer this app on Android too..

Thx, F.

like image 286
Frank Avatar asked Jun 30 '11 01:06

Frank


2 Answers

For the iphone, most people start with/use the Apple Reachability sample code. Using that code, it's pretty easy to tell if the current internet connection is a wifi connection. If it's not a wifi you can assume it's a 3g connection.

For Android, you use the ConnectivityManager getActiveNetworkInfo() API to get current Network Information.

like image 110
Shane Powell Avatar answered Sep 27 '22 23:09

Shane Powell


The iPhone will maintain its 3G link whenever connect to an ad-hoc WiFi network. This is how tether.com works. It would even some times keep the 3G network alive when there is an open TCP/IP connection even if WiFi is turned on and connected to the Internet.

Android phones would not connect to ad-hoc networks at all. API 14 (ICS) offers phone-to-phone connectivity with WiFiDirect but only between Android phones. You can, of course, root the phone and allow ad-hoc connections.

like image 38
Avner Avatar answered Sep 28 '22 01:09

Avner