Communicate between iPhone and macbook laptop - ios

In an effort to learn more about networking I'd like to do an exercise: write some code on an iPhone and macbook laptop that allows the devices to communicate over HTTP.
How would I set this up in general? I could write a very simple web server as illustrated in Beej's Guide. Then run this and make requests from the phone. Assume the two devices will be on the same wifi network.

In this book you can find an example of how to make a network to connect a Mac OS X app with an iOS app using Bonjour.
http://my.safaribooksonline.com/book/programming/mobile/9780132757058/bonjour-and-web-servers/ch28
Hope this helps you.

Using HTTP between two apps is very inefficient. Use NSNetService and raw sockets.
NSNetService Docs
There is an example project that shows how to setup the service for publishing, connect 2 services, and consume data from a socket connection.

Related

ASCII code on an external device through USB port

Is it possible to send an ASCII code on an external device through USB port using IOS API? I assume that it is possible through bluetooth connection, but I'm not sure through USB connector. Any thoughts?
I would appreciate if someone could put me in the right direction.
Thanking you in advance
That largely depends on the level of sophistication of this "external device". If this external device is just a bare metal embedded device without some sort of operating system you definitely need MFI.
Otherwise, you can run a usbmuxd server (e.g. on Raspberry PI with Linux) to establish a connection via USB. Usbmuxd is basically the technology that Apple uses to communicate between iOS devices and Desktop apps such as iTunes or Xcode. And yes, it is App Store compliant, e.g., Duet Display uses this approach to make an iPad a secondary display for your Desktop via USB.
There are several open source libraries that provide a high level API, e.g., PeerTalk or DarkLightning.

How does this iOS app communicate over the USB port?

This app promises to turn your iOS device into a second monitor and uses the standard USB cable to connect to the computer, as opposed to the network which all other similar apps use.
Back when I heard about it, it wasn't yet available so I thought it was a scam. To my surprise, they released the app and it actually works as described.
How does it work ? As far as I know there are no APIs to drive the USB port in iOS, and the computer connected via USB through the standard charging/syncing cable doesn't count as an MFI accessory.
Note that they provide the server software (the one that installs on the Mac and streams the desktop to the device) on their download page for free, reverse-engineering it could shed some light on this but I unfortunately don't have the skills for that.
Dean told about it on his blog.
Duet uses Peertalk, an open source library allowing to pass TCP connections through the USB connection without being part of the MFI program.
The information, code and tools to accomplish generic USB port communication is available to those who join the Apple MFi program. You have to do the paperwork and get licensed by Apple.
http://developer.apple.com/programs/mfi/
The libraries necessary are included in the app and then the usual streaming libraries and code do the rest.

Telnet iPhone Application that connect through iPhone USB port

I am looking for a weekend project to do and I was wondering if this was possible. I have these radios that are programmed using Telnet (to set the frequencies, output power, etc.) and I normally do this with my computer in the terminal. The radios have an RS-232 connector on them and I use a USB converter to connect to my computer. Having a small, portable device to program them with instead of a big, clunky laptop would be great, so what I am hoping is possible is to be able to create a telnet connection with my iPhone. Is it possible to create a Telnet application for my iPhones that can connect to these radios through the USB/lightning port on the iPhone? I know normally when people write Telnet applications for the iPhone, they are using over the air connections like WiFi/3G/4G to connect to the internet, but this radio is not connected to the internet but its own private network of other radios. If it is possible to connect the iPhone to the RS-232 port and accomplish the Telnet connection (also without frying my iPhone with too much current) that would be fantastic. Also, if it is possible, how would I access the lightning port? Thanks!
EDIT: Another possible connection is the iPhones lightning port to an RJ-45 connection. That would work as well. Is this possible? Thanks!
As far as I know, you can always study the specification of the lightning connector, you can find it here : http://en.wikipedia.org/wiki/Lightning_(connector). You can try to play with the SDK, trying to send commands from the iPhone and receiving information through the cable. The problem of that, and I was working in several medical applications with the 30 pin connector and the lightning as well, is you have to spend a lot of time to deal with the specification. The most important part is to understand how the connector works and what can you send and receive through the cable. If not, you would have to build your own connector, which is interesting and can help to learn a lot, but it´s not an easy thing. In a project I was working, we had to build several cables to adapt the signals to connect with the device, in my case an iPad1 and recently an iPad 4 although it works with the iPhone as well. As you know, or you should, you will have to learn about MFI.
You can find some information regarding that point here : Create an iPad app that can send/receive data via the USB cable?, but bear in mind everything goes through MFI, so it has its pros and cons....most of them cons. You can find several information here : https://developer.apple.com/programs/mfi/
good luck :)

iOS app communicate with an app running in OSX via usb cable connection

Does iOS SDK provide a way to let iOS app talk to app running in OSX/Windows via usb cable connection?
Or, socket is the only option?
If you want to interact with an OS X program from iOS via USB, the PeerTalk lib seems to provide a convenient way to do so (without having to join the MFi program).
According to the github page, PeerTalk
Provides you with USB device attach/detach events and attached device's info
Can connect to TCP services on supported attached devices (e.g. an iPhone), bridging the communication over USB transport
Offers a higher-level API (PTChannel and PTProtocol) for convenient implementations.
[is] Tested and designed for libdispatch (aka Grand Central Dispatch).
It also
has successfully been released on both the iOS and OS X app store.
A great example is Duet Display which is a fantastic piece of software allowing you to use your iDevice as an extra display for your Mac using the Lightning or 30-pin cable. [...]
Communication via USB cable is possible but everything is under strict MFi NDA.
One link that might interest you:
Microchip: 3-step Approach to Develop iPod®, iPhone® and iPad® Accessories
Some more information on Apple MFi program
There are no fees to enter the program but you will have to fill out some 'paperwork'.

iOS app talking to a Mac

I need to build a networking application for talking to a Mac from an iOS device.
Basically I'm trying to write a remote-control type of application for my Mac, and will need to send things like mouse-movement and keyboard-events.
But to start with, how do I talk to the Mac over the network, what API's or technologies should I use from the iOS device to do this with?
This tutorial on networking with Bonjour is gonna help you get started.

Resources