Saturday, August 25, 2012

PeerTalk and the BeagleBone

Earlier today I came across an excellent bit of wizardry by Rasmus Andersson called PeerTalk. It's a Objective-C library allowing you to communicate between your iPhone and your Mac over the USB dock cable using TCP sockets.

PeerTalk Demo

My immediate thought was that if this really only depended on having USB host mode capability at the far end, the same mechanism should be able to be used to talk to something like the BeagleBone, or the Raspberry Pi, not just your Mac. This would allow you connect your phone directly to the micro controller board and to drive hardware directly, a lot like the Redpark cable but bypassing Apple's External Accessory framework. 

Yup, this is going to be useful...
So I started digging around inside the source code to see if it depended on anything that was going to be specific to OS X, it became apparent that PeerTalk was mostly some really nice socket code sitting on top of the USB Multiplex Daemon (usbmuxd). This bit of software is in charge of talking to your iPhone over USB and coordinating access to its services by other applications. Effectively this is what iTunes and Xcode use to talk to your phone when you plug it into your Mac's USB port.

So any device that wants to talk to the iPhone using this method needs usbmuxd. Fortunately  for me there are a number of people that have worked oout how to talk to the iPhone from Linux, and there is a working usbmuxd for Linux.

The BeagleBone
As well as a few other dependences which aren't present on the stock Ångström Linux distribution on my BeagleBone, or even packages via opkg, building usbmuxd on my BeagleBone requires libusb and cmake. So before building usbmuxd, I had to build cmake, which meant resolving some problems with the stock compression libraries that shipped with Ångström.

However several hours later. after enough waiting around for software to build to convince me that before doing any serious development on the BeagleBone I really had to build an ARMv7 toolchain on my Mac to cross-compile things instead of building them directly on the board....

 The iPhone talking directly to my BeagleBone  using PeerTalk
...I managed to get a simple "hello" from my iPhone to the BeagleBone and then via screen to my Mac using port forwarding and that old stand by, telnet.

While I was hacking away on getting this working, I wasn't alone. David House was looking down some of the same back alleyways to get PeerTalk talking to his Raspberry Pi, and we batted the problem back and forth on Twitter while waiting for code to compile well into the night...

The next step is to put together a client on the BeagleBone sitting on top of usbmuxd that'll talk natively to the PeerTalk on iOS. Since I've got the source code of both ends, this isn't going to be too hard. I'll probably put something together in Python.
More soon...

Update: Following on from this I pushed forward till I managed to blink the BeagleBone's heartbeat LED from the iPhone which is, more-or-less, the "Hello World" stage of any hardware hack...

9 comments:

  1. Angstrom does include 'cmake' and 'libusb'. Try:
    opkg update
    opkg install libusb-1.0-0
    opkg install libusb-1.0-dev
    opkg install cmake

    I was able to easily follow the usbmuxd README to then build the library.

    ReplyDelete
  2. Interesting, that must have happened in the last couple of days then because they certainly weren't there a week ago...

    ReplyDelete
  3. opkg update ; opkg install cmake libusb-1.0-dev

    ReplyDelete
  4. angstrom@discovery:~/website/feeds/v2012.05/ipk/eglibc$ ls -la armv7a/base/cmake_2.8.5-r2.3_armv7a.ipk
    -rw-r--r-- 1 angstrom angstrom 4002160 2012-05-20 14:00 armv7a/base/cmake_2.8.5-r2.3_armv7a.ipk

    Has been there for over 2 months now

    ReplyDelete
    Replies
    1. As I said above, interesting. It didn't show up when I went looking for it...

      Delete
  5. Try this to add it to your feeds.

    With this command.

    $echo “src/gz angstrom201205 http://feeds.angstrom-distribution.org/feeds/v2012.05/ipk/eglibc/armv7a/base/” >> /etc/opkg/angstromArmv7a201205.conf

    Then

    $opkg update && opkg install cmake

    ReplyDelete
  6. There was a time when we were just a bunch of students, it was long ago when the actual online writing services didn’t exist and we were facing the problem of writing the assignments ourselves https://topswriting.com/review/ewriters, soon online services popped out but the prices were still not suitable for a student’s budget, that’s when we figured out it is an action time for making an affordable annotated bibliography writing service for students.

    ReplyDelete
  7. Word connections isn't just a solitary pursuit; it thrives on community engagement and collaboration. Players can compete against friends, join online tournaments, or participate in cooperative challenges where collective brainstorming leads to new discoveries.

    ReplyDelete