Wednesday, June 27, 2012

C# Class for Eye-Fi

[Nerd Scale: 5 out of 5 pocket protectors, with tape on my glasses]

Two years ago, I purchased an Eye-Fi memory card for one of my digital cameras.  At the time, the Eye-Fi was one of the only commercial SD Memory Card that had a built in WiFi transmitter.  Basically, with this bad boy in your camera, you can take a picture and have it transmit the image file to your computer over a WiFi connection.

Gone are the days where I would  have to perform the arduous task of connecting my camera via its USB cable to my computer.  My life is now complete.

The purpose of the purchase, other than owning something so awesomely cool, was to hopefully incorporate the Eye-Fi's functionality into a piece a software that I had created for my in-laws business, Snapshots.

Snapshots is a business that creates photographic memorabilia for golf tournaments.   In order to enhance the productivity of the business, I created a software package that would automate most of the steps required to turn a digital picture into a Snapshot.  The one thing that kept the new software from working as smoothly as possible was the fact that a user would still have to physically remove the memory card from the camera in order to plug it into the computer that was running the software.  During a golf tournament, this process could create some serious delays.

After my initial tests of the Eye-Fi hardware and software, it became clear to me that the software that came pacakged with the Eye-Fi was not going to do what I needed it to do.  The transfer times were kind of slow and there was no way to integrate the Eye-Fi software with my software.  It was becoming clear that I was going to have to write my own software to interface with the Eye-Fi transmission.

My first challenge was to understand how the Eye-Fi transmission worked.   The Eye-Fi software was basically a software package that acted as a web server that creates a LISTENING port on port 59278.  I was able to determine this by running netstat commands on my computer, launching the Eye-Fi software and figuring out which ports became active.

The netstat command showing the LISTENING port that Eye-Fi is using
Now that I knew which port it was using for communication, I was able to use Wireshark, a software that can be used to analyze port traffic, to watch the interactions that were taking place between the Eye-Fi SD Card and the Eye-Fi software package.

The process of figuring out the commands was mind-numbingly boring.  I had never taken the time to learn the underling code that is running when your make a request using HTTP protcols.   Who does? Super nerds, that's who.  As an exmaple, if you were to open your browser of choice and type the URL http://www.google.com, the Google website pops up.  Here are the HTTP comands that to happen:

A closer look at one of the GET commands shows the request for the Google nav_logo107.png file:

The GET request made to retrieve the nav_logo107.png file


And the response of the website sending the image:

The RESPONSE the web server send when requesting the nav_logo107.png

As I said before, mind-numbingly boring.  But the understanding of this language was necessary to getting my program to work properly.  I spent about 2 weeks researching HTTP and got to the point where I thought I had a good enough understanding of it to begin work on my program.  

C# was the programming language I was using.   Fortunately, C# has a great HTTPListener class that I could use to create my own web server.   After about a week, I had a functioning C# Class that worked excatly how I wanted and could be incorporated into the program that I had created for Snapshots.  

Here is a video that I created to tell other people about this software: 

If you are interested in the source code for this C# Class, you can find the software at my website.  You are welcomed to download it for free and use it however you wish.   If you find the software useful, come back and say something nice about it on my blog.

The webserver will require a credential string that is unique to each Eye-Fi card.   You can calculate the credential string by creating a hex MD5 hash of a string that consists of:
MAC Address of the Eye-Fi card + CNONCE Key + Upload Key

If you have problems finding any of these keys, please let me know and I will assist in helping you.  Or check out this web group:

http://tech.groups.yahoo.com/group/EyeFiHacking/

Monday, June 18, 2012

iFRO - iPod File Reorganizer

[Nerd Scale: 2 out of 5 pocket protectors]

I love problem-solving.

I find that my personality is well suited for it.  I have just the right combination of O.C.D and A.D.D. that allows me to start a project and usually finish it before being distracted by all the shiny things in my world.

So, when a good friend of mine accidentally deleted all of her music files from her hard drive and did not have any backups from which to restore, I was eager to help.

Fortunately, all her music had been synchronized to her iPod.  This gave me some data that I could use in the recovery process.  Unfortunately, iTunes renames each file to a random, four character file name when it copies music to an iPod which makes it very difficult to determine which file is which.  What to do?

Google searches returned no hits on a software package that would reorganize the music into a real-world library format of Artist | Album | Song Title.   It was clear that I was going to have to write my own program to resolve this problem.

I knew that mp3 and m4a files (Apple's slightly-reworked version of the mp3 format) store data about the song in data holders called ID3 tags, but I didn't really know anything about ID3 tags. Another quick google search led me here:  http://www.id3.org/

This site contained all the information that I needed to begin understanding ID3 tags.   I was able to learn how ID3 tags are constructed and where they exist within the file.  All I needed to do was create a program that would interrogate the files from the iPod and extract the useful data.

After a week or so, a little cursing and a lot of coffee, I had a nice little application that quickly reorganized the music files into a Artist | Album | Song Title format, all based on the ID3 tags.

I named my program iFro, short for iPod File Reorganizer.  Running the program allows the user to take these files:
iPod music files saved as random, four character file names
...extract the ID3 tags and use that information to create the Artist | Album folder structure:

Folder structure created by iFRO
 

...and finally copy and rename the file based on the song title:


File copied and renamed based off of ID3 tag information



iFRO interface

I have published this program on my website and it can be downloaded for free.   It will only work in a Windows environment and should be pretty straight forward to use.  It is a JAVA application, so you will need JAVA running on your system to use the program. You will also need to transfer the files from the iPod to your computer prior to running the software.  This is easy enough to do with early generation iPods.  Just connect it to your computer via a USB cable and navigate to the \iPod_Control\Music\F00 folder.   You may need to enable the ability to view hidden folders on your computer.   For newer iPods, you can no longer access these folders directly and will need to use a program such as Stellar iPod Recovery to recover the files to your hard drive.

Enjoy the software and leave me a message if you find it useful.

http://www.binkleyit.com/downloads/iFRO.zip