iPhone 3G / WiFi Connection
Asked Answered
C

3

6

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.

Clamor answered 30/6, 2011 at 1:52 Comment(1)
it sounds like we are both in similar situations. Can you provide a sample of how you got something working? I have an open question #8016053Ranit
E
3

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.

Emmerie answered 30/6, 2011 at 1:58 Comment(5)
Don't assume 3G if it's not wifi. There's specific enum values ReachableViaWWAN and ReachableViaWifi, check for those. If it's NotReachable then you need to inform the user 3G connectivity is not available and let them retry the connection at will, or automatically once 3G is back up (all this is shown in the Reachability sample). Also, this is a better version of Reachability than Apple's sample code: blog.ddg.com/?p=24Pituri
Thanks for the response guys.. Doesn't really answer my question though.. We are talking about two distinct network domains working simultaneously.. WiFi for a local subnet with NO internet connection and 3G for a server on the internet...Clamor
as far as I know, you can't have two connections on an iphone at the same time...Emmerie
@darvids0n is correct. I haven't seen that version of the Reachability code before, thanks!Emmerie
ok.. I have proved that this works.. I have successfully send and receive packets on WiFi (to IP 169.254.1.1, which is the sensor) and get the network reach ability to www.apple.com via Cellular.. So, yes.. However there is a nasty bug somewhere as my phone stopped working via 3G after several tests and a reboot required to restore. I will trace that as well.Clamor
C
1

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.

Chronic answered 13/5, 2012 at 13:49 Comment(0)
F
0

Short answer: yes, it works! Basically your Main iPhone will have an SSID that will give the possibility to other devices to connect with it. Those devices would self assign an ip address in the same subnet as the main one. Once they have no Default Gateway assigned, they wont be connected to the Internet.

Fulgurating answered 24/2, 2015 at 19:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.