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/

8 comments:

  1. Hi, the download link is not working. Can you please set it correct? Thanks in advance.

    ReplyDelete
  2. Hi, the download link is not working. Can you please set it correct? Thanks in advance.

    ReplyDelete
  3. Try this link: http://www.binkleyit.com/downloads/EyeFi.zip

    ReplyDelete
  4. Thank you for sharing !
    I can't figure out where to find CNONCE and Upload keys.
    Any input will be appreciated !
    Thanks by advance.

    ReplyDelete
  5. If you are using a Windows Vista, 7 or 8 system, you should be able to find the file containing that information on the computer you installed the Eye-Fi software at this location:

    %AppData%\Roaming\Eye-Fi\Settings.xml

    If not, you can always try sniffing the traffic between your eye-fi and computer using WireShark.

    ReplyDelete
  6. Thanks for the Settings.xml tip !

    ReplyDelete
  7. Web Development company is a company which involves in the development of a website for an intranet.This development can include the development of simple static page as a complex web-based electronic business

    ReplyDelete
  8. Hey man, i was able to create the webserver using ur code and the server was up and running. But the chip never sends a http request to the webserver. Can you please help ?

    ReplyDelete