Tag Archives: clojure

Wacnet – Making the jump to hardware

PCs are everywhere. Except when you need one.

I’ve recently released an open source BACnet webserver and toolkit onto this world. As with my traditional naivety, I was saying:

“It’s really simple! You just have to take any PC that you have available and make sure it’s never turned off.”

The response I got from many of my customers was underwhelming to say the least.

Well, turns out PCs are kind of a hard thing to get for some building managers. They can’t just take an old PC laying in a storage bin… many need to contact their IT department, ask the permission to get a PC and get someone to install and configure it. This often also means a new windows licence, new login/password for the machine… in short, it’s a pain.

In search of cheap computers

I decided to take matters into my own hands and to install Wacnet on the smallest machine I could get my hands on. This way, I might be able to sell small computers to my customers for a fraction of the cost of using one already owned by them. (This statement alone is mind boggling… it might be cheaper to buy new than to re-use something you already own if you must go thought all administrative hoops.)

First I was thinking about small netbooks. About 2 years ago, I was able to get a brand new one for around $300. Surely now they would be cheaper!

Wrong. Instead, the market shifted towards tablet with a nice little mean price of $500. Not really what I wanted.

The sad thing about tablets is also how hard it can be to tinker with them. Especially those without USB ports.

Almost dedicated hardware

A little saddened by this market shift, I decided to take a look to the Raspberry Pi and alike. In short, all the ARM based miniature PCs.

Not only was I able to install Wacnet with minimum hassle, I was also able to configure a linux distro to boot quickly and start Wacnet immediately.

For the user, this means no more installation necessary and no more shell script or batch file to start the application automatically.

You plug the power on the mini PC, and Wacnet starts! Magic!

I’ve effectively turned this mini PC into a (almost) dedicated hardware.

Behold, the mini PC I’m currently using:


MK802 picture shamelessly taken from http://pakitong.blogspot.ca/

While this is known as the MK802 Allwinner A10 Mini PC, Wacnet should be able to run on all the devices based on the same architecture.

A complete plug and play BACnet webserver for a fraction of the price of some thermostats? Count me in!

Introducing Wacnet: a BACnet Webserver

Here it is! A free open source BACnet webserver to help everyone with their BACnet networks!

  • Run without any installation;
  • Can run directly from a USB flash drive;
  • No licence or limit on the number of BACnet objects;


The purpose of BACnet is to provide interoperability between devices from multiple manufacturers.

The idea is that if all devices speak the same language, no one will be ‘trapped’ with a proprietary protocol, forcing him to always buy at the same place.

This common language also have other advantages, such as making it easy to gather data and make advanced analysis. Simply checking the historical data plotted on a graph is enough to find and solve most problem.

However, despite all BACnet’s promises, the landscape is still mostly occupied by a handful of manufacturers.

In addition, BACnet is pitched as an ‘open protocol’, but the standards need to be ordered; even bacnet.org doesn’t provide a link to download the specs. This isn’t making it easy for newcomers. Want to see and try BACnet? Well, send us money and we’ll send you a boring pdf, and maybe, maybe you will stick with us.

For the developers, there’s some highly cryptic application that will provide some support, but for the newcomer that’s simply counterproductive to even try them.

This results in an horrible situations for the users. Building managers are often clueless as to what to do with a BACnet network. They don’t know what’s in it, nor do they know how to browse it. (Of course manufacturers will offer their own software… for a price.) There’s nothing wrong with selling software, but for such a basic need, browsing the network, a free software should be available. It’s like comparing Notepad and Word. Sure, sell Word, but the user should at least be able to write basic stuff in notepad.

Wacnet is a humble try to ameliorate the situation. By enabling an easy and almost instantaneous setup, anyone can at least see what’s on the network. Newcomers can explore the different properties and learn them.


Getting the application

If you know Clojure, download the source and do lein uberjar.

If you do not, download the pre-packaged version at https://bacnethelp.com/how-to/wacnet.

Running the application

No installation necessary and can run from a USB key!

The standalone jar file can be started on any computer with Java installed. We recommend starting it from the command line as such:

 java -jar <filename>

For example:

 java -jar wacnet-0.1.1-BETA-standalone.jar

You can of course start it by simply double-clicking on the .jar file, but you might have a hard time finding the ‘off’ switch. (You will have to manually kill it.)

Once the application is started, go to http://localhost:47800 and browse your network!

Advanced usage (REPL)

The REPL is an interactive evaluation environment to enable power users to use tools tailored to their needs. If a feature is lacking, it’s even possible to add it on-the-fly!


I’ve done it!

My first real, service providing, payment subscription website. I must say it took longer than what I was expecting… (Paypal’s API is a bitch; many things don’t act like described in their manual).


Because I like privacy and encryption, I made sure BACnethelp.com would abide by these principles. What? You want me to encrypt only the payment section? Well first of all it wasn’t really necessary, as the payment section really is on the Paypal side. But even then, I only have this to say:


That’s right! Every single page is encrypted. No one on your network can see what you are looking at! They can, however, see that you are browsing BACnethelp.com because of the DNS resolving which isn’t encrypted. Hopefully this will change sooner rather than later.

Needless to say, I made sure that all the passwords are not saved in plain-text. This might seems self evident, but I’m constantly surprised by the number of website not doing it the right way. In fact, if a website gives you a maximum length for your password, run. Run as fast as you can, because this is a really, really bad sign.

