Skip to content
Kai Krueger edited this page Sep 16, 2013 · 2 revisions

This page is out of date, and only here for reference. If you want to set up a new Hexabus network, please refer to Routing Hexabus Packets.


0. Prerequisites

In order to get up and running, you need the following equipment:

  • An OpenWRT router. I highly recommend the Buffalo WZR-HP-G300NH, since its a rather powerful device, has one USB port and very good OpenWRT support. Actually, you can use any Linux machine for this step - just install radvd and make sure that your network configuration is ok.
  • A HexaBus USB Stick. This connects the router to the HexaBus devices.
  • One or more HexaBus plugs.

In addition you need a computer, coffee and some time. If you have any questions, feel free to ask on the hexabus mailing list.

1. Setup of the router

First, you need to install OpenWRT on the router. If you use the Buffalo router, just follow the notes in the OpenWRT wiki. I also use a simple shellscript for easy tftping (set the MAC-address for your device accordingly):

sudo ifconfig eth0 192.168.11.10 netmask 255.255.255.0
sudo arp -s 192.168.11.1 00:24:a5:b0:07:d3
tftpfoo=`(cat <<-EOF
binary\n
rexmt 1\n
timeout 60\n
trace\n
put openwrt-ar71xx-wzr-hp-g300nh-squashfs-tftp.bin\n
EOF
) `
echo $tftpfoo

then call ./flash.sh | tftp 192.168.11.1

The sequence of actions is:

  1. Setup your computer according to the OpenWRT wiki.
  2. Prepare the tftp command, but do not submit the put command.
  3. Unplug and replug the router to bring up the the bootloader. Now submit the put command

After a reboot you should be able to log in and make sure, you can access the internet from the device -- otherwise, installing packages might be hard. I found the following hints useful:

  • The DNSmasq daemon can be convinced to use another gateway by adding something like this to /etc/config/dhcp:

    config dhcp lan
      .....
      option dhcp_option "6,192.168.1.2" #dns server
      option dhcp_option "3,192.168.1.2" #default route
    
  • Enable IPv6 forwarding by adding to /etc/sysctl.conf:

    net.ipv6.conf.all.forwarding=1
    

Next, you need to install several packages to get the IPv6 stack running, this is also documented in the OpenWRT wiki. Specifically, you need to install the IPv6 Router Advertisement daemon (radvd) and the ohci-usb interface drivers.

  • radvd advertises the available prefixes to all connected IPv6 devices. I use two network prefixes: „aaaa::/64“ for the 6LoWPAN devices and „bbbb::/64“ for the Ethernet/WLAN devices. The router routes between those networks and has the IPs „aaaa::1“ and „bbbb::1“ on both interfaces, respectively. I did not understand how to map this in the usual OpenWRT /etc/config/radvd file, so I am using /etc/radvd.conf instead. This is it:

    interface br-lan                                                                  
    {                                                                                 
            AdvSendAdvert on;                                                         
            prefix bbbb::/64                                                          
            {                                                                         
                    AdvOnLink on;                                                     
                    AdvAutonomous on;                                                 
            };                                                                        
    }; 
    
  • The USB stick uses an ohci-interface and shows up as usb0. You can use the /etc/config/network file to configure the interface -- but this will happen in step 2.

  • Configure an interface to use IPv6 adresses. In my /etc/config/network, I do this:

    config interface lan
        option ifname   eth0
        option type     bridge
        option proto    static
        option ipaddr   192.168.1.1
        option ip6addr  bbbb::1/64
        option netmask  255.255.255.0
        option gateway  192.168.1.254
        option dns      8.8.8.8
        option dns      8.8.4.4
    

TODO: Provide an opkg install command here.

These packages are needed:

kmod-usb-net-cdc-ether
kmod-usb-ohci
kmod-usb-net
kmod-usb-uhci
kmod-usb2
usbutils
radvd
kmod-usb-acm

The /etc directory of my router is available here. The complete package list of a working router looks like this:

