Create an iPad app that can send/receive data via the USB cable? - iphone

I want to create an iPad app that connects to another machine, laptop or otherwise, via USB and communicates to some other application I develop running there.
I know that this is easy to achieve via Bluetooth or WiFi but this particular set of solutions must be done via a USB cable.
Is it possible to do so without access to the Apple MFi program? (I am about 5 weeks in and the response is not looking good).
iOS App --> USB Cable --> Mac OSX --> Desktop App (without MFi access)
Thanks

To use USB communication Apple does not provide any API within IOS SDK. The only option right now is MFI. I don't think Apple will allow this in near future.

To use serial communication, you need MFI as you may have discovered. However, there is a poor man's way of achieving this. I have done so during development.
Enable "Internet sharing" on your device and connect to it. Use "ifconfig" on your Mac to find out the interface to use. You do not need to use this as the default connection, but it needs to be active. If I remember correctly, only one end can initiate connections (it was a while so I am sorry that I don't remember the details).
EDIT: I would also like to point out that I did this on an iPhone, not an iPad.

Not over USB but over RS232 (serial port)
Look here: http://www.redpark.com/c2db9.html
But:
The cable uses the old 30 pin connector, but according to them it's compatible with the Lightning adapter
The application won't be accepted on the AppStore, it's for internal use only.
There is a (small) book that explains how to use this cable to connect an iPhone directly to an Arduino, it's been published in late 2011. "iOS Sensor Apps with Arduino Wiring the iPhone and iPad into the Internet of Things" http://shop.oreilly.com/product/0636920021179.do

Related

Establish communication link between a device and iOS

I'm developing an iPhone/iPad app that requires it communicate with another device. I'm actually more interested in receiving input from another device that the iPhone is connected to through USB. The solution needs to work with any iOS device and cannot require it to be jailbroken.
I've heard of apps that communicate with a piece of hardware that can be plugged to the iOS' serial connection, which is similar to what I'm going to develop except that the other device I'll be connecting to is a standalone music keyboard.
best regards,
fbr
If you are developing accessories that need to connect to iOS devices and want to use your own communication mechanism then you need to join the Apple MFi program.
Several options:
Forget MFi unless you have 1000s of $ backing up your product development. Apple won't even talk to you. I've tried.
Take a look at the Serial Cable from Redpark (http://redpark.com/c2db9.html)
I've got one of those and it's ideal for apps that you can deliver on your own, but you might also be able to get them into the App Store.
Another option is to use Wifi with a Wifi-to-Serial adapter on the other end. I've used the RN-174 and RN-134 from Roving Networks successfully.
However, these solutions only get you Serial connections, but can be quite fast, especially with the RN modules. There are also Serial-to-USB converters you can use on the device's end, but that would require the device to work as a USB host, usually. If you have a USB device that wants to act as a client, these common adapters won't do the trick.
So, unless you can actually afford the MFi program, and if you really need USB connectivity, you'll have to let someone create a small box containing a USB host adapter with a Wifi chip. I don't know of a ready-made solution for this yet, although I've seen quite a few area where people would like to have such a unit.

Listening on USB port for data in iPhone App

I am wanting to send data over the usb on the iphone and have it captured by my application. This application will be private and not sold. I would also like to just use the standard usb cable that is standard. Is this possible?
This is possible with Apple's MFI Program. The downside is this will probably be quite expensive and you will of course have to develop a piece of hardware that can be sold as a product for your application.
EDIT: If you look at the 'iOS Accessories' section on the MFI Program link above, it suggests that you can communicate over the 30-pin usb dock connector.

iPhone interaction between PC app and iPhone app using USB

I know since the 3.0 SDK we can use accessories, so my question is simple, what is the process to make an iPhone app and PC (or Mac) app interact, using the USB ?
I don't ask you any code, but just the paths and the keys for making that work.
Have I to access the iPhone disk through SSH and work with files ?
Or can I send data from the iPhone app and intercept (get) it on the PC app (and send data from PC to iPhone) ?
Thanks, and if this question is stupid, just tell me, I didn't find on Dev Center (I don't really know what I have to looking for...) !
Edit : I read some news from Microids, they will synchronize PC and iPhone games (i.g here), and somewhere (I can't find it again) they say connecting the iPhone on the USB, so I think this is possible
USB access on the phone is only supported via the External Accessory Framework. You cannot hook the iPhone up to arbitrary USB devices, the devices actually have to support the EA protocol. You can get more details about it via the Made for iPhone program.
Other than that there is no USB access available on to applications.
You want the External Accessory Framework. Having said that, I'm not sure that Apple's intention was for you to communicate with an application on a PC/Mac. It's really for talking to accessories such as iPod docks, remote controls, etc. Apple may not allow an application that talks to a PC in this manner in the App Store.
You might be interested in ssh_relay (earlier called iphone_tunnel).
There is a /System/Library/Lockdown/Services.plist on your iPhone and you can start any such services via AMDeviceStartService and then communicate with it.
The ssh_relay demonstrates how to do that by having a simple port forwarder as a service on the iPhone site and the client application on your PC, so you can forward any local iPhone port to your PC. This is not exactly what you wants here (it is handy in the case you have already another service running on the iPhone which communicates via simple TCP and you want to access that; for example SSH) but based on this example, it should be straight-forward to have any communication between the service (in Services.plist) and your PC.

How can an iPhone access another non-iPhone device over wireless or Bluetooth?

I'm trying to figure out if an iPhone can connect to another non-iPhone device over wireless or Bluetooth and have seen conflicting information. Much of what I've found was before version 3.0 of the SDK came out, when it certainly wasn't possible. Looking at Stack Overflow questions, like Can the iPhone 3.0 SDK provide full access to Bluetooth devices (headsets)? mention you can't connect to an arbitrary device unless if it's part of the "Works for iPhone" device. Do I need hardware that is part of this program?
Looking through the Apple documentation, Peer-to-Peer Connectivity, it mentions connecting two iPhones, not an iPhone to another Bluetooth device. Then there are articles like iPhone SDK focus: Bluetooth enhancements that includes this quote
...and with the newly-announced "standard support" should allow file transfer between the iPhone and a computer, as well as between nearby iPhones
Another Stack Overflow question, GameKit in iPhone SDK 3.0, mentions Bonjour, and the Apple documentation for Bonjour talks about connecting to Bonjour devices, but can an iPhone connect to any Bonjour device? Does it have to have a Wi-Fi connection, or can it use Bluetooth?
Even if I could use Bluetooth to connect to another device, it won't be available on first generation iPhones and iTouches, I believe. Is that correct? I'm thinking of an iPhone application that would need to communicate with other non-iPhone devices in the area, probably using Bluetooth, but possibly a direct wireless connection. What are the possibilities and limitations of this approach? Is it not possible to have an iPhone connect to an arbitrary Bluetooth device? Does the other device have to be on a wireless Bonjour network that? I'm trying to figure out if it's even possible for this to work or if it's not worth the effort.
The only way to communicate with other Bluetooth devices via the External Accessory framework in iPhone OS 3.0 is if they are in the Made for iPod accessory program. Even though they communicate through standard Bluetooth connections, accessories need special hardware in order to process the data stream coming from the iPhone / iPod touch. Unfortunately, this means that your idea of communicating with generic Bluetooth devices won't work on iPhone OS 3.0.
If the devices you want to talk to are Bonjour-discoverable via Wi-Fi, they don't need to be part of the Made for iPod program. However, that doesn't sound like your case.
Third-party developers in the near future may produce dongles that connect through the 30-pin dock port and give access to existing Bluetooth devices. If these developers opened up their communication protocol, that might enable your goal of communicating with these devices.
You can use NSStream for opening IPv4/IPv6 sockets on the iPhone. The devices to which you're connecting do not have to be iPhones or use Wi-Fi necessarily. Because of how network communication protocols are laid out, you simply don't have to care what kind of device your iPhone is communicating with.
Bonjour, on the other hand, uses NSStream internally. It's basically a nifty little wrapper which allows for auto-discovery. You need the Bonjour protocol installed on all devices which you want to participate in the auto-discovery process. There is even an implementation for Windows.
As part of the iPhone OS 3.0 SDK, Apple announced the ability to control hardware accessories through either Bluetooth or the dock connector. The dock connector supports standard protocols (that is, play, pause, etc.) as well as any custom protocols the developer wants to implement.
As far as connecting via Bluetooth, you can talk to other iPhones or other devices. For example, you can use stereo Bluetooth to connect compatible Bluetooth stereo headphones, car kits, or other accessories.
As far as what devices support Bluetooth communication, everything except the first generation iPod Touch should be okay.
See also Apple's page on iPhone OS accessories.

How to integrate iPhone with other non iPhone devices using serial port?

Anybody knows how to integrate iPhone with other non-iPhone devices using serial port?
You can't directly. There may be some sort of serial line (i2c) on the dock connecter, but it is not exposed through the SDK, the Made for iPhone/ExternalAccessory.framework stuff is only for USB and BT.
You could conceivably use a WiFi/serial bridge (such things do exist) since you can send whatever you want over a TCP tunnel, but I doubt that is what you want.
Underlying ExternalAccessoryFramework for 30-pin connector it's the real UART handshaking (using Tx, Rx, Gnd, Vcc and some detect pins and no flow control) but not USB. Those pins of USB are only used for iTunes, Xcode and powering. The iOS app does not need to understand UART and only needs to send/receive bytes through NSOutputStream and NSInputStream.
But you need to pay Apple for MFi(Made For iPhone) Program first and buy some confidential IC to enable your accessory to communicate with iOS. They will require you to propose a product plan and expected sales and consider whether they would accept you as a MFi manufacturer.
You can get the info on using the ExternalAccessory framework from apple's developer portal.
You can't get the required serial handshake(?) info without joining the Made for iPhone program. This requires that you are developing a commercial device.
I have tried to get information on this protocol from apple through my university and have thus far failed.
I successfully received serial communication from the Arduino on the iPhone. I made a google doc explaining my process.
https://docs.google.com/document/d/1Yi9_hcw8XSyYNCG2OJT9oHlTG-dC-Dnuc58VIULa81Q/edit