简体   繁体   中英

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.xx - 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.

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM