diff --git a/.gitattributes b/.gitattributes index 6e1dd14..3830cdd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,7 +6,8 @@ firmware_mod/config/lighttpd.user text eol=lf firmware_mod/bin/curl text eol=lf firmware_mod/bin/mosquitto_pub text eol=lf -firmware_mod/bin/mosquitto_pub text eol=lf +firmware_mod/bin/mosquitto_sub text eol=lf +firmware_mod/bin/lighttpd text eol=lf firmware_mod/controlscripts/* text eol=lf firmware_mod/scripts/* text eol=lf firmware_mod/config/autostart/* text eol=lf diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2260f5a --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,30 @@ +This is an issue tracking system only. +If you have general questions or are a newbie, please ask for help in our [chat channel](https://gitter.im/Xiaomi-Dafang-Hacks). + +To make sure your issue can be resolved as quickly as possible please state your + +* exact camera hardware: +* the Xiaomi-Dafang-Hacks commitid (from `git log`) you are experiencing the issue with: + + +### Description + +Describe what you were trying to achieve. +Tell us what happened and what you expected to happen. + +### What did you do to debug the issue + +Tell us what you did to remedy/debug the issue yourself and what you think causes the issue. + +### Evidence + +Please add snippets from the logfiles in: +* /system/sdcard/log/startup.log +* /var/log/* +* dmesg +* logcat +and/or screenshots you deem relevant. + +### Contribute Back + +If your issue was resolved, please consider contributing back to the project by creating a pull request to improve the code or documentation in order to avoid that this issue arises again for other people. diff --git a/README.md b/README.md index a872312..9c7bd15 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,8 @@ Start [here](/hacks/technical.md) [HomeKit](/integration/homekit/homekit.md) +[OpenHab](https://community.openhab.org/t/how-to-configure-a-hacked-xiaomi-dafang-to-work-with-openhab/51121) + [Synology](/integration/synology/synology.md) [tinyCam](/integration/tinycam/tinycam.md) diff --git a/firmware_mod/bin/autonight b/firmware_mod/bin/autonight index b854b2b..aaa08a3 100755 Binary files a/firmware_mod/bin/autonight and b/firmware_mod/bin/autonight differ diff --git a/firmware_mod/config/motion.conf.dist b/firmware_mod/config/motion.conf.dist index f35fdf3..8e878b1 100644 --- a/firmware_mod/config/motion.conf.dist +++ b/firmware_mod/config/motion.conf.dist @@ -19,3 +19,4 @@ publish_mqtt_message=false sendemail=false send_telegram=false save_dir=/system/sdcard/motion/stills +save_file_date_pattern="+%d-%m-%Y_%H.%M.%S" diff --git a/firmware_mod/config/mqtt.conf.dist b/firmware_mod/config/mqtt.conf.dist index 14c51fb..c98f5e4 100644 --- a/firmware_mod/config/mqtt.conf.dist +++ b/firmware_mod/config/mqtt.conf.dist @@ -32,8 +32,5 @@ MOSQUITTOOPTS="" # Add options for mosquitto_pub like -r for retaining messages MOSQUITTOPUBOPTS="" -# Add options for curl here e.g --user user:password -CURLOPTS="" - # Send a mqtt statusupdate every n seconds STATUSINTERVAL=30 diff --git a/firmware_mod/controlscripts/telegram-bot b/firmware_mod/controlscripts/telegram-bot new file mode 100644 index 0000000..263cb88 --- /dev/null +++ b/firmware_mod/controlscripts/telegram-bot @@ -0,0 +1,53 @@ +#!/bin/sh + +######### Bot commands ######### +# /mem - show memory information +# /shot - take a shot +# /on - motion detect on +# /off - motion detect off + +PIDFILE="/run/telegram-bot.pid" + +if [ ! -f /system/sdcard/config/telegram.conf ]; then + echo "You have to configure telegram first. Please see /system/sdcard/config/telegram.conf.dist for further instructions" +fi + +status() +{ + pid="$(cat "$PIDFILE" 2>/dev/null)" + if [ "$pid" ]; then + kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1 + fi +} + +start() +{ + if [ -f $PIDFILE ]; then + echo "Bot already running"; + else + echo "Starting bot" + /system/sdcard/bin/busybox nohup /system/sdcard/scripts/telegram-bot-daemon.sh >/dev/null 2>&1 & + echo "$!" > "$PIDFILE" + fi +} + +stop() +{ + pid="$(cat "$PIDFILE" 2>/dev/null)" + if [ "$pid" ]; then + kill -9 "$pid" + rm "$PIDFILE" + echo "Bot stopped" + else + echo "Could not find a bot to stop." + fi +} + +if [ $# -eq 0 ]; then + start +else + case $1 in start|stop|status) + $1 + ;; + esac +fi diff --git a/firmware_mod/driver/sensor_jxf23.ko b/firmware_mod/driver/sensor_jxf23.ko new file mode 100644 index 0000000..f0f5033 Binary files /dev/null and b/firmware_mod/driver/sensor_jxf23.ko differ diff --git a/firmware_mod/run.sh b/firmware_mod/run.sh index a07ddb0..7c83068 100755 --- a/firmware_mod/run.sh +++ b/firmware_mod/run.sh @@ -55,6 +55,22 @@ echo "Bind mounted /system/sdcard/root to /root" >> $LOGPATH mount -o bind /system/sdcard/etc /etc echo "Bind mounted /system/sdcard/etc to /etc" >> $LOGPATH +## Create a swap file on SD if desired +SWAP=false +SWAPPATH="/system/sdcard/swapfile" +SWAPSIZE=256 +if [ "$SWAP" = true ]; then + if [ ! -f $SWAPPATH ]; then + echo "Creating ${SWAPSIZE}MB swap file on SD card" >> $LOGPATH + dd if=/dev/zero of=$SWAPPATH bs=1M count=$SWAPSIZE + mkswap $SWAPPATH + echo "Swap file created in $SWAPPATH" >> $LOGPATH + fi + echo "Configuring swap file" >> $LOGPATH + swapon $SWAPPATH + echo "Swap set on file $SWAPPATH" >> $LOGPATH +fi + ## Create crontab dir and start crond: if [ ! -d /system/sdcard/config/cron ]; then mkdir -p ${CONFIGPATH}/cron/crontabs @@ -119,6 +135,7 @@ if [ ! -f $CONFIGPATH/ntp_srv.conf ]; then cp $CONFIGPATH/ntp_srv.conf.dist $CONFIGPATH/ntp_srv.conf fi ntp_srv="$(cat "$CONFIGPATH/ntp_srv.conf")" +timeout -t 30 sh -c "until ping -c1 \"$ntp_srv\" &>/dev/null; do sleep 3; done"; /system/sdcard/bin/busybox ntpd -p "$ntp_srv" ## Load audio driver module: @@ -159,7 +176,7 @@ insmod /driver/tx-isp.ko isp_clk=100000000 if [ $sensor = 'jxf22' ]; then insmod /driver/sensor_jxf22.ko data_interface=2 pwdn_gpio=-1 reset_gpio=18 sensor_gpio_func=0 else - insmod /driver/sensor_jxf23.ko data_interface=2 pwdn_gpio=-1 reset_gpio=18 sensor_gpio_func=0 + insmod /system/sdcard/driver/sensor_jxf23.ko data_interface=2 pwdn_gpio=-1 reset_gpio=18 sensor_gpio_func=0 fi ## Start FTP & SSH Server: diff --git a/firmware_mod/scripts/PTZpresets.sh b/firmware_mod/scripts/PTZpresets.sh index d66999a..bdc515c 100644 --- a/firmware_mod/scripts/PTZpresets.sh +++ b/firmware_mod/scripts/PTZpresets.sh @@ -41,11 +41,11 @@ move(){ # Differentiate the coordinates and calculate the number # of steps to reach the specified coordinates. if [[ "$1" = "X" ]];then - grep_text="x_steps" + grep_text="x" opt="r|l" text="Right|Left" else - grep_text="y_steps" + grep_text="y" opt="u|d" text="Up|Down" fi diff --git a/firmware_mod/scripts/common_functions.sh b/firmware_mod/scripts/common_functions.sh index 2b2f385..4e9ece5 100755 --- a/firmware_mod/scripts/common_functions.sh +++ b/firmware_mod/scripts/common_functions.sh @@ -40,11 +40,11 @@ rewrite_config(){ # Check if the value exists (without comment), if not add it to the file $(grep -v '^[[:space:]]*#' $1 | grep -q $2) ret="$?" - if [ "$ret" == "1" ] ; then - echo "$2=$3" >> $1 - else + if [ "$ret" == "1" ] ; then + echo "$2=$3" >> $1 + else sed -i -e "/\\s*#.*/!{/""$cfg_key""=/ s/=.*/=""$new_value""/}" "$cfg_path" - fi + fi } # Control the blue led @@ -178,9 +178,9 @@ motor(){ ;; status) if [ "$2" = "horizontal" ]; then - echo $(/system/sdcard/bin/motor -d u -s 0 | grep "x:" | awk '{print $2}') + /system/sdcard/bin/motor -d u -s 0 | grep "x:" | awk '{print $2}' else - echo $(/system/sdcard/bin/motor -d u -s 0 | grep "y:" | awk '{print $2}') + /system/sdcard/bin/motor -d u -s 0 | grep "y:" | awk '{print $2}' fi ;; esac @@ -290,27 +290,27 @@ motion_detection(){ esac } -# Control the motion detection mail function -motion_send_mail(){ - case "$1" in - on) +# Control the motion detection mail function +motion_send_mail(){ + case "$1" in + on) rewrite_config /system/sdcard/config/motion.conf sendemail "true" - ;; - off) + ;; + off) rewrite_config /system/sdcard/config/motion.conf sendemail "false" - ;; - status) - status=`awk '/sendemail/' /system/sdcard/config/motion.conf |cut -f2 -d \=` - case $status in - false) - echo "OFF" - ;; - true) - echo "ON" - ;; - esac - esac -} + ;; + status) + status=`awk '/sendemail/' /system/sdcard/config/motion.conf |cut -f2 -d \=` + case $status in + false) + echo "OFF" + ;; + true) + echo "ON" + ;; + esac + esac +} @@ -340,9 +340,9 @@ motion_tracking(){ night_mode(){ case "$1" in on) + /system/sdcard/bin/setconf -k n -v 1 ir_led on ir_cut off - /system/sdcard/bin/setconf -k n -v 1 ;; off) ir_led off @@ -380,6 +380,13 @@ auto_night_mode(){ esac } +# Take a snapshot +snapshot(){ + filename="/tmp/snapshot.jpg" + /system/sdcard/bin/getimage > "$filename" & + sleep 1 +} + # Update axis update_axis(){ source /system/sdcard/config/osd.conf > /dev/null 2>/dev/null @@ -388,3 +395,13 @@ update_axis(){ OSD="${OSD} ${AXIS}" fi } + +# Reboot the System +reboot_system() { + /sbin/reboot +} + +# Re-Mount the SD Card +remount_sdcard() { + mount -o remount,rw /system/sdcard +} diff --git a/firmware_mod/scripts/detectionOn.sh b/firmware_mod/scripts/detectionOn.sh index f8949da..eb185fb 100755 --- a/firmware_mod/scripts/detectionOn.sh +++ b/firmware_mod/scripts/detectionOn.sh @@ -11,14 +11,17 @@ fi # Save a snapshot if [ "$save_snapshot" = true ] ; then - filename=$(date +%d-%m-%Y_%H.%M.%S).jpg + pattern="${save_file_date_pattern:-+%d-%m-%Y_%H.%M.%S}" + filename=$(date $pattern).jpg if [ ! -d "$save_dir" ]; then mkdir -p "$save_dir" fi - # Limit the number of snapshots - if [ "$(ls "$save_dir" | wc -l)" -ge "$max_snapshots" ]; then - rm -f "$save_dir/$(ls -l "$save_dir" | awk 'NR==2{print $9}')" - fi + { + # Limit the number of snapshots + if [ "$(ls "$save_dir" | wc -l)" -ge "$max_snapshots" ]; then + rm -f "$save_dir/$(ls -ltr "$save_dir" | awk 'NR==2{print $9}')" + fi + } & /system/sdcard/bin/getimage > "$save_dir/$filename" & fi @@ -42,16 +45,16 @@ if [ "$send_telegram" = true ]; then if [ "$save_snapshot" = true ] ; then /system/sdcard/bin/telegram p "$save_dir/$filename" else - /system/sdcard/bin/getimage > "telegram_image.jpg" - + /system/sdcard/bin/telegram p "telegram_image.jpg" - + rm "telegram_image.jpg" + /system/sdcard/bin/getimage > "/tmp/telegram_image.jpg" + /system/sdcard/bin/telegram p "/tmp/telegram_image.jpg" + rm "/tmp/telegram_image.jpg" fi fi # Run any user scripts. for i in /system/sdcard/config/userscripts/motiondetection/*; do if [ -x "$i" ]; then - echo "Running: $i on" - $i on + echo "Running: $i on $save_dir/$filename" + $i on "$save_dir/$filename" & fi done diff --git a/firmware_mod/scripts/detectionTracking.sh b/firmware_mod/scripts/detectionTracking.sh index 7b70519..2aace0b 100755 --- a/firmware_mod/scripts/detectionTracking.sh +++ b/firmware_mod/scripts/detectionTracking.sh @@ -92,8 +92,7 @@ backtoOrigin() { #################### Start ### # If no argument that's mean the camera need to return to its original position -# the 5th arguments is '&' -if [ $# -ne 5 ] +if [ $# -eq 0 ] then backtoOrigin return 0; diff --git a/firmware_mod/scripts/mqtt-autodiscovery.sh b/firmware_mod/scripts/mqtt-autodiscovery.sh index 60e8305..43147ec 100644 --- a/firmware_mod/scripts/mqtt-autodiscovery.sh +++ b/firmware_mod/scripts/mqtt-autodiscovery.sh @@ -3,43 +3,49 @@ . /system/sdcard/config/mqtt.conf . /system/sdcard/scripts/common_functions.sh +MAC=$(cat /sys/class/net/wlan0/address) +MAC_SIMPLE=$(cat /sys/class/net/wlan0/address | tr -d :) +MANUFACTURER="Xiaomi" +MODEL="Dafang" +VER="Dafang Hacks" + # Motion sensor -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/binary_sensor/$DEVICE_NAME/motion/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion sensor\", \"icon\": \"mdi:run\", \"state_topic\": \"$TOPIC/motion\", \"device_class\": \"motion\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/binary_sensor/$DEVICE_NAME/motion/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion sensor\", \"unique_id\": \"$MAC_SIMPLE-motion-sensor\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:run\", \"state_topic\": \"$TOPIC/motion\", \"device_class\": \"motion\"}" # Motion detection on/off switch -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/motion_detection/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion detection\", \"icon\": \"mdi:run\", \"state_topic\": \"$TOPIC/motion/detection\", \"command_topic\": \"$TOPIC/motion/detection/set\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/motion_detection/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion detection\", \"unique_id\": \"$MAC_SIMPLE-motion-detection\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:run\", \"state_topic\": \"$TOPIC/motion/detection\", \"command_topic\": \"$TOPIC/motion/detection/set\"}" # Motion send mail alert on/off switch -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/motion_send_mail/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion send mail\", \"icon\": \"mdi:run\", \"state_topic\": \"$TOPIC/motion/send_mail\", \"command_topic\": \"$TOPIC/motion/send_mail/set\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/motion_send_mail/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion send mail\", \"unique_id\": \"$MAC_SIMPLE-motion-send-mail\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:run\", \"state_topic\": \"$TOPIC/motion/send_mail\", \"command_topic\": \"$TOPIC/motion/send_mail/set\"}" # Motion detection snapshots -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/camera/$DEVICE_NAME/motion_snapshot/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion snapshot\", \"topic\": \"$TOPIC/motion/snapshot\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/camera/$DEVICE_NAME/motion_snapshot/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion snapshot\", \"unique_id\": \"$MAC_SIMPLE-motion-snapshot\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"topic\": \"$TOPIC/motion/snapshot\"}" # Motion tracking on/off switch -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/motion_tracking/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion tracking\", \"icon\": \"mdi:run\", \"state_topic\": \"$TOPIC/motion/tracking\", \"command_topic\": \"$TOPIC/motion/tracking/set\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/motion_tracking/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion tracking\", \"unique_id\": \"$MAC_SIMPLE-motion-tracking\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:run\", \"state_topic\": \"$TOPIC/motion/tracking\", \"command_topic\": \"$TOPIC/motion/tracking/set\"}" # LEDs -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/blue_led/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME blue led\", \"icon\": \"mdi:led-on\", \"state_topic\": \"$TOPIC/leds/blue\", \"command_topic\": \"$TOPIC/leds/blue/set\"}" -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/yellow_led/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME yellow led\", \"icon\": \"mdi:led-on\", \"state_topic\": \"$TOPIC/leds/yellow\", \"command_topic\": \"$TOPIC/leds/yellow/set\"}" -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/ir_led/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME ir led\", \"icon\": \"mdi:led-on\", \"state_topic\": \"$TOPIC/leds/ir\", \"command_topic\": \"$TOPIC/leds/ir/set\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/blue_led/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME blue led\", \"unique_id\": \"$MAC_SIMPLE-blue-led\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:led-on\", \"state_topic\": \"$TOPIC/leds/blue\", \"command_topic\": \"$TOPIC/leds/blue/set\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/yellow_led/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME yellow led\", \"unique_id\": \"$MAC_SIMPLE-yellow-led\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:led-on\", \"state_topic\": \"$TOPIC/leds/yellow\", \"command_topic\": \"$TOPIC/leds/yellow/set\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/ir_led/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME ir led\", \"unique_id\": \"$MAC_SIMPLE-ir-led\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:led-on\", \"state_topic\": \"$TOPIC/leds/ir\", \"command_topic\": \"$TOPIC/leds/ir/set\"}" # IR Filter -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/ir_cut/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME ir filter\", \"icon\": \"mdi:image-filter-black-white\", \"state_topic\": \"$TOPIC/ir_cut\", \"command_topic\": \"$TOPIC/ir_cut/set\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/ir_cut/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME ir filter\", \"unique_id\": \"$MAC_SIMPLE-ir-filter\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:image-filter-black-white\", \"state_topic\": \"$TOPIC/ir_cut\", \"command_topic\": \"$TOPIC/ir_cut/set\"}" # Light Sensor -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/sensor/$DEVICE_NAME/ldr/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME light sensor\", \"icon\": \"mdi:brightness-5\", \"unit_of_measurement\": \"%\", \"state_topic\": \"$TOPIC/brightness\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/sensor/$DEVICE_NAME/ldr/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME light sensor\", \"unique_id\": \"$MAC_SIMPLE-light-sensor\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:brightness-5\", \"unit_of_measurement\": \"%\", \"state_topic\": \"$TOPIC/brightness\"}" # Night mode -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/night_mode/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME night mode\", \"icon\": \"mdi:weather-night\", \"state_topic\": \"$TOPIC/night_mode\", \"command_topic\": \"$TOPIC/night_mode/set\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/night_mode/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME night mode\", \"unique_id\": \"$MAC_SIMPLE-night-mode\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:weather-night\", \"state_topic\": \"$TOPIC/night_mode\", \"command_topic\": \"$TOPIC/night_mode/set\"}" # Night mode automatic -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/auto_night_mode/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME night mode auto\", \"icon\": \"mdi:weather-night\", \"state_topic\": \"$TOPIC/night_mode/auto\", \"command_topic\": \"$TOPIC/night_mode/auto/set\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/auto_night_mode/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME night mode auto\", \"unique_id\": \"$MAC_SIMPLE-night-mode-auto\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:weather-night\", \"state_topic\": \"$TOPIC/night_mode/auto\", \"command_topic\": \"$TOPIC/night_mode/auto/set\"}" # RTSP Server -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/rtsp_h264_server/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME h264 rtsp server\", \"icon\": \"mdi:cctv\", \"state_topic\": \"$TOPIC/rtsp_h264_server\", \"command_topic\": \"$TOPIC/rtsp_h264_server/set\"}" -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/rtsp_mjpeg_server/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME mjpeg rtsp server\", \"icon\": \"mdi:cctv\", \"state_topic\": \"$TOPIC/rtsp_mjpeg_server\", \"command_topic\": \"$TOPIC/rtsp_mjpeg_server/set\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/rtsp_h264_server/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME h264 rtsp server\", \"unique_id\": \"$MAC_SIMPLE-h264-rtsp-server\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:cctv\", \"state_topic\": \"$TOPIC/rtsp_h264_server\", \"command_topic\": \"$TOPIC/rtsp_h264_server/set\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/rtsp_mjpeg_server/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME mjpeg rtsp server\", \"unique_id\": \"$MAC_SIMPLE-mjpeg-rtsp-server\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"icon\": \"mdi:cctv\", \"state_topic\": \"$TOPIC/rtsp_mjpeg_server\", \"command_topic\": \"$TOPIC/rtsp_mjpeg_server/set\"}" # Motor up/down/left/right -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/cover/$DEVICE_NAME/motor_up_down/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME move up/down\", \"state_topic\": \"$TOPIC/motors/vertical\", \"command_topic\": \"$TOPIC/motors/vertical/set\", \"payload_close\": \"down\", \"payload_open\": \"up\", \"optimistic\": \"false\", \"value_template\": \"{{ ((value|int)/7.3)|round }}\"}" -/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/cover/$DEVICE_NAME/motor_left_right/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME move left/right\", \"state_topic\": \"$TOPIC/motors/horizontal\", \"command_topic\": \"$TOPIC/motors/horizontal/set\", \"payload_close\": \"right\", \"payload_open\": \"left\", \"optimistic\": \"false\", \"value_template\": \"{{ ((value|int)/27)|round }}\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/cover/$DEVICE_NAME/motor_up_down/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME move up/down\", \"unique_id\": \"$MAC_SIMPLE-move-up-down\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"state_topic\": \"$TOPIC/motors/vertical\", \"command_topic\": \"$TOPIC/motors/vertical/set\", \"payload_close\": \"down\", \"payload_open\": \"up\", \"optimistic\": \"false\", \"value_template\": \"{{ ((value|int)/7.3)|round }}\"}" +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/cover/$DEVICE_NAME/motor_left_right/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME move left/right\", \"unique_id\": \"$MAC_SIMPLE-move-left-right\", \"device\": {\"identifiers\": \"$MAC_SIMPLE\", \"connections\": [[\"mac\", \"$MAC\"]], \"manufacturer\": \"$MANUFACTURER\", \"model\": \"$MODEL\", \"name\": \"$MANUFACTURER $MODEL\", \"sw_version\": \"$VER\"}, \"state_topic\": \"$TOPIC/motors/horizontal\", \"command_topic\": \"$TOPIC/motors/horizontal/set\", \"payload_close\": \"right\", \"payload_open\": \"left\", \"optimistic\": \"false\", \"value_template\": \"{{ ((value|int)/27)|round }}\"}" diff --git a/firmware_mod/scripts/mqtt-control.sh b/firmware_mod/scripts/mqtt-control.sh index 3cfb972..f1e82a9 100755 --- a/firmware_mod/scripts/mqtt-control.sh +++ b/firmware_mod/scripts/mqtt-control.sh @@ -6,7 +6,7 @@ killall mosquitto_sub 2> /dev/null killall mosquitto_sub.bin 2> /dev/null -/system/sdcard/bin/mosquitto_sub.bin -v -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/# | while read -r line ; do +/system/sdcard/bin/mosquitto_sub.bin -v -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/# ${MOSQUITTOOPTS} | while read -r line ; do case $line in "${TOPIC}/set help") /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/help ${MOSQUITTOOPTS} -m "possible commands: configured topic + Yellow_LED/set on/off, configured topic + Blue_LED/set on/off, configured topic + set with the following commands: status, $(grep \)$ /system/sdcard/www/cgi-bin/action.cgi | grep -v '[=*]' | sed -e "s/ //g" | grep -v -E '(osd|setldr|settz|showlog)' | sed -e "s/)//g")" @@ -182,6 +182,10 @@ killall mosquitto_sub.bin 2> /dev/null motor down /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status vertical)" ;; + "${TOPIC}/motors/vertical/set calibrate") + motor vcalibrate # calibrate with endstops + /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status vertical)" + ;; "${TOPIC}/motors/horizontal/set left") motor left /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status horizontal)" @@ -190,11 +194,32 @@ killall mosquitto_sub.bin 2> /dev/null motor right /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status horizontal)" ;; + "${TOPIC}/motors/horizontal/set calibrate") + motor hcalibrate # calibrate with endstops + /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status horizontal)" + ;; + "${TOPIC}/motors/set calibrate") + motor calibrate # calibrate without endstops + /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status horizontal)" + ;; + "${TOPIC}/remount_sdcard/set ON") + remount_sdcard + /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/remount_sdcard ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "Remounting the SD Card" + ;; + + "${TOPIC}/reboot/set ON") + /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/reboot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "Rebooting the System" + reboot_system + ;; + "${TOPIC}/snapshot/set ON") + snapshot + /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/snapshot ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -f "$filename" + ;; "${TOPIC}/set "*) COMMAND=$(echo "$line" | awk '{print $2}') #echo "$COMMAND" - /system/sdcard/bin/curl -k -m 2 ${CURLOPTS} -s https://127.0.0.1/cgi-bin/action.cgi\?cmd="${COMMAND}" -o /dev/null 2>/dev/null + F_cmd="${COMMAND}" /system/sdcard/www/cgi-bin/action.cgi -o /dev/null 2>/dev/null if [ $? -eq 0 ]; then /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}/${COMMAND}" ${MOSQUITTOOPTS} -m "OK (this means: action.cgi invoke with parameter ${COMMAND}, nothing more, nothing less)" else diff --git a/firmware_mod/scripts/telegram-bot-daemon.sh b/firmware_mod/scripts/telegram-bot-daemon.sh new file mode 100755 index 0000000..0bd030e --- /dev/null +++ b/firmware_mod/scripts/telegram-bot-daemon.sh @@ -0,0 +1,78 @@ +#!/bin/sh + +CURL="/system/sdcard/bin/curl" +LASTUPDATEFILE="/tmp/last_update_id" +TELEGRAM="/system/sdcard/bin/telegram" +JQ="/system/sdcard/bin/jq" + +. /system/sdcard/config/telegram.conf +[ -z $apiToken ] && echo "api token not configured yet" && exit 1 +[ -z $userChatId ] && echo "chat id not configured yet" && exit 1 + +sendShot() { + /system/sdcard/bin/getimage > "/tmp/telegram_image.jpg" &&\ + $TELEGRAM p "/tmp/telegram_image.jpg" + rm "/tmp/telegram_image.jpg" +} + +sendMem() { + $TELEGRAM m $(free -k | awk '/^Mem/ {print "Mem: used "$3" free "$4} /^Swap/ {print "Swap: used "$3}') +} + +detectionOn() { + . /system/sdcard/scripts/common_functions.sh + motion_detection on && $TELEGRAM m "Motion detection started" +} + +detectionOff() { + . /system/sdcard/scripts/common_functions.sh + motion_detection off && $TELEGRAM m "Motion detection stopped" +} + +respond() { + case $1 in + /mem) sendMem;; + /shot) sendShot;; + /on) detectionOn;; + /off) detectionOff;; + *) $TELEGRAM m "I can't respond to '$1' command" + esac +} + +readNext() { + lastUpdateId=$(cat $LASTUPDATEFILE || echo "0") + json=$($CURL -s -X GET "https://api.telegram.org/bot$apiToken/getUpdates?offset=$lastUpdateId&limit=1&allowed_updates=message") + echo $json +} + +markAsRead() { + nextId=$(($1 + 1)) + echo "$nextId" > $LASTUPDATEFILE +} + +main() { + json=$(readNext) + + [ "$(echo "$json" | $JQ -r '.ok')" != "true" ] && return 1 + + chatId=$(echo "$json" | $JQ -r '.result[0].message.chat.id // ""') + [ -z "$chatId" ] && return 0 # no new messages + + cmd=$(echo "$json" | $JQ -r '.result[0].message.text // ""') + updateId=$(echo "$json" | $JQ -r '.result[0].update_id // ""') + + if [ "$chatId" != "$userChatId" ]; then + username=$(echo "$json" | $JQ -r '.result[0].message.from.username // ""') + firstName=$(echo "$json" | $JQ -r '.result[0].message.from.first_name // ""') + $TELEGRAM m "Received message from not authrized chat: $chatId\nUser: $username($firstName)\nMessage: $cmd" + else + respond $cmd + fi; + + markAsRead $updateId +} + +while true; do + main >/dev/null 2>&1 + [ $? -gt 0 ] && exit 1 +done; diff --git a/firmware_mod/www/cgi-bin/action.cgi b/firmware_mod/www/cgi-bin/action.cgi index c973c53..11e20fb 100755 --- a/firmware_mod/www/cgi-bin/action.cgi +++ b/firmware_mod/www/cgi-bin/action.cgi @@ -1,16 +1,16 @@ #!/bin/sh +. /system/sdcard/www/cgi-bin/func.cgi +. /system/sdcard/scripts/common_functions.sh + +export LD_LIBRARY_PATH=/system/lib +export LD_LIBRARY_PATH=/thirdlib:$LD_LIBRARY_PATH + echo "Content-type: text/html" echo "Pragma: no-cache" echo "Cache-Control: max-age=0, no-store, no-cache" echo "" -source ./func.cgi -source /system/sdcard/scripts/common_functions.sh - -export LD_LIBRARY_PATH=/system/lib -export LD_LIBRARY_PATH=/thirdlib:$LD_LIBRARY_PATH - if [ -n "$F_cmd" ]; then if [ -z "$F_val" ]; then F_val=100 @@ -447,6 +447,28 @@ if [ -n "$F_cmd" ]; then echo "Motion Configuration done" return ;; + autonight_sw) + if [ ! -f /system/sdcard/config/autonight.conf ]; then + echo "-S" > /system/sdcard/config/autonight.conf + fi + current_setting=$(sed 's/-S *//g' /system/sdcard/config/autonight.conf) + echo "-S" $current_setting > /system/sdcard/config/autonight.conf + ;; + autonight_hw) + if [ -f /system/sdcard/config/autonight.conf ]; then + sed -i 's/-S *//g' /system/sdcard/config/autonight.conf + fi + ;; + get_sw_night_config) + cat /system/sdcard/config/autonight.conf + exit + ;; + save_sw_night_config) + #This also enables software mode + night_mode_conf=$(echo "${F_val}"| sed "s/+/ /g" | sed "s/%2C/,/g") + echo $night_mode_conf > /system/sdcard/config/autonight.conf + echo Saved $night_mode_conf + ;; offDebug) /system/sdcard/controlscripts/debug-on-osd stop diff --git a/firmware_mod/www/cgi-bin/getispinfo.cgi b/firmware_mod/www/cgi-bin/getispinfo.cgi new file mode 100644 index 0000000..0203638 --- /dev/null +++ b/firmware_mod/www/cgi-bin/getispinfo.cgi @@ -0,0 +1,4 @@ +#!/bin/sh + +cat /proc/jz/isp/isp_info + diff --git a/firmware_mod/www/cgi-bin/state.cgi b/firmware_mod/www/cgi-bin/state.cgi old mode 100644 new mode 100755 index 8965115..7f33da1 --- a/firmware_mod/www/cgi-bin/state.cgi +++ b/firmware_mod/www/cgi-bin/state.cgi @@ -40,7 +40,14 @@ if [ -n "$F_cmd" ]; then auto_night_detection) echo $(auto_night_mode status) ;; - + auto_night_detection_mode) + if [ -f /system/sdcard/config/autonight.conf ]; + then night_mode=$(cat /system/sdcard/config/autonight.conf); + else + night_mode="HW"; + fi + echo $night_mode + ;; mqtt_status) if [ -f /run/mqtt-status.pid ]; then mqtt_status="ON"; diff --git a/firmware_mod/www/cgi-bin/status.cgi b/firmware_mod/www/cgi-bin/status.cgi index b8fff11..66c12e7 100755 --- a/firmware_mod/www/cgi-bin/status.cgi +++ b/firmware_mod/www/cgi-bin/status.cgi @@ -195,6 +195,10 @@ cat << EOF
+ + + +
diff --git a/firmware_mod/www/css/sw_night.css b/firmware_mod/www/css/sw_night.css new file mode 100644 index 0000000..b864786 --- /dev/null +++ b/firmware_mod/www/css/sw_night.css @@ -0,0 +1,54 @@ +input{ + text-align: center; + font-family: monospace; + font-size: large; +} + +.code_text{ + font-family: monospace; + font-size: large; +} +.wait{ + font-family: monospace; + font-size: large; + background-color: #89fcfd; +} +.mode{ + font-family: monospace; + font-size: large; + background-color:#ffe944; + box-shadow: 4px 4px 10px black; + text-shadow: 1px 1px 1px black; +} + +.save_button{ + color: white; + background-color: red; + display: block; + border:5 + font-size: 18px; + width:20%; + font-weight: bold; +} +input:disabled{ + font-family: monospace; + font-size: large; +} +.jitter{ + background-color: #89fcfd; +} +.eq1{ + background-color: #89fcfd; +} +.eq2{ + background-color: #bad5dc; +} +.eq2_1{ + background-color: #98b8cf; +} +.eq3{ + background-color: #bad5dc; +} +.eq3_1{ + background-color: #98b8cf; +} diff --git a/firmware_mod/www/index.html b/firmware_mod/www/index.html index 26fa2ef..bb7b679 100644 --- a/firmware_mod/www/index.html +++ b/firmware_mod/www/index.html @@ -19,6 +19,9 @@ + + +