diff --git a/src/busybox/.config b/src/busybox/.config index 4b1e02d..ac252d6 100644 --- a/src/busybox/.config +++ b/src/busybox/.config @@ -755,7 +755,7 @@ CONFIG_HEXEDIT=y # CONFIG_I2CSET is not set # CONFIG_I2CDUMP is not set # CONFIG_I2CDETECT is not set -# CONFIG_INOTIFYD is not set +CONFIG_INOTIFYD=y # CONFIG_LESS is not set CONFIG_FEATURE_LESS_MAXLINES=0 # CONFIG_FEATURE_LESS_BRACKETS is not set diff --git a/src/busybox/install.busybox b/src/busybox/install.busybox index 4043b2d..e6e1d24 100755 --- a/src/busybox/install.busybox +++ b/src/busybox/install.busybox @@ -15,3 +15,6 @@ echo "#!/mnt/mmc/sonoff-hack/bin/busybox" > ../../build/sonoff-hack/usr/bin/wget chmod 0755 ../../build/sonoff-hack/usr/bin/wget echo "#!/mnt/mmc/sonoff-hack/bin/busybox" > ../../build/sonoff-hack/usr/bin/xargs chmod 0755 ../../build/sonoff-hack/usr/bin/xargs +echo "#!/mnt/mmc/sonoff-hack/bin/busybox" > ../../build/sonoff-hack/usr/bin/inotifyd +chmod 0755 ../../build/sonoff-hack/usr/bin/inotifyd + diff --git a/src/static/static/sonoff-hack/script/fast_motion.sh b/src/static/static/sonoff-hack/script/fast_motion.sh new file mode 100644 index 0000000..733703c --- /dev/null +++ b/src/static/static/sonoff-hack/script/fast_motion.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +SONOFF_HACK_PREFIX="/mnt/mmc/sonoff-hack" +MQTT_HOST=192.168.11.5 +MQTT_USER=openhab_iot +MQTT_PASS=PASSWORD + +#LOG_FILE="/dev/null" +LOG_FILE="/tmp/fastmotion.log" + +log() { + echo "$(date +'%Y-%m-%d %H:%M:%S') -" "$*" >> $LOG_FILE +} +run() { + ${SONOFF_HACK_PREFIX}/usr/bin/inotifyd - /tmp:n | while read a b c; do + log received $a $b $c + if [ "$c" = "colinkPushNotice" ]; then + ${SONOFF_HACK_PREFIX}/bin/mosquitto_pub -h ${MQTT_HOST} -u ${MQTT_USER} -P ${MQTT_PASS} -t cam1/fast_motion -m ON + ${SONOFF_HACK_PREFIX}/bin/snapshot -f /tmp/snapfast.jpg + ${SONOFF_HACK_PREFIX}/bin/mosquitto_pub -h ${MQTT_HOST} -u ${MQTT_USER} -P ${MQTT_PASS} -t cam1/fast_image -f /tmp/snapfast.jpg + sleep 5 + ${SONOFF_HACK_PREFIX}/bin/mosquitto_pub -h ${MQTT_HOST} -u ${MQTT_USER} -P ${MQTT_PASS} -t cam1/fast_motion -m OFF + fi + done +} + +run_loop() { + while true; do + log "Starting fast mation detection ..." + run + log "aborted ... waiting 10 seconds" + sleep 10 + done +} + +run_loop diff --git a/src/static/static/sonoff-hack/script/system.sh b/src/static/static/sonoff-hack/script/system.sh index 256f8f4..c418885 100755 --- a/src/static/static/sonoff-hack/script/system.sh +++ b/src/static/static/sonoff-hack/script/system.sh @@ -343,6 +343,9 @@ fi # Run rtsp watchdog $SONOFF_HACK_PREFIX/script/wd_rtsp.sh & +# Run fast_motion +$SONOFF_HACK_PREFIX/script/fast_motion.sh & + # Add crontab CRONTAB=$(get_config CRONTAB) FREE_SPACE=$(get_config FREE_SPACE)