Debugging battery warning - iphone

I have an app that connects to an external accessory via Bluetooth. Testers have reported that the connection gets dropped when "Low Battery" alert is displayed. This was reported on iPod touch 2nd gen., so it may be peculiar to that device.
I am wondering if there is a way to run my app in debugger (connected to my computer) without charging the device. In other words, is there a way to disable USB charging of a device whose battery is not fully charged?

I have not tried it, but it is possible / likely you can do this by cutting the power cable within the usb cable.
I would buy a cheap usb extension cable (male <-> female), and carefully cut it open (remove the outer plastic in the middle of the cable without damaging the wires inside).
If you are lucky, there'll be a red cable, and that red cable will be the +5V line - if not, you'll have to use a multimeter to test which cable is pin 1 / +5V / VCC (pinout here: http://pinouts.ws/usb-pinout.html ). Once you identify it, cut that cable (and only that cable!).
Then plug your iphone/ipod into your PC using your new cable, and the iphone will hopefully still work with the debugger but will no longer charge.
As an aside, I could imagine the possibility that bluetooth is automatically disabled (or switched to a lower power mode) when the battery gets low - in which case losing the connection may be inevitable. You could try asking apple support if they are aware of anything like that.

Nope. The debugger only works when the dock cable is connected via USB to the development system, and that automatically causes the device to charge. You will have to find another way to monitor what your app is doing.

No, but you should have your user turn on logging on their test device and then send you the logs. (Or if you are that tester, turn on logging in the Settings app, under "Developer".)
Perhaps you can log the low battery message and the Bluetooth status as well.

Related

Is it possible to create a iPhone / iPad usb video input cable

Is it feasibly (by feasible, I mean would apple allow) To create a piece of hardware that would allow the USB cable to act as a video input. I have not been able to find anything like this on the market. I know that it's possible to stream video through WIFI locally, but from what I have read it's quite laggy. I also know that in order to create hardware you need a MFi membership, but I'm note even sure if apple would allow this sort of functionality.
Technically, yes it is possible, but in this case for Apple iPhone and iPad is not. USB protocol has a master/slave architecture, for example a Windows PC is the host, while the USB device is the slave. When the USB device is plugged in, the host is informed about the capabilities of the device through the USB descriptor, later the host will request/send abstract USB packets that may be audio, video, files, whatever.
In your case, for iPhone and iPad the host feature is disabled, they may be only clients for other hosts - a PC for instance. It's a marketing decision, because people would be able to buy cheap external storage, instead of more expensive devices or cloud storage. As a consequence your video streaming device which would be a client will not work.
There are two workarounds: one would be to crack Apple iPhone, iPad software, so you cannot build a business on top of it. The second one, would be that your USB video cable to be smart enough (through an embedded controller) to act as a host with the iPhone, iPad, and would a second software on the Apple device to talk with your hardware. It's not so easy, but maybe it worth the effort, who knows...
I know it is the old thread but my answer can be usefull for someone to make further investigation...eventually to provide some schematic, etc. Definitely IT IS POSSIBLE and I have already tried it. The DJI Lightbridge device used mainly for the UAV cameras and video transmission has an USB port and their own aplication for Android/iOS (iPhone) that can transmit the video and to view/record pictures from camera on tablets or phones. The phone acts as FPV monitor in that case. I have used it with the Android tablet and also with the iPhone 5s and it works great!

how to restart iPHone/iPad Bluetooth LE after communication hangs

What is the best way to COMPLETELY restart the iOS Bluetooth BTLE central and peripheral managers, after communication stops between two iOS devices (iPad-mini)?
Sometimes after a few minutes, my BTLE communication stops (central can not get response from peripheral, though debug output of each device shows app still running and central app still is trying to scan peripheral, and peripheral is still advertising), and will not start again:
after stopping scanning and stopping advertising, comm still doesn't work;
after re-opening the app, comm still doesn't work(!);
after POWER CYCLING the iPads comm works again, but then after a few minutes dies.
Therefore, something I'm doing is clobbering maybe the iOS core Bluetooth software.
Sometimes there are error messages from the underlying BTLE layer.
BACKGROUND:
Each iPad in this system alternately works as central, to read/write data to others, and then as peripheral, to be read by others. Never at the same time, and with a 1 second delay between transistions.
The bluetooth stack is not the most robust part of iOS. This may have improved in iOS7 but issues have always existed. You most probably are stressing the system so that this hang happens more often. You should create a bug report and send it to Apple. Or create a TSI, as a developer you have two of those every year. They are the only ones who can do something about it.
To solve the issue, restarting the app usually helps but sometimes bluetooth needs to be turned on/off or worst case the device needs to be power cycled. Unfortunately, there is not programmatic way to do any of these.

Is using airplane mode an acceptable way to test a lack of connection?

We are in the process of developing an method of caching so that our app can continue to operate in an area with very little/no signal.
Obviously users will try to continue to use functions that require data and we need to handle the inevitable failure of these requests appropriately.
Essentially we are sat in the office, switching airplane mode on and off to simulate entering/exiting signal then adjusting our app to fix any issues this may arise.
What I'd like to know is, is using airplane mode going to give us a reasonable simulation of entering/exiting an area with no data or are there other implications?
I've seen questions raising the issue that the 3G/EDGE connection may not always wake up after airplane mode is switched on - while I appreciate this method is no way as good as actually being out in the field testing, if we can get a reasonable simulation and account for the majority of the problems that arise then I think this is an acceptable tradeoff.
I apologise if this has been asked before, I did do a search on here & on google but couldn't find any appropriate results.
You should try the Network Link Conditioner
There is a WWDC 2012 session called Networking Best Practices that mentions it (but he does not explain how to use it there).
To get it, you have to go to XCode/Open Developer Tool/More Developer Tools.. and download the latest Hardware IO Tools for XCode.
Once you install it from the IO Tools pkg, "Network Link Conditioner" will appear in System Preferences
You can then do something like 100% packet loss to simulate one of those routers that pretends you are connected but actually doesn't work.
On iOS, the network link conditioner is under Settings / Developer (you must have enabled Developer mode in XCode first to see it)
The main problem is that in the Airplane Mode the networking operations fail fast, while spotty mobile signal will lead to timeouts and a-few-bytes-an-hour speeds. This is usually a significant difference from the UI viewpoint. (It might be worth a try to use some bandwidth throttle to starve the testing machine and see how it behaves when the network starts to break?)
A few years back, when testing remote devices which used the cell network to communicate with the 'home base', we did things like move them into a shielded room (make shift), place large shields on three of four sides to force them to connect to a certain tower (and therefore, network), etc. Brute force physical methods. Since this actually cuts off the signal, it may be a more realistic approach.
You may also want to try this through your wlan-router. First, disable data roaming on your iPhone. Then, let the iPhone be connected to the internet through your wlan network. Then, disconnect the gateway on your wlan router while your iPhone is still connected to the wlan network.
This depends on what failure modes you are trying to test.
I use Airplane mode as a first pass check to make sure an app submission isn't quickly rejected.
Other network failure handling checks might include:
3G only (no wifi).
WIFI only (in Airplane mode).
Pulling the power cord on the WIFI access point.
Pulling the network cable from the back of the WIFI access point after connecting to it (Reachability may falsely say yes).
Walking in and out of a basement
elevator (or other Faraday cage) in the middle of a transfer.
Driving between 2 cell towers during a data transfer.
Walking between 2 enabled WIFI access points between connection and data transfer.
Starting the app after more than 30 minutes of device inactivity (radios may be idle).
Running the app while another app (Safari, Mail) is downloading in the background.
etc.

Debugging an iOS app with an external accessory connected via Dock

Am I missing something glaringly obvious or is there no way to debug an iOS app which uses an external accessory that's connected via the 30-pin dock without using a bucket load of logs etc. I want to be able to use things such as breakpoints and Instruments.
Is there a way to remote debug perhaps, over Wi-Fi, Bluetooth?
Note: Yes, I asked this very recently and I deleted it because I thought I found the answer.. but the answer was only Instruments has support over Wi-Fi.. not Xcode debugging. So the question still remains...
And so...: Given that I've had no real luck finding the answer, and no one has given me an answer as yet - I take it that it is a big fat NO. :(
Makes me wonder are we just expected to magically guess where bugs occur, or log the crap out of everything while wearing out our dock connectors by continuously moving it back and forth between the device and accessory?
Time to file a bug report I guess.
At CES today, I talked to a developer from Wahoo Fitness that makes an ANT+ accessory for iPhone. They had this same problem, but found a solution.
They found a pass-through dock extender that has a mini-USB port. They used the mini-USB port for debugging while the accessory was connected.
The product they were using is http://www.cablejive.com/products/dockStubz.html
This blog talks about remote debugging iOS with a dock accessory attached
You could connect the external accessory to another iOS device (not the one tethered to the Mac running the Xcode debugger). Then tunnel all your EA framework messages from the accessory connected device to the device running the app being debugged over a pair of wifi sockets. Look at the code for tunneling accelerometer messages from a device to the iOS Simulator (a common trick for debugging game code on the Simulator) for one example of how this could be done.
After further researching, and having seen that people had to do sending strings over Wi-Fi to get around this, I'm concluding the answer is no.
I have filed a bug request for this.
In the mean time, it seems like the Wi-Fi logging, and on-device text logging will be the way to go for now.
Here's my understanding for why just the USB protocol works for some external accessories and doesn't for other external accessories. Looks like a fundamental problem, without an arbitrator, two masters can't talk to a single slave over USB, a serial Master/Slave protocol. So XCode is one master, the iPhone is the slave device. If the external accessory is a master too, one won't be able to connect the iPhone (Xcode slave) to the second master (the external accessory).
Probably the Wahoo Key for iPhone" is a slave device and that's why the dockStubz solution works for such an external accessory.
I have tested the dockStubz. It doesn't work for my external accessory. As suspected, the USB protocol can't be used to have two Master devices controlling a single slave device. Trying to hook up a Mac (Master) (via the mini USB ) & an external accessory (Master) (via the 30 pin connector) to the iPhone 4 (Slave) causes the iPhone to go in loop of connect & re-connect.
Following looks promising too, though expensive: digi.com/support/kbase/kbaseresultdetl.jsp?id=485.
Has any one tried to use USB to Ethernet connectors and use a router to route requests from two masters (XCode & External Accessory) to the slave (iPhone)? I am off to Best Buy to purchase USB to Ethernet cables and hook all three on to my IP router. Will report if it works.
This is what will be needed :
http://www.bestbuy.com/site/IOGEAR+-+USB+Ethernet+Extender/9614781.p?id=1218131339965&skuId=9614781&st=USB%20to%20Ethernet&cp=1&lp=1
http://www.frys.com/product/6103339
So connect XCode mac using the male end into the USB slot of your computer. . Use a ethernet cable to connect this to a router.
Connect the iPhone to the female part of the IO gear connector. Connect it to the router via ethernet cable.
Connect the external accessory with the male connector (Sabrent USB to Fast Ethernet Network Adapter.) Connect it to router.
I am still researching if this will work. Just ordered the parts. Will get it by Friday & will report back then.
Update:
The IOGear male end draws too much current when connected to router. Also, the female end can't charge iPhone when connected to the router even when 5V USB current supplied.
So tried to directly connect the iPhone to the USB slot of the router (used for printers). It does charge the iPhone. Also used USB to Fast Ethernet Network Adapter (BestBuy had one to connect Wii via USB) to connect the Mac to the router. It did connect to internet but couldn't find the iPhone. In the router client list I don't see any login entires for the iPhone. So this experiment was a failure unless someone have other pointers.

IPhone Connectivity Testing: How do I force it to lose connection?

Apple wants me to give the user a friendly apology if I can't find an internet connection. Using the Reachability Demo, this was easy enough. I want to take it a step further and monitor for a connection loss. The demo has this functionality, but I can't figure out how to shut my connection off to test if it works.
How would I go about simulating a loss of (or actually losing) a connection?
If you're developing in the iPhone Simulator, simply disconnect your computer from the internet. If your computer has no network access, neither does the iPhone Simulator.
To test on the device, you can do the following:
First, setup a WiFi router that you can use for testing.
You can turn on Airplane mode on the phone, then turn WiFi back on. This will prevent the 3G connection from providing data access.
Launch your application. Now you can simply disconnect your WiFi router to simulate a loss of connectivity.
You can use the SpeedLimit preference pane to simulate network latency under the simulator. And here's a command line version built on top of the ipfw command.
The advantage over just yanking the cord or killing WiFi is that you can specify the speed when hitting specific hosts so it can be used for testing without killing your regular network services.
You could install Apple's Network Link Conditioner
On Yosemite:
Network Link Conditioner can be found in the "Hardware IO Tools for Xcode" package. This can be downloaded from the Apple Developer Downloads page. Once the download has finished, open the DMG and double-click "Network Link Condition.prefPane" to install (source).
With this preferences panel you could create a profile with 0kbps speed.
On older versions of OSX:
Mountain Lion / Mavericks: Xcode > Open Developer Tool > More Developer Tools
Lion: /Developer/Applications/Utilities/Network Link Conditioner
For testing in the simulator I make great use of Little Snitch. It's a very useful application for writing rules as to what can communicate with the outside world and for how long.
It will also notify you if an application wishes to access the internet on the fly and you can temporarily restrict access for either that time, that session or forever.
As for testing on the device, I log into my wireless router and temporarily disable either the network or turn on restriction by MAC ID for the duration of the test.
Use Charles Web Proxy
You can inspect all HTTP/S requests your app sends and responses it receives, throttle connection to simulate any network speed. Create custom throttle profile called "Disconnected" with Bandwidth = 0, to simulate network disconnections.
Perhaps this preference pane is also useful for you: SpeedLimit.prefPane it can't loose the connection, but you can slow down it based on the host and port you're trying to reach.
Searching for similar need i.e. simulating a lossy wifi network connection on real device, I figured out how to do it :)
I connected my MacBook Pro on ethernet and shared my Wifi connection to the device.
Using Apple's Network Link Conditioner Prefpane then let me played with the connection quality.
Very useful to simulate 3G, Edge and other baudrate.
Next step : find and buy a usb wifi adapter working on MAC OS X to let all of us (developpers team) to test without wiring each computer to ethernet.
Hope this will help some of you.