-
11Step 11
Plumbery : syslog-ng
One of the good thing to interact with a Linux distribution is that a lot of mechanism are familiar. Especially restarting syslog-ng :
[root@kindle root]# /etc/init.d/syslog-ng restart system: I syslog-ng:def:stopping syslog-ng system: I syslog-ng:def:waiting for syslog-ng to die off system: I syslog-ng:def:waited 1 second system: I syslog-ng:def:waited 1 second system: I syslog-ng:def:waited 1 second system: I syslog-ng:def:starting syslog-ng
Nice we will soon be able to test the plumbing ;-) -
12Step 12
Home automation emulator
The python script you started on point 7 displays on the screen this kind of logs :
Docs $ python2 http_relay.py Server Starts - mbp:8080 192.168.1.110 - - [11/Aug/2015 21:36:36] "GET /?toggle=switch HTTP/1.0" 200 - 192.168.1.110 - - [11/Aug/2015 21:36:36] "GET /?toggle=the HTTP/1.0" 200 - 192.168.1.110 - - [11/Aug/2015 21:36:36] "GET /?toggle=CUISINE HTTP/1.0" 200 - 192.168.1.110 - - [11/Aug/2015 21:36:36] "GET /?toggle=BUREAU HTTP/1.0" 200 -
We can see the host and the port on the first lineAll following lines are for :
IP - - [DATE HOUR] "GET url_requested" 200.
You can repeat the commands on step 7 and see all new requests appear on the screen. You can also repeat commands on step 9 for the almost same result.
There is only one difference, the ip (first data of the line) of your computer and ip of your kindle (mine is 192.168.1.110).
-
13Step 13
Crafted ebook
Move the ebook from /tmp/ to /mnt/base-us :
[root@kindle root]# cp /tmp/domotique.pdf /mnt/base-us/documents/
Refresh kindle internal list of ebooks:
[root@kindle root]# dbus-send --system /default com.lab126.powerd.resuming int32:1
And now from the kindle open the ebook named "Domotique - PoC", and move cursor to words CUISINE or BUREAU and see logs in python script outputs.
-
14Step 14
Cleaning the kindle
At this time of the demo, one command is MANDATORY to your kindle : reverting to old syslog-ng.conf !
[root@kindle root]# mntroot rw system: I mntroot:def:Making root filesystem writeable /dev/mmcblk0p1 on / type ext3 (rw,noatime,nodiratime) [root@kindle root]# cd /etc/syslog-ng/ [root@kindle root]# cp syslog-ng.conf.ok syslog-ng.conf
This line MUST be commented with a # !
#log { source(src); filter(f_cvm); destination(cvm); };
-
15Step 15
(optional : the msp430 leds)
This is probably the less interesting part of the project BUT this it take most of the attention. I choose msp430 because it's :
- affordable
- has two leds
- easy to configure
- easy to program with energia.
So you have to
- Open the sketch provided in Docs
- Uploading it to the msp430
My msp430 is available to /dev/msp430. To manually set on/off leds I use echo.
Docs $ echo "1" > /dev/msp430 #toggle led1 -> on Docs $ echo "1" > /dev/msp430 #toggle led1 -> off Docs $ echo "0" > /dev/msp430 #toggle led0 -> on Docs $ echo "0" > /dev/msp430 #toggle led0 -> off
-
16Step 16
(optional : survive at reboot)
It's a caveat you MUST be aware : if syslog-ng can't find the program it will try to relaunch it over and over. It will drain your battery in less than a day.
There is a better place to store read_fifo. The better candidate is /opt/, maybe you prefer /usr/bin but consider /opt/.
- remount root filesystem read-write
- stop syslog-ng
- move read_fifo to /opt/ (even better /opt/homeautomation/)
- change destination cvm program path of /etc/syslog-ng/syslog-ng.conf to the appropriate path
- remount root filesystem read-only
- start syslog-ng
-
17Step 17
(optional : more events)
With this demo I only documented (for now) only one event : SupplementarInfoBox.
I tend to write my code as generic as possible and you can easily extend the actual code to other events even whose are not related to cvm.
Have a look in Docs/kindle.log to see what is generally available from power, to screensaver, to network related stuff, amazon stats …
Don't hesitate to ping me for help :-)May the tinkering be with you.
Cheers !
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.