Übersetzungen dieser Seite:

Smart-SARAH am Raspberry Pi

Smaer-Sarah

Spiele die Images auf eine SD Karte.

wget http://www.open-entry.com/osdomotics/osd-bin/smart-sarah/2013-08-19-wheezy-raspbian-sarah.tgz
tar -xzf 2013-08-19-wheezy-raspbian-sarah.tgz
dd bs=4M if=2013-08-19-wheezy-raspbian-sarah.img of=/dev/sd<d?>
Default login 	Username: pi Password: raspberry

Images findet man hier: http://www.open-entry.com/osdomotics/osd-bin/smart-sarah

Nach dem Starten des Pi können mit Hilfe eines Browsers die Verschiedenen Webdienste aufgerufen werden:

Design-View

Setup-View

Routing-View

Install Smart-SARAH

Smart-SARAH

apt-get update
apt-get upgrade

wget https://github.com/osdomotics/smart-sarah/archive/master.zip
unzip master.zip

tunslip6

wget https://github.com/osdomotics/osd-contiki/archive/osd.zip
unzip osd.zip
osd-contiki-osd/tools
make tunslip6
chmod 766 tunslip6
cp tunslip6 /usr/sbin/

RADVD

apt-get install radvd
cp smart-sarah-master/banana-edge/etc/radvd.conf /etc/radvd.conf
service radvd start

OMD

gpg --recv-keys 24BFF712
gpg --armor --export 24BFF712 | apt-key add -
# Add our repository for Debian 8 (jessie):
echo "deb http://dl.bananian.org/packages/ jessie main" > /etc/apt/sources.list.d/bananian.list
apt-get update
apt-get install omd-1.30

Coap

apt-get -y install libnagios-plugin-perl libnetaddr-ip-perl
wget http://downloads.sourceforge.net/project/libcoap/coap-18/libcoap-4.0.3.tar.gz
tar -xzf libcoap-4.0.3.tar.gz
cd libcoap-4.0.3
apt-get install autoconf
autoconf
apt-get install build-essential
./configure
make
cp examples/coap-client /usr/local/bin/
cd ..

check_coap

omd create mysite
wget https://github.com/osdomotics/check_coap/archive/master.zip
unzip master.zip
cd check_coap-master
cp check_coap* /omd/sites/mysite/lib/nagios/plugins/
cd nagios-conf.d/
cp coap_templates.cfg /omd/sites/mysite/etc/nagios/conf.d/
cp triops.cfg /omd/sites/mysite/etc/nagios/conf.d/
cd ..
cd ..
omd restart

OLD

Du hast einen Raspberry mit Raspian am laufen dann:

In der Console geben wir ein:

git clone https://github.com/osdomotics/smart-sarah.git
cd smart-sarah/raspi-edge/
sudo ./edge_install_script.sh

from scratch

Diese Anleitung fasst die Installation der Komponenten für ein Smart-SARAH System auf einem Raspberry Pi zusammen. Die einzelnen Teilschritte sind nur grob umrissen, bitte unbedingt die jeweiligen Installationsanleitungen lesen und verstehen!

Vorbereitungen

Wir beginnen mit einem Raspberry Pi mit Raspbian als Linux-Distribution.

„Installation“:

unzip 2013-05-25-wheezy-raspbian.zip
dd bs=4M if=2013-05-25-wheezy-raspbian.img of=/dev/sd<d?>

SHA-1 	131f2810b1871a032dd6d1482dfba10964b43bd2
Default login 	Username: pi Password: raspberry

Ist diese auf eine passende SD-Karte übertragen, muss nach der Erstinstallation noch IPv6 aktiviert werden:

/etc/modprobe.d/ipv6.conf
# Don't load ipv6 by default
# alias net-pf-10 off
#alias ipv6 off

Die Zeile mit ipv6 off muss auskommentiert sein, dann haben wir auch Verbindung zu den Sensoren ;-)

Jetzt parametrieren wir ipv6 forwarding durch Aktivierung nachstehender Configzeile:

sudo nano /etc/sysctl.conf
net.ipv6.conf.default.forwarding=1

Software installieren

  sudo aptitude update && sudo aptitude upgrade -y

Zu den bereits installierten Paketen kommen folgende hinzu:

  • autoconf
  • lighttpd
  • php5-cgi
  • libcurl4-openssl-dev
  • libcppunit-dev
  • liblog4cpp5-dev
  • liblua5.1-0-dev
  • vim (optional, but very helpful :)
