lauantai 14. elokuuta 2010

Moving blog to

As Blogspot is a bit limited blogging platform I have decided to move my blog to I recently registered a new domain for my blog: I would have wanted to have but the owner didn't feel like selling it.

So from this moment on my blog will be at and this blog isn't maintained anymore.

keskiviikko 4. elokuuta 2010

Using libmirror to read RFID tags with Violet's Mir:ror-reader

Libmirror is .NET-library that allows reading RFID tags with cheap reader from Violet called Mir:ror. Libmirror works in Windows on top of .NET Framework but by design it should also work in Linux and Mac OS X over mono but that hasn't been tested. Reader itself supports both A and B standards, connects to USB, looks cool and costs only about 50 €.
Violet is more known for their bunny Nabaztag. Personally I find the Nabaztag bunny pretty useless as also the Internet of Things ideology behind Mir:ror. At August 2009 Violet filed bankruptcy as their business seemed to have failed. Few months after bankruptcy, in October 2009, Violet was acquired by Mindscape. Recently the availability of Mir:rors and Nabaztags has resumed to pre-bankruptcy level so I decided to resurrect the libmirror projects.
Usually Mir:ror is used together with Violet's Mirware application that is based around the idea of internet of things. This means that every time you show RFID tag for the reader it will send it's identifier to Violet's server and look for any associated actions or applications. If applications or actions are found, them are then executed on client machine. For example you can associate action open URL with tag attached to umbrella and it will open Internet weather forecast site for you.
Libmirror frees Mir:ror from its restrictions and allows you to communicate directly with it without annoying Mirware. Current 2.0 version allows getting events for tag shown, hid, orientation changed and device removed.
Choreographies would allow controlling leds and sounds of Mir:ror but currently support for choreographies is non-existent as no-one has been able to reverse engineer the protocol. Currently it is possible to disable sounds and lights of device by calling SetChoreoOff after initialization before any tags are shown for the device but as no-one really understands the protocol I would recommend against using any methods related to choreographies. It's also possible to re-enable lights and sounds by calling PlayChoreo. That command also replays previous choreography.
To use libmirror go to and download latest version. Currently library uses 3.5 framework and should work on both 32 bit and 64 bit projects.
To get all connected mirrors you need to call MirrorFactory.GetMirrors() or if you want only the first one call MirrorFactory.GetMirror(). Here is example how to initialize one Mir:ror and attach events to it.
var description = MirrorFactory.GetMirror();
if( !description.IsInUse )
    var mirror = description.Create();
    mirror.TagShown += OnTagShown;
    mirror.DeviceRemoved += OnDeviceRemoved;
    mirror.OrientationChanged += OnOrientationChanged;
Remember that HIDDevice objects has to be correctly disposed otherwise device might appear in use as handler to device stays open until garbage collector disposes the object. This should be done with using syntax or binding to DeviceRemoved event and then gracefully disposing the object. Note that if you don't handle DeviceRemoved event then DeviceRemovedException is thrown by next method that tries to read or write to mirror. Here is example how to handle DeviceRemoved event.
private void OnDeviceRemoved(object sender, DeviceRemovedEventArgs e)
    e.IsHandled = true;

Other related projects and resources at net: