diff --git a/README.txt b/README.txt index de1718b..f4eb4b3 100644 --- a/README.txt +++ b/README.txt @@ -21,6 +21,7 @@ cat > /home/pi/.config/lxsession/LXDE/autostart <<"EOF" @./doorbuzz/buzzctrl.sh @./doorbuzz/videoplayer.sh @sudo python ./doorbuzz/shutdownbutton.py +@./doorbuzz/phone_notification_client.sh EOF @@ -34,6 +35,9 @@ you can add videos and they will be taken into account automatically when booting, the button led uses morsecode to send the low byte of the IP adress in decimal +phone_notification_client.sh communicates with pidor's doorbuzz_wrapper.sh +to command the flash light + todo ==== create a config file diff --git a/phone_notification_client.sh b/phone_notification_client.sh new file mode 100755 index 0000000..4265739 --- /dev/null +++ b/phone_notification_client.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +url=http://10.2.113.137 +run_file="/var/run/phone_ringing_status" +pidor=root@10.2.113.2 +old_status=0 +new_status=0 +while true # empty pipe +do + sleep 1 + while true + do + read -t 1 status <&"${COPROC[0]}" + ret=$? + if [ $ret -eq 1 ] # no more coprocess + then + echo "connecting to pidor" + coproc ssh -i ~/.ssh/doorbuzz $pidor + sleep 10 + echo "connected" + echo "flashoff" >&"${COPROC[1]}" + ret=0 + fi + if [ $ret -ne 0 ] + then + break + fi + echo "$status" + done + echo "spacestatus" >&"${COPROC[1]}" + read status <&"${COPROC[0]}" + if ! [ "$status" = "open" ]; then # do nothing if space is closed + continue + else +# if ! [ -e "$run_file" ]; then +# touch $run_file +# fi + + curl -q "$url" 2>/dev/null | grep Ringing + new_status=$? +# old_status=$(cat ${run_file}) + + if [ "$new_status" -eq "$old_status" ]; then + continue + fi + echo "phone status change detected" + if [ "$new_status" -eq 0 ]; then + echo "flashon" >&"${COPROC[1]}" + else + echo "flashoff" >&"${COPROC[1]}" + fi +# echo $new_status > ${run_file} + old_status=$new_status + fi +done