sudo aptitude install autoconf lighttpd  php5-cgi  libcurl4-openssl-dev libcppunit-dev liblog4cpp5-dev liblua5.1-0-dev vim -y

lighttpd

Damit PHP als FastCGI ausgeführt wird, müssen die passenden Module im Lighttpd aktiviert werden:

pi@raspberrypi ~ $ sudo su -
root@clipi:~# lighttpd-enable-mod fastcgi
Enabling fastcgi: ok
Run /etc/init.d/lighttpd force-reload to enable changes
root@clipi:~# lighttpd-enable-mod fastcgi-php
Enabling fastcgi-php: ok
Run /etc/init.d/lighttpd force-reload to enable changes

root@clipi:~# ls /etc/lighttpd/conf-enabled/
10-fastcgi.conf  15-fastcgi-php.conf

root@clipi:~# /etc/init.d/lighttpd force-reload
[ ok ] Reloading web server configuration: lighttpd.

pthsem

Pthsem ist eine Bibliothek für Threading. Sie wird von linknx benötigt.

root@clipi:~# wget http://www.auto.tuwien.ac.at/~mkoegler/pth/pthsem_2.0.8.tar.gz
root@clipi:/usr/src# tar xf ~/pthsem_2.0.8.tar.gz
root@clipi:/usr/src/pthsem-2.0.8# ./configure
[...]
root@clipi:/usr/src/pthsem-2.0.8# make
[...]
root@clipi:/usr/src/pthsem-2.0.8# make test
[...]
OK - ALL TESTS SUCCESSFULLY PASSED.
[...]
root@clipi:/usr/src/pthsem-2.0.8# make install

libcoap

Die derzeit verwendete Version von Contiki-OS unterstützt CoAP-13:

root@clipi:/usr/src# git clone git://libcoap.git.sourceforge.net/gitroot/libcoap/libcoap
root@clipi:/usr/src/libcoap# autoconf
root@clipi:/usr/src/libcoap# ./configure
root@clipi:/usr/src/libcoap# make
root@clipi:/usr/src/libcoap# cp examples/coap-client /usr/local/bin/
root@clipi:/usr/src/libcoap# coap-client -m get coap://node3.6lowpan.smekal.at:5683/sensors/button
{
 "name" : "button1",
 "state" : "off"
}

linknx

Zur Sicherheit aktualisieren wir unseren Library Pfad:

sudo ldconfig

autoreconf -i -I /usr/local/share/aclocal

Linknx herunterladen und installieren …

root@clipi:~# wget http://downloads.sourceforge.net/project/linknx/linknx/linknx-0.0.1.30/linknx-0.0.1.30.tar.gz
or unstable:
root@clipi:~# wget -O linknx.tar "http://linknx.cvs.sourceforge.net/viewvc/linknx/linknx/?view=tar"

root@clipi:/usr/src/linknx-0.0.1.30# ./configure --with-cppunit-prefix --with-cppunit-exec-prefix --with-libcurl --with-log4cpp --with-lua
root@clipi:/usr/src/linknx-0.0.1.30# make
[...]
root@clipi:/usr/src/linknx-0.0.1.30# make install

Danach werden User und Verzeichnisse eingerichtet.

root@clipi:~# useradd -r -g nogroup knx
root@clipi:~# mkdir -p /var/lib/linknx/persist /var/log/linknx /etc/linknx
root@clipi:~# chown knx:nogroup /var/log/linknx

Eine Konfigurationsdatei wird unter /etc/default/linknx angelegt:

/etc/default/linknx
# To enable eibd at startup set this everything != NO
START_LINKNX=YES
 
# Daemon options
REMOTE_ARGS="--config=/etc/linknx/smart-sarah.xml --write=/etc/linknx/smart-sarah.xml"

Ein Startscript ist im Open-entry Wiki zu finden. Es muss noch aktiviert werden:

root@clipi:~# update-rc.d linknx defaults
update-rc.d: using dependency based boot sequencing

Die linknx Konfigurationsdatei kann etwa so aussehen:

