Compare commits

...

18 Commits
py3 ... master

Author SHA1 Message Date
Door Buzz dab6ca239e adapted to the new way of doing lirc on rPi (stretch/systemd) 2018-03-14 20:18:02 +00:00
Door Buzz 379d3476b2 after reinstall: improved installation instructions 2018-03-14 12:53:05 +00:00
Door Buzz 0294d7ed8f after reinstall: improved installation instructions 2018-03-14 12:38:48 +00:00
Door Buzz c2cf4632fc after reinstall: improved installation instructions 2018-03-14 12:34:29 +00:00
doorbuzz 74eeb693a9 Merge branch 'master' of github.com:syn2cat/doorbuzz 2016-09-05 20:36:17 +02:00
doorbuzz d30d8bcd2b add timeout on read to avoid haning on the ssh tunnel 2016-09-05 20:11:17 +02:00
Georges Herber ecfca93d0d gunsticks unsaved changes 2016-05-07 08:38:24 +02:00
Level2 DoorBuzz de23e91533 pushing latest changes before doorbuzz dies completely" 2016-05-06 20:23:01 +02:00
Georges Herber 950267983a fixed typo 2016-04-03 10:10:14 +02:00
Georges Herber efe9414387 Merge branch 'master' of github.com:syn2cat/doorbuzz 2016-04-03 10:08:21 +02:00
Georges Herber 7883890571 added ssh config to readme 2016-04-03 10:07:50 +02:00
Georges Herber 03d2a4d9ff added separate power on/off buttons instead of single poweronoff 2016-04-02 16:52:24 +02:00
Georges Herber f78aab2f7f correcting lirc gpio pins 2016-04-01 23:26:59 +02:00
Georges Herber 06f9ca0f7b added lirc config to readme 2016-04-01 20:11:02 +02:00
Georges Herber eb3efc964e added lirc config 2016-04-01 20:01:40 +02:00
Raphaël Vinot a2f99ab3c2 Some more cleanup 2016-04-01 14:17:22 +02:00
Raphaël Vinot 07af5bf48a Typo 2016-04-01 00:39:11 +02:00
Raphaël Vinot f1bf78ca91 Make clean scripts 2016-04-01 00:37:54 +02:00
17 changed files with 465 additions and 63 deletions

View File

