Benutzer-Werkzeuge

Webseiten-Werkzeuge


Übersetzungen dieser Seite:
de:coap-linknx

Install linknx

Install:

apt-get install build-essential

apt-get install php5-cgi lighttpd

Nun aktivieren wir den Fast-cgi Mode:

lighttpd-enable-mod fastcgi

nano /etc/lighttpd/lighttpd.conf

insert at the end:

fastcgi.server = (
    ".php" => (
      "localhost" => (
        "bin-path" => "/usr/bin/php-cgi",
        "socket" => "/var/run/lighttpd/php-fastcgi.sock",
        "max-procs" => 4, # default value
        "bin-environment" => (
          "PHP_FCGI_CHILDREN" => "1", # default value
        ),
        "broken-scriptfilename" => "enable"
      ))
)

save and exit

/etc/init.d/lighttpd restart

download: http://www.auto.tuwien.ac.at/~mkoegler/index.php/pth

pthsem_2.0.8.tar.gz

To build the Debian package, download the tar.gz and extract it, change into the created directory and then run

apt-get install cdbs

chmod a+x debian/rules

dpkg-buildpackage -rfakeroot

cd ..

dpkg -i libpthsem20_2.0.8_i386.deb libpthsem-dev_2.0.8_i386.deb

downloads:

linknx-0.0.1.30.tar.gz

knxweb-0.6.1.tar.gz

extract knxweb-0.6.1.tar.gz to /var/www

extract linknx-0.0.1.30.tar.gz in your home directory

apt-get install libcurl4-dev libcppunit-dev liblog4cpp5-dev liblua5.1-0-dev

cd linknx-0.0.1.30

./configure –with-cppunit-prefix –with-cppunit-exec-prefix –with-libcurl –with-log4cpp –with-lua

make

make install

mkdir /var/lib/linknx/

mkdir /var/lib/linknx/persist/

mkdir /var/log/linknx/

adduser knx

chown knx /var/log/linknx/

Nun speichern wir unsere default startparameter unter defaults/linknx ab:

nano /etc/default/linknx

# To enable eibd at startup set this everything != NO
START_LINKNX=YES

# Daemon options
REMOTE_ARGS="--config=/etc/linknx/house.xml"

copy the linknx-startscript linknx to /etc/init.d/linknx

mkdir /etc/linknx

nano /etc/linknx/house.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="25" month="4" year="2011" />
            <date day="2" month="6" year="2011" />
            <date day="13" month="6" year="2011" />
            <date day="9" month="4" year="2012" />
            <date day="17" month="5" year="2012" />
            <date day="28" month="5" year="2012" />
            <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>

linknx kann mittels init.d gestartet werden:

/etc/init.d/linknx start

6LoWPAN & linknx

Nun wollen wir linknx mit unserem 6LoWPAN Netz mit hilfe des Coap Protokolls kommunizieren lassen:

Install coap-clinet

Currently mainline contiki implements coap-08 in erbium (used by erbr and rplinfo). To get the latest version of libcoap that works with with this version of erbium:

apt-get install doxygen automake
git clone git://libcoap.git.sourceforge.net/gitroot/libcoap/libcoap
cd libcoap
git checkout a662f73
autoconf
./configure
make
cp examples/coap-client /usr/local/bin

house.xml

Anbei ist eine demo house.xml Datei welche eine Led an einem Funkknoten Ein/Aus Schaltet und einen Temperatursensor einliest.

<?xml version="1.0" ?>
<config>
    <objects>
        <!-- ETS values exported as CSV, and parsed with some shell scripting -->
	<object type="1.001" id="3" gad="0/0/1">Toggleboard (on/off) </object>
	<object type="1.001" id="4" gad="0/0/2">Kitchen main light (on/off) </object>
        <object type="16.000" id="7" gad="0/0/5">Temp (DS1820) </object>
    </objects>
    <services>
        <xmlserver type="inet" port="1028"/>
        <persistence type="file" path="/var/lib/linknx/persist" logpath="/var/log/linknx/"/>
	<location lon="-3.41" lat="50.86"/>
	<!-- exceptiondays for heating -->
        <exceptiondays>
            <date month="10" />
            <date month="11" />
            <date month="12" />
            <date month="1" />
            <date month="2" />
            <date month="3" />
        </exceptiondays>
    </services>
    <rules>
        <!-- some general lights rules -->
        <rule id="led_on">
		<condition type='object' id='3' trigger='true' value='on'>
	    </condition>
	    <actionlist>
	        <!-- led Toggleboard -->
		<action type="shell-cmd" cmd="coap-client -mput coap://[aaaa::ff:fe00:3]:5683/led1 -e 'mode=on'" />
	    </actionlist>
	</rule>
        <!-- some general lights rules -->
        <rule id="led_off">
                <condition type='object' id='3' trigger='true' value='off'>
            </condition>
            <actionlist>
                <!-- leds Toggleboard -->
                <action type="shell-cmd" cmd="coap-client -mput coap://[aaaa::ff:fe00:3]:5683/led1 -e 'mode=off'" />
            </actionlist>
        </rule>
        <rule id="get temp">
                <condition type="timer" trigger="true">
                        <every>15</every>
                </condition>
                <actionlist>
                        <!-- set temp from devices -->
                        <action type="script">
                        local file = assert(io.popen('coap-client -B10 coap://[aaaa::ff:fe00:7]:5683/DS1820', 'r'));
                        local output = file:read(5);
                        file:close();
			if not output then
			output="*";
			end
                        set("7", output);
                        </action>
                </actionlist>
        </rule>
    </rules>

</config>
de/coap-linknx.txt · Zuletzt geändert: 2013/02/06 15:32 von wikisysop