To use moodlamps with the IPv6 enabled uberbus you have to follow the steps outlined on this page.

Preparations

After building a moodlmap the controller is (curently) flashed with a MLD compatible firmware.

To use the lamp with the uberbus a new firmware has to be flashed. To build your new firmware follow these steps on a Debian based Linux computer:

⚠ Note: There seems to be an obscure issue with current versions (tested with 4.9.2 and 5.2.0) of gcc that results in non-functional firmware even though the build process finishes successfully. Working firmware can be build using gcc 4.5.3 included in e.g. ubuntu precise.

apt-get install gcc-avr avr-libc avrdude make git
git clone git://github.com/muccc/uberbus.git
cd uberbus/fimrware/moodlamp-rf
make

If your lamp has an USB connector you can now flash your lamp using the bootloader.

Unplug your lamp and execute the following command:

make bootload

Now connect your lamp to the computer. It will be automatically updated with the new firmware.

If your lamp has no USB connection but only a RS485 or RF option you have to flash your lamp using a programming adapter.
Configure the defaults in your /etc/avrdude/avrdude.conf according to your programmer and run:

make program

If your lamp has a RF chip you have to set the jumper JP1 on the 6 pin connector on the bottom of the lamp to enable it. See the following picture:

moodlamp_rf-jumper.jpg

Software

The uberbus uses an IPv6 based communication protocol. If you want to set up your moodlamp(s) to be controlled with uberbus compatible programs you
have two options:

  1. If you have only one lamp connected to the USB or want all your lamps to to the same you can use the simplelamp server.
  2. If you have more than one lamp and want them to perform different tasks you need to set up the uberbus daemon(ubd). This is a substantively more complex task than to set up a simplelamp server but provides more flexibility

The simplelamp server connects to a single moodlamp connected via USB to a host computer. It opens TCP and UDP sockets on this computer to access the lamp.

The server is written in Python. It requires a python version with IPv6 enabled. Most Python version shipped with desktop Linux distributions have this enabled but Python supplied by OpenWRT or other small distributions may have this option disabled. In this case try using ubd.

To start the server get the project from the subversion repository as described in section preparations. Connect your lamp and perform the following steps:

cd uberbus/software/simplelamp
./simplelamp.py /dev/ttyUSB0

The simplelamp server resets your lamp and puts it into the bridge mode. It now transmits on its RS485 and wireless(if enabled) interfaces.

Commands transmitted to the server via TCP will be forwarded to the lamp attached to the USB. They are acknowledged by the simplelamp server when arriving at the lamp. Currently no data from the lamp will be sent back through the TCP connection. This means no information about the version, voltage or other
parameters of the lamp can be queried by scripts trying to access the lamp.

Commands transmitted to the server via UDP will also be sent to the lamp attached at the USB. They are forwarded to other lamps connected via RS485
or in range of the wireless transmitter. They are not acknowledged by the server and are not guaranteed to arrive at all lamps.

Keep this in mind when sending single commands to other lamps. Some might not get the command and won't respond.
If this is critical to your application try sending the same command multiple times or use ubd to transmit the command to every lamp separately.

If you use your moodlamp with an desktop computer or a laptop you might be using the suspend or hibernate feature of your
linux distribution. The simplelamp server always tries to open the serial port specified in its command line. But with the
computer resuming the path to the device might change. To prevent this a udev rule has to be set up which always creates the
device under the same path.

First you have to find the unique serial number of the USB chip on your moodlamp.

Execute the following with your lamp attached to the computer:

udevadm info -a -p `udevadm info -q path -n /dev/ttyUSB0` | grep ATTRS\{serial

The first line returned contains the serial number.

Now execute the following line an insert the serial number of your device:

echo ATTRS{serial}=="<serial number from above>", SYMLINK="moodlamp", GROUP="tty", MODE="0660" | sudo tee /etc/udev/rules.d/23-moodlamp.rules

Now the moodlamp will always be created as /dev/moodlamp. You can use this path with the simplelamp server.

When running an installation using ubd have a look at its wiki page for instructions.

Clients

All clients work with a full blown ubd installation as well with a simplelamp server. They all use the packet format specified by the uberbus.(See the uberbus page to learn more about the format)

Currently there are two folders with example scripts for lamps attached to the uberbus:

Under uberbus/software/pythonlib a small library to access the uberbus and lamps attached to the ueberbus is provided.

See the Readme file included in this directory on how to use those scripts. TODO: create Readme file

A simple example to fade a lamp to a specified color in a specified time is fade.py. You can use it the following way:

uberbus/software/pythonlib/fade.py <IPv6 address of lamp> <Red value> <Green value> <Blue value> <Time in seconds>

The fadeexample script fades a lamp in a loop by sending fade commands to an IPv6 address associated with a lamp.

uberbus/software/bashscripts/fadeexample <IPv6 address of lamp> <Time in seconds>

When using the simplelamp server the IPv6 address of the lamp any IPv6 address of the host computer and only the lamp attached via USB
will start to fade.

The color values and the time are specified in decimal notation(0…255)

Under uberbus/software/bashscripts some examples using bash and netcat are provided.

The blink script blinks a lamp by sending color commands via UDP to an IPv6 address associated with a lamp.

uberbus/software/bashscripts/blink <IPv6 address of lamp>

When using this script with the simplelamp server all lamps connected via RS485 or in reach of the wireless transmitter will start to fade if
they receive the commands.

  • projekte/uberbus/moodlamp.txt
  • Last modified: 2021/04/18 12:35
  • by 127.0.0.1