/etc/linknx/smart-sarah.xml
<?xml version="1.0" ?>
<config>
    <services>
        <knxconnection url="ip:127.0.0.1" />
        <xmlserver type="inet" port="1028"/>
        <exceptiondays>
            <date day="1" month="1" />
            <date day="1" month="5" />
            <date day="15" month="8" />
            <date day="25" month="12" />
            <date day="1" month="4" year="2013" />
            <date day="9" month="5" year="2013" />
            <date day="20" month="5" year="2013" />
            <date day="21" month="4" year="2014" />
            <date day="29" month="5" year="2014" />
            <date day="9" month="6" year="2014" />
        </exceptiondays>
    </services>
    <objects>
        <object type="1.001" id="test_on_off" gad="1/1/1">Objet test</object>
        <object type="10.001" id="cur_time" gad="1/1/200">Current Time</object>
        <object type="11.001" id="cur_date" gad="1/1/201" flags="cwtuf">Current Date</object>
    </objects>
    <rules>
        <rule id="cur_time_date">
            <condition type="timer" trigger="true">
                <every>1h</every>
            </condition>
            <actionlist>
                <action type="set-value" id="cur_time" value="now" />
                <action type="set-value" id="cur_date" value="now" />
            </actionlist>
        </rule>
    </rules>
</config>

Mehr darüber kann die Linknx Dokumentation verraten.

linknx kann nun gestartet werden:

root@clipi:~# /etc/init.d/linknx start

knxweb

KnxWeb ist das Webinterface zu linknx. Es basiert auf PHP und Javascript (JQuery um genau zu sein).

Installiert wird wie folgt:

root@clipi:~# wget http://downloads.sourceforge.net/project/linknx/knxweb/knxweb-0.9/knxweb-0.9.2.tar.gz
or unstable
root@clipi:~# wget -O knxweb.tar "http://linknx.cvs.sourceforge.net/viewvc/linknx/knxweb/?view=tar"
root@clipi:~# cd /var/www/
root@clipi:/var/www# tar xf ~/knxweb-0.9.2.tar.gz
root@clipi:/var/www/knxweb2# chown -R www-data /var/www/knxweb2/pictures/
root@clipi:/var/www/knxweb2# chown -R www-data /var/www/knxweb2/design/
root@clipi:/var/www/knxweb2# mkdir /var/www/knxweb2/template/template_c/
root@clipi:/var/www/knxweb2# chown -R www-data /var/www/knxweb2/template/template_c/
root@clipi:/var/www/knxweb2# chown -R www-data /var/www/knxweb2/include/

Danach konfiguriert man KnxWeb über den Webbrowser unter http://<smart-sarah.local>/knxweb/knxweb2/check_install.php

openhab

Wenn man openHAB auf einem Raspberry Pi betreibt, muss man ein paar Dinge beachten, um einen stabilen Betrieb und eine brauchbare Performance zu erreichen.

http://www.gsurf.de/openhab-auf-raspberry-pi/

edge-router

Wenn man den OSD-Funkstick sein eigen nennt, verwandelt man den Raspberry mit Hilfe von tunslip6 und Radvd in einen 6loWPAN Edge-Router.

Als erster spielt man die Firmware „rpl-border-router“ in den Funkstick.

http://www.open-entry.com/osdomotics/osd-bin/osd-20130225/rpl-boarder-router

Danach benötigen wir einen Tunslip Client unter Linux. Wir compilieren uns Tunslip6

Kopiere die Datei tunslip6.c vom OSD-Contiki in den Raspi.

wget https://raw.githubusercontent.com/osdomotics/osd-contiki/master/tools/tunslip6.c
gcc tunslip6.c -o tunslip6
chmod 766 tunslip6
sudo cp tunslip6 /usr/sbin/

Jetzt legen wir unser Startscript tunslip6.sh unter /usr/sbin/ an und kopieren den folgenden Inhalt hinein:

#! /bin/sh
echo -n "start slip .. ";
# disable autoconfiguration, enable eth0
echo 0 > /proc/sys/net/ipv6/conf/default/accept_ra
echo 1 > /proc/sys/net/ipv6/conf/eth0/accept_ra

# get panid from uboot
  panid="AAAC"
# get lowpanprefix from uboot
  lowpanprefix="aaaa::"
# start daemon
#tunslip6 -B 115200 -L -v3 -s ttyFIM0 aaaa::1/64 &
/usr/sbin/tunslip6 -B 38400 -L -v3 -s ttyUSB0 ${lowpanprefix}1/64 &
sleep 10
ifconfig tun0 inet  up
#ifconfig tun0 fe80::1/64
#ifconfig tun0 ${lowpanprefix}1/64

# get mac address from uboot and calculate devaddr

devaddr="ba27:ebff:fef1:8e19"
# get ipprefix from uboot
echo "set eth0 ipv6 address"
  ipprefix="abbb::"

ifconfig eth0 add ${ipprefix}${devaddr}/64
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
sleep 2
# bird ripng
#/usr/sbin/buildbirdconf.sh
sleep 2
#bird -s var/run/bird6.ctl -c /etc/bird.conf
#/etc/init.d/bird6 restart &
# Radvd
/etc/init.d/radvd restart &
echo -n "done ";
#end