root@OpenWrt:~# opkg list-installed
base-files - 42-r20728
busybox - 1.15.3-2
crda - 1.1.0-2
dnsmasq - 2.52-2
dropbear - 0.52-4
firewall - 1-10
hotplug2 - 1.0-beta-1
ip - 2.6.29-1-2
ip6tables - 1.4.6-2
iptables - 1.4.6-2
iptables-mod-conntrack - 1.4.6-2
iptables-mod-nat - 1.4.6-2
iputils-ping6 - 20071127-1
iputils-traceroute6 - 20071127-1
iw - 0.9.19-1
kernel - 2.6.32.10-1
kmod-ath - 2.6.32.10+2010-03-24-5
kmod-ath9k - 2.6.32.10+2010-03-24-5
kmod-button-hotplug - 2.6.32.10-1
kmod-cfg80211 - 2.6.32.10+2010-03-24-5
kmod-crc-ccitt - 2.6.32.10-1
kmod-crypto-aes - 2.6.32.10-1
kmod-crypto-arc4 - 2.6.32.10-1
kmod-crypto-core - 2.6.32.10-1
kmod-ide-core - 2.6.32.10-1
kmod-input-core - 2.6.32.10-1
kmod-input-gpio-buttons - 2.6.32.10-1
kmod-input-polldev - 2.6.32.10-1
kmod-ip6tables - 2.6.32.10-1
kmod-ipt-conntrack - 2.6.32.10-1
kmod-ipt-core - 2.6.32.10-1
kmod-ipt-nat - 2.6.32.10-1
kmod-ipt-nathelper - 2.6.32.10-1
kmod-ipv6 - 2.6.32.10-1
kmod-leds-gpio - 2.6.32.10-1
kmod-mac80211 - 2.6.32.10+2010-03-24-5
kmod-nls-base - 2.6.32.10-1
kmod-ppp - 2.6.32.10-1
kmod-pppoe - 2.6.32.10-1
kmod-usb-acm - 2.6.32.10-1
kmod-usb-core - 2.6.32.10-1
kmod-usb-net - 2.6.32.10-1
kmod-usb-net-cdc-ether - 2.6.32.10-1
kmod-usb-net-rndis - 2.6.32.10-1
kmod-usb-ohci - 2.6.32.10-1
kmod-usb-serial - 2.6.32.10-1
kmod-usb-uhci - 2.6.32.10-1
kmod-usb2 - 2.6.32.10-1
libc - 0.9.30.1-42
libgcc - 4.3.3+cs-42
libiptc - 1.4.6-2
liblua - 5.1.4-6
libncurses - 5.7-2
libnl-tiny - 0.1-1
libpcap - 1.0.0-2
libuci - 12012009.5-1
libuci-lua - 12012009.5-1
libusb - 0.1.12-2
libxtables - 1.4.6-2
lua - 5.1.4-6
luci - 0.9.0-1
luci-admin-core - 0.9.0-1
luci-admin-full - 0.9.0-1
luci-admin-mini - 0.9.0-1
luci-app-firewall - 0.9.0-1
luci-app-initmgr - 0.9.0-1
luci-cbi - 0.9.0-1
luci-core - 0.9.0-1
luci-http - 0.9.0-1
luci-i18n-english - 0.9.0-1
luci-ipkg - 0.9.0-1
luci-lmo - 0.9.0-1
luci-nixio - 0.9.0-1
luci-sgi-cgi - 0.9.0-1
luci-sys - 0.9.0-1
luci-theme-base - 0.9.0-1
luci-theme-openwrt - 0.9.0-1
luci-uci - 0.9.0-1
luci-uvl - 0.9.0-1
luci-web - 0.9.0-1
mtd - 12
netcat - 0.7.1-2
opkg - 513-2
ppp - 2.4.4-5
ppp-mod-pppoe - 2.4.4-5
radvd - 1.6-1
screen - 4.0.3-2
swconfig - 5
tcpdump - 4.0.0-2
uci - 12012009.5-1
udevtrigger - 106-1
uhttpd - 7
usbutils - 0.86-1
wireless-tools - 29-4
wpad-mini - 20100309-1
zlib - 1.2.3-5

Final check of this stage:

  • Check if your computer gets an IPv6 address with the prefix bbbb.
  • Ping the router using IPv6: ping6 bbbb::1
  • Check whether you want another cup of coffee.

2. Configure USB Stick & Computer

Now, we need to establish the communication to the 6LoWPAN network. Just plug the USB stick into the router and observe the output of dmesg. You should see that the Linux kernel brings up a new device called usb0 or similar. I get the following output:

