mypod.me

iPhone hackery and networkery with chewy BSD goodness!

rainbow

Posts Tagged ‘iPhone’

WpTouch

Thanks to this nifty new WordPress plugin, this blog (and my other blogs) now looks very pretty when accessed via iPhone or iPod Touch. Give it a try.

And if anyone wants to access this blog using another WebKit based mobile browser (Nokia N95 or equivalent), I’d be interested in hearing about your user experience.

Simplify Media & the Death of Radio

A just released app from Simplify Media now allows me to stream my iTunes library to my iPhone and my iPod Touch. From anywhere. It’ll work within the house over the wifi, but – far more significantly – it allows me to stream my iTunes library over the 3G network.

So now, my music is entirely portable. And yes, that sound you heard was commercial radio, dying.

The iPhone app is free for the first 100,000 downloads. So if you have an iPhone, get it now!

Qik

Qik, the streaming video shot out for jailbroken iPhone 3G. Which is yet another reason to jailbreak. Probably the best one so far.

iServe 0.01 – Come and Play!

After two days of hackery, a very basic version of iServe is up and running and available for all of you to play with here. Please be nice, don’t upload anything too large (and be prepared to wait during the bigger uploads) and if you upload anything other than the stated file types, you won’t see it. But please do upload – and download. It’s all running on my iPod Touch.

There are lots of implementation details and scripts to share, and I’ll be doing that tomorrow.

iServe

Let me explain why you really do need a web server on your iPhone.

When I mentioned this on Twitter and thereabouts, a few days ago, I was greeted with incredulity. After all, the web is big and wide – why would you also need a web server that you can carry around in your pocket?

The answer is simple, and so very obvious that I’m now shocked Apple didn’t think of this themselves.

Let me present my latest invention: iServe.

iServe leverages the ubiquitous technology of the World Wide Web with the fast-becoming-ubiquitous technology of ZeroConf (known as Bonjour in the Apple universe). When you put these two technologies together into a jailbroken iPod Touch or iPhone, you get a portable and fully scalable document viewing platform. Let me explain…

I have been using my iPhone to read PDF files – specifically, I’ve been reading Apple’s Safari Web Content Guide for iPhone OS. It’s useful – and came in handy for iServe – but it’s a book-style PDF file, which means that the pages are too big to be comfortably read on the iPhone’s screen. Silly for Apple to make a mistake like this, but they’re still thinking of a “book” as something that’s printed on 8 1/2 x 11″ or A4 size pages. It isn’t, not really, but PDF format (or rather, the viewers for PDF format) don’t take this into account. So, I read the Apple PDF in landscape mode on my iPhone, but, even with the 480 pixel-width screen, I had to constantly swipe a finger across the screen to see the end of the line I was reading. Not at all pleasant. (Yes, I could shrink the document to fit across the display, but I can not read 4-point font sizes. Reading should not be an optometric exam.)

iServe provides an elegant solution to this problem. Using the lighttpd web server I installed this morning, which has a document root at /var/www, I created a new subdirectory, /var/www/iserve. Into this directory I place whatever PDF, DOC and XLS files I might want to view. I then wrote a Python script, index.py, placed into this directory, so it is executed whenever a request for the iserve directory contents is received. This script simply reads the contents of the directory and gives a nicely-formatted HTML output in response. This script either works directly from Mobile Safari on the iPhone (where it’s accessed at http://localhost/iserve/), or, because of Bonjour services which are always running on the iPhone, it can be accessed at http://lugh.local/iserve/ from any machine residing on the same physical network as my iPhone. And that’s the magic of it: if I want to read a PDF on my iPhone, I can do it, using Mobile Safari as a launchpad. If I want to read it from, say, my MacBook Pro, I can do that too, using Safari (or Firefox) as a launchpad.

Suddenly I have a scaleable, ubiquitous display capability for any of the documents on my iPhone.

A few pictures might help. Here’s the icon for iServe on my iPhone:

iServe icon

When I tap on that icon, I launch Mobile Safari, and this is what I see:

iServe

I can scroll through and tap on any of these documents, launching the appropriate viewer.

Now, if I should wander into my flat, I can walk up to my MacBookPro, and do precisely the same thing:

iServe Desktop

Voila. Portability and scalability. This is more than a convenience. I could perhaps be carrying documents to a client for review. I can review them on the train as I travel to the meeting, then, when I arrive in the client’s offices, I can simply present my iPhone, connect to the client’s network, and browse the documents. The client can do a “Save As…” command on their browser, should they want their own copy of these documents.

It’s all very simple, and very elegant. And it makes me very confused that Apple overlooked this. Now perhaps some enterprising entrepreneur is putting together something in the App Store which does this. In some sense, FileMagnet (an iPhone app which I own) does this. But it’s entirely proprietary and requires a client program to be installed on a Mac or PC. Using standard web technologies makes this much easier. Web browsers are everywhere. Wireless networks are everywhere. Shouldn’t an iPhone or iPod Touch put those ubiquitous resources to work?

It’s called a reverse SSH tunnel

And it’s used to keep a link from a device that may be behind a firewall. Or perhaps it’s connected to a highly variable mobile network. When it’s opened, it allows users to “tunnel” through the connection, to wherever the device might be.

Here’s what I put into the shell script “tunnel”, on my iPhone’s ~/mobile directory:

#!/bin/sh
ssh -R 8022:localhost:22 -f -N mpesce@webearth.org

That fairly simple line opens a connection via port 8022 on webearth.org (which sits underneath my telly), to port 22 (which is the normal SSH port) on my iPhone. Thus, if I go to the command line on webearth.org and type the following:

ssh -p 8022 mobile@localhost

Voila, I have a shell into my iPhone.

Yes, those of you who are not serious network geeks, this seems like rocket science. It’s not. Reverse SSH tunnels are used all the time by folks behind, say, the Great Firewall of China, or simply the NSW Public Schools network.

Update: I’ve realized that SSH, as a security precaution, will shut down open connections if they’re not used. In ~/mobile/.ssh, create a new file named config, and put the following line in the file:

ServerAliveInterval 60

That should keep things connected indefinitely.