Bitcoin Forum
April 24, 2018, 12:55:53 PM *
News: Latest stable version of Bitcoin Core: 0.16.0  [Torrent]. (New!)
   Home   Help Search Donate Login Register  
Pages: [1]
Author Topic: [15 BTC bounty] A tutorial for simple functions in Clojure (and BACnet)  (Read 3848 times)
Sr. Member
Offline Offline

Activity: 434
Merit: 250

View Profile
May 31, 2011, 12:29:41 AM

Here's the deal: I want to be able to create some input/output with some descriptions in BACnet. (
For this, I want to use Clojure. My devices are located in my LAN (so any Ethernet implementation should work, but feel free to use IP if needed).

There's already some libraries written for BACnet, such as this one in java (which, as I understand, should be easy to use with Clojure), and this one in C.

So the goal is: I put an input in a Clojure function, it creates my input and I then can add a description.
However I'm pretty sure you don't have BACnet devices laying around, so a simple proof of concept from one function to another is sufficient.

What's the catch?
I'm awful.
This means I require a tutorial:
  • Start the project with Leiningen
  • How to include the existing library
  • How to find the required functions
  • Write the Clojure functions
  • Test them
  • Creating an independent .jar would be nice..

That's it.

I would like if you could use Emacs, but I left this as a choice.

I will post the accepted tutorial here, available for all. You can post it on your own blog if you want, although I would appreciate if you could say I financed it and put this Bitcoin address for any thanks: 1nZJ4JJTxwt4XZ7N39j3EHaVojBHMvZVK
Hero Member
Offline Offline

Posts: 1524574553

View Profile Personal Message (Offline)

Reply with quote  #2

Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
Sr. Member
Offline Offline

Activity: 434
Merit: 250

View Profile
June 18, 2011, 12:27:51 AM

Hello all!

A great fellow sent me a quick draft.
It didn't fully fulfill my desires, but I still sent him 5 BTC. The bounty is now [15 BTC]!

Here is what I have so far:

1. Install leiningen. That is, download the script from
   and run 'lein self-install'

2. Create a project, for example:
   lein new clj-bacnet
   to create a project skeleton in clj-bacnet directory

3. Add bacnet4j as dependency.
   Leiningen prefers to obtain its dependencies from a maven repository.
   Since I didn't find any, I took the liberty of adding a copy of bacnet4j
   to the repository.

   After adding the bacnet dependency your project.clj should look like this:

(defproject clj-bacnet "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.2.1"]
                 [org.clojars.jarpiain/bacnet4j "1.2.0"]
                 [org.clojars.jarpiain/sero-utils "1.0.0."]])

4. Run 'lein deps' to download the bacnet jars (and a copy of clojure)
   to your project directory

Now you can run 'lein repl' and start playing with bacnet4j objects

For example,

(com.serotonin.bacnet4j.Network. 1 (byte-array (map byte [127 0 0 1])))

creates a new Network object
#<Network Network(networkNumber=1, networkAddress=[7f,0,0,1])>


(.getNetworkAddress *1)

calls the getNetworkAddress method on it.

To avoid typing the package name, enter e.g.

(import '[com.serotonin.bacnet4j Network LocalDevice RemoteDevice])

in the REPL. Then the previous example would look like
(Network. 1 (byte-array (map byte [127 0 0 1])))

Leiningen created a src/clj_bacnet/core.clj in the project
and you can add the import declaration

(ns clj.bacnet.core
  (:import [com.serotonin.bacnet4j Network LocalDevice RemoteDevice]))

to use the short names in your code.

With emacs and SLIME you can add lein-swank as a dependency and start
a swank server with 'lein swank' and then connect from emacs as explained in

Please note that it took me quite a while to wrap my head around this; I really need things to be explained in details.

The next step should be to create and test the clojure functions. This is where a BACnet knowledge could be handy, if you have any.

Full Member
Offline Offline

Activity: 168
Merit: 100

View Profile
June 18, 2011, 12:26:58 PM

 i can finish this if need be.  i will start working on it now and you will get a finished copy by the end of the day
Sr. Member
Offline Offline

Activity: 434
Merit: 250

View Profile
June 26, 2011, 04:01:25 AM

The bounty is still available!
Pages: [1]
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!