@ -14,31 +14,67 @@ how to install
* The basics
```
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install vim tmux
# now you get funky errors: "unexpected end of file or stream"
# fix it:
sudo apt-get clean
sudo apt-get --fix-broken install
* sometimes you ask yourself why the locales are not generated as needed
sudo sed -i "$(locale | awk -F= '$2!=""{gsub("\"","");if(!a[$2]++){print "s/# *" $2 "/" $2 "/;"}}' )" /etc/locale.gen
sudo locale-gen
```
* authorize boorduzz to connect to pidor and vice versa
```
mkdir /home/pi/.ssh
chmod go= /home/pi/.ssh /home/pi/.ssh/authorized_keys
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTVHK+yXSXHm42vr1RZ4sgKBFdkL3vi1u8BXYD/zkcbJkDSyWWRlU5q/qzEQYVk2zae870jcSQ5oTeoLZ99ujkuGltTCdzcCin24Aoig8ATyztFXoSHIfdUPCw5dbjhQXGWRPIkk1lSGU6mtLJRmVwLeY0rzVSQKdlspQlKBLwFBeIuACZQZfUzbIB2XiHIaoxcUja9fRfsZpo9TsWiqCMbseAj926qUgV2iotTQF7XLF/f+H8j2MR3iltKHqc35y/PiWy2doxRFHjW9I66Bit+ddOBtrsL6AzjxZP1DyoAc7jqhRpVazeXkMeNPMigpsV4rhLMEeVi2OqgTO7d3Jv root@pidor" >> /home/pi/.ssh/authorized_keys
```
copy the doorbuzz private key to /home/pi/.ssh/doorbuzz (backup of the key located on pidor at /root/.ssh/doorbuzz)
cp -p ~/.ssh/doorbuzz ~/.ssh/id_rsa
* get the package
cd /home/pi
git clone https://github.com/syn2cat/doorbuzz
cd doorbuzz
git config --global user.email "infolevel2.lu"
git config --global user.name "Door Buzz"
git remote set-url origin git@github.com:syn2cat/doorbuzz.git
* If you want to chroot into the image have a look at [this script](https://github.com/CIRCL/Circlean/blob/master/proper_chroot.sh)
* Remove screensaver from `/etc/xdg/lxsession/LXDE/autostart`
* Remove screensaver from `/etc/xdg/lxsession/LXDE/autostart `
``` bash
sudo vi /etc/xdg/lxsession/LXDE/autostart
```
* Copy the files present in `root_files` accordingly on the file system
* Set the hostname: replace the content of `/etc/hostname` with doorbuzz
** sets IP without using dhcp
** sets hostname (replace the content of `/etc/hostname` with door-buzz)
** sets localhost alias
** removes screensaver in /etc/xdg/lxsession/LXDE/autostart
** configures lirc
* Install the suff
* Install the stuff
``` bash
sudo apt-get install unclutter xdotool git-core screen imagemagick x11-xserver-utils
cd /home/pi
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
git clone https://github.com/syn2cat/doorbuzz
mkdir -p /home/pi/.config/lxsession/LXDE/
cat > /home/pi/.config/lxsession/LXDE/autostart <<"EOF"
cat > /home/pi/.config/lxsession/LXDE-pi/autostart <<"EOF"
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xset s off
@xset -dpms
@xset s noblank
@ -62,14 +98,13 @@ when booting, the button led uses morsecode to send the low byte of the IP adres
`phone_notification_client.sh` communicates with pidor's `doorbuzz_wrapper.sh` to command the flash light
# new: using redis to manage the 60 led circle
* new: using redis to manage the 60 led circle
```
sudo apt-get install python-pip redis-server
sudo pip install redis neopixel
sudo apt-get install python-pip redis-server python-redis
```
# the redi.sh comes from here: https://github.com/crypt1d/redi.sh
* redi.sh comes from here: https://github.com/crypt1d/redi.sh
```
cd ~
@ -77,16 +112,15 @@ git clone https://github.com/jgarff/rpi_ws281x.git
cd rpi_ws281x
sudo apt-get install scons swig python-dev
scons
sudo scons
cd python
sudo python setup.py install
```
# setup watchdog
* setup watchdog
```
sudo modprobe bcm2708_wdog
echo "bcm2708_wdog" | sudo tee -a /etc/modules
sudo modprobe bcm2835_wdt
echo "bcm2835_wdt" | sudo tee -a /etc/modules
sudo apt-get install watchdog
@ -103,6 +137,21 @@ sudo service watchdog start
Note: `projectionscreen.sh` is a standalone program called remotely by pidor because pidor knows the IP adress of the projector but doorbuzz has the RF remote connected.
The remote command works with ssh, so install pidor's root pub key into `~pi/.ssh/authorized_keys`
* setup lirc for AV-receiver remote control
this is the new way of doing lirc, doc is not yet tested to replay correctly. ymmv
copy (if not yet done) files from ~pi/doorbuzz/root_files/etc/lirc/ to /etc/lirc/
https://www.raspberrypi.org/forums/viewtopic.php?t=192891
```
sudo apt-get install lirc
sudo /bin/su -c "echo 'dtoverlay=lirc-rpi,gpio_out_pin=17,gpio_in_pin=21' >> /boot/config.txt"
echo "lirc_dev" >> /etc/modules
echo "lirc_rpi gpio_in_pin=21 gpio_out_pin=17" >> /etc/modules
systemctl start lidcd.socket lircd.service
```
todo
====

View File

@ -8,7 +8,6 @@ cd $(dirname "$0")
showleds() {
./redi.sh <<EOF
valid=no
neoaction=$1
neored=$2
neogreen=$3
@ -125,10 +124,10 @@ do
else
while wget -O - --timeout=1 --tries=1 $BUZZERSTATUSURL|grep '<relay1state>1</relay1state>'
do
ledcolor 0 255 0
sleep 0.9
ledcolor 0 255 255
sleep 0.1
ledcolor 0 255 0
# sleep 0.2
ledcolor 0 255 255
# sleep 0.2
done
fi
logger $0 "button push action finished"

20
copy_to_final.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
set -e
set -x
if [ -z "$1" ]; then
echo "Path to the mounted image needed."
exit
fi
CHROOT_PATH=${1}
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
# prepare fs archive
tar -cvpzf backup.tar.gz -C root_files/ .
tar -xzf backup.tar.gz -C ${CHROOT_PATH}/

View File

@ -13,7 +13,7 @@ do
sleep 1
while true
do
read -t 1 status <&"${COPROC[0]}"
read -t 1 status <&"${COPROC[0]}" 2>/dev/null
ret=$?
if [ $ret -eq 1 ] # no more coprocess
then
@ -32,14 +32,18 @@ do
done
ocounter="$counter"
echo "peoplecounter" >&"${COPROC[1]}"
read counter <&"${COPROC[0]}"
read -t 1 counter <&"${COPROC[0]}"
if [ $? -ne 0 ]
then
counter=-1
fi
if [ "$counter" != "$ocounter" ]
then
logger $0 peoplecounter=$counter
echo "neocounter=$counter" | ./redi.sh
fi
echo "spacestatus" >&"${COPROC[1]}"
read status <&"${COPROC[0]}"
read -t 1 status <&"${COPROC[0]}"
if ! [ "$status" = "open" ]; then # do nothing if space is closed
continue
else
@ -56,10 +60,10 @@ do
fi
logger $0 "phone status change detected"
if [ "$new_status" -eq 0 ]; then
echo "neoaction=flash" | ./redi.sh
printf "neoaction=flash\nvalid=yes\n" | ./redi.sh
echo "flashon" >&"${COPROC[1]}"
else
echo "neoaction=pulse" | ./redi.sh
printf "neoaction=pulse\nvalid=yes\n" | ./redi.sh
echo "flashoff" >&"${COPROC[1]}"
fi
# echo $new_status > ${run_file}

View File

@ -1,3 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# this gives number of people present via spaceapi
# but if network down, this does not work
# better get data direct from pidor or peoplecounter

View File

@ -43,4 +43,3 @@ nohook lookup-hostname
interface eth0
static ip_address=10.2.113.9/24
static routers=10.2.113.1
static domain_name_servers=10.2.113.1

1
root_files/etc/hostname Normal file
View File

@ -0,0 +1 @@
door-buzz

6
root_files/etc/hosts Normal file
View File

@ -0,0 +1,6 @@
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 door-buzz

View File

@ -0,0 +1,26 @@
########################################################
# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS="--uinput"
# Don't start lircmd even if there seems to be a good config file
# START_LIRCMD=false
# Don't start irexec, even if a good config file seems to exist.
# START_IREXEC=false
# Try to load appropriate kernel modules
LOAD_MODULES=true
# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="default"
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"
# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""
########################################################

View File

@ -0,0 +1,19 @@
[lircd]
nodaemon = False
driver = default
device = /dev/lirc0
output = /var/run/lirc/lircd
pidfile = /var/run/lirc/lircd.pid
plugindir = /usr/lib/arm-linux-gnueabihf/lirc/plugins
permission = 666
allow-simulate = No
repeat-max = 600
uinput = True
[lircmd]
uinput = False
nodaemon = False
[modinit]
code = modprobe lirc_rpi

View File

@ -0,0 +1,9 @@
# Populated config files can be found at http://sf.net/p/lirc-remotes. The
# irdb-get(1) and lirc-setup(1) tools can be used to search and download
# config files.
#
# From 0.9.2 config files could just be dropped as-is in the lircd.conf.d
# directory and be included by this file.
include "lircd.conf.d/*.conf"

View File

@ -0,0 +1,182 @@
# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sun Mar 13 09:40:54 2016
#
# contributed by
#
# brand: /etc/lirc/pioneer.conf
# model no. of remote control:
# devices being controlled by this remote:
#
begin remote
name PIONEER
flags RAW_CODES|CONST_LENGTH
eps 30
aeps 100
gap 89162
begin raw_codes
name KEY_POWER
9109 4481 562 1674 587 518
589 1654 580 519 587 519
588 1647 589 517 588 1648
588 517 588 1655 557 542
588 1648 588 1648 588 518
563 1680 581 517 588 518
588 1648 587 518 589 1647
589 1654 582 517 563 542
588 517 590 1647 588 517
589 1648 587 524 582 518
587 1649 588 1648 588 1648
587
name KEY_POWER2
9103 4497 555 1672 588 519
562 1673 588 518 589 517
563 1672 588 518 564 1672
588 518 562 1674 569 537
587 1648 587 1650 587 518
588 1648 588 518 570 1666
588 1648 563 543 562 1674
587 1648 596 510 587 519
587 518 587 518 564 542
588 1648 587 519 563 542
595 1641 588 1648 564 1673
587
name KEY_CD
8455 4283 493 1590 534 516
534 1591 534 516 534 515
534 1595 531 515 535 1591
509 541 509 1590 534 517
534 1595 530 1590 535 515
535 1589 511 540 509 541
509 516 534 1595 530 1591
534 516 534 516 534 1591
534 516 534 1566 534 1590
535 515 535 515 535 1590
535 1590 534 516 539 1561
535
name KEY_DVD
8479 4243 556 1542 558 492
559 1565 560 490 560 490
560 1570 555 490 560 1565
560 490 560 1540 560 490
560 1564 565 1561 559 491
559 1565 560 490 560 1540
560 490 560 1570 555 490
560 490 560 490 576 473
561 1565 560 490 560 1570
530 490 560 1565 560 1565
560 1565 560 1569 531 514
536
name KEY_TAPE
8479 4246 554 1566 534 490
561 1564 560 490 560 490
561 1569 556 489 561 1564
561 489 560 1539 561 490
560 1565 561 1564 560 489
561 1565 560 489 561 1540
560 490 565 485 560 489
561 1564 561 489 561 489
561 489 561 489 561 1569
556 1564 535 1565 561 489
560 1565 560 1565 565 1560
535
name KEY_TUNER
8506 4214 560 1566 534 519
531 1565 560 490 560 489
561 1565 560 489 561 1565
565 484 561 1564 536 489
561 1564 561 1564 560 490
561 1564 561 489 561 1539
561 1564 561 1563 561 489
566 485 560 489 562 1564
560 490 561 489 560 489
561 489 536 1569 556 1564
561 1564 560 490 561 1564
560
name KEY_TV
8512 4211 558 1572 554 490
560 1540 560 490 560 490
559 1566 560 490 560 1570
555 490 560 1564 536 515
535 1565 560 1565 560 495
555 1564 561 490 560 490
560 490 560 1540 560 1565
564 486 560 489 561 489
560 491 559 1565 560 1565
561 489 561 494 555 1540
560 1565 560 1564 561 1565
560
name KEY_VCR
8510 4213 558 1565 560 490
560 1545 555 490 560 490
560 1564 561 490 560 1565
559 491 559 1566 560 489
535 1566 559 1565 560 490
560 1570 555 490 560 1566
559 1540 560 1565 560 1565
564 487 559 490 560 490
560 490 560 490 560 490
560 489 560 491 560 1544
556 1565 559 1565 570 1555
561
name KEY_VCR2
8504 4215 559 1567 559 490
560 1540 560 490 565 485
559 1566 560 490 560 1565
560 490 560 1565 560 494
556 1540 559 1566 559 491
559 1565 561 490 559 490
565 1561 559 1541 559 1565
560 490 560 490 560 490
560 495 555 1565 559 492
559 490 560 490 560 1565
535 1565 564 1560 561 1565
560
name KEY_VOLUMEUP
8505 4216 558 1567 559 490
560 1571 529 515 535 490
560 1565 560 490 560 1564
561 490 560 1565 560 490
560 1540 559 1566 560 490
559 1565 561 489 561 490
560 1564 561 489 561 1539
560 490 560 490 565 485
560 490 560 1566 559 490
560 1565 560 490 560 1569
531 1565 560 1565 560 1565
560
name KEY_VOLUMEDOWN
8510 4211 559 1566 560 494
556 1565 560 490 535 514
536 1565 560 490 560 1565
564 486 560 1564 561 490
560 1565 535 1565 559 490
560 1565 560 490 560 1565
560 1565 535 515 534 1566
565 485 559 491 560 490
560 490 560 490 560 490
559 1566 560 490 560 1570
555 1540 560 1564 561 1565
560
end raw_codes
end remote

View File

@ -0,0 +1,97 @@
# this config file was automatically generated
# using lirc-0.8.6(default) on Tue Sep 21 17:58:58 2010
#
# contributed by Robert Bedlinski
#
# brand:
# model no. of remote control: RMT B104P
# devices being controlled by this remote:
# SONY BLU RAY BDP S360
begin remote
name SONY_BD2
bits 12
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 2426 565
one 1221 569
zero 627 569
post_data_bits 8
post_data 0x47
gap 44934
min_repeat 2
toggle_bit_mask 0x0
begin codes
KEY_POWER 0xA8B
KEY_1 0x00B
KEY_2 0x80B
KEY_3 0x40B
KEY_4 0xC0B
KEY_5 0x20B
KEY_6 0xA0B
KEY_7 0x60B
KEY_8 0xE0B
KEY_9 0x10B
KEY_0 0x90B
KEY_AUDIO 0x26B
KEY_SUBTITLE 0xC6B
KEY_ANGLE 0xA6B
KEY_TIME 0X14B
KEY_RED 0xE6B
KEY_GREEN 0x16B
KEY_YELLOW 0x96B
KEY_BLUE 0x66B
KEY_MENU 0x34B
X_KEY_POPUPMENU 0x94B # Was: KEY_POPUPMENU
KEY_LEFT 0xDCB
KEY_RIGHT 0x3CB
KEY_DOWN 0x5CB
KEY_UP 0x9CB
X_KEY_RETURN 0xC2B # Was: KEY_RETURN
X_KEY_OPTIONS 0xFCB # Was: KEY_OPTIONS
KEY_OK 0xBCB
KEY_HOME 0x42B
KEY_PLAY 0x58B
KEY_PAUSE 0x98B
KEY_STOP 0x18B
KEY_DISPLAY 0x82B
X_KEY_FAST_REWERSE 0xD8B # Was: KEY_FAST_REWERSE
X_KEY_FAST_FORWARD 0x38B # Was: KEY_FAST_FORWARD
KEY_PREVIOUS 0xEAB
X_KEY_INSTANT_REPLAY 0x6EB # Was: KEY_INSTANT_REPLAY
X_KEY_INSTANT_ADVENCE 0xAEB # Was: KEY_INSTANT_ADVENCE
KEY_NEXT 0x6AB
end codes
end remote
begin remote
name SONY-BD
bits 12
flags SPACE_ENC|CONST_LENGTH
eps 30
aeps 100
header 2441 556
one 1234 557
zero 637 557
gap 44888
min_repeat 2
toggle_bit_mask 0x0
begin codes
KEY_VOLUMEUP 0x490
KEY_VOLUMEDOWN 0xC90
KEY_POWER2 0xA90
X_KEY_INPUT 0xA50 # Was: KEY_INPUT
end codes
end remote

View File

@ -1,23 +0,0 @@
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet static
address 10.2.113.9
netmask 255.255.255.0
gateway 10.2.113.1
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

View File

@ -1,4 +1,5 @@
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# sets color of first neo pixel
from __future__ import division
import time
@ -43,11 +44,11 @@ if __name__ == '__main__':
myredis=redis.StrictRedis(host='localhost', port=6379, db=0)
while True:
time.sleep(50/1000.0)
try:
try:
r=int(myredis.get('neored'))
except:
r=0
try:
try:
g=int(myredis.get('neogreen'))
except:
g=0
@ -65,10 +66,11 @@ if __name__ == '__main__':
valid="yes"
if ( valid != "yes" ):
continue
myredis.set('valid','no')
if(action == "set"):
print "Color set to: ",r,g,b
for i in range(0,LED_COUNT):
strip.setPixelColor(i, Color(r,g,b))
strip.setPixelColor(i, Color(g,r,b))
showit()
if(action == "number"):
tmp=myredis.get('neovalue')
@ -109,7 +111,7 @@ if __name__ == '__main__':
morsep+=1
strip.setPixelColor(morsep, Color(0,0,0))
morsep+=1
showit()
showit()
time.sleep(1)
if(action == "pulse"):
print "Pulsing with: ",r,g,b
@ -132,14 +134,15 @@ if __name__ == '__main__':
for j in range(0,60,5):
strip.setPixelColor(clockcalc(j), color)
# put the current people count as magenta
strip.setPixelColor(clockcalc(myredis.get('neocounter')),Color(10,0,10))
if myredis.get('neocounter') >= 0:
strip.setPixelColor(clockcalc(myredis.get('neocounter')),Color(10,0,10))
# put the minute hand as red
strip.setPixelColor(clockcalc(time.strftime('%M',time.localtime())),Color(30,0,0))
# put the seconds hand as green
strip.setPixelColor(clockcalc(time.strftime('%S',time.localtime())),Color(0,30,0))
showit()
showit()
time.sleep(50/1000.0)
if(action == "flash"):
print "Flashing with: ",r,g,b
print myredis.get('neoaction')
@ -154,7 +157,7 @@ if __name__ == '__main__':
for q in range(3):
for i in range(0, strip.numPixels(), 3):
strip.setPixelColor(i+q, wheel((i+j) % 255))
showit()
showit()
time.sleep(wait_ms/1000.0)
for i in range(0, strip.numPixels(), 3):
strip.setPixelColor(i+q, 0)

View File

@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
buttonpin=24
import RPi.GPIO as GPIO
import time
@ -7,15 +10,15 @@ import os
GPIO.setmode(GPIO.BCM)
GPIO.setup(buttonpin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
exit
while True:
print "waiting..."
os.system('logger shutdownbutton waiting for press...')
try:
GPIO.wait_for_edge(buttonpin, GPIO.FALLING)
try:
GPIO.wait_for_edge(buttonpin, GPIO.FALLING)
print('Button Pressed')
os.system('logger shutdownbutton pressen. bye bye')
os.system("shutdown now -h")
except KeyboardInterrupt:
GPIO.cleanup() # clean up GPIO on CTRL+C exit
# os.system("shutdown now -h")
except KeyboardInterrupt:
GPIO.cleanup() # clean up GPIO on CTRL+C exit
GPIO.cleanup() #

View File

@ -1,4 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib, json
url = "https://spaceapi.syn2cat.lu/status/json"
response = urllib.urlopen(url);
data = json.loads(response.read())