Und geben ihm die Rechte:

chmod 766 tunslip.sh

Als letztes benötigen wir noch den init Dämon „tunslip6“:

pi@clipi ~ $ cat /etc/init.d/tunslip6
#! /bin/sh
### BEGIN INIT INFO
# Provides:          skeleton
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Example initscript
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.
### END INIT INFO

# Author: Foo Bar <foobar@baz.org>
#
# Please remove the "Author" lines above and replace them
# with your own name if you copy and modify this script.

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="tunslip6 6loWPAN"
NAME=tunslip6.sh
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS="--options args"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
                || return 1
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
                $DAEMON_ARGS \
                || return 2
        # Add code here, if necessary, that waits for the process to be ready
        # to handle requests from services started subsequently which depend
        # on this one.  As a last resort, sleep for some time.
}

#
# Function that stops the daemon/service
#
do_stop()
{
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
        RETVAL="$?"
        [ "$RETVAL" = 2 ] && return 2
        # Wait for children to finish too if this is a daemon that forks
        # and if the daemon is only ever run from this initscript.
        # If the above conditions are not satisfied then add some other code
        # that waits for the process to drop all resources that could be
        # needed by services started subsequently.  A last resort is to
        # sleep for some time.
        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
        [ "$?" = 2 ] && return 2
        # Many daemons don't delete their pidfiles when they exit.
        rm -f $PIDFILE
        return "$RETVAL"
}

#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
        #
        # If the daemon can reload its configuration without
        # restarting (for example, when it is sent a SIGHUP),
        # then implement that here.
        #
        start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
        return 0
}

case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
        do_start
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  status)
        status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
        ;;
  #reload|force-reload)
        #
        # If do_reload() is not implemented then leave this commented out
        # and leave 'force-reload' as an alias for 'restart'.
        #
        #log_daemon_msg "Reloading $DESC" "$NAME"
        #do_reload
        #log_end_msg $?
        #;;
  restart|force-reload)
        #
        # If the "reload" option is implemented then remove the
        # 'force-reload' alias
        #
        log_daemon_msg "Restarting $DESC" "$NAME"
        do_stop
        case "$?" in
          0|1)
                do_start
                case "$?" in
                        0) log_end_msg 0 ;;
                        1) log_end_msg 1 ;; # Old process is still running
                        *) log_end_msg 1 ;; # Failed to start
                esac
                ;;
          *)
                # Failed to stop
                log_end_msg 1
                ;;
        esac
        ;;
  *)
        #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
        echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
        exit 3
        ;;
esac

:

Danach melden wir das tunslip6 Startscript im init.d an.

sudo update-rd.d tunslip6 defaults

radvd

Jetzt fehlt uns noch das Routing Danach installieren wir den Radvd Demon:

apt-get install radvd

Danach erzeugen wir die /etc/radvd.conf Datei

nano /etc/radvd.conf
interface eth0
{
  AdvSendAdvert on;
  prefix abbb::/64
  {
    AdvOnLink on;
    AdvAutonomous on;
   AdvRouterAddr on;
  };
};

interface tun0
{
    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;
    };
};

Aktiviere den Dämon mit Hilfe von rcconfig oder einem andern Tool.

Restarte den Raspberry

Viel Spaß beim Experimentiren.


Wer den Bird anstatt den Radvd verwenden will findet hier eine experimentelle Anleitung:

Bird6 Experimente

Danach installieren wir den Bird Demon:

apt-get install bird6

Danach ändern wir die bird6.conf Datei

# bird.conf
#
# dynamic routing configuration
#
# v0.1 2011-10-21 GS (goesta@smekal.at)

# global parameters

log syslog all;
debug protocols { routes, events, packets };

router id 192.168.3.32;

## routing protocols

# device parameters
protocol device {
  scan time 10;
  primary "eth0" abbb::240:9dff:fe3b:c804;
  primary "tun0" aaaa::1;
}

protocol direct{
  interface "*";
}

# kernel routing table
protocol kernel {
  scan time 10;
  persist yes;
  learn yes;
  import all;
  export all;
}

# router advertisments
protocol radv {
  interface "tun0";
  interface "eth0";
}

# dynamic routing using RIPng
protocol rip myrip{
  authentication none;
#  authentication md5;
#  password "verysecure";
  honor neighbor;
  import all;
  export all;
  interface "eth0" { metric 1; };
}

de/projekte/smart-sarah/raspberry.txt · Zuletzt geändert: 2016/06/21 16:01 von harald42