Busylight Lync SDK Released! (inc. code samples)
With the new SDK, you can use the Busylight as a system status alert for SCOM, Twitter, CI Builds – whatever you want!
Update 29th May 2013
A while ago, I blogged about how you could use the DLL that came with the Busylight to create your own colours and control it from within your application.
The Busylight is a USB device with a speaker and light. It’s designed to show your presence from Microsoft Lync and other UC applications in a more visual way. In open plan offices, it’s a good way of signalling that you’re on a call and don’t want to be disturbed. There’s a good write-up by Scott Hanselman about it.
When I blogged this before, I used the DLL that came with the stock application to control some of the functionality of the Busylight, and I moaned about the lack of an SDK. At the time, Morten Ostergaard, a Partner at Plenom a/s (the people behind Busylight) made contact, gave me some hints and tips, and confirmed that an SDK would be coming for Busylight.
Well, it’s arrived! The official SDK from Busylight is now available, via their Developer section at http://www.busylight.com/develop.
When I last looked at the DLL that came with the Busylight, it was possible to get it to display colours on demand, but it wasn’t particuarly simple, and it was a bit too hacky to be used comfortably in a production environment. However, the SDK has made it really simple to control the Busylight, which makes it ideal for hundreds of use cases outside of the standard Lync presence reporting.
In the examples below I created a new Console Application in Visual Studio. You can do this if you want to follow along. Either way, add a reference to Busylight.Sdk.dll which is included in the download.
Busylight UC vs. Busylight Lync
The SDK works with both Busylight UC and Busylight Lync,
although the website only talks about the Busylight UC.
In an early version of the SDK, the default constructor for the controller object only worked with the Busylight UC and you had to call an overloaded method, passing IDs, in order to use it with the Busylight Lync.
Plenom have since updated the SDK to make it easier to use with the Busylight Lync. There is now a separate controller object especially for Busylight Lync.
All the samples below are for Busylight Lync, but include the Busylight UC constructor as a comment. If you have a Busylight UC, just comment & uncomment accordingly.
Here’s how simple Plenom have made it to control the Busylight from your application:
There’s a choice of 4 colours: Red, Blue, Green and Yellow. I found that if you set the light, it will stay on for about 10 seconds before turning off. If that’s too long, you can call Light() with the color enumeration Off.
In the future, it would be cool to be able to specify custom colour combinations, maybe using RGB values, to allow for a range of different colours. Plenom actually got back to me about this. It turns out it IS possible to create your own colours rather than just using the 4 enumerations, I’d just not noticed it. You can create a new BusylightColour object and specify the RGB parts as properties. Here’s an example of doing this to create a nice purple colour:
As well as just displaying a light colour, you can also draw attraction by altering the opacity of the light, to create a pulsating effect:
The SDK allows you to specify a colour, and up to 8 steps. Each step property is a tinyint (0-255) representing the opacitiy of the light. 0 is off, 255 is full brightness. The steps are executed in order, very quickly (I would say about 250 milliseconds between them). The example above gives a sort of fade in and fade out effect. Each sequence is executed in full 7 times, before the light turns off. You can also use this to save yourself writing loop code, if you want to show a flashing light. Just set each odd step at zero and each even step at 255. It turns out looking like this:
Light and Sound
One of the big things I couldn’t work out how to do before the SDK was sound. It’s included in this SDK however, as part of the Alert() method:
There’s a choice of 8 different sound clips and 4 different volume settings.
I noticed that when using the Alert() method, the alert never seemed to stop. The light would turn off after about 10 seconds, but the sound continued. I waited 3 minutes for it to stop, and ended up unplugging it to get it to shut up!
However, calling Light() will stop the sound. I use this trick in the code sample to cancel the sound after 10 seconds.
There’s also a method called AlertAndReturn(), but I couldn’t work out what this did differently from Alert(), apart from always using a blue light regardless of what you chose.
Plenom have made it really simple to integrate use of the Busylight into your own applications. Building a simple hardware notification to react to events such as system errors, or notifications is usually either expensive or complicated. However, the Busylight is an inexpensive and simple solution and you won’t have to spend ages putting it together.
To take just one example: Continuous Integration server build notifications. There are many ingenious and cool solutions out there, but sometimes you don’t have time, and just want something that works. I reckon I could hook this into TFS in less than a day. If I get time to try it, I’ll post up the code.