iPhone interaction between PC app and iPhone app using USB - iphone

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.

Related

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

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

How to create a Mac/PC server app that interacts with iPhone/iPad App?

Can someone please point me in the right direction to create a Mac/PC server app that runs in the background and connects to an iPad app over the local WiFi network?
No matter how I phrase a search on Google it just brings up various apps like Remote Mouse and whatnot and no tutorials or even a hint of where to start.
I just need to send simple commands from iPad to computer over local wifi. A point in the right direction and I can likely fill in the blanks.
Thank you.
Thomas
EDIT: I am using web languages for the iPad version that I will build as a native app using open source tools.
OK, then. It actually depends on what you really need. I made the assumption you need real-time and perhaps binary data transfer.
Your best bet is to write your server application using standard C or C++ so it compiles on both as simply as possible.
If you want to avoid all the burden of writing a protocol for service discovery or asking users to enter the ip address of your server you will use a mDNS implementation for your server and your iPhone app.
If I were you I would try bonjour: http://www.apple.com/support/bonjour/
on iPhone You could start here: http://developer.apple.com/library/mac/#documentation/Networking/Conceptual/NSNetServiceProgGuide/Articles/PublishingServices.html
Once you have your sockets you will have to implement a networking protocol between your server application and your iPhone app.
You will have to be careful about byte ordering and little subtle problems with latency, disconnections and other problems inherent to networking and WiFi.
In windows you will want to register your application as a service and in Mac OS X/UNIX you'll probably want to deamonize it.
Good luck!

iPhone - Browsing iPhone files through computer

I want to be able to send files from an iPhone app to a computer. What would be the easiest way of doing this?
I've made simple server client programs before, but in those, the client has always needed to connect to the server before being able to receive messages from it. There is an app for the iPhone called iSimulate, where you put a server on a Mac (the iPhone simulator), and then you use the iSimulate app of an iTouch or iPhone to send touch events to the server. This app does not require you to type in an ip-address. Instead it presents a list of available computers that have this server up and running.
How exactly is this being done? Can a server broadcast a message over a network, w/o anyone being connected to the server? How does that work? How does a client listen for that broadcast?
Here's a video of the app I'm talking about:
http://www.youtube.com/watch?v=N3Qpd1ycZh4
alt text http://a1.phobos.apple.com/us/r1000/051/Purple/7b/07/70/mzl.mvwjifyc.320x480-75.jpg
That app may be using Bonjour.
I've seen similar apps use a peer-to-peer Bluetooth connection to exchange files between a iPhone and a desktop.

How to Share Files Between my iPhone App and a Mac/PC

I have developed an iPhone app which stores photos in the /Documents directory of my app.
I would like to add a feature which gives to the user the opportunity to transfer those pictures to his/her PC or Mac.
I don't really know how to do that.
What is the best way, using Bonjour, bluetooth, or directly USB (if it is possible) ?
I really need some advices on that point ...
Any ideas ?
PS: Forgive my English, I am French :-)
Try NSNetService to register the service in Bonjour, and NSFileHandle to send data over a socket connection associated with the service.
If you do not want to write a Mac or PC part for your app then you can also consider to build in a little http server that people can use to access the data in your app. There are some nice open source http servers available for Cocoa which you can find with Google.
Using Bonjour you can advertise your http server so that people can easily find it with a Bonjour enabled browser like Safari. (Your iPhone app's web server will appear automatically under the dynamic bonjour bookmarks items)
You've edited the question to say that it's about transferring photos. Could you store the photos on the iPhone's photo roll with UIImageWriteToSavedPhotosAlbum(), and let Apple handle getting them onto the computer?
Bonjour!
I mean that both as a greeting and an answer. You have to setup a bonjour connection over wifi to transfer files directly to and from an app. That's actually pretty simple to do on both the iPhone and Mac side. The PC is a little tougher.
You can do bluetooth but bluetooth capability is still fairly rare on desktops.
Without knowing more about your specific application, I agree with Graham Lee--either directly saving to the Camera Roll or giving the user an option to save one or more photos to the Camera Roll is much simpler than http/bonjour.

Secure iPhone-Desktop Connection

Background
There are a lot of App Store released iPhone apps that require an IP based server on the desktop so that the iPhone can connect to the desktop as a client. For example, there are many programs that emulate a keyboard, touchpad, or Apple remote on the iPhone so that a desktop computer can be controlled over wifi. However, many of these applications get around writing their own server by requiring the user to install some VNC server variant.
Question
What is the best way to implement a secure (encrypted) IP server on a desktop (Mac and Windows platforms) that allows for simple two way message passing between itself and an iPhone client on a wifi network?
Sample Use Case
An event on the desktop causes the desktop to push a small image or text to the iPhone. An event on the iPhone causes a short text message to be pushed to the desktop. Any single event can happen at any time (doesn't appear synchronized to the user).
1st Follow-Up Question
Would this type of project be best handled using something like XML or JSON over HTTP? Or is there a better protocol, like BEEP or Bonjour(XMPP)?
What is the best way to implement a secure (encrypted) IP server on a desktop (Mac and Windows platforms) that allows for simple two way message passing between itself and an iPhone client on a wifi network?
Not sure if there is a "best" way, but much code is already available to do xyz-over-HTTPS (TLS/SSL). In that case, the "xyz" can be any web-based message exchange protocol, such as XML, JSON, etc. via REST or SOAP, etc.
If you want to be able to push events to a non-jailbroken iPhone you can't do it other than via Apple's Push Server which causes a notification to the client program if it is running or otherwise displays an alert of some kind to the user.
Typical architecture has those notifications handled by the client program as an indication it should go and get some data from the server - Apple insist we do not regard the notifications as trusted delivery.
I suggest a read of this article on using Bonjour and local networking, whilst it's iPhone to iPhone it should apply to desktop OS/X also.