What it does

But really, what does my website do? It enables you to see what’s on your BACnet network.

A Data Communication Protocol for Building Automation and
Control Networks
– BACnet.org

By that I don’t mean there isn’t already some tools to browse a BACnet network. Unfortunately for the user, those tools often cost more than a thousand dollar for a single license. Add some more thousands if you want to save the data in a database, or add a web-server. Want to use BACnet at home? Well this seems like a good choice; take one of your micro-controllers, add it a BACnet stack and you’re rolling baby! Except won’t you be able to retrieve the data easily. This is the weird state of BACnet right now. Yes, its main goal is integrability, yet most of us can’t see what’s on the network unless we drop only a grand or two.

This is where BACnet help comes in. Tada! By running a little application, you are able to scan the entire network in a single swoop. It’s grabbing everything: IP addresses, MAC addresses, current values, descriptions, out-of-service, (…) trend-logs and even backups! It takes a snapshot of your network. “How was the network when I finished servicing it? Does someone played with some values and caused havoc?” All you need to do, is press a single button: https://frozenlock.files.wordpress.com/2012/06/wpid-bacnethelp-scanner1.png

This couldn’t be any simpler. Of course there’s some advanced settings if you want to customize a little more your scanning experience.

In other words, this is what BACnet help lets you do: Scan and see your network.


As many of you probably determined by now, the scanner doesn’t provide a real time view of the network; it’s a snapshot. It’s not meant to send commands, only to see your network. One of the constraints I had to cope with was that some of BACnet’s heavy users don’t have an Internet access on the same network. I know, I know, why the hell not. On one side it would be silly to hack into a system only to change a room temperature set point. On the other side, there’s no authentication (that I know of) on the BACnet network. Anyone can just connect to port 47808 and voilĂ !

So how can I take a snapshot of a network and send it to BACnet help later, when the user has an Internet access? The resulting file must also be able to go through most firewalls (to send it via email). Finally, the most important point, the user must be able to use it. (In the HVAC world, there’s some people still sending faxes, don’t expect them to know how to do the simplest computer task. Don’t get me wrong, they might be gods to maintain a boiler system… but they suck at computers. Nobody can do everything.) What’s the solution for an easy to use file, usable on any machine and transparent to firewalls? An HTML file! All data is crammed inside it, ready to be send when the user click on the “Send” button.

Now calm down, I know what you are thinking “Won’t all this info help others reverse engineer your so-nice-I-wish-I-could-marry-it network scanner? Well no, because…

Open source

The scanner is open source! You can grab the source whenever you want! I must warn you, many shortcuts where taken as I didn’t need the entire BACnet range of functions to do what I wanted. You can check the BACnet4J library if you want to build something more hardcore. Because I’m also a big fan of free softwares, I must mention that the scanner works on the JVM (written in Clojure), meaning it can also work on GNU/Linux! The .exe scanner is simply a wrapped .jar, meaning that you can open it using the Java runtime.

So I need to pay to use it?

Only if you use it extensively! As a non-subscriber, you can save up to 3 projects, each with a maximum of 5 devices. This is more then enough for a home project! You can also delete devices you don’t use and put new ones in their places. The important thing here is to stay below the maximum number. Unless you are using it extensively, it’s 100% free!

Please, try it! I would love to have your feedbacks!

Clojure on Windows 7

The installation of Clojure on Windows is quite an accomplishement in itself. The following steps are those I finally isolated from multiple forums, blogs and painful discoveries. It’s mostly a note for myself.


https://frozenlock.files.wordpress.com/2012/03/wpid-leiningen-banner.png Grab the last stable version of Leiningen’s .bat file. If you don’t have Wget installed on your machine, install it or put the binary (wget.exe) in the same folder as lein.bat. In this directory, open the command window and type lein self-install. This will install leiningen-1.x.x-standalone.jar on your machine. It will probably be in your user directory, depending of your configurations.

Environment variables and the PATH

Copy the path to your new lein.bat. Then type <win><pause> (windows key and the key to the right of screen lock). Now go in Advanced system setting, Environment Variables. Find the PATH variable and click edit. Now type a semicolon and paste the path to your lein.bat file. This will make sure you can call Leiningen from anywhere in your command line with the simple “lein”. You should try it now, just to make sure everything is ok.


At this point you have a working installation of Clojure. But surely you want more, don’t you?

Emacs (SLIME)

Assuming you want to use Clojure in its most natural environment, you should use Emacs (yay!).

Install clojure-mode from git or Marmalade.


Update 2012-03-07 mer.: Be sure to restart Emacs if you changed the environment variables in the previous step!


Swank Clojure is a server that allows SLIME (the Superior Lisp Interaction Mode for Emacs) to connect to Clojure projects.

To install Swank-clojure, open once again the command line and type

lein plugin install swank-clojure 1.4.0

(Where 1.4.0 is the version you want to install).

If Clojars.org isn’t blocked, (which it is, at my office, God only knows why…) you should see the plugin being downloaded and installed. That’s it.

No, really, that’s it!

Beginners’ traps

Before you try jack-in, you should make a project as described in Leiningen instructions. The most important part before trying anything else is to have a .clj ready. You must have this file opened in Emacs before you do the magic M-x clojure-jack-in!!

If you get an error message complaining about “$SHELL”, type M-x customize-variable RET clojure-swank-command RET and enter “lein jack-in %s” instead of the current value.