usb 1-1: new full speed USB device using ar71xx-ehci and address 2
usb 1-1: configuration #130 chosen from 5 choices
usb0: register 'cdc_ether' at usb-ar71xx-ehci-1, CDC Ethernet Device, 02:11:22:33:44:55
cdc_acm 1-1:130.2: ttyACM0: USB ACM device

Now, lets configure this network device. As I said earlier, we will use the aaaa prefix for the 6LoWPAN network. You can simply configure the usb0 device like any other device in OpenWRT. My /etc/config/network contains this section:

    config interface pan             
        option ifname   usb0       
        option proto    static    
        option ip6addr  aaaa::1/64

Now, ping6 this device while you're logged into the router:

# ping6 aaaa::1
PING aaaa::1 (aaaa::1): 56 data bytes
64 bytes from aaaa::1: seq=0 ttl=64 time=0.368 ms
64 bytes from aaaa::1: seq=1 ttl=64 time=0.327 ms
64 bytes from aaaa::1: seq=2 ttl=64 time=0.324 ms
^C
--- aaaa::1 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.324/0.339/0.368 ms

Whee! Your 6LoWPAN interface should work now. But you also need to advertise the network to your Ethernet/WLAN network. Put this in your radvd config:

    interface usb0                                                                    
    {                                                                                 
            AdvSendAdvert on;                                                         
            AdvLinkMTU 1280;                                                          
            AdvCurHopLimit 128;                                                       
            AdvReachableTime 360000;                                                  
            MinRtrAdvInterval 100;                                                    
            MaxRtrAdvInterval 150;                                                    
            AdvDefaultLifetime 200;                                                   
            prefix aaaa::/64                                                          
            {                                                                         
                    AdvOnLink on;                                                     
                    AdvAutonomous on;                                                 
                    AdvPreferredLifetime 4294967295;                                  
                    AdvValidLifetime 4294967295;                                      
            };                                                                        
    };       

Please restart the radvd daemon to tell him that the network configuration has changed. Afterwards, the ping6 command should also work from your computer.

3. Hook up the sockets

Pairing the socket

For first use, the usb stick and the socket must be paired. Press the button on the usb stick for 2 seconds, until the LED flashes red. Do the same on the socket for 2 seconds. The two devices get paired, both should blink 3 times green afterwards.

Connecting to the socket

Before you connect the socket, you need to identify the IPv6 adress that you're going to use. Typically, a sticker on the socket shows its mac address. Since you know the network prefix (aaaa in this example), you can compute the network address for the socket:

TODO: Show computation.

Alternatively, you can use a network sniffer to observe the network. Currently, there are two tools documented:

In the following examples, I assume the link-local address of the socket to be fe80::11:22ff:fe33:4411, while the routed address is aaaa::11:22ff:fe33:4411. Make sure that the usb stick is connected to the router, is properly configured and that radvd is running on the router. You should be able to ping the socket from your computer:

$ ping6 aaaa::11:22ff:fe33:4411
PING6(56=40+8+8 bytes) bbbb::f07b:a2b8:ed4e:8c19 --> aaaa::11:22ff:fe33:4411
16 bytes from aaaa::11:22ff:fe33:4411, icmp_seq=0 hlim=127 time=73.636 ms
16 bytes from aaaa::11:22ff:fe33:4411, icmp_seq=1 hlim=127 time=73.646 ms

You can also access the builtin webserver on the socket. Please note that you have to enter the IPv6 address in square brackets:

Hexabus builtin webserver

If you navigate to the "Socket Status" page, you can switch the socket from your browser:

Hexabus builtin webserver

The configuration page allows you to set different parameters such as the default state of the relay after power loss.

Hexabus builtin webserver

You might notice the DNS name "Socket" - this is actually the name that is broadcasted using MDNS. This means that you also can access the socket using a normal DNS name - in my case "socket.local":

Hexabus builtin webserver

The configuration of the MDNS-Mechanism is beyond the scope of this guide.

Where to go now

Now that your initial setup is complete, you may want to explore the following pages:

  • HexaBusProgramming: How to use the builtin bootloader, how to write extensions
  • HexaBusHostSoftware: There are small POSIX tools that can switch the HexaBus plug remotely.
  • MDNSSetup: How to configure the MDNS responder to forward HexaBus device names.
Clone this wiki locally