June 2, 2009
Since getting a CurrentCost CC128 “smart” electricity meter a few weeks ago the hacker in me has had a resurgence and I have started writing hobby-code again on top of my day job. There seems to be a small industry of software for interacting with these smart meters, and publishing and recording the data to various sources such as Pachube that allow you to share your electricity consumption data with others. At the consumer/home level things seem to still be targeting tinkerer’s like myself, rather than the general consumer. Most of the tools seem to be centered around the linux and java community, which is all well and good, but why can’t us Microsoft .Net folks get in on some of the action.
Microsoft’s Windows Home Server is a perfect platform to act as a hub for this type of stuff. It’s designed to be always on, with an add-in model that allows extensions, so I decided to embark on using my HP MediaSmart EX470 to publish the CC128 sensor data in a variety of ways.
As part of IBM’s work surrounding telemetry and sensor messaging they have made, freely available, what they are calling a “nano broker”, the Really Small Message Broker (RSMB). This broker talks the Message Queue Telemetry Transport (MQTT) protocol, designed again, by IBM (the brainchild of Andy Stanford-Clark, IBM Master Inventor and illustrious enough to have his own wikipedia page). The idea is that you can publish data on a specific Topic to the RSMB via MQTT, and the RSMB will then distribute that data to any “client” that is subscribed to that topic. Being IBM, the code is primarily targeted at the linux community, however they are also nice enough to provide a Windows console application binary.
Getting a console application to run when Windows Home Server boots is not as simple as putting it in the Start menu, or in one of the myriad of “Run” registry sections. Fortunately, Microsoft provides two executables, instsrv.exe (service installer) and srvany.exe (run any program as a service) as part of the Windows Server 2003 Resource Kit, and these can be used to run any program as a service, which means that you can get IBM’s RSMB running at server boot without having to have a user logon session.
The following steps will allow you to run the RSMB on Windows Home Server so that it starts up at server boot. These instructions assume you have installed the Windows Server 2003 Resource Kit in the standard location, and you have unzipped the RSMB to C:\RSMB. Alter the instructions for your paths if they vary. You’ll have to do all this by logging onto the server using the remote desktop client, not the standard windows home server console.
1. Use InstSvc.exe to install an SvrAny.exe based service.
32bit Windows Server (ie, HP MediaSmart EX470 etc)
"C:\Program Files\Windows Resource Kits\Tools\instsrv" RSMB "C:\program files\Windows Resource Kits\Tools\srvany.exe"
64bit Windows Server
"C:\Program Files (x86)\Windows Resource Kits\Tools\instsrv" RSMB "C:\program files (x86)\Windows Resource Kits\Tools\srvany.exe"
2. Alter the registry to let SrvAny.exe know that it should run the broker.
Note the important part here is setting the AppDirectory, without which the RSMB will mysteriously start and then immediately stop because it can’t find it’s Messages file.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\RSMB\Parameters] "Application"="C:\\rsmb\\broker.exe" "AppDirectory"="C:\\rsmb\\"
That’s all there is to it. If you go into Computer Manager and the services browser, you should be able to start the RSMB service and the broker will be running silently in the background. You can check this out by looking at Task Manager, Processes Tab, where you will see both the SrvAny.exe and Broker.exe processes. You can also run netstat -an in a powershell or cmd.exe window to check that the server is listening on port 1883.
The only thing that you should do on top of this is to change the service to run with a non administrative account with locked down settings (read/write access to the RSMB folder and the ability to listen to connections on port 1883 should do the trick).
May 20, 2009
Thats all Nothing fancy.
Looks like I messed up doing the upgrade by copying over old images etc. So be it, I’ll be starting a-fresh on the new server.
February 16, 2008
If you are a software engineer then most likely you subscribe to a number of email lists, or get regular daily / periodical email updates that can clog up your email inbox.Â Also most likely you use Outlook, connected via POP to download your email, and have a myriad of rules that move messages into folders to keep everything as organized as possible.
Late last year I moved email hosting for @markallanson.net emails over to Google Apps For Your Domain in order to make use of GMails excellent online client, search ability and also to ensure reliable and *fast* email access both online and offline. When I switched to Google Apps I altered my Outlook client to use POP to download the mail, and kept all of my rules in Outlook. This has been working perfectly since, but a few weeks ago I got myself a HTC Touch Dual and wanted to get it to sync with my mail hosted on Google.
Ever since moving to Google Apps and using their online client the one thing that bugged me was that all mailing lists appeared in my main inbox. I switched outlook to connect via IMAP and sure enough the same thing happens, all emails were being synchronized to the single inbox folder. I synchronized Windows Mobile on the Touch Dual via IMAP and the same thing happens, as expected. The noise is too much to deal with on a mobile device so it’s time to start categorizing email – but on the server side in GMail – not using Outlook.
GMail supports filters and labels for categorizing email. You can tag an email with as many labels as you like and then view slice and dice via a labels. When tagging an email with a GMail label it appears in Outlook as a separate folder. The same thing happens on your windows mobile device. I tagged all emails from the WiX-Users mailing list and a WiX-Users folder appears in Outlook and Windows Mobile. Unfortunately however the same email also stays in your inbox and the noise is still there.
GMail also allows you to perform actions on arriving email in a similar way to Outlook rules so assigning labels automatically upon email arrival was trivial using the Filters functionality. Still this does not solve the noise problem.
In order to remove the noise, there is an option you must set on each incoming message filter. Once the filter criteria has been set up you must also check the box that tells GMail to archive the email once the filter has been applied.Â Now archiving to me originally sounded like too much of a “Final” operation, so I ignored the option, but in effect ticking the archive box just removes it from your inbox. The labels applied via the filter are still usable, and the email can still be searched, but the noise is removed from the inbox.
So, to have a usable version of your email on WinMo6 via GMail you need to do the following.
One final thing: When you set up a sync in Windows Mobile by default only the last N days of headers are synced from the server. I had some emails that I needed to have available at all times, such as all emails relating to my upcoming trip to Florida. The way I did this was to apply a Holiday_Orlando label to each of the emails that I needed to have on the phone always. At the next sync Windows Mobile created a new folder called Holiday_Orlando with no messages (none were newer than 3 days). I then had to modify the Holiday_Orlando folder synchronization options to add an override for that folder which told it to sync all messages in the folder.Â Voila, all messages about the vacation are now available, with their attachments!
God knows how non-techies are supposed to ever figure this stuff out! (and apologies for the random rambling format of this post, I just *had* to write this down for others wanting to do the same thing.)