Private API to toggle wifi and 3G - iphone

I'm working on test automation for an app. I'm looking for a way to automate connectivity tests. For that I need to be able to toggle 3G and wifi. I've been going through the private api headers but I haven't found a method that would scream 'I do that!'.
Can anyone point me in the right direction, please?

I can't see this being possible. The iPhone 4 has a setting for 3g on or off in iOS 5, but the iPhone 4s doesn't. If it was possible to turn off 3g in the iPhone 4s I think Apple would have retained that ability in iOS 5.
I assume you've seen the reachability sample code

Thinking about this laterally, iOS connects to known WiFi hotspots when available - so you don't necessarily have to run this on the phone. You could just toggle your WiFi hotspot which you're connecting to on/off, and iOS should automatically switch (as long as any other known WiFi access points aren't in range) to 3G and WiFi respectively.

Related

How can I connect an iOS device to non iOS device (Arduino devices) via Bluetooth?

After searching on Google, I found that people say it's only possible to connect an iOS device with a non iOS device with the 'MFi program'. Is that true?
My project is mainly focused on sending and receiving information with the Arduino device via Bluetooth directly.
Is communication between iOS and non iOS devices without jailbreak possible? If yes, is there a reference?
(I viewed Stack Overflow question How can an iPhone access another non-iPhone device over wireless or Bluetooth?.)
As I stated in the above-linked question, general Bluetooth communication to external devices on non-jailbroken iOS devices is restricted to MFi-compliant Bluetooth hardware.
However, newer iOS devices (iPhone 4S, new iPad) are capable of Bluetooth 4.0 LE communication with external devices without the need for those devices to be MFi-compliant. This interaction is done through the new Core Bluetooth framework, which lets you send and receive arbitrary data to and from Bluetooth LE devices. This only works with those listed newer iOS devices, though.
Tim points out an interesting hack that you might be able to get away with in making your device appear like a Bluetooth HID keyboard. Devices like this barcode scanner have special modes to appear as HID devices to iOS. You might be able to pull something together based on this, but all data transfer will be one-way from your device, and it looks like this will require entering that data into text fields as if you had a keyboard connected.
Alasdair Alan's "iOS Sensor Apps with Arduino" is a good resource to look at. I've used Wifi with another microprocessor (mbed) but not sure about bluetooth. Alasdair is active on Twitter and he usually is kind enough to answer questions.

iPhone simulator - simulate 3G connection

I am testing the Reachability api, but my physical device only has WiFi access, as I don't have a phone contract. My code needs to distinguish between being connected to 3G/2G or WiFi. Is it possible to simulate a 3G connection on the iPhone simulator?
Clarifications: I am using Snow Leopard. Limiting the bandwidth is not what I need. I need for the actual interface to be identified as the 3G or 2G radio, as opposed to WiFi.
If you are using Lion try the Network Link Conditioner
Nowdays there is a part in Preferences on the device (when registered as a developer device) where a "Network Link Conditioner" is available.
You might also like Speed Limit.
Edit: I'm not sure if this will work as an identifier for 3g though. I'll update my answer after I do some tests (I'm working on exactly the same thing right now!)
I dont think that it is a build-in-functionality in iphone-simulator. But I test it sometimes on my device with wifi (and 3g) disabled.
If you dont have an iPhone but sth. similar (Android for instance) then just enable tethering on your device and use the tethered internet-connection. Then your iPhone-Simulator only gets slow speed ;)
edit: another idea is to limit the bandwidth of your mac. I found this tool online (have not tested it) which should be able to limit network-traffic (to your local router/modem)

Is iphone simulator geolocation features working with the Ethernet/Wired network connection only?

I'm trying to develop an iPhone application which uses the geolocation libraries. Is this feasible for the iphone simulator to simulate the GPS functionality without the use of my PC's Wi-Fi infrastructure? Does anyone know if the iphone simulator can spot your location using your IP-address only (so only the Ethernet cable connection is required)?
Thanks in advance.
You should test that functionality on an actual device. I believe the simulator will always show Cupertino, CA as the location.
No it won't work using ethernet. Core location appears to only work with WIFI even though at the end is the same router.
CoreLocation doesn't work in the simulator, but there are options
http://github.com/futuretap/FTLocationSimulator
Simulator doesn't have this functionality, but iSimulate has (it's not mine :-( ). It connects the device and simulator per WiFi and sends location events to the application within simulator: real GPS events and a few predefined locations around the world. Pretty cool!

How to determine if an iOS device has a cellular radio?

Is it possible, without including an exhaustive list of models in the code, to determine if an iOS device includes a cellular radio?
I am working on adding a check for host reachability to an app, and I'd like the failure message to be appropriate for the device. For example:
A network connection is not available. Please join a Wi-Fi network or move to a location with better cellular reception.
This is fine for iPhone and iPad 3G, but it's amateur for an iPod touch or iPad without 3G. For those devices, I'd like to remove mention of cellular service.
I don't want to create an array in code of every iOS device that Apple has shipped that has a cellular radio.
There doesn't seem to be a way. Erica Sadun has an interesting UIDevice-hardware extension project on github but it can't determine whether there is cellular radio either.
The best you can do is use the Apple provided sample project for Reachability.
http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html
It has three states of the network status:
typedef enum {
NotReachable = 0,
ReachableViaWiFi,
ReachableViaWWAN
} NetworkStatus;
If the ReachableViaWiFi state is returned, don't mention cellular service.
This will be an improvement because even with a cellular radio you might in a wifi only location.

Accessing Bluetooth via Bonjour/GameKit from the iPhone SDK simulator (circa 3.1.3)

I'm in the process of getting hardware for an iPhone prototype, and I'm wondering if it's possible to access bluetooth (ExternalAccessory, Bonjour or GameKit) exposed by development box (eg. a macbook) using the SDK's simulator as of the latest version (3.1.3 at the time of writing)
Before I get any answers on the subject, I accept that I will need an iPhone for the actual development - this is simply a prototype.
I'm not sure I understand your question entirely.
I can state that in iOS (as of May 2011) the only access you have to bonjour is through the Gamekit functionality. That functionality is fairly robust, but (for instance) you will not be able to create a BT based bonjour service that other non-iOS BT enabled devices can find.
On the simulator, even if the underlying device HAS bluetooth capabilities, you will NOT be able to perform "real" bluetooth operations. Instead the simulator will simulate some capabilities, and ignore others. You really do need multiple devices to load your code onto and run, in order to test out BT code.
Bluetooth connectivity is inaccessible using the Simulator. If WiFi is good enough for you, that works with Bonjour and GameKit on the Simulator as well. Otherwise, just like for the accelerometer and several other components of the device, you will need an actual device.