1
0
mirror of https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git synced 2025-09-03 05:02:40 +02:00

Merge branch 'beta'

This commit is contained in:
dewi-ny-je
2020-10-28 22:44:34 +01:00
243 changed files with 124287 additions and 12083 deletions

View File

@@ -7,13 +7,15 @@ This repository contains custom firmwares for the following devices:
Name | Picture
--- | ---
Xiaomi Dafang | ![Dafang](/dafang.png)
Xiaomi Xiaofang 1S (only old Version with T20, newer Version with T20L not supported yet!) | ![XiaoFang](/xiaofang.png)
Xiaomi Xiaofang 1S (old Version with T20 is supported, newer Version with T20L is in beta) | ![XiaoFang](/xiaofang.png)
Wyzecam Pan | ![Dafang](/dafang.png)
Wyzecam V2 | ![XiaoFang](/xiaofang.png)
Neos SmartCam | ![XiaoFang](/xiaofang.png)
Sannce I21AG, MixSight HX-I2110T2, WanScam HW0036, Digoo BB-M2 | ![XiaoFang](/sannce.jpg)
Any other Device with Ingenic T10/T20 Device https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/issues/980 | ![T20](/t20.png)
If you want to test the Xiaofang T20L (newer version) please check out the [beta branch in this repository](https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/tree/beta).
If you have a classic XiaoFang with a ARM-Processor, consider using https://github.com/samtap/fang-hacks
### Attentention: Do not install the latest Firmware on your Device. It will disable the support of this hack.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -4,6 +4,8 @@ OSD=on
JPEG=on
MOTION=on
POOLSIZE=on
# Augment this value to get higher OSD fonts
POOLSIZEBUFFER=0x64000
FontFixedWidth=/system/sdcard/fonts/NotoMono-Regular.ttf
FontRegular=/system/sdcard/fonts/NotoSans-Regular.ttf
@@ -27,3 +29,5 @@ DetectionTracking=/system/sdcard/scripts/detectionTracking.sh
#Quality=2
# The maximum number of gop occupied by the same scene
#maxSameSceneCnt=6
# Maximum GOP
#maxgop=8

View File

@@ -0,0 +1,6 @@
# min hour day month weekday command
*/15 * * * * busybox run-parts /system/sdcard/config/cron/periodic/15min
0 * * * * busybox run-parts /system/sdcard/config/cron/periodic/hourly
0 2 * * * busybox run-parts /system/sdcard/config/cron/periodic/daily
0 3 * * 6 busybox run-parts /system/sdcard/config/cron/periodic/weekly
0 5 1 * * busybox run-parts /system/sdcard/config/cron/periodic/monthly

View File

@@ -15,16 +15,16 @@ mimetype.assign = (
)
index-file.names = ( "index.html" )
server.modules = ("mod_alias",
"mod_auth",
"mod_authn_file",
"mod_redirect",
"mod_rewrite",
"mod_cgi",
"mod_fastcgi",
"mod_dirlisting",
"mod_staticfile",
"mod_accesslog",
"mod_openssl")
"mod_auth",
"mod_authn_file",
"mod_redirect",
"mod_rewrite",
"mod_cgi",
"mod_fastcgi",
"mod_dirlisting",
"mod_staticfile",
"mod_accesslog",
"mod_openssl")
cgi.assign = ( ".cgi" => "/bin/sh" )
@@ -40,38 +40,38 @@ $SERVER["socket"] == ":443" {
# (we don't want to upgrade to SSL nor auth' this path)
$HTTP["url"] !~ "^/.well-known/(.*)" {
$HTTP["scheme"] == "https" {
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/system/sdcard/config/lighttpd.user"
auth.require = ( "/" => ("method" => "basic", "realm" => "all", "require" => "user=root"))
alias.url = ( "/viewer" => "/system/sdcard/DCIM/" )
$HTTP["url"] =~ "^/viewer($|/)" { server.dir-listing = "enable" }
}
$HTTP["scheme"] == "https" {
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/system/sdcard/config/lighttpd.user"
auth.require = ( "/" => ("method" => "basic", "realm" => "all", "require" => "user=root"))
alias.url = ( "/viewer" => "/system/sdcard/DCIM/" )
$HTTP["url"] =~ "^/viewer($|/)" { server.dir-listing = "enable" }
}
#If below 7 lines are commented out then SSL is disabled if un-commented SSL is enabled
#SSL is enabled by default
#If disabling SSL you must clear your site cookie
$HTTP["scheme"] == "http" {
# capture vhost name with regex conditiona -> %0 in redirect pattern
# must be the most inner block to the redirect rule
$HTTP["host"] =~ ".*" {
url.redirect = (".*" => "https://%0$0")
}
}
$HTTP["scheme"] == "http" {
# capture vhost name with regex conditiona -> %0 in redirect pattern
# must be the most inner block to the redirect rule
$HTTP["host"] =~ ".*" {
url.redirect = (".*" => "https://%0$0")
}
}
}
## enable debugging
#debug.log-request-header = "enable"
#debug.log-response-header = "enable"
#debug.log-request-handling = "enable"
#debug.log-file-not-found = "enable"
#debug.log-condition-handling = "enable"
#debug.log-request-header = "enable"
#debug.log-response-header = "enable"
#debug.log-request-handling = "enable"
#debug.log-file-not-found = "enable"
#debug.log-condition-handling = "enable"
## where to send error-messages to
server.errorlog = "/tmp/lighttpd-error.log"
server.errorlog = "/tmp/lighttpd-error.log"
## CGI (etc) stderr log
server.breakagelog = "/tmp/lighttpd-cgi-stderr.log"
server.breakagelog = "/tmp/lighttpd-cgi-stderr.log"
## accesslog module
accesslog.filename = "/tmp/lighttpd-access.log"
accesslog.filename = "/tmp/lighttpd-access.log"

View File

@@ -39,7 +39,7 @@ STATUSINTERVAL=30
# If the device doesn't come with a hardware sensor, your only option is to use 'virtual'.
#
# Options:
# hw = Use 'hw' if the device has build in hardware light sensor. For more details, see . See issue eg. #1120 for more details...
# virtual = Use 'virtual' calculations, based on the lightlevel on the image, also known as ISP exposure (from /proc/jz/isp/isp_info)
# false = Use 'false' (default) to DISABLE the topic (It will not publishing details about light level)
# hw = Use 'hw' if the device has build in hardware light sensor. For more details, see . See issue eg. #1120 for more details...
# virtual = Use 'virtual' calculations, based on the lightlevel on the image, also known as ISP exposure (from /proc/jz/isp/isp_info)
# false = Use 'false' (default) to DISABLE the topic (It will not publishing details about light level)
LIGHT_SENSOR="false"

View File

@@ -1,9 +1,9 @@
DISPLAY_AXIS=true
ENABLE_OSD=true
OSD="%H:%M:%S %d.%m.%Y"
COLOR=0
SIZE=0
POSY=
FIXEDW=0
DISPLAY_AXIS=false
COLOR=3
SIZE=18
SPACE=
POSY=
FIXEDW=false
FONTNAME=

View File

@@ -1,24 +1,24 @@
{
"presets":{
"home":{
"x":1400,
"y":350
},
"left":{
"x":0,
"y":350
},
"top":{
"x":1400,
"y":700
},
"right":{
"x":2800,
"y":350
},
"bottom":{
"x":1400,
"y":0
}
"home":{
"x":1400,
"y":350
},
"left":{
"x":0,
"y":350
},
"top":{
"x":1400,
"y":700
},
"right":{
"x":2800,
"y":350
},
"bottom":{
"x":1400,
"y":0
}
}
}

View File

@@ -1,11 +1,12 @@
#######################################################################
# Edit this file and move it to /system/sdcard/config/rtspserver.conf #
# if you need to add options, otherwise defaults will be used #
# if you need to add options, otherwise defaults will be used #
#######################################################################
# Configure RTSP Servers
# Use /system/sdcard/bin/v4l2rtspserver-master -h to see available options
CODEC="H264"
LOG=false
LOGDIR="/tmp"
LOGPATH="$LOGDIR/v4l2rtspserver-master.log"
@@ -15,19 +16,24 @@ PORT=8554
USERNAME=
USERPASSWORD=
# H264 RTSP server options
# Examples:
# RTSPH264OPTS="-W960 -H540"
# To enable authentication:
# RTSPH264OPTS="-U user:password"
RTSPH264OPTS=""
#Path to save recordings to:
#Set to main Recording directory
DCIM_PATH="/system/sdcard/DCIM/Recording"
# MJPEG RTSP server options
#Add a subdirectory if required:
#Add sub directory to main DCIM path seperated by date then by
#hour for faster loading over ftp
SUB_DIR="$(date +%Y-%m-%d)/$(date +%H)"
#Set the filename format to use
FILE_NAME="REC_$(date +%H-%M-%S.h264)"
# RTSP server options
# Examples:
# RTSPMJPEGOPTS="-W960 -H540"
# RTSPOPTS="-W960 -H540"
# To enable authentication:
# RTSPMJPEGOPTS="-U user:password"
RTSPMJPEGOPTS=""
# RTSPOPTS="-U user:password"
RTSPOPTS=""
# Enable multicast stream
# Example:

View File

@@ -34,22 +34,22 @@ fi
export OPENSSL_CONF="${CONFIGPATH}/openssl.cnf"
if [ "$LETSENCRYPT_METHOD" = "webroot" ]; then
./acme.sh/acme.sh --issue -d ${LETSENCRYPT_DOMAIN} --home ${ACMEPATH} \
-w ${CONFIGPATH}/../www/ \
${DEBUG}
./acme.sh/acme.sh --issue -d ${LETSENCRYPT_DOMAIN} --home ${ACMEPATH} \
-w ${CONFIGPATH}/../www/ \
${DEBUG}
elif [ "$LETSENCRYPT_METHOD" = "dns" ]; then
./acme.sh/acme.sh --issue -d ${LETSENCRYPT_DOMAIN} --home ${ACMEPATH} \
--dns ${LETSENCRYPT_DNS_PROVIDER} \
${DEBUG}
./acme.sh/acme.sh --issue -d ${LETSENCRYPT_DOMAIN} --home ${ACMEPATH} \
--dns ${LETSENCRYPT_DNS_PROVIDER} \
${DEBUG}
fi
./acme.sh/acme.sh --install-cert -d ${LETSENCRYPT_DOMAIN} --home ${ACMEPATH} \
--cert-file ${ACMEPATH}/host.crt \
--key-file ${ACMEPATH}/host.key \
--fullchain-file ${ACMEPATH}/fullchain.crt \
--reloadcmd "cat ${ACMEPATH}/fullchain.crt ${ACMEPATH}/host.key > ${CONFIGPATH}/lighttpd.pem ;\
pkill lighttpd.bin ;\
/system/sdcard/bin/lighttpd -f ${CONFIGPATH}/lighttpd.conf"
--cert-file ${ACMEPATH}/host.crt \
--key-file ${ACMEPATH}/host.key \
--fullchain-file ${ACMEPATH}/fullchain.crt \
--reloadcmd "cat ${ACMEPATH}/host.crt ${ACMEPATH}/host.key > ${CONFIGPATH}/lighttpd.pem ;\
pkill lighttpd.bin ;\
/system/sdcard/bin/lighttpd -f ${CONFIGPATH}/lighttpd.conf"
## Adding cronjob to keep the cert updated

View File

@@ -3,6 +3,7 @@ TIMELAPSE_INTERVAL=2.0
# Duration of the script should run, in minutes, set to 0 for unlimited
TIMELAPSE_DURATION=0
# Save dir config
DCIM_PATH='/system/sdcard/DCIM/Timelapse'
SAVE_DIR_PER_DAY=1
# Enable compression
COMPRESSION_QUALITY=80
COMPRESSION_QUALITY=100

View File

@@ -13,12 +13,12 @@
FILECAMERAPOS=/system/sdcard/config/cameraposition
if [ -f ${FILECAMERAPOS} ]; then
# Get values in saved config file
origin_x_axis=`grep "x:" ${FILECAMERAPOS} | sed "s/x: //"`
origin_y_axis=`grep "y:" ${FILECAMERAPOS} | sed "s/y: //"`
# Get values in saved config file
origin_x_axis=`grep "x:" ${FILECAMERAPOS} | sed "s/x: //"`
origin_y_axis=`grep "y:" ${FILECAMERAPOS} | sed "s/y: //"`
else
# No such file exists: create it with the current values
/system/sdcard/bin/motor -d s > ${FILECAMERAPOS}
# No such file exists: create it with the current values
/system/sdcard/bin/motor -d s > ${FILECAMERAPOS}
fi
# go to home for both axis

View File

@@ -6,12 +6,12 @@ ctrl_interface_group=0
ap_scan=1
network={
ssid="SSID"
# Uncomment to connect to Hidden SSIDs
#scan_ssid=1
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP WEP104 WEP40
psk="PW"
priority=2
ssid="SSID"
# Uncomment to connect to Hidden SSIDs
#scan_ssid=1
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP WEP104 WEP40
psk="PW"
priority=2
}

View File

@@ -6,7 +6,7 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
@@ -14,16 +14,16 @@ start()
{
. $CONF_FILE
if [ -f /run/auto-night-detection.pid ]; then
echo "Auto night detection already running";
echo "Auto night detection already running";
else
if [ "$autonight_mode" == "sw" ]; then
echo "Starting software auto night detection"
/system/sdcard/bin/busybox nohup /system/sdcard/bin/autonight $sw_parameters &>/dev/null &
else
echo "Starting hardware auto night detection"
/system/sdcard/bin/busybox nohup /system/sdcard/bin/autonight $hw_parameters &>/dev/null &
fi
echo "$!" > "$PIDFILE"
if [ "$autonight_mode" == "sw" ]; then
echo "Starting software auto night detection"
/system/sdcard/bin/busybox nohup /system/sdcard/bin/autonight $sw_parameters &>/dev/null &
else
echo "Starting hardware auto night detection"
/system/sdcard/bin/busybox nohup /system/sdcard/bin/autonight $hw_parameters &>/dev/null &
fi
echo "$!" > "$PIDFILE"
fi
}
@@ -31,7 +31,7 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid" && rm "$PIDFILE"
kill "$pid" && rm "$PIDFILE"
fi
}
@@ -39,8 +39,8 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -6,14 +6,14 @@ if [ ! -f /system/sdcard/config/motion.conf ]; then
fi
if [ -f /system/sdcard/config/motion.conf ] ; then
. /system/sdcard/config/motion.conf 2>/dev/null
/system/sdcard/bin/setconf -k r -v ${region_of_interest} 2>/dev/null
if [ "$motion_detection" = "off" ]; then
/system/sdcard/bin/setconf -k m -v -1 2>/dev/null
else
/system/sdcard/bin/setconf -k m -v ${motion_sensitivity} 2>/dev/null
fi
/system/sdcard/bin/setconf -k z -v ${motion_indicator_color} 2>/dev/null
/system/sdcard/bin/setconf -k t -v ${motion_tracking} 2>/dev/null
/system/sdcard/bin/setconf -k u -v ${motion_timeout} 2>/dev/null
. /system/sdcard/config/motion.conf 2>/dev/null
/system/sdcard/bin/setconf -k r -v ${region_of_interest} 2>/dev/null
if [ "$motion_detection" = "off" ]; then
/system/sdcard/bin/setconf -k m -v -1 2>/dev/null
else
/system/sdcard/bin/setconf -k m -v ${motion_sensitivity} 2>/dev/null
fi
/system/sdcard/bin/setconf -k z -v ${motion_indicator_color} 2>/dev/null
/system/sdcard/bin/setconf -k t -v ${motion_tracking} 2>/dev/null
/system/sdcard/bin/setconf -k u -v ${motion_timeout} 2>/dev/null
fi;

View File

@@ -2,17 +2,17 @@
## Get OSD-Information
if [ -f /system/sdcard/config/osd.conf ]; then
. /system/sdcard/config/osd.conf > /dev/null 2>/dev/null
AXIS=""
# Call setconf only if we have something to set, to avoid outputing error messages
[ "${DISPLAY_AXIS}" = true ] && AXIS=$(/system/sdcard/bin/motor -d s | sed '3d' | awk '{printf ("%s ",$0)}' | awk '{print " X="$2,"Y="$4}')
[ "${ENABLE_OSD}" = true ] && /system/sdcard/bin/setconf -k o -v "${OSD}${AXIS}" 2>/dev/null
[ ! -z "${COLOR}" ] && /system/sdcard/bin/setconf -k c -v ${COLOR} 2>/dev/null
[ ! -z "${SIZE}" ] && /system/sdcard/bin/setconf -k s -v ${SIZE} 2>/dev/null
[ ! -z "${POSY}" ] && /system/sdcard/bin/setconf -k x -v ${POSY} 2>/dev/null
[ ! -z "${FIXEDW}" ] && /system/sdcard/bin/setconf -k w -v ${FIXEDW} 2>/dev/null
[ ! -z "${SPACE}" ] && /system/sdcard/bin/setconf -k p -v ${SPACE} 2>/dev/null
[ ! -z "${FONTNAME}" ] && /system/sdcard/bin/setconf -k e -v ${FONTNAME} 2>/dev/null
. /system/sdcard/config/osd.conf > /dev/null 2>/dev/null
AXIS=""
# Call setconf only if we have something to set, to avoid outputing error messages
[ "${DISPLAY_AXIS}" = true ] && AXIS=$(/system/sdcard/bin/motor -d s | sed '3d' | awk '{printf ("%s ",$0)}' | awk '{print " X="$2,"Y="$4}')
[ "${ENABLE_OSD}" = true ] && /system/sdcard/bin/setconf -k o -v "${OSD}${AXIS}" 2>/dev/null
[ ! -z "${COLOR}" ] && /system/sdcard/bin/setconf -k c -v ${COLOR} 2>/dev/null
[ ! -z "${SIZE}" ] && /system/sdcard/bin/setconf -k s -v ${SIZE} 2>/dev/null
[ ! -z "${POSY}" ] && /system/sdcard/bin/setconf -k x -v ${POSY} 2>/dev/null
[ ! -z "${FIXEDW}" ] && /system/sdcard/bin/setconf -k w -v ${FIXEDW} 2>/dev/null
[ ! -z "${SPACE}" ] && /system/sdcard/bin/setconf -k p -v ${SPACE} 2>/dev/null
[ ! -z "${FONTNAME}" ] && /system/sdcard/bin/setconf -k e -v ${FONTNAME} 2>/dev/null
else
/system/sdcard/bin/setconf -k o -v ""
/system/sdcard/bin/setconf -k o -v ""
fi

View File

@@ -6,19 +6,19 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ -f ${PIDFILE} ]; then
echo "Debug on OSD already running";
echo "Debug on OSD already running";
else
echo "Starting debug on OSD"
/system/sdcard/scripts/debugInOsd.sh &>/dev/null &
# /system/sdcard/bin/busybox nohup /system/sdcard/scripts/debugInOsd.sh &>/dev/null
echo "$!" > "$PIDFILE"
echo "Starting debug on OSD"
/system/sdcard/scripts/debugInOsd.sh &>/dev/null &
# /system/sdcard/bin/busybox nohup /system/sdcard/scripts/debugInOsd.sh &>/dev/null
echo "$!" > "$PIDFILE"
fi
}
@@ -26,10 +26,10 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "${pid}" ]; then
kill "$pid" && rm "$PIDFILE"
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
source /system/sdcard/controlscripts/configureOsd
fi
kill "$pid" && rm "$PIDFILE"
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
source /system/sdcard/controlscripts/configureOsd
fi
fi
}
@@ -38,8 +38,8 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -1,55 +1,55 @@
#!/bin/sh
PIDFILE="/var/run/bftpd.pid"
PIDFILE="/var/run/ftp_server.pid"
status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
echo "Starting bftpd server"
PID="$(pidof -o %PPID /system/sdcard/bin/bftpd)"
if [ -z "$PID" ]; then
/system/sdcard/bin/bftpd -d
if [ $? -gt 0 ]; then
echo "Failed to start bftpd Server"
else
# wait until it forks
sleep 2
echo $(pidof -o %PPID bftpd) > $PIDFILE
echo "bftpd server started"
fi
else
echo "Failed to start bftpd Server"
fi
echo "Starting bftpd server"
PID="$(pidof -o %PPID /system/sdcard/bin/bftpd)"
if [ -z "$PID" ]; then
/system/sdcard/bin/bftpd -d
if [ $? -gt 0 ]; then
echo "Failed to start bftpd Server"
else
# wait until it forks
sleep 2
echo $(pidof -o %PPID bftpd) > $PIDFILE
echo "bftpd server started"
fi
else
echo "Failed to start bftpd Server"
fi
}
stop()
{
echo "Stopping bftpd Server"
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
kill -15 $(cat $PIDFILE)
rm $PIDFILE
echo "bftpd server stopped"
else
echo "Failed to stop bftpd Server"
fi
echo "Stopping bftpd Server"
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
kill -15 $(cat $PIDFILE)
rm $PIDFILE
echo "bftpd server stopped"
else
echo "Failed to stop bftpd Server"
fi
}
restart()
{
$0 stop
sleep 1
$0 start
$0 stop
sleep 1
$0 start
}
if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|restart|status)
$1
;;
$1
;;
esac
fi

View File

@@ -9,25 +9,25 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ -f $PIDFILE ]; then
echo "MQTT Control already running";
echo "MQTT Control already running";
else
. /system/sdcard/config/mqtt.conf
if [ -z ${AUTODISCOVERY_PREFIX+x} ];
then echo "MQTT autodiscovery is not enabled";
else
echo "MQTT autodiscovery is enabled - now publishing initial configurations";
/system/sdcard/scripts/mqtt-autodiscovery.sh
fi
echo "Starting MQTT - Control"
/system/sdcard/bin/busybox nohup /system/sdcard/scripts/mqtt-control.sh &>/dev/null &
echo "$!" > "$PIDFILE"
. /system/sdcard/config/mqtt.conf
if [ -z ${AUTODISCOVERY_PREFIX+x} ];
then echo "MQTT autodiscovery is not enabled";
else
echo "MQTT autodiscovery is enabled - now publishing initial configurations";
/system/sdcard/scripts/mqtt-autodiscovery.sh
fi
echo "Starting MQTT - Control"
/system/sdcard/bin/busybox nohup /system/sdcard/scripts/mqtt-control.sh &>/dev/null &
echo "$!" > "$PIDFILE"
fi
}
@@ -35,10 +35,10 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
killall mosquitto_sub 2>/dev/null
killall mosquitto_sub.bin 2>/dev/null
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
killall mosquitto_sub 2>/dev/null
killall mosquitto_sub.bin 2>/dev/null
fi
}
@@ -46,7 +46,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -9,18 +9,18 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ -f $PIDFILE ]; then
echo "MQTT-Status already running";
echo "MQTT-Status already running";
else
echo "Starting MQTT-Status"
/system/sdcard/bin/busybox nohup /system/sdcard/scripts/mqtt-status-interval.sh &>/dev/null &
echo "$!" > "$PIDFILE"
echo "Starting MQTT-Status"
/system/sdcard/bin/busybox nohup /system/sdcard/scripts/mqtt-status-interval.sh &>/dev/null &
echo "$!" > "$PIDFILE"
fi
}
@@ -28,7 +28,7 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid" && rm "$PIDFILE"
kill "$pid" && rm "$PIDFILE"
fi
}
@@ -36,7 +36,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -2,11 +2,10 @@
. /system/sdcard/config/rtspserver.conf
PIDFILE="/run/recording.pid"
DCIM_PATH="/system/sdcard/DCIM/Recording"
## UserName and password
if [ "$USERNAME" != "" ]; then
CREDENTIALS="$USERNAME:$USERPASSWORD@"
CREDENTIALS="$USERNAME:$USERPASSWORD@"
fi
if [ ! -d "$DCIM_PATH" ]; then
@@ -17,32 +16,29 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ -f $PIDFILE ]; then
echo "Recording already running.";
echo "Recording already running.";
else
echo "Started recording."
# Add sub directory to main dcim path seperated by date then by
# hour for faster loading over ftp
SUB_DIR="$(date +%Y-%m-%d)/$(date +%H)"
if [ ! -d "$DCIM_PATH/$SUB_DIR" ]; then
mkdir -p "$DCIM_PATH/$SUB_DIR"
fi
echo "Started recording."
if [ ! -d "$DCIM_PATH/$SUB_DIR" ]; then
mkdir -p "$DCIM_PATH/$SUB_DIR"
fi
# Create the recording with timestamp
FILE_NAME="REC_$(date +%H-%M-%S.h264)"
RECORDING_PATH="$DCIM_PATH/$SUB_DIR/$FILE_NAME"
# wait for rtspserver to become available
until pids=$(pidof v4l2rtspserver-master)
do
sleep 1
done
/system/sdcard/bin/busybox nohup /system/sdcard/bin/avconv -flags low_delay -fflags nobuffer -probesize 32 -i rtsp://"$CREDENTIALS"0.0.0.0:$PORT/unicast -strict experimental -y -vcodec copy -an $RECORDING_PATH &>/dev/null &
echo "$!" > "$PIDFILE"
RECORDING_PATH="$DCIM_PATH/$SUB_DIR/$FILE_NAME"
# wait for rtspserver to become available
until pids=$(pidof v4l2rtspserver-master)
do
sleep 1
done
/system/sdcard/bin/busybox nohup /system/sdcard/bin/avconv -flags low_delay -fflags nobuffer -probesize 32 -i rtsp://"$CREDENTIALS"0.0.0.0:$PORT/unicast -strict experimental -y -vcodec copy -an $RECORDING_PATH &>/dev/null &
echo "$!" > "$PIDFILE"
fi
}
@@ -50,11 +46,11 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
echo "Stopped recording."
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
echo "Stopped recording."
else
echo "Could not find a running recording to stop."
echo "Could not find a running recording to stop."
fi
}
@@ -62,7 +58,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -0,0 +1,116 @@
#!/bin/sh
PIDFILE="/run/rtsp.pid"
LOGDIR="/tmp"
LOGPATH="$LOGDIR/v4l2rtspserver-master.log"
export LD_LIBRARY_PATH='/system/sdcard/lib:/thirdlib:/system/lib'
if [ ! -f /system/sdcard/config/rtspserver.conf ]; then
cp /system/sdcard/config/rtspserver.conf.dist /system/sdcard/config/rtspserver.conf
fi
if [ -f /system/sdcard/config/rtspserver.conf ]; then
. /system/sdcard/config/rtspserver.conf
fi
if [ "$LOG" != true ] ; then
LOGPATH="/dev/null"
fi
if [ -f /system/sdcard/config/osd.conf ]; then
. /system/sdcard/config/osd.conf 2>/dev/null
fi
if [ -z "${CODEC+x}" ]; then
CODEC="H264"
fi
status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
# Prints PID: $pid if exists and returns 0(no error) else returns 1(error condition)
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ "$(status)" != "" ]; then
echo "A v4l2rtspserver is already running, please stop it or reboot"
else
echo "Starting v4l2rtspserver-master"
## Configure OSD
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
. /system/sdcard/controlscripts/configureOsd 2>/dev/null
fi
## Configure Motion
if [ -f /system/sdcard/controlscripts/configureMotion ]; then
. /system/sdcard/controlscripts/configureMotion 2>/dev/null
fi
## Bitrate
/system/sdcard/bin/setconf -k b -v ${BITRATE} 2>/dev/null
## Framerate
if [ "$FRAMERATE_DEN" != "" ] && [ "$FRAMERATE_NUM" != "" ]; then
/system/sdcard/bin/setconf -k d -v "$FRAMERATE_NUM,$FRAMERATE_DEN" 2>/dev/null
fi
## Audio
if [ "$AUDIOFORMAT" != "OFF" ] ; then
AUDIOPARAM="-E $AUDIOFORMAT:$AUDIOINBR:$AUDIOOUTBR"
/system/sdcard/bin/setconf -k h -v "$HWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k i -v "$SWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k q -v "$FILTER" 2>/dev/null
/system/sdcard/bin/setconf -k l -v "$HIGHPASSFILTER" 2>/dev/null
/system/sdcard/bin/setconf -k a -v "$AECFILTER" 2>/dev/null
else
AUDIOPARAM="-A"
fi
## Video format
if [ "$VIDEOFORMAT" != "" ]; then
VIDEOFORMAT="-r $VIDEOFORMAT -F $FRAMERATE_NUM"
fi
## UserName and password
if [ "$USERNAME" != "" ]; then
CREDENTIAL="-U $USERNAME:$USERPASSWORD"
fi
## Port
if [ "$PORT" != "" ]; then
PORT="-P $PORT"
fi
## Multicast
if [ "$MULTICASTDEST" != "" ]; then
MULTICASTDEST="-M $MULTICASTDEST"
fi
## FLIP
if [ "$FLIP" == "ON" ]; then
/system/sdcard/bin/setconf -k f -v 1
else
/system/sdcard/bin/setconf -k f -v 0
fi
echo "================== START ===============" >> "$LOGPATH"
echo "/system/sdcard/bin/v4l2rtspserver-master -f$CODEC $RTSPOPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST" >> "$LOGPATH"
/system/sdcard/bin/v4l2rtspserver-master -f$CODEC $RTSPOPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST 2>> "$LOGPATH" >> "$LOGPATH" &
echo "$!" > "$PIDFILE"
fi
}
stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
fi
}
if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
esac
fi

View File

@@ -1,5 +1,5 @@
#!/bin/sh
PIDFILE="/run/v4l2rtspserver-master-h264.pid"
PIDFILE="/run/rtsp-h264.pid"
export LD_LIBRARY_PATH='/system/sdcard/lib/:/thirdlib:/system/lib'
if [ ! -f /system/sdcard/config/rtspserver.conf ]; then
@@ -22,84 +22,84 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
# return current pid if pidfile exists and contained pid is alive
# return 1 if pidfile existed but the contained pid is dead
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
# return current pid if pidfile exists and contained pid is alive
# return 1 if pidfile existed but the contained pid is dead
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
else
# return 2 if pidfile did not exist
return 2
# return 2 if pidfile did not exist
return 2
fi
}
start()
{
if [ "$(status)" != "" ]; then
echo "A v4l2rtspserver is already running, please stop it or reboot"
echo "A v4l2rtspserver is already running, please stop it or reboot"
else
echo "Starting v4l2rtspserver-master"
/system/sdcard/controlscripts/rtsp-mjpeg stop
echo "Starting v4l2rtspserver-master"
/system/sdcard/controlscripts/rtsp-mjpeg stop
## Configure OSD
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
. /system/sdcard/controlscripts/configureOsd 2>/dev/null
fi
## Configure OSD
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
. /system/sdcard/controlscripts/configureOsd 2>/dev/null
fi
## Configure Motion
if [ -f /system/sdcard/controlscripts/configureMotion ]; then
. /system/sdcard/controlscripts/configureMotion 2>/dev/null
fi
## Bitrate
/system/sdcard/bin/setconf -k b -v ${BITRATE} 2>/dev/null
## Configure Motion
if [ -f /system/sdcard/controlscripts/configureMotion ]; then
. /system/sdcard/controlscripts/configureMotion 2>/dev/null
fi
## Bitrate
/system/sdcard/bin/setconf -k b -v ${BITRATE} 2>/dev/null
## Framerate
if [ "$FRAMERATE_DEN" != "" ] && [ "$FRAMERATE_NUM" != "" ]; then
/system/sdcard/bin/setconf -k d -v "$FRAMERATE_NUM,$FRAMERATE_DEN" 2>/dev/null
fi
## Framerate
if [ "$FRAMERATE_DEN" != "" ] && [ "$FRAMERATE_NUM" != "" ]; then
/system/sdcard/bin/setconf -k d -v "$FRAMERATE_NUM,$FRAMERATE_DEN" 2>/dev/null
fi
## Audio
if [ "$AUDIOFORMAT" != "OFF" ] ; then
AUDIOPARAM="-E $AUDIOFORMAT:$AUDIOINBR:$AUDIOOUTBR"
/system/sdcard/bin/setconf -k h -v "$HWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k i -v "$SWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k q -v "$FILTER" 2>/dev/null
/system/sdcard/bin/setconf -k l -v "$HIGHPASSFILTER" 2>/dev/null
/system/sdcard/bin/setconf -k a -v "$AECFILTER" 2>/dev/null
else
AUDIOPARAM="-A"
fi
## Audio
if [ "$AUDIOFORMAT" != "OFF" ] ; then
AUDIOPARAM="-E $AUDIOFORMAT:$AUDIOINBR:$AUDIOOUTBR"
/system/sdcard/bin/setconf -k h -v "$HWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k i -v "$SWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k q -v "$FILTER" 2>/dev/null
/system/sdcard/bin/setconf -k l -v "$HIGHPASSFILTER" 2>/dev/null
/system/sdcard/bin/setconf -k a -v "$AECFILTER" 2>/dev/null
else
AUDIOPARAM="-A"
fi
## Video format
if [ "$VIDEOFORMAT" != "" ]; then
VIDEOFORMAT="-r $VIDEOFORMAT -F $FRAMERATE_NUM"
fi
## Video format
if [ "$VIDEOFORMAT" != "" ]; then
VIDEOFORMAT="-r $VIDEOFORMAT -F $FRAMERATE_NUM"
fi
## UserName and password
if [ "$USERNAME" != "" ]; then
CREDENTIAL="-U $USERNAME:$USERPASSWORD"
fi
## UserName and password
if [ "$USERNAME" != "" ]; then
CREDENTIAL="-U $USERNAME:$USERPASSWORD"
fi
## Port
if [ "$PORT" != "" ]; then
PORT="-P $PORT"
fi
## Port
if [ "$PORT" != "" ]; then
PORT="-P $PORT"
fi
## Multicast
if [ "$MULTICASTDEST" != "" ]; then
MULTICASTDEST="-M $MULTICASTDEST"
fi
## Multicast
if [ "$MULTICASTDEST" != "" ]; then
MULTICASTDEST="-M $MULTICASTDEST"
fi
## FLIP
if [ "$FLIP" == "ON" ]; then
/system/sdcard/bin/setconf -k f -v 1
elif [ "$FLIP" == "OFF" ]; then
/system/sdcard/bin/setconf -k f -v 0
fi
## FLIP
if [ "$FLIP" == "ON" ]; then
/system/sdcard/bin/setconf -k f -v 1
elif [ "$FLIP" == "OFF" ]; then
/system/sdcard/bin/setconf -k f -v 0
fi
echo "================== START ===============" >> "$LOGPATH"
echo "/system/sdcard/bin/v4l2rtspserver-master $RTSPH264OPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST" >> "$LOGPATH"
cd /system/sdcard/hls
/system/sdcard/bin/v4l2rtspserver-master $RTSPH264OPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST 2>> "$LOGPATH" >> "$LOGPATH" &
echo "$!" > "$PIDFILE"
echo "================== START ===============" >> "$LOGPATH"
echo "/system/sdcard/bin/v4l2rtspserver-master $RTSPOPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST" >> "$LOGPATH"
cd /system/sdcard/hls
/system/sdcard/bin/v4l2rtspserver-master $RTSPOPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST 2>> "$LOGPATH" >> "$LOGPATH" &
echo "$!" > "$PIDFILE"
fi
}
@@ -107,8 +107,9 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
fi
}
@@ -116,7 +117,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -1,5 +1,5 @@
#!/bin/sh
PIDFILE="/run/v4l2rtspserver-master-mjpeg.pid"
PIDFILE="/run/rtsp-mpjeg.pid"
LOGDIR="/tmp"
LOGPATH="$LOGDIR/v4l2rtspserver-master.log"
export LD_LIBRARY_PATH='/system/sdcard/lib:/thirdlib:/system/lib'
@@ -20,79 +20,79 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
# Prints PID: $pid if exists and returns 0(no error) else returns 1(error condition)
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
# Prints PID: $pid if exists and returns 0(no error) else returns 1(error condition)
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ "$(status)" != "" ]; then
echo "A v4l2rtspserver is already running, please stop it or reboot"
echo "A v4l2rtspserver is already running, please stop it or reboot"
else
echo "Starting v4l2rtspserver-master with parameter -fMJPG"
/system/sdcard/controlscripts/rtsp-h264 stop
echo "Starting v4l2rtspserver-master with parameter -fMJPG"
/system/sdcard/controlscripts/rtsp-h264 stop
## Configure OSD
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
. /system/sdcard/controlscripts/configureOsd 2>/dev/null
fi
## Configure OSD
if [ -f /system/sdcard/controlscripts/configureOsd ]; then
. /system/sdcard/controlscripts/configureOsd 2>/dev/null
fi
## Configure Motion
if [ -f /system/sdcard/controlscripts/configureMotion ]; then
. /system/sdcard/controlscripts/configureMotion 2>/dev/null
fi
## Bitrate
/system/sdcard/bin/setconf -k b -v ${BITRATE} 2>/dev/null
## Configure Motion
if [ -f /system/sdcard/controlscripts/configureMotion ]; then
. /system/sdcard/controlscripts/configureMotion 2>/dev/null
fi
## Bitrate
/system/sdcard/bin/setconf -k b -v ${BITRATE} 2>/dev/null
## Framerate
if [ "$FRAMERATE_DEN" != "" ] && [ "$FRAMERATE_NUM" != "" ]; then
/system/sdcard/bin/setconf -k d -v "$FRAMERATE_NUM,$FRAMERATE_DEN" 2>/dev/null
fi
## Framerate
if [ "$FRAMERATE_DEN" != "" ] && [ "$FRAMERATE_NUM" != "" ]; then
/system/sdcard/bin/setconf -k d -v "$FRAMERATE_NUM,$FRAMERATE_DEN" 2>/dev/null
fi
## Audio
if [ "$AUDIOFORMAT" != "OFF" ] ; then
AUDIOPARAM="-E $AUDIOFORMAT:$AUDIOINBR:$AUDIOOUTBR"
/system/sdcard/bin/setconf -k h -v "$HWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k i -v "$SWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k q -v "$FILTER" 2>/dev/null
/system/sdcard/bin/setconf -k l -v "$HIGHPASSFILTER" 2>/dev/null
/system/sdcard/bin/setconf -k a -v "$AECFILTER" 2>/dev/null
else
AUDIOPARAM="-A"
fi
## Audio
if [ "$AUDIOFORMAT" != "OFF" ] ; then
AUDIOPARAM="-E $AUDIOFORMAT:$AUDIOINBR:$AUDIOOUTBR"
/system/sdcard/bin/setconf -k h -v "$HWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k i -v "$SWVOLUME" 2>/dev/null
/system/sdcard/bin/setconf -k q -v "$FILTER" 2>/dev/null
/system/sdcard/bin/setconf -k l -v "$HIGHPASSFILTER" 2>/dev/null
/system/sdcard/bin/setconf -k a -v "$AECFILTER" 2>/dev/null
else
AUDIOPARAM="-A"
fi
## Video format
if [ "$VIDEOFORMAT" != "" ]; then
VIDEOFORMAT="-r $VIDEOFORMAT -F $FRAMERATE_NUM"
fi
## Video format
if [ "$VIDEOFORMAT" != "" ]; then
VIDEOFORMAT="-r $VIDEOFORMAT -F $FRAMERATE_NUM"
fi
## UserName and password
if [ "$USERNAME" != "" ]; then
CREDENTIAL="-U $USERNAME:$USERPASSWORD"
fi
## UserName and password
if [ "$USERNAME" != "" ]; then
CREDENTIAL="-U $USERNAME:$USERPASSWORD"
fi
## Port
if [ "$PORT" != "" ]; then
PORT="-P $PORT"
fi
## Port
if [ "$PORT" != "" ]; then
PORT="-P $PORT"
fi
## Multicast
if [ "$MULTICASTDEST" != "" ]; then
MULTICASTDEST="-M $MULTICASTDEST"
fi
## Multicast
if [ "$MULTICASTDEST" != "" ]; then
MULTICASTDEST="-M $MULTICASTDEST"
fi
## FLIP
if [ "$FLIP" == "ON" ]; then
/system/sdcard/bin/setconf -k f -v 1
elif [ "$FLIP" == "OFF" ]; then
/system/sdcard/bin/setconf -k f -v 0
fi
## FLIP
if [ "$FLIP" == "ON" ]; then
/system/sdcard/bin/setconf -k f -v 1
elif [ "$FLIP" == "OFF" ]; then
/system/sdcard/bin/setconf -k f -v 0
fi
echo "================== START ===============" >> "$LOGPATH"
echo "/system/sdcard/bin/v4l2rtspserver-master -fMJPG $RTSPMJPEGOPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST" >> "$LOGPATH"
/system/sdcard/bin/v4l2rtspserver-master -fMJPG $RTSPMJPEGOPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST 2>> "$LOGPATH" >> "$LOGPATH" &
echo "$!" > "$PIDFILE"
echo "================== START ===============" >> "$LOGPATH"
echo "/system/sdcard/bin/v4l2rtspserver-master -fMJPG $RTSPOPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST" >> "$LOGPATH"
/system/sdcard/bin/v4l2rtspserver-master -fMJPG $RTSPOPTS $AUDIOPARAM $VIDEOFORMAT $CREDENTIAL $PORT $MULTICASTDEST 2>> "$LOGPATH" >> "$LOGPATH" &
echo "$!" > "$PIDFILE"
fi
}
@@ -100,8 +100,8 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
kill "$pid"
rm "$PIDFILE" 1> /dev/null 2>&1
fi
}
@@ -109,7 +109,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -0,0 +1,11 @@
#!/bin/sh
CONF_FILE_DATE=$(date +%Y-%m-%d_%H-%M-%S)
CONF_FILE_NAME="savedConf-${CONF_FILE_DATE}.tar.gz"
CONF_PATH="/system/sdcard/config"
CONF_DEST="/system/sdcard/DCIM/Config"
if [ ! -d $CONF_DEST ]; then
mkdir $CONF_DEST
fi
tar -zcf $CONF_DEST/$CONF_FILE_NAME -C $CONF_PATH --exclude='*.dist' .

View File

@@ -3,7 +3,7 @@
status()
{
if [ -f /system/sdcard/config/autostart/sound-on-startup ]; then
echo "enabled"
echo "enabled"
fi
}
@@ -12,15 +12,15 @@ start()
UPTIME=$( sed 's/\..*//g' < /proc/uptime )
if [ ! -f /system/sdcard/config/autostart/sound-on-startup ] && [ "${UPTIME}" -gt 60 ] ; then
echo "#!/bin/sh" > "/system/sdcard/config/autostart/sound-on-startup"
echo "/system/sdcard/controlscripts/sound-on-startup" >> "/system/sdcard/config/autostart/sound-on-startup"
echo "enabling sound on startup"
echo "#!/bin/sh" > "/system/sdcard/config/autostart/sound-on-startup"
echo "/system/sdcard/controlscripts/sound-on-startup" >> "/system/sdcard/config/autostart/sound-on-startup"
echo "enabling sound on startup"
fi
# Don't play sound on activation
if [ "${UPTIME}" -lt 60 ]; then
/system/sdcard/bin/audioplay /usr/share/notify/CN/speaker.wav &
echo "Please configure this option at least 1 minute after system startup"
/system/sdcard/bin/audioplay /usr/share/notify/CN/speaker.wav &
echo "Please configure this option at least 1 minute after system startup"
fi
}
@@ -34,8 +34,8 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -16,18 +16,18 @@ status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
if [ -f $PIDFILE ]; then
echo "Bot already running";
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"
echo "Starting bot"
/system/sdcard/bin/busybox nohup /system/sdcard/scripts/telegram-bot-daemon.sh >/dev/null 2>&1 &
echo "$!" > "$PIDFILE"
fi
}
@@ -35,11 +35,11 @@ stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -9 "$pid"
rm "$PIDFILE"
echo "Bot stopped"
kill -9 "$pid"
rm "$PIDFILE"
echo "Bot stopped"
else
echo "Could not find a bot to stop."
echo "Could not find a bot to stop."
fi
}
@@ -47,7 +47,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

View File

@@ -4,52 +4,52 @@ PIDFILE="/var/run/telnetd.pid"
status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" >/dev/null && echo "PID: $pid" || return 1
fi
}
start()
{
echo "Starting telnetd"
PID="$(pidof -o %PPID /sbin/telnetd)"
if [ -z "$PID" ]; then
/sbin/telnetd
if [ $? -gt 0 ]; then
echo "Failed to start telnetd"
else
# wait until it forks
sleep 2
echo $(pidof -o %PPID telnetd) > $PIDFILE
echo "Telnetd started"
fi
else
echo "Failed to start telnetd"
fi
echo "Starting telnetd"
PID="$(pidof -o %PPID /sbin/telnetd)"
if [ -z "$PID" ]; then
/sbin/telnetd
if [ $? -gt 0 ]; then
echo "Failed to start telnetd"
else
# wait until it forks
sleep 2
echo $(pidof -o %PPID telnetd) > $PIDFILE
echo "Telnetd started"
fi
else
echo "Failed to start telnetd"
fi
}
stop()
{
echo "Stopping telnetd"
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
kill -15 $(cat $PIDFILE)
rm $PIDFILE
echo "Telnetd stopped"
else
echo "Failed to stop telnetd"
fi
echo "Stopping telnetd"
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
kill -15 $(cat $PIDFILE)
rm $PIDFILE
echo "Telnetd stopped"
else
echo "Failed to stop telnetd"
fi
}
restart()
{
$0 stop
sleep 1
$0 start
$0 stop
sleep 1
$0 start
}
if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|restart|status)
$1
;;
$1
;;
esac
fi

View File

@@ -29,7 +29,7 @@ if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
$1
;;
esac
fi

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
firmware_mod/lib/libtls.so Executable file

Binary file not shown.

BIN
firmware_mod/lib/libz.so Executable file

Binary file not shown.

View File

@@ -1,8 +1,8 @@
#!/bin/sh
#######################################################
# Accepts either presets or step coordinates #
# Created by slm4996 #
# Accepts either presets or step coordinates #
# Created by slm4996 #
# slm4996+github@gmail.com | 4-29-2020 | v0.0.1 Beta #
#######################################################
@@ -11,10 +11,10 @@ set -e
LOG=false
logger() {
echo "$1"
if $LOG; then
echo "$(date '+%Y-%m-%d-%H:%M:%S') $1" >> /system/sdcard/log/ptz.log
fi
echo "$1"
if $LOG; then
echo "$(date '+%Y-%m-%d-%H:%M:%S') $1" >> /system/sdcard/log/ptz.log
fi
}
PIDFILE="/var/run/PTZpresets.pid"
@@ -22,17 +22,17 @@ PIDFILE="/var/run/PTZpresets.pid"
# check pidfile
if [ -e "$PIDFILE" ] && [ -e "/proc/$(cat $PIDFILE)" ]
then
# A process exists with our saved PID
logger "PTZpresets.sh is already running with PID $PID_SAVED; exiting"
exit 1
# A process exists with our saved PID
logger "PTZpresets.sh is already running with PID $PID_SAVED; exiting"
exit 1
fi
# write pidfile
if ! echo $$ >"$PIDFILE"
then
# If we couldn't save the PID to the lockfile...
logger "Failed to create PID file for PID $$ in $PIDFILE; exiting"
exit 1
# If we couldn't save the PID to the lockfile...
logger "Failed to create PID file for PID $$ in $PIDFILE; exiting"
exit 1
fi
trap 'rm "$PIDFILE"' EXIT
@@ -49,119 +49,119 @@ FILEPRESETS=/system/sdcard/config/ptz_presets.conf
# Check for custom presets file, load examples if not present
if [ ! -f ${FILEPRESETS} ]; then
cp /system/sdcard/config/ptz_presets.conf.dist /system/sdcard/config/ptz_presets.conf
cp /system/sdcard/config/ptz_presets.conf.dist /system/sdcard/config/ptz_presets.conf
fi
# Print usage
print_usage() {
logger "Usage:"
logger "Presets: PTZpresets.sh preset [preset_name]"
logger "Example: PTZpresets.sh preset home"
logger "Presets are defined in /system/sdcard/config/ptz_presets.conf.dist."
logger ""
logger "Steps: PTZpresets.sh [X axis steps] [Y axis steps]"
logger "Example: PTZpresets.sh 1400 350"
logger "Usage:"
logger "Presets: PTZpresets.sh preset [preset_name]"
logger "Example: PTZpresets.sh preset home"
logger "Presets are defined in /system/sdcard/config/ptz_presets.conf.dist."
logger ""
logger "Steps: PTZpresets.sh [X axis steps] [Y axis steps]"
logger "Example: PTZpresets.sh 1400 350"
}
# Calculate relative steps for axis
calculate_relative_steps() {
case $1 in
x|X)
current_x_axis=$($MOTOR -d s | grep "$1" | awk '{print $2}')
relative_x_steps=$(echo $(($2 - current_x_axis)) | sed 's/-//')
;;
y|Y)
current_y_axis=$($MOTOR -d s | grep "$1" | awk '{print $2}')
relative_y_steps=$(echo $(($2 - current_y_axis)) | sed 's/-//')
;;
*)
exit 1
;;
esac
case $1 in
x|X)
current_x_axis=$($MOTOR -d s | grep "$1" | awk '{print $2}')
relative_x_steps=$(echo $(($2 - current_x_axis)) | sed 's/-//')
;;
y|Y)
current_y_axis=$($MOTOR -d s | grep "$1" | awk '{print $2}')
relative_y_steps=$(echo $(($2 - current_y_axis)) | sed 's/-//')
;;
*)
exit 1
;;
esac
}
# Handle preset arguments
preset() {
target_x_axis=$(/system/sdcard/bin/jq ".presets.$1.x" "$FILEPRESETS")
target_y_axis=$(/system/sdcard/bin/jq ".presets.$1.y" "$FILEPRESETS")
if [ "$target_y_axis" = 'null' ]; then
logger "Error: Preset \"$1\" is not defined!"
exit 1
else
logger "Loading preset $1: X=$target_x_axis, Y=$target_y_axis"
fi
target_x_axis=$(/system/sdcard/bin/jq ".presets.$1.x" "$FILEPRESETS")
target_y_axis=$(/system/sdcard/bin/jq ".presets.$1.y" "$FILEPRESETS")
if [ "$target_y_axis" = 'null' ]; then
logger "Error: Preset \"$1\" is not defined!"
exit 1
else
logger "Loading preset $1: X=$target_x_axis, Y=$target_y_axis"
fi
}
# Handle location arguments
location() {
case $2 in
[0-9]*)
target_x_axis=$1
target_y_axis=$2
logger "Location defined: X=$target_x_axis, Y=$target_y_axis"
;;
*)
print_usage
exit 1
;;
esac
case $2 in
[0-9]*)
target_x_axis=$1
target_y_axis=$2
logger "Location defined: X=$target_x_axis, Y=$target_y_axis"
;;
*)
print_usage
exit 1
;;
esac
}
# Main
case "$1" in
preset)
preset "$2"
;;
[0-9]*)
location "$1" "$2"
;;
*)
print_usage
exit 1
;;
preset)
preset "$2"
;;
[0-9]*)
location "$1" "$2"
;;
*)
print_usage
exit 1
;;
esac
calculate_relative_steps "x" "$target_x_axis"
calculate_relative_steps "y" "$target_y_axis"
if [ "$relative_x_steps" -ne 0 ]; then
if [ "$target_x_axis" -lt "$current_x_axis" ]; then
dir="l"
else
dir="r"
fi
if [ "$target_x_axis" -lt "$current_x_axis" ]; then
dir="l"
else
dir="r"
fi
CMD="$MOTOR -d $dir -s $relative_x_steps"
logger "$CMD"
$CMD > /dev/null 2>&1
CMD="$MOTOR -d $dir -s $relative_x_steps"
logger "$CMD"
$CMD > /dev/null 2>&1
# Motor runs 1.3 time as long as the number of steps.
SLEEP_NUM=$(awk -v a="$relative_x_steps" 'BEGIN{printf ("%f",a*1.3/1000)}')
# Motor runs 1.3 time as long as the number of steps.
SLEEP_NUM=$(awk -v a="$relative_x_steps" 'BEGIN{printf ("%f",a*1.3/1000)}')
# Wait for motor to run
sleep "$SLEEP_NUM"
# Wait for motor to run
sleep "$SLEEP_NUM"
else
logger "X axis is already at position: $current_x_axis"
logger "X axis is already at position: $current_x_axis"
fi
if [ "$relative_y_steps" -ne 0 ]; then
if [ "$target_y_axis" -lt "$current_y_axis" ]; then
dir="d"
else
dir="u"
fi
if [ "$target_y_axis" -lt "$current_y_axis" ]; then
dir="d"
else
dir="u"
fi
CMD="$MOTOR -d $dir -s $relative_y_steps"
logger "$CMD"
$CMD > /dev/null 2>&1
CMD="$MOTOR -d $dir -s $relative_y_steps"
logger "$CMD"
$CMD > /dev/null 2>&1
# Motor runs 1.3 time as long as the number of steps.
SLEEP_NUM=$(awk -v a="$relative_y_steps" 'BEGIN{printf ("%f",a*1.3/1000)}')
# Motor runs 1.3 time as long as the number of steps.
SLEEP_NUM=$(awk -v a="$relative_y_steps" 'BEGIN{printf ("%f",a*1.3/1000)}')
# Wait for motor to run
sleep "$SLEEP_NUM"
# Wait for motor to run
sleep "$SLEEP_NUM"
else
logger "Y axis is already at position: $current_y_axis"
logger "Y axis is already at position: $current_y_axis"
fi
# Update OSD_AXIS

File diff suppressed because it is too large Load Diff

View File

@@ -3,22 +3,22 @@ IF=wlan0
while true
do
R1=`cat /sys/class/net/${IF}/statistics/rx_bytes`
T1=`cat /sys/class/net/${IF}/statistics/tx_bytes`
sleep 1
R2=`cat /sys/class/net/${IF}/statistics/rx_bytes`
T2=`cat /sys/class/net/${IF}/statistics/tx_bytes`
TBPS=$(($T2-$T1))
RBPS=$(($R2-$R1))
TKBPS=$(($TBPS/1024))
RKBPS=$(($RBPS/1024))
IP=`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'`
# CPU=`grep 'cpu ' /proc/stat | awk '{ printf("%.0f", ($2+$4)*100/($2+$4+$5)) }'`
CPU=`top -n 1 | grep CPU: | grep -v grep| awk '{ print $2}'`
freemem=`free | grep Mem |grep -v grep | awk '{ printf("%.0f", $4/$2 * 100.0) }'`
memtop=`top -n 1 | grep Mem: |grep -v grep | awk '{ printf("Used=%.0fk Free=%.0fk",$2,$4)}'`
string="`hostname` ${IP} tx:$TKBPS kb/s rx:$RKBPS kb/s CPU=${CPU}% FreeMem=${freemem}% ${memtop}"
# echo ".$string." >> /var/log/osd
/system/sdcard/bin/setconf -k o -v "${string}"
R1=`cat /sys/class/net/${IF}/statistics/rx_bytes`
T1=`cat /sys/class/net/${IF}/statistics/tx_bytes`
sleep 1
R2=`cat /sys/class/net/${IF}/statistics/rx_bytes`
T2=`cat /sys/class/net/${IF}/statistics/tx_bytes`
TBPS=$(($T2-$T1))
RBPS=$(($R2-$R1))
TKBPS=$(($TBPS/1024))
RKBPS=$(($RBPS/1024))
IP=`ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'`
# CPU=`grep 'cpu ' /proc/stat | awk '{ printf("%.0f", ($2+$4)*100/($2+$4+$5)) }'`
CPU=`top -n 1 | grep CPU: | grep -v grep| awk '{ print $2}'`
freemem=`free | grep Mem |grep -v grep | awk '{ printf("%.0f", $4/$2 * 100.0) }'`
memtop=`top -n 1 | grep Mem: |grep -v grep | awk '{ printf("Used=%.0fk Free=%.0fk",$2,$4)}'`
string="`hostname` ${IP} tx:$TKBPS kb/s rx:$RKBPS kb/s CPU=${CPU}% FreeMem=${freemem}% ${memtop}"
# echo ".$string." >> /var/log/osd
/system/sdcard/bin/setconf -k o -v "${string}"
done

View File

@@ -17,8 +17,8 @@ fi
# Run any user scripts.
for i in /system/sdcard/config/userscripts/motiondetection/*; do
if [ -x $i ]; then
echo "Running: $i off"
$i off
fi
if [ -x $i ]; then
echo "Running: $i off"
$i off
fi
done

72
firmware_mod/scripts/detectionOn.sh Executable file → Normal file
View File

@@ -23,7 +23,7 @@ record_video () {
# Got the lock
debug_msg "Begin recording to $video_tempfile for $video_duration seconds"
if [ "$video_use_rtsp" = true ]; then
if [ "$video_use_rtsp" = true ]; then
output_buffer_size="$((($BITRATE*100)+150000))"
if [ -z "$USERNAME" ]; then
/system/sdcard/bin/openRTSP -4 -w "$video_rtsp_w" -h "$video_rtsp_h" -f "$video_rtsp_f" -d "$video_duration" -b "$output_buffer_size" rtsp://127.0.0.1:$PORT/unicast > "$video_tempfile"
@@ -31,19 +31,19 @@ record_video () {
/system/sdcard/bin/openRTSP -4 -w "$video_rtsp_w" -h "$video_rtsp_h" -f "$video_rtsp_f" -d "$video_duration" -b "$output_buffer_size" rtsp://$USERNAME:$USERPASSWORD@127.0.0.1:$PORT/unicast > "$video_tempfile"
fi
else
# Use avconv to stitch multiple JPEGs into 1fps video.
# I couldn't get it working another way.
# /dev/videoX inputs fail.
# Localhost rtsp takes very long (10+ seconds) to start streaming and gets flaky when when memory or cpu are pegged.
# This is a clungy method, but works well even at high res, fps, cpu, and memory load!
( while [ "$(/system/sdcard/bin/busybox date "+%s")" -le "$(/system/sdcard/bin/busybox expr "$(/system/sdcard/bin/busybox stat -c "%X" /run/recording_video.flock)" + "$video_duration")" ]; do
/system/sdcard/bin/getimage
sleep 1
done ) | /system/sdcard/bin/avconv -analyzeduration 0 -f image2pipe -r 1 -c:v mjpeg -c:a none -i - -c:v copy -c:a none -f mp4 -y "$video_tempfile"
fi
else
# Use avconv to stitch multiple JPEGs into 1fps video.
# I couldn't get it working another way.
# /dev/videoX inputs fail.
# Localhost rtsp takes very long (10+ seconds) to start streaming and gets flaky when when memory or cpu are pegged.
# This is a clungy method, but works well even at high res, fps, cpu, and memory load!
( while [ "$(/system/sdcard/bin/busybox date "+%s")" -le "$(/system/sdcard/bin/busybox expr "$(/system/sdcard/bin/busybox stat -c "%X" /run/recording_video.flock)" + "$video_duration")" ]; do
/system/sdcard/bin/getimage
sleep 1
done ) | /system/sdcard/bin/avconv -analyzeduration 0 -f image2pipe -r 1 -c:v mjpeg -c:a none -i - -c:v copy -c:a none -f mp4 -y "$video_tempfile"
fi
debug_msg "Finished recording"
debug_msg "Finished recording"
fi
}
@@ -171,30 +171,30 @@ fi
# SMB snapshot and video
if [ "$smb_snapshot" = true -o "$smb_video" = true ]; then
(
smbclient_cmd="/system/bin/smbclient $smb_share"
if [ "$smb_password" != "" ]; then
smbclient_cmd="$smbclient_cmd $smb_password"
else
smbclient_cmd="$smbclient_cmd -N"
fi
if [ "$smb_username" != "" ]; then
smbclient_cmd="$smbclient_cmd -U $smb_username"
fi
(
smbclient_cmd="/system/bin/smbclient $smb_share"
if [ "$smb_password" != "" ]; then
smbclient_cmd="$smbclient_cmd $smb_password"
else
smbclient_cmd="$smbclient_cmd -N"
fi
if [ "$smb_username" != "" ]; then
smbclient_cmd="$smbclient_cmd -U $smb_username"
fi
# Save snapshot
if [ "$smb_snapshot" = true ]; then
debug_msg "Saving SMB snapshot to $smb_share/$smb_stills_path"
snapshot_tempfilename=${snapshot_tempfile:5}
$smbclient_cmd -D "$smb_stills_path" -c "lcd /tmp; mkdir $groupname; cd $groupname; put $snapshot_tempfilename; rename $snapshot_tempfilename $filename.jpg"
fi
# Save video
if [ "$smb_video" = true ]; then
debug_msg "Saving SMB video to $smb_share/$smb_videos_path"
video_tempfilename=${video_tempfile:5}
# Save snapshot
if [ "$smb_snapshot" = true ]; then
debug_msg "Saving SMB snapshot to $smb_share/$smb_stills_path"
snapshot_tempfilename=${snapshot_tempfile:5}
$smbclient_cmd -D "$smb_stills_path" -c "lcd /tmp; mkdir $groupname; cd $groupname; put $snapshot_tempfilename; rename $snapshot_tempfilename $filename.jpg"
fi
# Save video
if [ "$smb_video" = true ]; then
debug_msg "Saving SMB video to $smb_share/$smb_videos_path"
video_tempfilename=${video_tempfile:5}
$smbclient_cmd -D "$smb_videos_path" -c "lcd /tmp; mkdir $groupname; cd $groupname; put $video_tempfilename; rename $video_tempfilename $filename.mp4"
fi
) &
fi
) &
fi
# Publish a mqtt message
@@ -243,7 +243,7 @@ if [ "$send_telegram" = true ]; then
debug_msg "Send telegram video"
if [ "$video_use_rtsp" = true ]; then
/system/sdcard/bin/telegram v "$video_tempfile"
else
else
/system/sdcard/bin/avconv -i "$video_tempfile" "$video_tempfile-lo.mp4"
/system/sdcard/bin/telegram v "$video_tempfile-lo.mp4"
rm "$video_tempfile-lo.mp4"

View File

@@ -4,15 +4,15 @@
# The screen is split as shown below
# (1,2,3,4 are the arguments of the script)
#
# +--------------------------------------+
# | | |
# | 1 | 2 |
# | | |
# +--------------------------------------+
# | | |
# | 3 | 4 |
# | | |
# +--------------------------------------+
# +--------------------------------------+
# | | |
# | 1 | 2 |
# | | |
# +--------------------------------------+
# | | |
# | 3 | 4 |
# | | |
# +--------------------------------------+
. /system/sdcard/scripts/common_functions.sh
@@ -21,25 +21,25 @@ FILECAMERAPOS=/system/sdcard/config/cameraposition
backtoOrigin() {
if [ -f ${FILECAMERAPOS} ]; then
# Get values in saved config file
origin_x_axis=`grep "x:" ${FILECAMERAPOS} | sed "s/x: //"`
origin_y_axis=`grep "y:" ${FILECAMERAPOS} | sed "s/y: //"`
else
# No such file exists: create it with the current values
/system/sdcard/bin/motor -d s > ${FILECAMERAPOS}
fi
if [ -f ${FILECAMERAPOS} ]; then
# Get values in saved config file
origin_x_axis=`grep "x:" ${FILECAMERAPOS} | sed "s/x: //"`
origin_y_axis=`grep "y:" ${FILECAMERAPOS} | sed "s/y: //"`
else
# No such file exists: create it with the current values
/system/sdcard/bin/motor -d s > ${FILECAMERAPOS}
fi
# return to origin for both axis
/system/sdcard/scripts/PTZpresets.sh $origin_x_axis $origin_y_axis
# return to origin for both axis
/system/sdcard/scripts/PTZpresets.sh $origin_x_axis $origin_y_axis
}
#################### Start ###
# If no argument that's mean the camera need to return to its original position
if [ $# -eq 0 ]; then
backtoOrigin
return 0
backtoOrigin
return 0
fi
# Display the areas ...
@@ -49,8 +49,8 @@ echo $3 $4
# Sum all the parameters, that gives the number of region detected
# Only 2 are supported
if [ $((${1} + ${2} + ${3} +${4})) -gt 2 ]; then
echo "no move: more than 2 detected regions"
return 0
echo "no move: more than 2 detected regions"
return 0
fi
UP=0
@@ -60,49 +60,49 @@ LEFT=0
# Calculate the movement
if [ "${1}" == "1" ] || [ "${2}" == "1" ]; then
UP=1
UP=1
fi
if [ "${3}" == "1" ] || [ "${4}" == "1" ]; then
DOWN=1
DOWN=1
fi
if [ "${2}" == "1" ] || [ "${4}" == "1" ]; then
RIGHT=1
RIGHT=1
fi
if [ "${1}" == "1" ] || [ "${3}" == "1" ]; then
LEFT=1
LEFT=1
fi
# Sanity checks
if [ ${UP} != 0 ] && [ ${DOWN} != 0 ]; then
echo "no move vertically: up and down at the same time"
UP=0
DOWN=0
echo "no move vertically: up and down at the same time"
UP=0
DOWN=0
fi
if [ ${RIGHT} != 0 ] && [ ${LEFT} != 0 ]; then
echo "no move horizontally: right and left at the same time"
RIGHT=0
LEFT=0
echo "no move horizontally: right and left at the same time"
RIGHT=0
LEFT=0
fi
# Do the actual movement in the background
(
if [ ${UP} == 1 ]; then
motor up ${STEPS}
fi
if [ ${UP} == 1 ]; then
motor up ${STEPS}
fi
if [ ${DOWN} == 1 ]; then
motor down ${STEPS}
fi
if [ ${DOWN} == 1 ]; then
motor down ${STEPS}
fi
if [ ${RIGHT} == 1 ]; then
motor right ${STEPS}
fi
if [ ${RIGHT} == 1 ]; then
motor right ${STEPS}
fi
if [ ${LEFT} == 1 ]; then
motor left $STEPS
fi
if [ ${LEFT} == 1 ]; then
motor left $STEPS
fi
) &>/dev/null

View File

@@ -5,34 +5,34 @@ awk '
BEGIN { OFS = "\t"; }
/\<Cell/ {
# Print previous AP
if (wpa) {
security = "WPA"
} else if (wep) {
security = "WEP"
} else {
security = "None"
}
if (essid) print essid, address, security, quality;
# Reset security flags.
wep = 0; wpa = 0;
# Print previous AP
if (wpa) {
security = "WPA"
} else if (wep) {
security = "WEP"
} else {
security = "None"
}
if (essid) print essid, address, security, quality;
# Reset security flags.
wep = 0; wpa = 0;
address = $5
address = $5
}
/\<ESSID:/ {
essid = substr($0, index($0, ":") + 1);
essid = substr(essid, 2, length(essid) - 2) # discard quotes
essid = substr($0, index($0, ":") + 1);
essid = substr(essid, 2, length(essid) - 2) # discard quotes
}
/\<Quality/ {
split($1, q, "[:=]"); # q[1] -> "Quality", q[2] -> value
split(q[2], qvalues, "/");
if (qvalues[2]) {
quality = int(qvalues[1] / qvalues[2] * 100); # we have both parts, divide
} else {
quality = qvalues[1]; # we have only one part, use it as-is
}
split($1, q, "[:=]"); # q[1] -> "Quality", q[2] -> value
split(q[2], qvalues, "/");
if (qvalues[2]) {
quality = int(qvalues[1] / qvalues[2] * 100); # we have both parts, divide
} else {
quality = qvalues[1]; # we have only one part, use it as-is
}
}
/\<Encryption key:(o|O)n/ { wep = 1 }
@@ -40,7 +40,7 @@ BEGIN { OFS = "\t"; }
/\<IE:.*WPA.*/ { wpa = 1 }
END {
# Print last AP
if (wpa) { security = "WPA" } else { if (wep) { security = "WEP" } else { security = "None" }}
if (essid) print essid, address, security, quality;
# Print last AP
if (wpa) { security = "WPA" } else { if (wep) { security = "WEP" } else { security = "None" }}
if (essid) print essid, address, security, quality;
}'

View File

@@ -4,8 +4,8 @@
while true; do
if [ -f /system/sdcard/config/ldr-average.conf ]; then
. /system/sdcard/config/ldr-average.conf 2>/dev/null
#read config in every iteration, so we can change the average online
. /system/sdcard/config/ldr-average.conf 2>/dev/null
#read config in every iteration, so we can change the average online
fi
if [ -z "$AVG" ]; then AVG=1; fi
@@ -28,9 +28,9 @@ while true; do
if [ "$AVGMEASUREMENT" -lt 50 ]; then # Light detected
night_mode off
night_mode off
else # nothing in Buffer -> no light
night_mode on
night_mode on
fi
sleep 10
done

View File

@@ -0,0 +1,28 @@
#!/bin/sh
# Check if there is new parameters in the dist config file
CONF_PATH="/system/sdcard/config"
CONF_LIST="mqtt.conf rtspserver.conf matrix.conf motion.conf autonight.conf letsencrypt.conf sendmail.conf swap.conf telegram.conf"
for CONF in $CONF_LIST; do
CONF_NEW_VARS_COUNT=0
if [ -f "${CONF_PATH}/${CONF}" ]; then
echo "Check ${CONF}"
CONF_DIST_VARS=$(grep -o '^[^#]*' "${CONF_PATH}/${CONF}.dist" | cut -d= -f1 | sort)
CONF_USER_VARS=$(grep -o '^[^#]*' ${CONF_PATH}/${CONF} | cut -d= -f1 | sort)
for VAR in $CONF_DIST_VARS; do
if [ ! -n "$(echo $CONF_USER_VARS | grep $VAR)" ]; then
CONF_NEW_VARS_COUNT=$((CONF_NEW_VARS_COUNT+1))
echo "# Parameter added by merge tool" >> "${CONF_PATH}/${CONF}"
grep $VAR "${CONF_PATH}/${CONF}.dist" >> "${CONF_PATH}/${CONF}"
fi
done
if [ $CONF_NEW_VARS_COUNT == 0 ]; then
echo "No new parameters between ${CONF} ${CONF}.dist"
else
echo "Merging ${CONF_NEW_VARS_COUNT} parameters in ${CONF}"
fi
else
echo "${CONF} not exist"
fi
done

View File

@@ -55,7 +55,7 @@
# Light Sensor
if [ "$LIGHT_SENSOR" != "false" ]; then
$MQTT_COMMAND "$AUTODISCOVERY_PREFIX/sensor/$DEVICE_NAME/light_sensor/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME light sensor\", \"unique_id\": \"$MAC_SIMPLE-light-sensor\", $DEVICE_INFO, \"icon\": \"mdi:brightness-5\", \"unit_of_measurement\": \"%\", \"state_topic\": \"$TOPIC/brightness\"}"
$MQTT_COMMAND "$AUTODISCOVERY_PREFIX/sensor/$DEVICE_NAME/light_sensor/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME light sensor\", \"unique_id\": \"$MAC_SIMPLE-light-sensor\", $DEVICE_INFO, \"icon\": \"mdi:brightness-5\", \"unit_of_measurement\": \"%\", \"state_topic\": \"$TOPIC/brightness\"}"
fi
# Night mode

View File

@@ -27,418 +27,423 @@ done
/system/sdcard/bin/mosquitto_sub.bin -v -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/# -t "${LOCATION}/set" ${MOSQUITTOOPTS} | while read -r line ; do
case $line in
"${LOCATION}/set announce")
/system/sdcard/scripts/mqtt-autodiscovery.sh
;;
"${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")"
;;
"${LOCATION}/set announce")
/system/sdcard/scripts/mqtt-autodiscovery.sh
;;
"${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")"
;;
"${TOPIC}/set status")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(/system/sdcard/scripts/mqtt-status.sh)"
;;
"${TOPIC}/set status")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(/system/sdcard/scripts/mqtt-status.sh)"
;;
"${TOPIC}/play "*)
AUDIOFILE=$(echo "$line" | awk '{print $2}')
VOLUME=$(echo "$line" | awk '{print $3}')
VOLUME=${VOLUME:-50}
/system/sdcard/bin/audioplay "/system/sdcard/media/$AUDIOFILE" "$VOLUME" $
;;
"${TOPIC}/play "*)
AUDIOFILE=$(echo "$line" | awk '{print $2}')
VOLUME=$(echo "$line" | awk '{print $3}')
VOLUME=${VOLUME:-50}
/system/sdcard/bin/audioplay "/system/sdcard/media/$AUDIOFILE" "$VOLUME" $
;;
"${TOPIC}/leds/blue")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/blue ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(blue_led status)"
;;
"${TOPIC}/leds/blue")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/blue ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(blue_led status)"
;;
"${TOPIC}/leds/blue/set ON")
blue_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/blue ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(blue_led status)"
;;
"${TOPIC}/leds/blue/set ON")
blue_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/blue ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(blue_led status)"
;;
"${TOPIC}/leds/blue/set OFF")
blue_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/blue ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(blue_led status)"
;;
"${TOPIC}/leds/blue/set OFF")
blue_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/blue ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(blue_led status)"
;;
"${TOPIC}/leds/yellow")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/yellow ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(yellow_led status)"
;;
"${TOPIC}/leds/yellow")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/yellow ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(yellow_led status)"
;;
"${TOPIC}/leds/yellow/set ON")
yellow_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/yellow ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(yellow_led status)"
;;
"${TOPIC}/leds/yellow/set ON")
yellow_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/yellow ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(yellow_led status)"
;;
"${TOPIC}/leds/yellow/set OFF")
yellow_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/yellow ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(yellow_led status)"
;;
"${TOPIC}/leds/yellow/set OFF")
yellow_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/yellow ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(yellow_led status)"
;;
"${TOPIC}/leds/ir")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/ir ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_led status)"
;;
"${TOPIC}/leds/ir")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/ir ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_led status)"
;;
"${TOPIC}/leds/ir/set ON")
ir_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/ir ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_led status)"
;;
"${TOPIC}/leds/ir/set ON")
ir_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/ir ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_led status)"
;;
"${TOPIC}/leds/ir/set OFF")
ir_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/ir ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_led status)"
;;
"${TOPIC}/leds/ir/set OFF")
ir_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/leds/ir ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_led status)"
;;
"${TOPIC}/ir_cut")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ir_cut ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_cut status)"
;;
"${TOPIC}/ir_cut")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ir_cut ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_cut status)"
;;
"${TOPIC}/ir_cut/set ON")
ir_cut on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ir_cut ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_cut status)"
;;
"${TOPIC}/ir_cut/set ON")
ir_cut on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ir_cut ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_cut status)"
;;
"${TOPIC}/ir_cut/set OFF")
ir_cut off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ir_cut ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_cut status)"
;;
"${TOPIC}/ir_cut/set OFF")
ir_cut off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/ir_cut ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ir_cut status)"
;;
"${TOPIC}/brightness")
if [ $LIGHT_SENSOR == 'hw' ]
then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ldr status)"
elif [ $LIGHT_SENSOR == 'virtual' ]
then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(exposure status)"
fi
;;
"${TOPIC}/brightness")
if [ $LIGHT_SENSOR == 'hw' ]
then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(ldr status)"
elif [ $LIGHT_SENSOR == 'virtual' ]
then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(exposure status)"
fi
;;
"${TOPIC}/rtsp_h264_server")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_h264_server status)"
;;
"${TOPIC}/rtsp_h264_server")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_h264_server status)"
;;
"${TOPIC}/rtsp_h264_server/set ON")
rtsp_h264_server on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_h264_server status)"
;;
"${TOPIC}/rtsp_h264_server/set ON")
rtsp_h264_server on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_h264_server status)"
;;
"${TOPIC}/rtsp_h264_server/set OFF")
rtsp_h264_server off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_h264_server status)"
;;
"${TOPIC}/rtsp_h264_server/set OFF")
rtsp_h264_server off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_h264_server status)"
;;
"${TOPIC}/rtsp_mjpeg_server")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_mjpeg_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_mjpeg_server status)"
;;
"${TOPIC}/rtsp_mjpeg_server")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_mjpeg_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_mjpeg_server status)"
;;
"${TOPIC}/rtsp_mjpeg_server/set ON")
rtsp_mjpeg_server on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_mjpeg_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_mjpeg_server status)"
;;
"${TOPIC}/rtsp_mjpeg_server/set ON")
rtsp_mjpeg_server on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_mjpeg_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_mjpeg_server status)"
;;
"${TOPIC}/rtsp_mjpeg_server/set OFF")
rtsp_mjpeg_server off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_mjpeg_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_mjpeg_server status)"
;;
"${TOPIC}/rtsp_mjpeg_server/set OFF")
rtsp_mjpeg_server off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_mjpeg_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(rtsp_mjpeg_server status)"
;;
"${TOPIC}/night_mode")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(night_mode status)"
;;
"${TOPIC}/night_mode")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(night_mode status)"
;;
"${TOPIC}/night_mode/set ON")
night_mode on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(night_mode status)"
;;
"${TOPIC}/night_mode/set ON")
night_mode on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(night_mode status)"
;;
"${TOPIC}/night_mode/set OFF")
night_mode off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(night_mode status)"
;;
"${TOPIC}/night_mode/set OFF")
night_mode off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(night_mode status)"
;;
"${TOPIC}/night_mode/auto")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(auto_night_mode status)"
;;
"${TOPIC}/night_mode/auto")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(auto_night_mode status)"
;;
"${TOPIC}/night_mode/auto/set ON")
auto_night_mode on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(auto_night_mode status)"
;;
"${TOPIC}/night_mode/auto/set ON")
auto_night_mode on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(auto_night_mode status)"
;;
"${TOPIC}/night_mode/auto/set OFF")
auto_night_mode off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(auto_night_mode status)"
;;
"${TOPIC}/night_mode/auto/set OFF")
auto_night_mode off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(auto_night_mode status)"
;;
"${TOPIC}/motion/detection")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)"
;;
"${TOPIC}/motion/detection")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)"
;;
"${TOPIC}/motion/detection/set ON")
motion_detection on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)"
;;
"${TOPIC}/motion/detection/set ON")
motion_detection on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)"
;;
"${TOPIC}/motion/detection/set OFF")
motion_detection off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)"
;;
"${TOPIC}/motion/detection/set OFF")
motion_detection off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)"
;;
"${TOPIC}/motion/led")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/led ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_led status)"
;;
"${TOPIC}/motion/led")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/led ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_led status)"
;;
"${TOPIC}/motion/led/set ON")
motion_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/led ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_led status)"
;;
"${TOPIC}/motion/led/set ON")
motion_led on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/led ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_led status)"
;;
"${TOPIC}/motion/led/set OFF")
motion_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/led ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_led status)"
;;
"${TOPIC}/motion/led/set OFF")
motion_led off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/led ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_led status)"
;;
"${TOPIC}/motion/snapshot")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_snapshot status)"
;;
"${TOPIC}/motion/snapshot")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_snapshot status)"
;;
"${TOPIC}/motion/snapshot/set ON")
motion_snapshot on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_snapshot status)"
;;
"${TOPIC}/motion/snapshot/set ON")
motion_snapshot on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_snapshot status)"
;;
"${TOPIC}/motion/snapshot/set OFF")
motion_snapshot off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_snapshot status)"
;;
"${TOPIC}/motion/snapshot/set OFF")
motion_snapshot off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_snapshot status)"
;;
"${TOPIC}/motion/video")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/video ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_video status)"
;;
"${TOPIC}/motion/video")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/video ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_video status)"
;;
"${TOPIC}/motion/video/set ON")
motion_video on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/video ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_video status)"
;;
"${TOPIC}/motion/video/set ON")
motion_video on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/video ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_video status)"
;;
"${TOPIC}/motion/video/set OFF")
motion_video off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/video ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_video status)"
;;
"${TOPIC}/motion/video/set OFF")
motion_video off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/video ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_video status)"
;;
"${TOPIC}/motion/mqtt_publish")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_publish ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_publish status)"
;;
"${TOPIC}/motion/mqtt_publish")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_publish ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_publish status)"
;;
"${TOPIC}/motion/mqtt_publish/set ON")
motion_mqtt_publish on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_publish ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_publish status)"
;;
"${TOPIC}/motion/mqtt_publish/set ON")
motion_mqtt_publish on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_publish ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_publish status)"
;;
"${TOPIC}/motion/mqtt_publish/set OFF")
motion_mqtt_publish off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_publish ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_publish status)"
;;
"${TOPIC}/motion/mqtt_publish/set OFF")
motion_mqtt_publish off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_publish ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_publish status)"
;;
"${TOPIC}/motion/mqtt_snapshot")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_snapshot status)"
;;
"${TOPIC}/snapshot/image GET")
/system/sdcard/bin/getimage > "/tmp/mqtt_snapshot"
/system/sdcard/bin/jpegoptim -S 25k "/tmp/mqtt_snapshot"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/snapshot/image ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -f "/tmp/mqtt_snapshot"
rm "/tmp/mqtt_snapshot"
;;
"${TOPIC}/motion/mqtt_snapshot")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_snapshot status)"
;;
"${TOPIC}/snapshot/image GET")
/system/sdcard/bin/getimage > "/tmp/mqtt_snapshot"
/system/sdcard/bin/jpegoptim -S 25k "/tmp/mqtt_snapshot"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/snapshot/image ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -f "/tmp/mqtt_snapshot"
rm "/tmp/mqtt_snapshot"
;;
"${TOPIC}/motion/mqtt_snapshot/set ON")
motion_mqtt_snapshot on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_snapshot status)"
;;
"${TOPIC}/motion/mqtt_snapshot/set ON")
motion_mqtt_snapshot on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_snapshot status)"
;;
"${TOPIC}/motion/mqtt_snapshot/set OFF")
motion_mqtt_snapshot off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_snapshot status)"
;;
"${TOPIC}/motion/mqtt_snapshot/set OFF")
motion_mqtt_snapshot off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/mqtt_snapshot ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_mqtt_snapshot status)"
;;
"${TOPIC}/motion/send_mail")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)"
;;
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)"
;;
"${TOPIC}/motion/send_mail/set ON")
motion_send_mail on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)"
;;
"${TOPIC}/motion/send_mail/set ON")
motion_send_mail on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)"
;;
"${TOPIC}/motion/send_mail/set OFF")
motion_send_mail off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)"
;;
"${TOPIC}/motion/send_mail/set OFF")
motion_send_mail off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)"
;;
"${TOPIC}/motion/send_telegram")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_telegram status)"
;;
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_telegram status)"
;;
"${TOPIC}/motion/send_telegram/set ON")
motion_send_telegram on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_telegram status)"
;;
"${TOPIC}/motion/send_telegram/set ON")
motion_send_telegram on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_telegram status)"
;;
"${TOPIC}/motion/send_telegram/set OFF")
motion_send_telegram off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_telegram status)"
;;
"${TOPIC}/motion/send_telegram/set OFF")
motion_send_telegram off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_telegram status)"
;;
"${TOPIC}/motion/tracking")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)"
;;
"${TOPIC}/motion/tracking")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)"
;;
"${TOPIC}/motion/tracking/set ON")
motion_tracking on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)"
;;
"${TOPIC}/motion/tracking/set ON")
motion_tracking on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)"
;;
"${TOPIC}/motion/tracking/set OFF")
motion_tracking off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)"
;;
"${TOPIC}/motion/tracking/set OFF")
motion_tracking off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)"
;;
"${TOPIC}/motors/vertical/set up")
motor up
"${TOPIC}/motors/vertical/set up")
motor up
MOTORSTATE=$(motor status vertical)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_Y - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
"${TOPIC}/motors/vertical/set down")
motor down
"${TOPIC}/motors/vertical/set down")
motor down
MOTORSTATE=$(motor status vertical)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_Y - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
"${TOPIC}/motors/vertical/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
MOTORSTATE=$(motor status vertical)
if [ -n "$COMMAND" ] && [ "$COMMAND" -eq "$COMMAND" ] 2>/dev/null; then
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
echo Changing motor from $COMMAND to $MOTORSTATE
TARGET=$(busybox expr $MOTORSTATE + $COMMAND - $MAX_Y)
else
echo Changing motor from $MOTORSTATE to $COMMAND
TARGET=$(busybox expr $COMMAND - $MOTORSTATE)
fi
echo Moving $TARGET
if [ "$TARGET" -lt 0 ]; then
motor down $(busybox expr $TARGET \* -1)
else
motor up $TARGET
fi
else
echo Requested $COMMAND is not a number
fi
;;
"${TOPIC}/motors/vertical/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
MOTORSTATE=$(motor status vertical)
if [ -n "$COMMAND" ] && [ "$COMMAND" -eq "$COMMAND" ] 2>/dev/null; then
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
echo Changing motor from $COMMAND to $MOTORSTATE
TARGET=$(busybox expr $MOTORSTATE + $COMMAND - $MAX_Y)
else
echo Changing motor from $MOTORSTATE to $COMMAND
TARGET=$(busybox expr $COMMAND - $MOTORSTATE)
fi
echo Moving $TARGET
if [ "$TARGET" -lt 0 ]; then
motor down $(busybox expr $TARGET \* -1)
else
motor up $TARGET
fi
else
echo Requested $COMMAND is not a number
fi
;;
"${TOPIC}/motors/horizontal/set left")
motor left
"${TOPIC}/motors/horizontal/set left")
motor left
MOTORSTATE=$(motor status horizontal)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_X - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
"${TOPIC}/motors/horizontal/set right")
motor right
"${TOPIC}/motors/horizontal/set right")
motor right
MOTORSTATE=$(motor status horizontal)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_X - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;
"${TOPIC}/motors/horizontal/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
MOTORSTATE=$(motor status horizontal)
if [ -n "$COMMAND" ] && [ "$COMMAND" -eq "$COMMAND" ] 2>/dev/null; then
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
echo Changing motor from $COMMAND to $MOTORSTATE
TARGET=$(busybox expr $MOTORSTATE + $COMMAND - $MAX_X)
else
echo Changing motor from $MOTORSTATE to $COMMAND
TARGET=$(busybox expr $COMMAND - $MOTORSTATE)
fi
echo Moving $TARGET
if [ "$TARGET" -lt 0 ]; then
motor left $(busybox expr $TARGET \* -1)
else
motor right $TARGET
fi
else
echo Requested $COMMAND is not a number
fi
;;
"${TOPIC}/motors/horizontal/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
MOTORSTATE=$(motor status horizontal)
if [ -n "$COMMAND" ] && [ "$COMMAND" -eq "$COMMAND" ] 2>/dev/null; then
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
echo Changing motor from $COMMAND to $MOTORSTATE
TARGET=$(busybox expr $MOTORSTATE + $COMMAND - $MAX_X)
else
echo Changing motor from $MOTORSTATE to $COMMAND
TARGET=$(busybox expr $COMMAND - $MOTORSTATE)
fi
echo Moving $TARGET
if [ "$TARGET" -lt 0 ]; then
motor left $(busybox expr $TARGET \* -1)
else
motor right $TARGET
fi
else
echo Requested $COMMAND is not a number
fi
;;
"${TOPIC}/motors/set calibrate")
motor reset_pos_count
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status horizontal)"
;;
"${TOPIC}/motors/set calibrate")
motor reset_pos_count
/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}/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}/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}/recording")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(recording status)"
;;
"${TOPIC}/recording")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(recording status)"
;;
"${TOPIC}/recording/set ON")
recording on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(recording status)"
;;
"${TOPIC}/recording/set ON")
recording on
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(recording status)"
;;
"${TOPIC}/recording/set OFF")
recording off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(recording status)"
;;
"${TOPIC}/recording/set OFF")
recording off
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(recording status)"
;;
"${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}/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}/update/set update")
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/update ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -m "Upgrade started"
result=$(/bin/sh /system/sdcard/autoupdate.sh -s -v -f)
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/update ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -m "Upgrade finish: ${result}"
;;
"${TOPIC}/update/set update")
if [ -f "/system/sdcard/VERSION" ]; then
branch=$(/system/sdcard/bin/jq -r .branch /system/sdcard/VERSION)
else
branch="master"
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/update ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -m "Upgrade started"
result=$(/bin/sh /system/sdcard/autoupdate.sh -s -v -f -r $branch)
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/update ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -m "Upgrade finish: ${result}"
;;
"${TOPIC}/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
#echo "$COMMAND"
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
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}/error" ${MOSQUITTOOPTS} -m "An error occured when executing ${line}"
fi
# Publish updated states
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(/system/sdcard/scripts/mqtt-status.sh)"
;;
"${TOPIC}/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
#echo "$COMMAND"
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
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}/error" ${MOSQUITTOOPTS} -m "An error occured when executing ${line}"
fi
# Publish updated states
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(/system/sdcard/scripts/mqtt-status.sh)"
;;
esac
done

View File

@@ -15,10 +15,10 @@ do
if [ $LIGHT_SENSOR == 'hw' ]
then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(ldr status)"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(ldr status)"
elif [ $LIGHT_SENSOR == 'virtual' ]
then
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(exposure status)"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/brightness ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(exposure status)"
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/rtsp_h264_server ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(rtsp_h264_server status)"
@@ -37,16 +37,16 @@ do
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/recording ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(recording status)"
MOTORSTATE=$(motor status vertical)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_Y - $MOTORSTATE)
TARGET=$(busybox expr $MAX_Y - $MOTORSTATE)
else
TARGET=$MOTORSTATE
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$TARGET"
MOTORSTATE=$(motor status horizontal)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_X - $MOTORSTATE)
TARGET=$(busybox expr $MAX_X - $MOTORSTATE)
else
TARGET=$MOTORSTATE
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$TARGET"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}" ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -r -m "$(/system/sdcard/scripts/mqtt-status.sh)"

View File

@@ -38,28 +38,28 @@ Content-Disposition: inline
${BODY}
"
for i in $(seq 1 ${NUMBEROFPICTURES}); do
# using sleep and wait so each step takes the specified amount of time
# instead of the loop-time + the time between snapshots
if [ ${i} -lt ${NUMBEROFPICTURES} ]; then
sleep ${TIMEBETWEENSNAPSHOT} &
fi
# using sleep and wait so each step takes the specified amount of time
# instead of the loop-time + the time between snapshots
if [ ${i} -lt ${NUMBEROFPICTURES} ]; then
sleep ${TIMEBETWEENSNAPSHOT} &
fi
printf '%s\n' "--${boundary}
printf '%s\n' "--${boundary}
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"${FILENAME}${i}.jpg\"
"
if [ ${QUALITY} -eq -1 ]; then
/system/sdcard/bin/getimage | /system/sdcard/bin/openssl enc -base64
else
/system/sdcard/bin/getimage | /system/sdcard/bin/jpegoptim -m${QUALITY} --stdin --stdout --quiet | /system/sdcard/bin/openssl enc -base64
fi
if [ ${QUALITY} -eq -1 ]; then
/system/sdcard/bin/getimage | /system/sdcard/bin/openssl enc -base64
else
/system/sdcard/bin/getimage | /system/sdcard/bin/jpegoptim -m${QUALITY} --stdin --stdout --quiet | /system/sdcard/bin/openssl enc -base64
fi
echo
echo
# wait for our sleep to finish
wait
# wait for our sleep to finish
wait
done
# print last boundary with closing --

36
firmware_mod/scripts/telegram-bot-daemon.sh Executable file → Normal file
View File

@@ -56,17 +56,17 @@ respond() {
cmd=$1
[ $chatId -lt 0 ] && cmd=${1%%@*}
case $cmd in
/mem) sendMem;;
/shot) sendShot;;
/on) detectionOn;;
/off) detectionOff;;
/nighton) nightOn;;
/nightoff) nightOff;;
/textalerts) textAlerts;;
/imagealerts) imageAlerts;;
/videoalerts) videoAlerts;;
/help | /start) $TELEGRAM m "######### Bot commands #########\n# /mem - show memory information\n# /shot - take a snapshot\n# /on - motion detection on\n# /off - motion detection off\n# /nighton - night mode on\n# /nightoff - night mode off\n# /textalerts - Text alerts on motion detection\n# /imagealerts - Image alerts on motion detection\n# /videoalerts - Video alerts on motion detection";;
*) $TELEGRAM m "I can't respond to '$cmd' command"
/mem) sendMem;;
/shot) sendShot;;
/on) detectionOn;;
/off) detectionOff;;
/nighton) nightOn;;
/nightoff) nightOff;;
/textalerts) textAlerts;;
/imagealerts) imageAlerts;;
/videoalerts) videoAlerts;;
/help | /start) $TELEGRAM m "######### Bot commands #########\n# /mem - show memory information\n# /shot - take a snapshot\n# /on - motion detection on\n# /off - motion detection off\n# /nighton - night mode on\n# /nightoff - night mode off\n# /textalerts - Text alerts on motion detection\n# /imagealerts - Image alerts on motion detection\n# /videoalerts - Video alerts on motion detection";;
*) $TELEGRAM m "I can't respond to '$cmd' command"
esac
}
@@ -86,9 +86,9 @@ main() {
[ -z "$json" ] && return 0
if [ "$(echo "$json" | $JQ -r '.ok')" != "true" ]; then
echo "$(date '+%F %T') Bot error: $json" >> /tmp/telegram.log
[ "$(echo "$json" | $JQ -r '.error_code')" == "401" ] && return 1
return 0
echo "$(date '+%F %T') Bot error: $json" >> /tmp/telegram.log
[ "$(echo "$json" | $JQ -r '.error_code')" == "401" ] && return 1
return 0
fi;
messageAttr="message"
@@ -107,11 +107,11 @@ main() {
cmd=$(echo "$json" | $JQ -r ".result[0].$messageAttr.text // \"\"")
if [ "$chatId" != "$userChatId" ]; then
username=$(echo "$json" | $JQ -r ".result[0].$messageAttr.from.username // \"\"")
firstName=$(echo "$json" | $JQ -r ".result[0].$messageAttr.from.first_name // \"\"")
$TELEGRAM m "Received message from unauthorized chat id: $chatId\nUser: $username($firstName)\nMessage: $cmd"
username=$(echo "$json" | $JQ -r ".result[0].$messageAttr.from.username // \"\"")
firstName=$(echo "$json" | $JQ -r ".result[0].$messageAttr.from.first_name // \"\"")
$TELEGRAM m "Received message from unauthorized chat id: $chatId\nUser: $username($firstName)\nMessage: $cmd"
else
respond $cmd
respond $cmd
fi;
markAsRead $updateId

View File

@@ -5,10 +5,9 @@
PIDFILE='/run/timelapse.pid'
TIMELAPSE_CONF='/system/sdcard/config/timelapse.conf'
DCIM_PATH='/system/sdcard/DCIM/Timelapse'
if [ -f "$TIMELAPSE_CONF" ]; then
. "$TIMELAPSE_CONF" 2>/dev/null
. "$TIMELAPSE_CONF" 2>/dev/null
fi
if [ -z "$TIMELAPSE_INTERVAL" ]; then TIMELAPSE_INTERVAL=2.0; fi
@@ -21,36 +20,36 @@ last_prefix=''
ts_started=$(date +%s)
while true; do
SAVE_DIR=$DCIM_PATH
if [ $SAVE_DIR_PER_DAY -eq 1 ]; then
SAVE_DIR="$DCIM_PATH/$(date +%Y-%m-%d)/$(date +%H)"
fi
if [ ! -d "$SAVE_DIR" ]; then
mkdir -p $SAVE_DIR
fi
filename_prefix="$(date +%Y-%m-%d_%H-%M-%S)"
if [ "$filename_prefix" = "$last_prefix" ]; then
counter=$(($counter + 1))
else
counter=1
last_prefix="$filename_prefix"
fi
counter_formatted=$(printf '%03d' $counter)
filename="${filename_prefix}_${counter_formatted}.jpg"
if [ -z "$COMPRESSION_QUALITY" ]; then
/system/sdcard/bin/getimage > "$SAVE_DIR/$filename" &
else
/system/sdcard/bin/getimage | /system/sdcard/bin/jpegoptim -m"$COMPRESSION_QUALITY" --stdin --stdout > "$SAVE_DIR/$filename" &
fi
sleep $TIMELAPSE_INTERVAL
SAVE_DIR=$DCIM_PATH
if [ $SAVE_DIR_PER_DAY -eq 1 ]; then
SAVE_DIR="$DCIM_PATH/$(date +%Y-%m-%d)/$(date +%H)"
fi
if [ ! -d "$SAVE_DIR" ]; then
mkdir -p $SAVE_DIR
fi
filename_prefix="$(date +%Y-%m-%d_%H-%M-%S)"
if [ "$filename_prefix" = "$last_prefix" ]; then
counter=$(($counter + 1))
else
counter=1
last_prefix="$filename_prefix"
fi
counter_formatted=$(printf '%03d' $counter)
filename="${filename_prefix}_${counter_formatted}.jpg"
if [ -z "$COMPRESSION_QUALITY" ]; then
/system/sdcard/bin/getimage > "$SAVE_DIR/$filename" &
else
/system/sdcard/bin/getimage | /system/sdcard/bin/jpegoptim -m"$COMPRESSION_QUALITY" --stdin --stdout > "$SAVE_DIR/$filename" &
fi
sleep $TIMELAPSE_INTERVAL
if [ $TIMELAPSE_DURATION -gt 0 ]; then
ts_now=$(date +%s)
elapsed=$(($ts_now - $ts_started))
if [ $(($TIMELAPSE_DURATION * 60)) -le $elapsed ]; then
break
fi
fi
if [ $TIMELAPSE_DURATION -gt 0 ]; then
ts_now=$(date +%s)
elapsed=$(($ts_now - $ts_started))
if [ $(($TIMELAPSE_DURATION * 60)) -le $elapsed ]; then
break
fi
fi
done
# loop completed so let's purge pid file

View File

@@ -0,0 +1,14 @@
baudrate=115200
bootargs=console=ttyS1,115200n8 mem=39M@0x0 ispmem=5M@0x2700000 rmem=20M@0x2C00000 init=/linuxrc rootfstype=squashfs root=/dev/mtdblock2 rw mtdparts=jz_sfc:256k(boot),2048k(kernel),3392k(root),640k(driver),4736k(appfs),2048k(backupk),640k(backupd),2048k(backupa),256k(config),256k(para),-(flag)
bootcmd=sf probe;sf read 0x80600000 0x40000 0x280000; bootm 0x80600000;
bootdelay=1
ethact=Jz4775-9161
ethaddr=00:11:22:33:44:55
gatewayip=193.169.4.1
ipaddr=193.169.4.81
loads_echo=1
netmask=255.255.255.0
serverip=193.169.4.2
stderr=serial
stdin=serial
stdout=serial

View File

@@ -0,0 +1,14 @@
baudrate=115200
bootargs=console=ttyS1,115200n8 mem=39M@0x0 ispmem=5M@0x2700000 rmem=20M@0x2C00000 init=/linuxrc rootfstype=squashfs root=/dev/mtdblock2 rw mtdparts=jz_sfc:256k(boot),2048k(kernel),3392k(root),640k(driver),4736k(appfs),2048k(backupk),640k(backupd),2048k(backupa),256k(config),256k(para),-(flag)
bootcmd=fatload mmc 0:1 0x80600000 kernel.bin;bootm 0x80600000
bootdelay=1
ethact=Jz4775-9161
ethaddr=00:11:22:33:44:55
gatewayip=193.169.4.1
ipaddr=193.169.4.81
loads_echo=1
netmask=255.255.255.0
serverip=193.169.4.2
stderr=serial
stdin=serial
stdout=serial

315
firmware_mod/www/camera.html Executable file
View File

@@ -0,0 +1,315 @@
<div class="w3-panel w3-card">
<h1>Camera Configuration</h1>
<!-- Tab menu -->
<div class="w3-row">
<a href="javascript:void(0)" onclick="openTab(event, 'videoTab');">
<div class="w3-quarter tablink w3-bottombar w3-hover-light-grey w3-padding w3-border-theme">Video</div>
</a>
<a href="javascript:void(0)" onclick="openTab(event, 'audioTab');">
<div class="w3-quarter tablink w3-bottombar w3-hover-light-grey w3-padding">Audio</div>
</a>
<a href="javascript:void(0)" onclick="openTab(event, 'timelapseTab');">
<div class="w3-quarter tablink w3-bottombar w3-hover-light-grey w3-padding">Timelapse</div>
</a>
<a href="javascript:void(0)" onclick="openTab(event, 'osdTab');">
<div class="w3-quarter tablink w3-bottombar w3-hover-light-grey w3-padding">OSD</div>
</a>
</div>
<!-- Tab video -->
<div id="videoTab" class="w3-container tab">
<form class="w3-container" onsubmit="saveConfig('video');return false" id="video">
<p></p>
<!-- Setting accordion-->
<button class="accordion" type='button'>Format</button>
<div class="panel">
<p></p>
<div class="w3-row-padding">
<div class="w3-third">
<label>Codec for RTSP server</label>
<select id="codec" class="w3-select" name="option">
<option value="H264">H264</option>
<option value="MJPG">MPJEG</option>
</select>
</div>
<div class="w3-third">
<label>Video size:</label>
<select id="videoSize" class="w3-select" name="option">
<option value="-W640 -H360">640x360</option>
<option value="-W768 -H432">768x432</option>
<option value="-W960 -H540">960x540</option>
<option value="-W1280 -H720">1280x720</option>
<option value="-W1600 -H900">1600x900</option>
<option value="-W1920 -H1080">1920x1080</option>
</select>
</div>
<div class="w3-third">
<label>Bitrate (kbps):</label>
<input id="bitRate" class="w3-input" type="text">
</div>
</div>
<p></p>
<div class="w3-row-padding">
<div class="w3-third">
<label>Format:</label>
<select id="format" class="w3-select" name="option">
<option value="0">FixedQp</option>
<option value="1">CBR</option>
<option value="2">VBR</option>
<option value="3">SMART</option>
</select>
</div>
<div class="w3-third">
<label>Flip Image:</label>
<select id="flip" class="w3-select" name="option">
<option value="OFF">Off</option>
<option value="ON">On</option>
</select>
</div>
<div class="w3-third">
<label>Frame rate (images per secondes):</label>
<div class="w3-row-padding">
<div class="w3-half">
<label>Images:</label>
<input id="frmRateNum" class="w3-input" type="text">
</div>
<div class="w3-half">
<label>Seconds:</label>
<input id="frmRateDen" class="w3-input" type="text">
</div>
</div>
</div>
</div>
<p></p>
</div>
<!-- Network / Security accordion -->
<button class="accordion" type='button'>Network / Security</button>
<div class="panel">
<p></p>
<div class="w3-row-padding">
<div class="w3-half">
<label>Username:</label>
<input id="videoUser" class="w3-input" type="text">
</div>
<div class="w3-half">
<label>Password:</label>
<input id="videoPassword" class="w3-input" type="password">
</div>
</div>
<p></p>
<div class="w3-row-padding">
<div class="w3-half">
<label>Port (default 8554):</label>
<input id="videoPort" class="w3-input" type="number">
</div>
<div class="w3-half">
<label>Multicast address (leave blank to disable multicast):</label>
<input id="multicast" class="w3-input" type="text">
</div>
</div>
<p></p>
</div>
<!-- Auto Night accordion -->
<button class="accordion" type='button'>Auto Night</button>
<div class="panel">
<p></p>
<label>Auto Night Mode</label>
<select id="autoNightMode" class="w3-select" name="option">
<option value="hw">Hardware</option>
<option value="sw">Software</option>
</select>
<br />
<label>Use average measurement on switching. Number of measurements:</label>
<select id="avg" class="w3-select" name="option">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
</select>
</div>
<p><button class="w3-btn w3-theme" >Save</button></p></form>
</div>
<!-- Tab audio -->
<div id="audioTab" class="w3-container tab" style="display:none">
<p><form class="w3-container" onsubmit="saveConfig('audio');return false" id="audio"></p>
<div class="w3-row-padding">
<div class="w3-half">
<label>Audio format</label>
<select id="audioinFormat" class="w3-select">
<option value="OFF">OFF</option>
<option value="OPUS">OPUS</option>
<option value="PCM">PCM</option>
<option value="PCMU">PCMU</option>
<option value="MP3">MP3</option>
</select>
</div>
<div class="w3-half">
<label>Volume</label><br />
<input name="audioinVol" step="1" min="-1" max="120" type="range" class="w3-input">
</div>
</div>
<p></p>
<div class="w3-row-padding">
<div class="w3-half">
<label>Sample rate in</label>
<select id="audioinBR" class="w3-select" >
<option value="8000">8000</option>
<option value="16000">16000</option>
<option value="24000">24000</option>
<option value="44100">44100</option>
<option value="48000">48000</option>
</select>
</div>
<div class="w3-half">
<label>Sample rate out</label>
<select id="audiooutBR" class="w3-select">
<option value="8000">8000</option>
<option value="16000">16000</option>
<option value="24000">24000</option>
<option value="44100">44100</option>
<option value="48000">48000</option>
</select>
</div>
</div>
<p></p>
<div class="w3-row-padding">
<div class="w3-third">
<label>Filter (low filter)</label>
<select id="audioinFilter" class="w3-select" name="option">
<option value="0">No filter</option>
<option value="1">Filter 1</option>
<option value="2">Filter 2</option>
<option value="3">NS Filter LOW</option>
<option value="4">NS Filter MODERATE</option>
<option value="5">NS Filter HIGH</option>
<option value="6">NS Filter VERY HIGH</option>
</select>
</div>
<div class="w3-third">
<label>Hight pass filter</label>
<select id="HFEnabled" class="w3-select" name="option">
<option value="false">Deactivate</option>
<option value="true">Activate</option>
</select>
</div>
<div class="w3-third">
<label>AEC Filter</label>
<select id="AECEnabled" class="w3-select" name="option">
<option value="false">Deactivate</option>
<option value="true">Activate</option>
</select>
</div>
</div>
<p><button class="w3-btn w3-theme" >Save</button></p></form>
</div>
<!-- Tab timelapse -->
<div id="timelapseTab" class="w3-container tab" style="display:none">
<p><form class="w3-container" onsubmit="saveConfig('timelapseF');return false" id="timelapseF"></p>
<label>Interval (in seconds)</label>
<input class="w3-input" id="tlinterval" type="text">
<br />
<label>Duration (in minutes)</label>
<input class="w3-input" id="tlduration" type="text">
<br />
<p><button class="w3-btn w3-theme" >Save</button></p></form>
</div>
<!-- Tab OSD-->
<div id="osdTab" class="w3-container tab" style="display:none">
<p><form class="w3-container" onsubmit="saveConfig('osd');return false" id="osd"></p>
<div class="w3-row-padding">
<div class="w3-third">
<label>Date saveConfigate</label>
<input id="osdText" class="w3-input" type="text">
</div>
<div class="w3-third">
<label>OSD Text</label>
<select id="osdEnable" class="w3-select" name="option">
<option value="false">Deactivate</option>
<option value="true">Activate</option>
</select>
</div>
<div class="w3-third">
<label>OSD Axis</label>
<select id="osdAxis" class="w3-select" name="option">
<option value="false">Deactivate</option>
<option value="true">Activate</option>
</select>
</div>
</div>
<p></p>
<div class="w3-row-padding">
<div class="w3-third">
<label>OSD Text color</label>
<select id="osdColor" class="w3-select" name="option">
<option value="0">White</option>
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Blue</option>
<option value="5">Cyan</option>
<option value="6">Yellow</option>
<option value="7">Purple</option>
</select>
</div>
<div class="w3-third">
<label>OSD Font name</label>
<select id="osdFonts" class="w3-select">
</select>
</div>
<div class="w3-third">
<label>OSD Text size</label>
<input id="osdSize" class="w3-input" type="number">
</div>
</div>
<p></p>
<div class="w3-row-padding">
<div class="w3-third">
<label>Pixel between chars</label>
<input id="osdPixel" class="w3-input" type="text">
</div>
<div class="w3-third">
<label>Y position</label>
<input id="osdY" class="w3-input" type="text">
</div>
<div class="w3-third">
<label>Fixed width ( only work for "default" fonts)</label>
<select id="osdFixW" class="w3-select" name="option">
<option value="false">Deactivate</option>
<option value="true">Activate</option>
</select>
</div>
</div>
<p><button class="w3-btn w3-theme" >Save</button></form></p>
</div>
<!-- Modal save box -->
<div id="save_confirm" class="w3-modal">
<div class="w3-modal-content">
<header class="w3-container w3-theme">
<span onclick="document.getElementById('save_confirm').style.display='none'"
class="w3-button w3-display-topright">&times;</span>
<h2>Save config</h2>
</header>
<div class="w3-container">
<p id="save_result"></p>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/camera.js"></script>

View File

@@ -389,8 +389,7 @@ auto_night_mode_status)
frmRateDen=$(printf '%b' "${F_frmRateDen/%/\\x}")
frmRateNum=$(printf '%b' "${F_frmRateNum/%/\\x}")
rewrite_config /system/sdcard/config/rtspserver.conf RTSPH264OPTS "\"$video_size\""
rewrite_config /system/sdcard/config/rtspserver.conf RTSPMJPEGOPTS "\"$video_size\""
rewrite_config /system/sdcard/config/rtspserver.conf RTSPOPTS "\"$video_size\""
rewrite_config /system/sdcard/config/rtspserver.conf BITRATE "$brbitrate"
rewrite_config /system/sdcard/config/rtspserver.conf VIDEOFORMAT "$video_format"
rewrite_config /system/sdcard/config/rtspserver.conf USERNAME "$videouser"

0
firmware_mod/www/cgi-bin/api.cgi Normal file → Executable file
View File

2
firmware_mod/www/cgi-bin/currentpic.cgi Normal file → Executable file
View File

@@ -2,4 +2,4 @@
echo "Content-type: image/jpeg"
echo ""
/system/sdcard/bin/getimage
exec /system/sdcard/bin/getimage

0
firmware_mod/www/cgi-bin/currentpicoptim.cgi Normal file → Executable file
View File

0
firmware_mod/www/cgi-bin/dumpbootloader.cgi Normal file → Executable file
View File

View File

@@ -1,67 +0,0 @@
#!/bin/sh
echo "Content-type: application/json"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo
. /system/sdcard/scripts/common_functions.sh
motion_indicator_color=`/system/sdcard/bin/setconf -g z 2>/dev/null`
if [ "${motion_indicator_color}X" == "X" ]
then
motion_indicator_color="0"
fi
motion_sensitivity=`/system/sdcard/bin/setconf -g m 2>/dev/null`
if [ "${motion_sensitivity}X" == "X" ]
then
motion_sensitivity="0"
fi
region_of_interest=`/system/sdcard/bin/setconf -g r 2>/dev/null`
if [ "${region_of_interest}X" == "X" ]
then
region_of_interest="0,0,0,0"
fi
motion_tracking=`/system/sdcard/bin/setconf -g t 2>/dev/null`
if [ "${motion_tracking}X" == "X" ]
then
motion_tracking=false
fi
motion_timeout=`/system/sdcard/bin/setconf -g u 2>/dev/null`
if [ "${motion_timeout}X" == "X" ]
then
motion_timeout=60
fi
process=`ps -l| grep v4l2rtspserver-master | grep -v grep`
w=`echo ${process}| awk -F '-W' '{print $2}' | awk '{print $1}'`
if [ "${w}X" == "X" ]
then
w="1280"
fi
h=`echo ${process} | awk -F '-H' '{print $2}' | awk '{print $1}'`
if [ "${h}X" == "X" ]
then
h="720"
fi
if [ "$(motion_detection status)" == "ON" ]
then
motion_detection="true"
else
motion_detection="false"
fi
echo "{\"motion_indicator_color\": ${motion_indicator_color},
\"motion_sensitivity\": ${motion_sensitivity},
\"motion_detection\": ${motion_detection},
\"region_of_interest\": [${region_of_interest}],
\"motion_tracking\": ${motion_tracking},
\"motion_timeout\": ${motion_timeout},
\"width\": ${w},
\"height\": ${h}}"

View File

@@ -1,40 +0,0 @@
#!/bin/sh
. /system/sdcard/www/cgi-bin/func.cgi
echo "Content-type: text/html"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo
if [ "$F_dir" == "recording" ] || [ "$F_dir" == "timelapse" ] || [ "$F_dir" == "motion" ]; then
echo "<h1 class='is-size-4' >${F_dir} files on SD card</h1>"
cat << EOF
<table id="files">
<tr class="header">
<th>Filename</th>
<th>Size</th>
<th>Date</th>
<th>Actions</th>
</tr>
EOF
for file in $(find /system/sdcard/DCIM/${F_dir}/ -type f)
do
if [[ -f $file ]]; then
ip_addr=$(ip -o -4 addr show | sed 's/.* inet \([^/]*\).*/\1/' | grep -v "127.0.0.1")
file_size=$(ls -lh $file | awk '{print $5}')
file_url=$(ls -lh $file | awk '{print $9}' | sed 's/\/system\/sdcard\/DCIM/\/viewer/')
file_date=$(ls -lh $file | awk '{print $6 "-" $7 "-" $8}')
file_name=$(ls -lh $file | awk '{print $9}' | awk -F / '{print $(NF)}')
echo "
<tr>
<td>${file_name}</td>
<td>${file_size}</td>
<td>${file_date}</td>
<td><a href="${file_url}">download</a>
</tr>
"
fi
done
echo "</table>"
else
echo "<h1 class='is-size-4' >Wrong parameters</h1>"
fi

View File

@@ -1,20 +0,0 @@
#!/bin/sh
echo "Content-type: text/html"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
source ./func.cgi
if [ -e "/etc/fang_hacks.cfg" ]; then source /etc/fang_hacks.cfg; fi
PATH="/bin:/sbin:/usr/bin:/system/bin"
cat << EOF
Information:
<pre>Interfaces:<br/>$(ifconfig; iwconfig)</pre>
<pre>Routes:<br/>$(route)</pre>
<pre>DNS:<br/>$(cat /etc/resolv.conf)</pre>
</body>
</html>
EOF

View File

@@ -1,145 +0,0 @@
#!/bin/sh
source ./func.cgi
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
SCRIPT_HOME="/system/sdcard/controlscripts/"
if [ -n "$F_script" ]; then
script="${F_script##*/}"
if [ -e "$SCRIPT_HOME/$script" ]; then
case "$F_cmd" in
start)
echo "Content-type: text/html"
echo ""
echo "Running script '$script'..."
echo "<pre>$("$SCRIPT_HOME/$script" 2>&1)</pre>"
;;
disable)
rm "/system/sdcard/config/autostart/$script"
echo "Content-type: application/json"
echo ""
echo "{\"status\": \"ok\"}"
;;
stop)
echo "Content-type: text/html"
echo ""
status='unknown'
echo "Stopping script '$script'..."
echo "<pre>"
"$SCRIPT_HOME/$script" stop 2>&1 && echo "OK" || echo "NOK"
echo "</pre>"
;;
enable)
echo "#!/bin/sh" > "/system/sdcard/config/autostart/$script"
echo "$SCRIPT_HOME$script" >> "/system/sdcard/config/autostart/$script"
echo "Content-type: application/json"
echo ""
echo "{\"status\": \"ok\"}"
;;
view)
echo "Content-type: text/html"
echo ""
echo "Contents of script '$script':"
echo "<pre>$(cat "$SCRIPT_HOME/$script" 2>&1)</pre>"
;;
*)
echo "Content-type: text/html"
echo ""
echo "<p>Unsupported command '$F_cmd'</p>"
;;
esac
else
echo "Content-type: text/html"
echo ""
echo "<p>$F_script is not a valid script!</p>"
fi
return
fi
echo "Content-type: text/html"
echo ""
if [ ! -d "$SCRIPT_HOME" ]; then
echo "<p>No scripts.cgi found in $SCRIPT_HOME</p>"
else
SCRIPTS=$(ls -A "$SCRIPT_HOME")
for i in $SCRIPTS; do
# Card - start
echo "<div class='card script_card'>"
# Header
echo "<header class='card-header'><p class='card-header-title'>"
# echo "<div class='card-content'>"
if [ -x "$SCRIPT_HOME/$i" ]; then
if grep -q "^status()" "$SCRIPT_HOME/$i"; then
status=$("$SCRIPT_HOME/$i" status)
badgestatus=$status
if [ $? -eq 0 ]; then
if [ -n "$status" ]; then
badge="";
else
badge="is-badge-warning";
fi
else
badge="is-badge-danger"
badgestatus="NOK"
fi
echo "<span class='badge $badge' data-badge='$badgestatus'>$i</span>"
else
echo "$i"
fi
# echo "</div>"
echo "</p></header>"
# Footer
echo "<footer class='card-footer'>"
echo "<span class='card-footer-item'>"
# Start / Stop / Run buttons
echo "<div class='buttons'>"
if grep -q "^start()" "$SCRIPT_HOME/$i"; then
echo "<button data-target='cgi-bin/scripts.cgi?cmd=start&script=$i' class='button is-link script_action_start' data-script='$i' "
if [ ! -z "$status" ]; then
echo "disabled"
fi
echo ">Start</button>"
else
echo "<button data-target='cgi-bin/scripts.cgi?cmd=start&script=$i' class='button is-link script_action_start' data-script='$i' "
echo ">Run</button>"
fi
if grep -q "^stop()" "$SCRIPT_HOME/$i"; then
echo "<button data-target='cgi-bin/scripts.cgi?cmd=stop&script=$i' class='button is-danger script_action_stop' data-script='$i' "
if [ ! -n "$status" ]; then
echo "disabled"
fi
echo ">Stop</button>"
fi
echo "</div>"
echo "</span>"
# Autostart Switch
echo "<span class='card-footer-item'>"
echo "<input type='checkbox' id='autorun_$i' name='autorun_$i' class='switch is-rtl autostart' data-script='$i' "
echo " data-unchecked='cgi-bin/scripts.cgi?cmd=disable&script=$i'"
echo " data-checked='cgi-bin/scripts.cgi?cmd=enable&script=$i'"
if [ -f "/system/sdcard/config/autostart/$i" ]; then
echo " checked='checked'"
fi
echo "'>"
echo "<label for='autorun_$i'>Autorun</label>"
echo "</span>"
# View link
echo "<a href='cgi-bin/scripts.cgi?cmd=view&script=$i' class='card-footer-item view_script' data-script="$i">View</a>"
echo "</footer>"
fi
# Card - End
echo "</div>"
done
fi
script=$(cat /system/sdcard/www/scripts/scripts.cgi.js)
echo "<script>$script</script>"

View File

@@ -13,6 +13,54 @@ echo ""
if [ -n "$F_cmd" ]; then
case "$F_cmd" in
all)
echo "auto_night_mode:$(auto_night_mode status)"
if [ -f /system/sdcard/config/autostart/sound-on-startup ]; then
echo "sound_on_startup:ON"
else
echo "sound_on_startup:OFF"
fi
echo "ir_led:$(ir_led status)"
echo "ir_cut:$(ir_cut status)"
echo "blue_led:$(blue_led status)"
echo "yellow_led:$(yellow_led status)"
echo "motion_detection:$(motion_detection status)"
if [ get_config "/system/sdcard/config/motion.conf" "send_email" ] ; then
echo "motion_mail:ON"
else
echo "motion_mail:OFF"
fi
if [ get_config "/system/sdcard/config/motion.conf" "send_telegram" ]; then
echo "motion_telegram:ON"
else
echo "motion_telegram:OFF"
fi
if [ get_config "/system/sdcard/config/motion.conf" "motion_trigger_led" ]; then
echo "motion_led:ON"
else
echo "motion_led:OFF"
fi
if [ get_config "/system/sdcard/config/motion.conf" "save_snapshot" ]; then
echo "motion_snapshot:ON"
else
echo "motion_snapshot:OFF"
fi
if [ get_config "/system/sdcard/config/motion.conf" "publish_mqtt_message" ]; then
echo "motion_mqtt:ON"
else
echo "motion_mqtt:OFF"
fi
if [ get_config "/system/sdcard/config/motion.conf" "publish_mqtt_snapshot" ]; then
echo "motion_mqtt_snapshot:ON"
else
echo "motion_mqtt_snapshot:OFF"
fi
if [ get_config "/system/sdcard/config/motion.conf" "publish_mqtt_video" ]; then
echo "motion_mqtt_video:ON"
else
echo "motion_mqtt_video:OFF"
fi
;;
blue_led)
echo $(blue_led status)
;;
@@ -154,7 +202,7 @@ if [ -n "$F_cmd" ]; then
if [ -s "/system/sdcard/VERSION" ]; then
V_BRANCH=$(/system/sdcard/bin/jq -r .branch /system/sdcard/VERSION)
V_COMMIT=$(/system/sdcard/bin/jq -r .commit /system/sdcard/VERSION)
echo "commit <b>${V_COMMIT}</b> from branch <b>${V_BRANCH}</b>"
echo "commit <b>${V_COMMIT}</b> from the <b>${V_BRANCH}</b> branch"
else
echo "Need to update to create a version file."
fi

View File

@@ -1,147 +0,0 @@
#!/bin/sh
source /system/sdcard/scripts/common_functions.sh
echo "Content-type: text/html"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
mount|grep "/system/sdcard"|grep "rw,">/dev/null
if [ $? == 1 ]; then
cat << EOF
<!-- sdcard warning -->
<article class="message is-warning">
<div class="message-header">
<p>Warning</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
Your sdcard is mounted read-only. Settings can't be saved.
<br>
<p>Please try rebooting. If the problem persists, please <a target="_blank" href="https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/search?q=read+only+sdcard&type=Issues">search
for possible solutions.</a></p>
</div>
</article>
<!-- end sdcard warning -->
EOF
fi
cat << EOF
<!-- System -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>System</p></header>
<div class='card-content'>
<div class='content'>
<table>
<tbody>
<tr>
<td> Hostname </td>
<td> $(hostname) </td>
</tr>
<tr>
<td> Model </td>
<td> $(detect_model) </td>
</tr>
<tr>
<td> Firmware date </td>
<td> $(if [ -s "/system/sdcard/VERSION" ]; then /system/sdcard/bin/jq -r .date /system/sdcard/VERSION; else echo "Never updated. Make an update to get version."; fi) </td>
</tr>
<tr>
<td> Firmware branch </td>
<td> $(if [ -s "/system/sdcard/VERSION" ]; then /system/sdcard/bin/jq -r .branch /system/sdcard/VERSION; else echo "Never updated. Make an update to get version."; fi) </td>
</tr>
<tr>
<td> Firmware commit </td>
<td> $(if [ -s "/system/sdcard/VERSION" ]; then echo $(check_commit); else echo "Never updated through UI, please run update to get a version file."; fi) </td>
</tr>
<tr>
<td> Kernel Version </td>
<td> $(/system/sdcard/bin/busybox uname -v) </td>
</tr>
<tr>
<td> Bootloader Version </td>
<td> $(busybox strings /dev/mtd0 | grep "U-Boot 2") </td>
<tr>
<tr>
<td> Local Time </td>
<td> $(date) </td>
</tr>
<tr>
<td> Uptime </td>
<td> $(uptime | sed 's/^.*up *//;s/, *[0-9]* user.*$/m/; s/ day[^0-9]*/d, /;s/ \([hms]\).*m$/\1/;s/:/h, /') </td>
</tr>
<tr>
<td> Load Average </td>
<td> $(uptime | awk -F': ' '{print $2}') </td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Network -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>Network (WLAN0)</p></header>
<div class='card-content'>
<div class='content'>
<table>
<tbody>
<tr>
<td> SSID </td>
<td> $(/system/bin/iwgetid -r) </td>
</tr>
<tr>
<td> Link Quality </td>
<td> $(cat /proc/net/wireless | awk 'END { print $3 }' | sed 's/\.$//') </td>
</tr>
<tr>
<td> IP Address </td>
<td> $(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d:) </td>
</tr>
<tr>
<td> MAC Address </td>
<td> $(cat /sys/class/net/wlan0/address) </td>
</tr>
<tr>
<td> Netmask </td>
<td> $(ifconfig wlan0 | sed -rn '2s/ .*:(.*)$/\1/p') </td>
</tr>
<tr>
<td> Gateway </td>
<td> $(route | awk '/default/ { print $2}') </td>
</tr>
<tr>
<td> DNS </td>
<td> <pre>$(cat /etc/resolv.conf) </pre></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Bootloader -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>Bootloader</p></header>
<div class='card-content'>
Bootloader MD5:
<pre>$(md5sum /dev/mtd0 |cut -f 1 -d " ")</pre>
Bootloader Version:
<pre>$(busybox strings /dev/mtd0 | grep "U-Boot 2")</pre>
Your CMDline is:
<pre>$(cat /proc/cmdline)</pre>
<a target="_blank" href="cgi-bin/dumpbootloader.cgi">Download Bootloader</a>
</div>
</div>
EOF

View File

@@ -1,68 +0,0 @@
#!/bin/sh
echo "Content-type: text/html"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
# source header.cgi
mount|grep "/system/sdcard"|grep "rw,">/dev/null
if [ $? == 1 ]; then
cat << EOF
<!-- sdcard warning -->
<article class="message is-warning">
<div class="message-header">
<p>Warning</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
Your sdcard is mounted read-only. Settings can't be saved.
<br>
<p>Please try rebooting. If the problem persists, please <a target="_blank" href="https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/search?q=read+only+sdcard&type=Issues">search
for possible solutions.</a></p>
</div>
</article>
<!-- end sdcard warning -->
EOF
fi
cat << EOF
<!-- Passwords -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>Passwords</p></header>
<div class='card-content'>
<form id="passwordForm" action="cgi-bin/action.cgi?cmd=set_http_password" method="post">
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Set HTTP Password</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input class="input" id="password" name="password" type="password" size="12" value="*****"/>
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input id="pwSubmit" class="button is-primary" type="submit" value="Set" />
</div>
</div>
</div>
</div>
</form>
</div>
</div>
EOF
script=$(cat /system/sdcard/www/scripts/status.cgi.js)
echo "<script>$script</script>"

View File

@@ -1,198 +0,0 @@
#!/bin/sh
echo "Content-type: text/html"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
# source header.cgi
mount|grep "/system/sdcard"|grep "rw,">/dev/null
if [ $? == 1 ]; then
cat << EOF
<!-- sdcard warning -->
<article class="message is-warning">
<div class="message-header">
<p>Warning</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
Your sdcard is mounted read-only. Settings can't be saved.
<br>
<p>Please try rebooting. If the problem persists, please <a target="_blank" href="https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/search?q=read+only+sdcard&type=Issues">search
for possible solutions.</a></p>
</div>
</article>
<!-- end sdcard warning -->
EOF
fi
cat << EOF
<!-- Audio Settings -->
<div class='card status_card'>
<header class='card-header'>
<p class='card-header-title'>Audio Settings</p>
</header>
<div class='card-content'>
<form id="formaudioin" action="cgi-bin/action.cgi?cmd=conf_audioin" method="post">
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Select audio format</label>
</div>
<div class="field-body">
<div class="select">
<select name="audioinFormat">
<option value="OFF" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOFORMAT | grep OFF)" != "" ]; then echo selected; fi)>OFF</option>
<option value="OPUS" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOFORMAT | grep OPUS)" != "" ]; then echo selected; fi)>OPUS</option>
<option value="PCM" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOFORMAT | grep -w PCM)" != "" ]; then echo selected; fi)>PCM</option>
<option value="PCMU" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOFORMAT | grep -w PCMU)" != "" ]; then echo selected; fi)>PCMU</option>
<option value="MP3" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOFORMAT | grep -w MP3)" != "" ]; then echo selected; fi)>MP3</option>
</select>
</div>
<span class="help">
Needs a restart to become active.
</span>
</div>
</div>
<div class="columns">
<div class="column">
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Select in sample rate</label>
</div>
<div class="field-body">
<div class="select">
<select name="audioinBR">
<option value="8000" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOINBR | grep 8000)" != "" ]; then echo selected; fi)>8000</option>
<option value="16000" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOINBR | grep 16000)" != "" ]; then echo selected; fi)>16000</option>
<option value="24000" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOINBR | grep -w 24000)" != "" ]; then echo selected; fi)>24000</option>
<option value="44100" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOINBR | grep -w 44100)" != "" ]; then echo selected; fi)>44100</option>
<option value="48000" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOINBR | grep -w 48000)" != "" ]; then echo selected; fi)>48000</option>
</select>
</div>
<span class="help">
Above 16000 some filters become inactive
</span>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Filter (low filter)</label>
</div>
<div class="field-body">
<div class="select">
<select name="audioinFilter">
<option value="0" $(if [ "$(/system/sdcard/bin/setconf -g q)" == "0" ]; then echo selected; fi)>No filter</option>
<option value="1" $(if [ "$(/system/sdcard/bin/setconf -g q)" == "1" ]; then echo selected; fi)>Filter 1</option>
<option value="2" $(if [ "$(/system/sdcard/bin/setconf -g q)" == "2" ]; then echo selected; fi)>Filter 2</option>
<option value="3" $(if [ "$(/system/sdcard/bin/setconf -g q)" == "3" ]; then echo selected; fi)>NS Filter LOW</option>
<option value="4" $(if [ "$(/system/sdcard/bin/setconf -g q)" == "4" ]; then echo selected; fi)>NS Filter MODERATE</option>
<option value="5" $(if [ "$(/system/sdcard/bin/setconf -g q)" == "5" ]; then echo selected; fi)>NS Filter HIGH</option>
<option value="6" $(if [ "$(/system/sdcard/bin/setconf -g q)" == "6" ]; then echo selected; fi)>NS Filter VERY HIGH</option>
</select>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">High pass filter</label>
</div>
<div class="field-body">
<p class="control">
<div class="double">
<input type="checkbox" name="HFEnabled" value="enabled" $(if [ "$(/system/sdcard/bin/setconf -g l)" == "true" ]; then echo checked; fi)/>
</div>
</p>
</div>
</div>
</div>
<div class="column">
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Select out sample rate</label>
</div>
<div class="field-body">
<div class="select">
<select name="audiooutBR">
<option value="8000" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOOUTBR | grep 8000)" != "" ]; then echo selected; fi)>8000</option>
<option value="16000" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOOUTBR | grep 16000)" != "" ]; then echo selected; fi)>16000</option>
<option value="24000" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOOUTBR | grep -w 24000)" != "" ]; then echo selected; fi)>24000</option>
<option value="44100" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOOUTBR | grep -w 44100)" != "" ]; then echo selected; fi)>44100</option>
<option value="48000" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $AUDIOOUTBR | grep -w 48000)" != "" ]; then echo selected; fi)>48000</option>
</select>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Volume</label>
</div>
<input class="slider is-fullwidth" name="audioinVol" step="1" min="-1" max="120" value="$(/system/sdcard/bin/setconf -g h)" type="range">
</div>
<br><br>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">AEC filter</label>
</div>
<div class="field-body">
<p class="control">
<div class="double">
<input type="checkbox" name="AECEnabled" value="enabled" $(if [ "$(/system/sdcard/bin/setconf -g a)" == "true" ]; then echo checked; fi)/>
</div>
</p>
</div>
</div>
</div>
</div>
<p class="control">
<input id="audioinSubmit" class="button is-primary" type="submit" value="Set" />
</p>
</form>
</div>
</div>
<!-- Audio Testing -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>Audio Test</p></header>
<div class='card-content'>
<div class="columns">
<div class="column">
<form id="formAudio" action="cgi-bin/action.cgi?cmd=audio_test" method="post">
<label>Audio Output Test</label>
<div class="select">
<select name="audioSource">
$(
for i in `/system/sdcard/bin/busybox find /usr/share/notify/ /system/sdcard/media -name *.wav`
do
echo "<option value=$i> `/system/sdcard/bin/busybox basename $i` </option>"
done
)
</select>
</div>
<input class="slider is-fullwidth" name="audiotestVol" step="1" min="0" max="120" value="50" type="range">
<div class="field-body">
<div class="field">
<div class="control">
<input id="AudioTestSubmit" class="button is-primary" type="submit" value="Play" />
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
EOF
script=$(cat /system/sdcard/www/scripts/status.cgi.js)
echo "<script>$script</script>"

View File

@@ -1,94 +0,0 @@
#!/bin/sh
echo "Content-type: text/html"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
# source header.cgi
mount|grep "/system/sdcard"|grep "rw,">/dev/null
if [ $? == 1 ]; then
cat << EOF
<!-- sdcard warning -->
<article class="message is-warning">
<div class="message-header">
<p>Warning</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
Your sdcard is mounted read-only. Settings can't be saved.
<br>
<p>Please try rebooting. If the problem persists, please <a target="_blank" href="https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/search?q=read+only+sdcard&type=Issues">search
for possible solutions.</a></p>
</div>
</article>
<!-- end sdcard warning -->
EOF
fi
cat << EOF
<script>
function call(url){
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.send();
}
</script>
<!-- Blue / Yellow LED -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>LED</p></header>
<div class='card-content'>
<div class="columns">
<div class="column">
<label>Blue LED</label>
<div class="buttons">
<button class="button is-link" onClick="call('cgi-bin/action.cgi?cmd=blue_led_on')">On</button>
<button class="button is-warning" onClick="call('cgi-bin/action.cgi?cmd=blue_led_off')">Off</button>
</div>
</div>
<div class="column">
<label>Yellow LED</label>
<div class="buttons">
<button class="button is-link" onClick="call('cgi-bin/action.cgi?cmd=yellow_led_on')">On</button>
<button class="button is-warning" onClick="call('cgi-bin/action.cgi?cmd=yellow_led_off')">Off</button>
</div>
</div>
</div>
</div>
</div>
<!-- IR LED / (Filter)Cut-->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>IR</p></header>
<div class='card-content'>
<div class="columns">
<div class="column">
<label>IR LED</label>
<div class="buttons">
<button class="button is-link" onClick="call('cgi-bin/action.cgi?cmd=ir_led_on')">On</button>
<button class="button is-warning" onClick="call('cgi-bin/action.cgi?cmd=ir_led_off')">Off</button>
</div>
</div>
<div class="column">
<label>IR Filter</label>
<div class="buttons">
<button class="button is-link" onClick="call('cgi-bin/action.cgi?cmd=ir_cut_on')">On</button>
<button class="button is-warning" onClick="call('cgi-bin/action.cgi?cmd=ir_cut_off')">Off</button>
</div>
</div>
</div>
</div>
</div>
EOF
script=$(cat /system/sdcard/www/scripts/status.cgi.js)
echo "<script>$script</script>"

View File

@@ -1,225 +0,0 @@
#!/bin/sh
echo "Content-type: text/html"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
# source header.cgi
mount|grep "/system/sdcard"|grep "rw,">/dev/null
if [ $? == 1 ]; then
cat << EOF
<!-- sdcard warning -->
<article class="message is-warning">
<div class="message-header">
<p>Warning</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
Your sdcard is mounted read-only. Settings can't be saved.
<br>
<p>Please try rebooting. If the problem persists, please <a target="_blank" href="https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/search?q=read+only+sdcard&type=Issues">search
for possible solutions.</a></p>
</div>
</article>
<!-- end sdcard warning -->
EOF
fi
cat << EOF
<script>
function call(url){
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.send();
}
</script>
<!-- OSD -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>OSD Display</p></header>
<div class='card-content'>
<form id="formOSD" action="cgi-bin/action.cgi?cmd=osd" method="post">
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Enable Text</label>
</div>
<div class="field-body">
<div class="field is-grouped">
<p class="control">
<input type="checkbox" name="OSDenable" value="enabled" $(if [ "$(grep ENABLE_OSD /system/sdcard/config/osd.conf | sed s/ENABLE_OSD=//)" == "true" ]; then echo checked; fi) />
</p>
<p class="control">
<input class="input" id="osdtext" name="osdtext" type="text" size="25" value="$(source /system/sdcard/config/osd.conf && echo "$OSD")"/>
<span class="help">
Enter time-variables in <a href="http://strftime.org/" target="_blank">strftime</a> format
</span>
</p>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Enable Axis</label>
</div>
<div class="field-body">
<div class="field is-grouped">
<p class="control">
<input type="checkbox" name="AXISenable" value="enabled" $(if [[ "$(grep DISPLAY_AXIS /system/sdcard/config/osd.conf | sed s/DISPLAY_AXIS=//)" == "true" ]];then echo checked; fi) />
</p>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">OSD Color</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<div class="select">
<select name="color">
<option value="0" $(if [ "$(grep COLOR /system/sdcard/config/osd.conf | sed s/COLOR=//)" -eq 0 ]; then echo selected; fi)>White</option>
<option value="1" $(if [ "$(grep COLOR /system/sdcard/config/osd.conf | sed s/COLOR=//)" -eq 1 ]; then echo selected; fi)>Black</option>
<option value="2" $(if [ "$(grep COLOR /system/sdcard/config/osd.conf | sed s/COLOR=//)" -eq 2 ]; then echo selected; fi)>Red</option>
<option value="3" $(if [ "$(grep COLOR /system/sdcard/config/osd.conf | sed s/COLOR=//)" -eq 3 ]; then echo selected; fi)>Green</option>
<option value="4" $(if [ "$(grep COLOR /system/sdcard/config/osd.conf | sed s/COLOR=//)" -eq 4 ]; then echo selected; fi)>Blue</option>
<option value="5" $(if [ "$(grep COLOR /system/sdcard/config/osd.conf | sed s/COLOR=//)" -eq 5 ]; then echo selected; fi)>Cyan</option>
<option value="6" $(if [ "$(grep COLOR /system/sdcard/config/osd.conf | sed s/COLOR=//)" -eq 6 ]; then echo selected; fi)>Yellow</option>
<option value="7" $(if [ "$(grep COLOR /system/sdcard/config/osd.conf | sed s/COLOR=//)" -eq 7 ]; then echo selected; fi)>Purple</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Font name</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<div class="select">
<select name="FontName">
$(
fontName="$(/system/sdcard/bin/setconf -g e)"
echo -n "<option value=\"\""
if [ -n "${fontName-unset}" ] ; then echo selected; fi
echo -n ">Default fonts </option>"
for i in `/system/sdcard/bin/busybox find /system/sdcard/fonts -name *.ttf`
do
echo -n "<option value=\"$i\" "
if [ "$fontName" == "$i" ] ; then echo selected; fi
echo -n ">`/system/sdcard/bin/busybox basename $i` </option>"
done
)
</select>
</div>
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">OSD Text Size</label>
</div>
<div class="field-body">
<div class="field">
<p class="control">
<input class="input" id="OSDSize" name="OSDSize" type="number" size="4"
value="$(
fontSize=$(/system/sdcard/bin/setconf -g s)
if [ "$fontSize" == "0" ]; then echo 18
elif [ "$fontSize" == "1" ]; then echo 40
else echo "$fontSize"
fi
)"/>
</p>
<p class="help">Too high value won't display anything</p>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Pixels between chars</label>
</div>
<div class="field-body">
<div class="field">
<p class="control">
<input class="input" id="spacepixels" name="spacepixels" type="number" size="4" value="$(source /system/sdcard/config/osd.conf && echo "$SPACE")"/>
</p>
<p class="help">Can be negative</p>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Y Position</label>
</div>
<div class="field-body">
<div class="field">
<p class="control">
<input class="input" id="posy" name="posy" type="number" size="6" value="$(source /system/sdcard/config/osd.conf && echo "$POSY")"/>
</p>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Fixed width</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<div class="select">
<select name="fixedw">
<option value="0" $(if [ "$(grep FIXEDW /system/sdcard/config/osd.conf | sed s/FIXEDW=//)" -eq 0 ]; then echo selected; fi)>No</option>
<option value="1" $(if [ "$(grep FIXEDW /system/sdcard/config/osd.conf | sed s/FIXEDW=//)" -eq 1 ]; then echo selected; fi)>Yes</option>
</select>
</div>
<p class="help">Fixed width works only for "default" fonts</p>
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input id="osdSubmit" class="button is-primary" type="submit" value="Set" />
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<!-- OSD Debug -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>Display debug info on OSD</p></header>
<div class='card-content'>
<button class="button is-link" onClick="call('cgi-bin/action.cgi?cmd=onDebug')">On</button>
<button class="button is-warning" onClick="call('cgi-bin/action.cgi?cmd=offDebug')">Off</button>
</div>
</div>
EOF
script=$(cat /system/sdcard/www/scripts/status.cgi.js)
echo "<script>$script</script>"

View File

@@ -1,82 +0,0 @@
#!/bin/sh
echo "Content-type: text/html"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
# source header.cgi
mount|grep "/system/sdcard"|grep "rw,">/dev/null
if [ $? == 1 ]; then
cat << EOF
<!-- sdcard warning -->
<article class="message is-warning">
<div class="message-header">
<p>Warning</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
Your sdcard is mounted read-only. Settings can't be saved.
<br>
<p>Please try rebooting. If the problem persists, please <a target="_blank" href="https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/search?q=read+only+sdcard&type=Issues">search
for possible solutions.</a></p>
</div>
</article>
<!-- end sdcard warning -->
EOF
fi
cat << EOF
<script>
function call(url){
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.send();
}
</script>
<!-- Motor -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>Motor</p></header>
<div class='card-content'>
<table class="motor_control">
<tr>
<td></td>
<td>
<button class="button is-link" onclick="call('cgi-bin/action.cgi?cmd=motor_up&val='+document.getElementById('val').value)">&uarr; Up</button>
</td>
<td></td>
</tr>
<tr>
<td>
<button class="button is-link" onclick="call('cgi-bin/action.cgi?cmd=motor_left&val='+document.getElementById('val').value)">&larr; Left</button>
</td>
<td>
<input class="input has-text-centered" type="text" id="val" name="val" value="100">
</td>
<td>
<button class="button is-link" onclick="call('cgi-bin/action.cgi?cmd=motor_right&val='+document.getElementById('val').value)">Right &rarr;</button>
</td>
</tr>
<tr>
<td></td>
<td>
<button class="button is-link" onclick="call('cgi-bin/action.cgi?cmd=motor_down&val='+document.getElementById('val').value)">&darr; Down</button>
</td>
<td></td>
</tr>
</table>
<div class="buttons">
<button class="button is-warning" onclick="call('cgi-bin/action.cgi?cmd=motor_calibrate')">Calibrate</button>
</div>
</div>
</div>
EOF
script=$(cat /system/sdcard/www/scripts/status.cgi.js)
echo "<script>$script</script>"

View File

@@ -1,106 +0,0 @@
#!/bin/sh
echo "Content-type: text/html"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
# source header.cgi
mount|grep "/system/sdcard"|grep "rw,">/dev/null
if [ $? == 1 ]; then
cat << EOF
<!-- sdcard warning -->
<article class="message is-warning">
<div class="message-header">
<p>Warning</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
Your sdcard is mounted read-only. Settings can't be saved.
<br>
<p>Please try rebooting. If the problem persists, please <a target="_blank" href="https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/search?q=read+only+sdcard&type=Issues">search
for possible solutions.</a></p>
</div>
</article>
<!-- end sdcard warning -->
EOF
fi
cat << EOF
<script>
function call(url){
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.send();
}
</script>
<!-- System -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>System Properties</p></header>
<div class='card-content'>
<form id="tzForm" action="cgi-bin/action.cgi?cmd=settz" method="post">
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label" for="tz">Time Zone</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<div class="select">
<select name="timeZone">
$(/system/sdcard/bin/busybox awk -F '\t' -v tzn="$(cat /system/sdcard/config/timezone.conf)" '{print "<option value=\""$1"\""; if ($1==tzn) print "selected"; print ">" $1 "</option>"}' /system/sdcard/www/timezones.tsv)
</select>
</div>
<p class="help">$(date) - $(cat /etc/TZ)</p>
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label" for="ntp_srv">NTP Server</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input class="input" id="ntp_srv" name="ntp_srv" type="text" size="25" value="$(cat /system/sdcard/config/ntp_srv.conf)" />
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label" for="hostname">Hostname</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input class="input" id="hostname" name="hostname" type="text" size="15" value="$(hostname)" />
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input id="tzSubmit" class="button is-primary" type="submit" value="Set" />
</div>
</div>
</div>
</div>
</form>
</div>
</div>
EOF
script=$(cat /system/sdcard/www/scripts/status.cgi.js)
echo "<script>$script</script>"

View File

@@ -1,363 +0,0 @@
#!/bin/sh
echo "Content-type: text/html"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
# source header.cgi
mount|grep "/system/sdcard"|grep "rw,">/dev/null
if [ $? == 1 ]; then
cat << EOF
<!-- sdcard warning -->
<article class="message is-warning">
<div class="message-header">
<p>Warning</p>
<button class="delete" aria-label="delete"></button>
</div>
<div class="message-body">
Your sdcard is mounted read-only. Settings can't be saved.
<br>
<p>Please try rebooting. If the problem persists, please <a target="_blank" href="https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/search?q=read+only+sdcard&type=Issues">search
for possible solutions.</a></p>
</div>
</article>
<!-- end sdcard warning -->
EOF
fi
cat << EOF
<script>
function call(url){
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.send();
}
</script>
<!-- Video settings -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>Video Settings</p></header>
<div class='card-content'>
<form id="formResolution" action="cgi-bin/action.cgi?cmd=set_video_size" method="post">
<div class="columns">
<div class="column">
<div class="field is-horizontal">
<div class="field-body">
<div class="field-label is-normal">
<label class="label">Video username</label>
</div>
<div class="field">
<div class="control">
<input class="input" id="videouser" name="videouser" type="text" size="12" value="$(source /system/sdcard/config/rtspserver.conf; echo $USERNAME)" />
</div>
</div>
</div>
</div>
</div>
<div class="column">
<div class="field-body">
<div class="field-label is-normal">
<label class="label">Video password</label>
</div>
<div class="field">
<div class="control">
<input class="input" id="videopassword" name="videopassword" type="password" size="12" value="$(source /system/sdcard/config/rtspserver.conf; echo $USERPASSWORD)" />
</div>
</div>
</div>
</div>
<div class="column">
<div class="field-body">
<div class="field-label is-normal">
<label class="label">Video port</label>
</div>
<div class="field">
<div class="control">
<input class="input" id="videoport" name="videoport" type="number" size="12" value=$(source /system/sdcard/config/rtspserver.conf; echo $PORT) />
</div>
</div>
<span class="help">
Default is 8554
</span>
</div>
</div>
</div>
<div class="columns">
<div class="column">
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Video Size</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<div class="select">
<select name="video_size">
<option value="-W640 -H360" $(source /system/sdcard/config/rtspserver.conf; if [ "$RTSPH264OPTS" == "-W640 -H360" ]; then echo selected; fi) >640x360</option>
<option value="-W768 -H432" $(source /system/sdcard/config/rtspserver.conf; if [ "$RTSPH264OPTS" == "-W768 -H432" ]; then echo selected; fi) >768x432</option>
<option value="-W960 -H540" $(source /system/sdcard/config/rtspserver.conf; if [ "$RTSPH264OPTS" == "-W960 -H540" ]; then echo selected; fi) >960x540</option>
<option value="-W1280 -H720" $(source /system/sdcard/config/rtspserver.conf; if [ "$RTSPH264OPTS" == "-W1280 -H720" ] || [ -z "$RTSPH264OPTS" ]; then echo selected; fi) >1280x720</option>
<option value="-W1600 -H900" $(source /system/sdcard/config/rtspserver.conf; if [ "$RTSPH264OPTS" == "-W1600 -H900" ]; then echo selected; fi) >1600x900</option>
<option value="-W1920 -H1080" $(source /system/sdcard/config/rtspserver.conf; if [ "$RTSPH264OPTS" == "-W1920 -H1080" ]; then echo selected; fi) >1920x1080</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Video format</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<div class="select">
<select name="video_format">
0 = FixedQp, 1 = CBR, 2 = VBR, 3 = SMART
<option value="0" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $VIDEOFORMAT | grep -w 0)" != "" ]; then echo selected; fi)>FixedQp</option>
<option value="1" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $VIDEOFORMAT | grep -w 1)" != "" ]; then echo selected; fi)>CBR</option>
<option value="2" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $VIDEOFORMAT | grep -w 2)" != "" ] || [ -z "$VIDEOFORMAT" ] ; then echo selected; fi)>VBR</option>
<option value="3" $(source /system/sdcard/config/rtspserver.conf; if [ "$(echo $VIDEOFORMAT | grep -w 3)" != "" ]; then echo selected; fi)>SMART</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-body">
<div class="field-label is-horizontal">
<label class="label">FrameRate: number of image(s) </label>
</div>
<div class="field">
<div class="control">
<input class="input" id="frmRateNum" name="frmRateNum" type="text" size="5" value="$(source /system/sdcard/config/rtspserver.conf; echo $FRAMERATE_NUM)" placeholder="25"/>
</div>
</div>
<div class="field-label is-horizontal">
<label class="label">per </label>
</div>
<div class="field">
<div class="control">
<input class="input" id="frmRateDen" name="frmRateDen" type="text" size=5 value="$(source /system/sdcard/config/rtspserver.conf; echo $FRAMERATE_DEN)" placeholder="1" />
</div>
</div>
<div class="field-label is-horizontal">
<label class="label"> second(s) </label>
</div>
</div>
</div>
</div>
<div class="column">
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">bitrate</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input class="input" id="brbitrate" name="brbitrate" type="text" size="5" value="$(/system/sdcard/bin/setconf -g b)"/> kbps
</div>
</div>
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-body">
<div class="field">
<div class="control">
<input id="resSubmit" class="button is-primary" type="submit" value="Set" />
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<!-- Video Test -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>Video Test</p></header>
<div class='card-content'>
<div class="columns">
<div class="column">
<div class="buttons">
<a class="button is-link" href='cgi-bin/currentpic.cgi' target='_blank'>Get Image</a>
</div>
</div>
</div>
</div>
</div>
<!-- Auto Night Mode -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>Auto Night Mode</p></header>
<div class='card-content'>
<div class="columns">
<div class="column">
<button class="button is-link" onClick="call('cgi-bin/action.cgi?cmd=auto_night_mode_start')">On</button>
<button class="button is-warning" onClick="call('cgi-bin/action.cgi?cmd=auto_night_mode_stop')">Off</button>
<input class="is-checkradio" id="night_config_hw" type="radio" name="night_config" $(if [ "$(grep -q -e "=hw" /system/sdcard/config/autonight.conf; echo $?)" != 0 ]; then echo "checked"; fi) onClick="call('cgi-bin/action.cgi?cmd=autonight_hw')" >
<label for="night_config_hw">HW</label>
<input class="is-checkradio" id="night_config_sw" type="radio" name="night_config" $(if [ "$(grep -q -e "=sw" /system/sdcard/config/autonight.conf; echo $?)" == 0 ]; then echo "checked"; fi) onClick="call('cgi-bin/action.cgi?cmd=autonight_sw')">
<label for="night_config_sw">SW</label>
</div>
<div class="column">
<form id="formldr" action="cgi-bin/action.cgi?cmd=setldravg" method="post">
<p>Use average measurement on switching.</p>
<label class="label">Number of measurements</label>
<div class="field is-grouped">
<div class="control">
<div class="select">
<select class="select" name="avg">
<option value="1" $(if [ "$(sed s/AVG=// /system/sdcard/config/ldr-average.conf)" -eq 1 ]; then echo selected; fi)>1</option>
<option value="2" $(if [ "$(sed s/AVG=// /system/sdcard/config/ldr-average.conf)" -eq 2 ]; then echo selected; fi)>2</option>
<option value="3" $(if [ "$(sed s/AVG=// /system/sdcard/config/ldr-average.conf)" -eq 3 ]; then echo selected; fi)>3</option>
<option value="4" $(if [ "$(sed s/AVG=// /system/sdcard/config/ldr-average.conf)" -eq 4 ]; then echo selected; fi)>4</option>
<option value="5" $(if [ "$(sed s/AVG=// /system/sdcard/config/ldr-average.conf)" -eq 5 ]; then echo selected; fi)>5</option>
<option value="10" $(if [ "$(sed s/AVG=// /system/sdcard/config/ldr-average.conf)" -eq 10 ]; then echo selected; fi)>10</option>
<option value="15" $(if [ "$(sed s/AVG=// /system/sdcard/config/ldr-average.conf)" -eq 15 ]; then echo selected; fi)>15</option>
</select>
</div>
</div>
<p class="control">
<input id="ldrSubmit" class="button is-primary" type="submit" value="Set" />
</p>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- RTSP -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>RTSP</p></header>
<div class='card-content'>
<div class="columns">
<div class="column">
<label>Night Vision</label>
<div class="buttons">
<button class="button is-link" onClick="call('cgi-bin/action.cgi?cmd=toggle-rtsp-nightvision-on')">On</button>
<button class="button is-warning" onClick="call('cgi-bin/action.cgi?cmd=toggle-rtsp-nightvision-off')">Off</button>
</div>
</div>
<div class="column">
<br>
<div class="field is-horizontal">
<div class="field">
<input class="switch" name="flip" id="flip" type="checkbox" $(if [ "$(/system/sdcard/bin/setconf -g f)" == 1 ]; then echo "checked"; fi) >
<label for="flip">Image flip</label>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- H264 RTSP -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>Start H264 RTSP</p></header>
<div class='card-content'>
<button class="button is-link" onClick="call('cgi-bin/action.cgi?cmd=h264_start')">Start</button>
<button class="button is-warning" onClick="call('cgi-bin/action.cgi?cmd=rtsp_stop')">Stop</button>
EOF
PATH="/bin:/sbin:/usr/bin:/media/mmcblk0p2/data/bin:/media/mmcblk0p2/data/sbin:/media/mmcblk0p2/data/usr/bin"
IP=$(ifconfig wlan0 |grep "inet addr" |awk '{print $2}' |awk -F: '{print $2}')
echo "<p>Path to feed: <a href='rtsp://$IP:$(source /system/sdcard/config/rtspserver.conf; echo $PORT)/unicast'>rtsp://$IP:$(source /system/sdcard/config/rtspserver.conf; echo $PORT)/unicast</a></p>"
echo "<p>HLS: <a href='http://$IP:$(source /system/sdcard/config/rtspserver.conf; echo $PORT)/unicast.m3u8'>http://$IP:$(source /system/sdcard/config/rtspserver.conf; echo $PORT)/unicast.m3u8</a></p>"
echo "<p>hls.js web player: <a href='http://$IP:$(source /system/sdcard/config/rtspserver.conf; echo $PORT)'>http://$IP:$(source /system/sdcard/config/rtspserver.conf; echo $PORT)</a></p>"
echo "<p>MPEG-DASH: <a href='http://$IP:$(source /system/sdcard/config/rtspserver.conf; echo $PORT)/unicast.mpd'>http://$IP:$(source /system/sdcard/config/rtspserver.conf; echo $PORT)/unicast.mpd</a></p>"
echo "HLS & MPEG-DASH require the rtspserver to be started with the -S flag. This may reduce the compatibility with some ip camera viewers such as ipcamviewer etc."
cat << EOF
</div>
</div>
<!-- MJPEG RTSP -->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>Start MJPEG RTSP</p></header>
<div class='card-content'>
<button class="button is-link" onClick="call('cgi-bin/action.cgi?cmd=mjpeg_start')">Start</button>
<button class="button is-warning" onClick="call('cgi-bin/action.cgi?cmd=rtsp_stop')">Stop</button>
EOF
PATH="/bin:/sbin:/usr/bin:/media/mmcblk0p2/data/bin:/media/mmcblk0p2/data/sbin:/media/mmcblk0p2/data/usr/bin"
IP=$(ifconfig wlan0 |grep "inet addr" |awk '{print $2}' |awk -F: '{print $2}')
echo "<p>Path to feed : <a href='rtsp://$IP:$(source /system/sdcard/config/rtspserver.conf; echo $PORT)/unicast'>rtsp://$IP:$(source /system/sdcard/config/rtspserver.conf; echo $PORT)/unicast</a></p>"
cat << EOF
</div>
</div>
<!-- Timelapse Config-->
<div class='card status_card'>
<header class='card-header'><p class='card-header-title'>Timelapse Settings</p></header>
<div class='card-content'>
<form id="formTimelapse" action="cgi-bin/action.cgi?cmd=conf_timelapse" method="post">
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Interval</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input class="input" id="tlinterval" name="tlinterval" type="text" size="5" value="$(source /system/sdcard/config/timelapse.conf && echo "$TIMELAPSE_INTERVAL")"/> seconds
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Duration</label>
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input class="input" id="tlduration" name="tlduration" type="text" size="5" value="$(source /system/sdcard/config/timelapse.conf && echo "$TIMELAPSE_DURATION")"/> minutes
</div>
<p class="help">Set to 0 for unlimited</p>
<p class="help">These settings configure the timelapse mode. Start the timelapse on the Services page.</p>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
</div>
<div class="field-body">
<div class="field">
<div class="control">
<input id="tlSubmit" class="button is-primary" type="submit" value="Save Configuration" />
</div>
</div>
</div>
</div>
</form>
</div>
</div>
EOF
script=$(cat /system/sdcard/www/scripts/status.cgi.js)
echo "<script>$script</script>"

View File

@@ -0,0 +1,271 @@
#!/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 ""
if [ -n "$F_cmd" ]; then
case "$F_cmd" in
get_config)
source /system/sdcard/config/rtspserver.conf
source /system/sdcard/config/autonight.conf
source /system/sdcard/config/ldr-average.conf
source /system/sdcard/config/timelapse.conf
source /system/sdcard/config/osd.conf
echo "multicast#:#${MULTICASTDEST}"
echo "flip#:#${FLIP}"
echo "codec#:#${CODEC}"
echo "videoSize#:#${RTSPOPTS}"
echo "bitRate#:#${BITRATE}"
echo "format#:#${VIDEOFORMAT}"
echo "frmRateNum#:#${FRAMERATE_NUM}"
echo "frmRateDen#:#${FRAMERATE_DEN}"
echo "videoUser#:#${USERNAME}"
echo "videoPassword#:#${USERPASSWORD}"
echo "videoPort#:#${PORT}"
echo "autoNightMode#:#${autonight_mode}"
echo "avg#:#${AVG}"
echo "audioinFormat#:#${AUDIOFORMAT}"
echo "audioinBR#:#${AUDIOINBR}"
echo "audiooutBR#:#${AUDIOOUTBR}"
echo "audioinFilter#:#$(/system/sdcard/bin/setconf -g q)"
echo "HFEnabled#:#$(/system/sdcard/bin/setconf -g l)"
echo "AECEnabled#:#$(/system/sdcard/bin/setconf -g a)"
echo "audioinVol#:#$(/system/sdcard/bin/setconf -g h)"
echo "tlinterval#:#${TIMELAPSE_INTERVAL}"
echo "tlduration#:#${TIMELAPSE_DURATION}"
echo "osdEnable#:#${ENABLE_OSD}"
echo "osdText#:#${OSD}"
echo "osdAxis#:#${DISPLAY_AXIS}"
echo "osdColor#:#${COLOR}"
echo "osdSize#:#$(/system/sdcard/bin/setconf -g s)"
echo "osdPixel#:#${SPACE}"
echo "osdY#:#${POSY}"
echo "osdFixW#:#${FIXEDW}"
echo "osdFonts#:#$(getFonts)"
;;
save_config)
if [ -n "${F_codec+x}" ]; then
video_codec=$(echo "${F_codec}"| sed -e 's/+/ /g')
rewrite_config /system/sdcard/config/rtspserver.conf CODEC "\"$video_codec\""
echo "Server video codec set to $video_codec<br/>"
fi
if [ -n "${F_videoSize+x}" ]; then
video_size=$(echo "${F_videoSize}"| sed -e 's/+/ /g')
rewrite_config /system/sdcard/config/rtspserver.conf RTSPOPTS "\"$video_size\""
echo "Video resolution set to $video_size<br/>"
fi
if [ -n "${F_bitRate+x}" ]; then
brbitrate=$(printf '%b' "${F_bitRate/%/\\x}")
rewrite_config /system/sdcard/config/rtspserver.conf BITRATE "$brbitrate"
echo "Bitrate set to $brbitrate<br/>"
fi
if [ -n "${F_format+x}" ]; then
video_format=$(printf '%b' "${F_format/%/\\x}")
rewrite_config /system/sdcard/config/rtspserver.conf VIDEOFORMAT "$video_format"
echo "Video format set to $video_format (0 = FixedQp, 1 = CBR, 2 = VBR and 3 = SMART)<br/>"
fi
if [ -n "${F_flip+x}" ]; then
video_flip=$(echo "${F_flip}"| sed -e 's/+/ /g')
rewrite_config /system/sdcard/config/rtspserver.conf FLIP "\"$video_flip\""
echo "Server video flip set to $video_flip<br/>"
fi
if [ -n "${F_frmRateNum+x}" ]; then
frmRateNum=$(printf '%b' "${F_frmRateNum/%/\\x}")
if [ "$frmRateNum" != "" ]; then
rewrite_config /system/sdcard/config/rtspserver.conf FRAMERATE_NUM "$frmRateNum"
fi
fi
if [ -n "${F_frmRateDen+x}" ]; then
frmRateDen=$(printf '%b' "${F_frmRateDen/%/\\x}")
if [ "$frmRateDen" != "" ]; then
rewrite_config /system/sdcard/config/rtspserver.conf FRAMERATE_DEN "$frmRateDen"
fi
echo "FrameRate set to $frmRateDen/$frmRateNum <br/>"
/system/sdcard/bin/setconf -k d -v "$frmRateNum,$frmRateDen" 2>/dev/null
fi
if [ -n "${F_videoUser+x}" ]; then
videouser=$(printf '%b' "${F_videoUser//%/\\x}")
rewrite_config /system/sdcard/config/rtspserver.conf USERNAME "$videouser"
fi
if [ -n "${F_videoPassword+x}" ]; then
videopassword=$(printf '%b' "${F_videoPassword//%/\\x}")
rewrite_config /system/sdcard/config/rtspserver.conf USERPASSWORD "$videopassword"
echo "Set user and password for video stream<br />"
fi
if [ -n "${F_multicast+x}" ]; then
multicast_dest=$(printf '%b' "${F_multicast//%/\\x}")
rewrite_config /system/sdcard/config/rtspserver.conf MULTICASTDEST "$multicast_dest"
echo "Set multicast address to ${multicast_dest}<br />"
fi
if [ -n "${F_videoPort+x}" ]; then
videoport=$(echo "${F_videoPort}"| tr '\n')
rewrite_config /system/sdcard/config/rtspserver.conf PORT "$videoport"
echo "Set video port tp ${videoport}"
fi
if [ -n "${F_autoNightMode+x}" ]; then
rewrite_config /system/sdcard/config/autonight.conf autonight_mode $F_autoNightMode
echo "Set autonight to mode ${F_autoNightMode} <br />"
fi
if [ -n "${F_avg+x}" ]; then
ldravg=$(printf '%b' "${F_avg/%/\\x}")
ldravg=$(echo "$ldravg" | sed "s/[^0-9]//g")
echo AVG="$ldravg" > /system/sdcard/config/ldr-average.conf
echo "Average set to $ldravg iterations. <br />"
fi
if [ -n "${F_audioinFormat+x}" ]; then
audioinFormat=$(printf '%b' "${F_audioinFormat/%/\\x}")
if [ "$audioinFormat" == "OPUS" ]; then
audioOutBR="48000"
fi
if [ "$audioinFormat" == "PCM" ]; then
audioOutBR = audioinBR
fi
if [ "$audioinFormat" == "PCMU" ]; then
audioOutBR = audioinBR
fi
rewrite_config /system/sdcard/config/rtspserver.conf AUDIOFORMAT "$audioinFormat"
echo "Audio format $audioinFormat <br/>"
fi
if [ -n "${F_audioinBR+x}" ]; then
audioinBR=$(printf '%b' "${F_audioinBR/%/\\x}")
if [ "$audioinBR" == "" ]; then
audioinBR="8000"
fi
rewrite_config /system/sdcard/config/rtspserver.conf AUDIOINBR "$audioinBR"
echo "In audio bitrate $audioinBR <br/>"
fi
if [ -n "${F_audiooutBR+x}" ]; then
audiooutBR=$(printf '%b' "${F_audiooutBR/%/\\x}")
if [ "$audiooutBR" == "" ]; then
audioOutBR = audioinBR
fi
rewrite_config /system/sdcard/config/rtspserver.conf AUDIOOUTBR "$audiooutBR"
echo "Out audio bitrate $audiooutBR <br/>"
fi
if [ -n "${F_audioinFilter+x}" ]; then
rewrite_config /system/sdcard/config/rtspserver.conf FILTER "$F_audioinFilter"
echo "Filter $F_audioinFilter <br/>"
system/sdcard/bin/setconf -k q -v "$F_audioinFilter" 2>/dev/null
fi
if [ -n "${F_HFEnabled+x}" ]; then
rewrite_config /system/sdcard/config/rtspserver.conf HIGHPASSFILTER "$F_HFEnabled"
echo "High Pass Filter $F_HFEnabled <br/>"
/system/sdcard/bin/setconf -k l -v "$F_HFEnabled" 2>/dev/null
fi
if [ -n "${F_AECEnabled+x}" ]; then
rewrite_config /system/sdcard/config/rtspserver.conf AECFILTER "$F_AECEnabled"
echo "AEC Filter $F_AECEnabled <br/>"
/system/sdcard/bin/setconf -k a -v "$F_AECEnabled" 2>/dev/null
fi
if [ -n "${F_audioinVol+x}" ]; then
rewrite_config /system/sdcard/config/rtspserver.conf HWVOLUME "$F_audioinVol"
rewrite_config /system/sdcard/config/rtspserver.conf SWVOLUME "-1"
echo "Volume $F_audioinVol <br/>"
/system/sdcard/bin/setconf -k h -v "$F_audioinVol" 2>/dev/null
fi
if [ -n "${F_tlinterval+x}" ]; then
tlinterval=$(printf '%b' "${F_tlinterval/%/\\x}")
tlinterval=$(echo "$tlinterval" | sed "s/[^0-9\.]//g")
if [ "$tlinterval" ]; then
rewrite_config /system/sdcard/config/timelapse.conf TIMELAPSE_INTERVAL "$tlinterval"
echo "Timelapse interval set to $tlinterval seconds. <br />"
else
echo "Invalid timelapse interval <br />"
fi
fi
if [ -n "${F_tlduration+x}" ]; then
tlduration=$(printf '%b' "${F_tlduration/%/\\x}")
tlduration=$(echo "$tlduration" | sed "s/[^0-9\.]//g")
if [ "$tlduration" ]; then
rewrite_config /system/sdcard/config/timelapse.conf TIMELAPSE_DURATION "$tlduration"
echo "Timelapse duration set to $tlduration minutes. <br />"
else
echo "Invalid timelapse duration <br />"
fi
fi
if [ -n "${F_osdEnable+x}" ]; then
if [ "${F_osdEnable}" == "true" ]; then
echo "ENABLE_OSD=true" > /system/sdcard/config/osd.conf
update_axis
echo "OSD enabled <br />"
else
echo "ENABLE_OSD=false" > /system/sdcard/config/osd.conf
echo "OSD disabled <br />"
/system/sdcard/bin/setconf -k o -v ""
fi
fi
if [ -n "${F_osdText+x}" ]; then
osdtext=$(printf '%b' "${F_osdText//%/\\x}")
osdtext=$(echo "$osdtext" | sed -e "s/\\+/ /g")
echo "OSD=\"${osdtext}\"" | sed -r 's/[ ]X=.*"/"/' >> /system/sdcard/config/osd.conf
echo "OSD set text ${osdtext}<br />"
fi
if [ -n "${F_osdAxis+x}" ];then
if [ "${F_osdAxis}" == "true" ]; then
echo "DISPLAY_AXIS=true" >> /system/sdcard/config/osd.conf
echo "OSD Display axis enabled<br />"
else
echo "DISPLAY_AXIS=false" >> /system/sdcard/config/osd.conf
echo "OSD Display axis disabled<br />"
fi
fi
if [ -n "${F_osdColor+x}" ]; then
color='white black red green blue cyan yellow purple'
echo "COLOR=${F_osdColor}" >> /system/sdcard/config/osd.conf
/system/sdcard/bin/setconf -k c -v "${F_osdColor}"
echo -n "Set text color to "
echo -n $(echo $color | cut -d ' ' -f $(($F_osdColor + 1)))
echo "<br />"
fi
if [ -n "${F_osdSize+x}" ]; then
echo "SIZE=${F_osdSize}" >> /system/sdcard/config/osd.conf
/system/sdcard/bin/setconf -k s -v "${F_osdSize}"
echo "Set OSD text size to ${F_osdSize}<br />"
fi
if [ -n "${F_osdPixel+x}" ]; then
echo "SPACE=${F_osdPixel}" >> /system/sdcard/config/osd.conf
/system/sdcard/bin/setconf -k p -v "${F_osdPixel}"
echo "Set OSD pixel betwwen chars to ${F_osdPixel}<br />"
fi
if [ -n "${F_osdY+x}" ]; then
echo "POSY=${F_osdY}" >> /system/sdcard/config/osd.conf
system/sdcard/bin/setconf -k x -v "${F_osdY}"
echo "Set OSD Y position to ${F_osdY}<br />"
fi
if [ -n "${F_osdFixW+x}" ]; then
echo "FIXEDW=${F_osdFixW}" >> /system/sdcard/config/osd.conf
/system/sdcard/bin/setconf -k w -v "${F_osdFixW}"
echo "Set OSD fixed width to ${F_osdFixW}<br />"
fi
if [ -n "${F_osdFonts+x}" ]; then
fontName=$(printf '%b' "${F_osdFonts//%/\\x}")
fontName=$(echo "$fontName" | sed -e "s/\\+/ /g")
echo "FONTNAME=${fontName}" >> /system/sdcard/config/osd.conf
/system/sdcard/bin/setconf -k e -v "${fontName}"
echo "Set OSD font to ${fontName}<br />"
fi
if [ "$(/system/sdcard/controlscripts/rtsp status)" != "" ]; then
echo "Restart rtsp server"
/system/sdcard/controlscripts/rtsp stop
/system/sdcard/controlscripts/rtsp start
fi
return
;;
*)
echo "Unsupported command '$F_cmd'"
;;
esac
fi
exit 0

View File

@@ -0,0 +1,85 @@
#!/bin/sh
. /system/sdcard/www/cgi-bin/func.cgi
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 ""
if [ -n "$F_cmd" ]; then
case "$F_cmd" in
get_services)
services="auto-night-detection debug-on-osd ftp_server mqtt-control mqtt-status onvif-srvd recording rtsp sound-on-startup telegram-bot timelapse"
for service in $services ; do
echo "${service}#:#$(test -f /run/${service}.pid && echo 'started' || echo 'stopped')#:#$(test -f /system/sdcard/config/autostart/${service} && echo 'true' || echo 'false')#:#false"
done
return
;;
autoStartService)
if [ $F_service == "auto_night_mode" ]; then
F_service="auto-night-detection"
fi
if $F_action ; then
echo "#!/bin/sh" > "/system/sdcard/config/autostart/${F_service}"
echo "/system/sdcard/controlscripts/${F_service}" >> "/system/sdcard/config/autostart/${F_service}"
else
rm "/system/sdcard/config/autostart/${F_service}"
fi
return
;;
services)
$(/system/sdcard/controlscripts/${F_service} $F_action) > /dev/null
return
;;
getFiles)
ip_addr=$(ip -o -4 addr show | sed 's/.* inet \([^/]*\).*/\1/' | grep -v "127.0.0.1")
for file in $(find /system/sdcard/DCIM/${F_dir}/ -type f)
do
if [[ -f $file ]]; then
file_size=$(ls -lh $file | awk '{print $5}')
file_url=$(ls -lh $file | awk '{print $9}' | sed 's/\/system\/sdcard\/DCIM/\/viewer/')
file_date=$(ls -lh $file | awk '{print $6 "-" $7 "-" $8}')
file_name=$(ls -lh $file | awk '{print $9}' | awk -F / '{print $(NF)}')
echo "${file_name}#:#${file_size}#:#${file_date}#:#${file_url}"
fi
done
return
;;
del_config)
F_file=$(echo ${F_file} | sed -e 's/%2F/\//g' | sed -e 's/viewer/system\/sdcard\/DCIM/')
echo "Remove ${F_file}"
rm $F_file
;;
restore_config)
F_file=$(echo ${F_file} | sed -e 's/%2F/\//g' | sed -e 's/viewer/system\/sdcard\/DCIM/')
tar -xf $F_file -C /system/sdcard/config/
echo "Restore done"
/sbin/reboot
;;
save_config)
/system/sdcard/controlscripts/saveConfig.sh
;;
reboot)
echo "Rebooting device..."
/sbin/reboot
return
;;
shutdown)
echo "Shutting down device.."
/sbin/halt
return
;;
*)
echo "Unsupported command '$F_cmd'"
;;
esac
fi
exit 0

View File

@@ -0,0 +1,80 @@
#!/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 ""
if [ -n "$F_cmd" ]; then
case "$F_cmd" in
get_config)
echo "hostname#:#$(hostname)"
echo "model#:#$(detect_model)"
echo "fwDate#:#$(if [ -s "/system/sdcard/VERSION" ]; then /system/sdcard/bin/jq -r .date /system/sdcard/VERSION; else echo "Never updated. Make an update to get version."; fi)"
echo "fwBranch#:#$(if [ -s "/system/sdcard/VERSION" ]; then /system/sdcard/bin/jq -r .branch /system/sdcard/VERSION; else echo "Never updated. Make an update to get version."; fi)"
echo "fwCommit#:#$(if [ -s "/system/sdcard/VERSION" ]; then echo $(check_commit); else echo "Never updated. Make an update to get version."; fi)"
echo "kernel#:#$(/system/sdcard/bin/busybox uname -v)"
echo "bootLoader#:#$(busybox strings /dev/mtd0 | grep "U-Boot 2")"
echo "localTime#:#$(date)"
echo "uptime#:#$(uptime | sed 's/^.*up *//;s/, *[0-9]* user.*$/m/; s/ day[^0-9]*/d, /;s/ \([hms]\).*m$/\1/;s/:/h, /')"
echo "loadAvg#:#$(uptime | awk -F': ' '{print $2}')"
echo "ssid#:#$(/system/bin/iwgetid -r)"
echo "linkQuality#:#$(cat /proc/net/wireless | awk 'END { print $3 }' | sed 's/\.$//')"
echo "ip#:#$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d:)"
echo "mac#:#$(cat /sys/class/net/wlan0/address)"
echo "netmask#:#$(ifconfig wlan0 | sed -rn '2s/ .*:(.*)$/\1/p')"
echo "gateway#:#$(route | awk '/default/ { print $2}')"
echo "dns#:#$(cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2)"
echo "bootMD5#:#$(md5sum /dev/mtd0 |cut -f 1 -d " ")"
echo "bootVersion#:#$(busybox strings /dev/mtd0 | grep "U-Boot 2")"
echo "bootCMD#:#$(cat /proc/cmdline)"
return
;;
get_info)
case "$F_info" in
netInt)
ifconfig
iwconfig
;;
netRoutes)
route
;;
netDNS)
cat /etc/resolv.conf
;;
dmesg)
dmesg
;;
logVideo)
cat /tmp/v4l2rtspserver-master.log
;;
logCat)
/system/bin/logcat -d
;;
logUpdate)
cat /system/sdcard/log/update.log
;;
logProcess)
ps
;;
logMounts)
mount
;;
esac
return
;;
*)
echo "Unsupported command '$F_cmd'"
;;
esac
fi
exit 0

View File

@@ -0,0 +1,114 @@
#!/bin/sh
# CGI file for live view
. /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"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
if [ -n "$F_cmd" ]; then
case "$F_cmd" in
status_all)
echo "auto_night_mode:$(auto_night_mode status)"
echo "ir_led:$(ir_led status)"
echo "ir_cut:$(ir_cut status)"
echo "blue_led:$(blue_led status)"
echo "yellow_led:$(yellow_led status)"
echo "motion_detection:$(motion_detection status)"
echo "motion_mail:$(motion_send_mail status)"
echo "motion_telegram:$(motion_send_telegram status)"
echo "motion_led:$(motion_led status)"
echo "motion_snapshot:$(motion_snapshot status)"
echo "motion_mqtt:$(motion_mqtt_publish status)"
echo "motion_mqtt_snapshot:$(motion_snapshot status)"
echo "motion_mqtt_video:$(motion_mqtt_video status)"
;;
show_HWmodel)
detect_model
return
;;
hostname)
echo $(hostname);
;;
motor)
if [ -z "$F_val" ]; then
F_val=100
fi
motor $F_move $F_val
;;
version)
if [ -s "/system/sdcard/VERSION" ]; then
V_BRANCH=$(/system/sdcard/bin/jq -r .branch /system/sdcard/VERSION)
V_COMMIT=$(/system/sdcard/bin/jq -r .commit /system/sdcard/VERSION)
echo "commit <b>${V_COMMIT}</b> from the <b>${V_BRANCH}</b> branch"
else
echo "Need to update to create a version file."
fi
;;
auto_night_mode)
auto_night_mode $F_action
;;
ir_led)
ir_led $F_action
;;
ir_cut)
ir_cut $F_action
;;
blue_led)
blue_led $F_action
;;
yellow_led)
yellow_led $F_action
;;
motion_detection)
motion_detection $F_action
;;
motion_mail)
motion_send_mail $F_action
;;
motion_telegram)
motion_send_telegram $F_action
;;
motion_led)
motion_led $F_action
;;
motion_snapshot)
motion_snapshot $F_action
;;
motion_mqtt)
motion_mqtt_publish $F_action
;;
motion_mqtt_snapshot)
motion_mqtt_snapshot $F_action
;;
motion_mqtt_video)
motion_mqtt_video $F_action
;;
recording)
recording $F_action
;;
flip)
if [ $(/system/sdcard/bin/setconf -g f) == "0" ]; then
/system/sdcard/bin/setconf -k f -v 1
else
/system/sdcard/bin/setconf -k f -v 0
fi
;;
*)
echo "Unsupported command '$F_cmd'"
;;
esac
fi
exit 0

View File

@@ -0,0 +1,247 @@
#!/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"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
if [ -n "$F_cmd" ]; then
case "$F_cmd" in
get_config)
if [ ! -f "/system/sdcard/config/motion.conf" ]; then
$(cp /system/sdcard/config/motion.conf.dist /system/sdcard/config/motion.conf)
fi
source /system/sdcard/config/motion.conf
echo "currentRegions#:#${region_of_interest}"
echo "motionSensitivity#:#${motion_sensitivity}"
echo "motionIndicatorColor#:#${motion_indicator_color}"
echo "motionDetection#:#${motion_detection}"
echo "motionTimeout#:#${motion_timeout}"
echo "motionTracking#:#${motion_tracking}"
echo "saveSnapshot#:#${save_snapshot}"
echo "maxSnaphotDays#:#${max_snapshot_days}"
echo "maxVideoDays#:#${max_video_days}"
echo "ftpSnapshot#:#${ftp_snapshot}"
echo "ftpVideo#:#${ftp_video}"
echo "ftpHost#:#${ftp_host}"
echo "ftpPort#:#${ftp_port}"
echo "ftpUsername#:#${ftp_username}"
echo "ftpPassword#:#${ftp_password}"
echo "ftpStillsDir#:#${ftp_stills_dir}"
echo "ftpVideosDir#:#${ftp_videos_dir}"
echo "smbSnapshot#:#${smb_snapshot}"
echo "smbVideo#:#${smb_video}"
echo "smbShare#:#${smb_share}"
echo "smbUsername#:#${smb_username}"
echo "smbPassword#:#${smb_password}"
echo "smbStillsDir#:#${smb_stills_path}"
echo "smbVideosDir#:#${smb_videos_path}"
echo "motionTriggerLed#:#${motion_trigger_led}"
echo "mqttMessage#:#${publish_mqtt_message}"
echo "mqttSnapshot#:#${publish_mqtt_snapshot}"
echo "mqttVideo#:#${publish_mqtt_video}"
echo "sendEmail#:#${send_email}"
echo "sendTelegram#:#${send_telegram}"
echo "telegramAlertType#:#${telegram_alert_type}"
echo "sendMatrix#:#${send_matrix}"
;;
save_config)
if [ -n "${F_motionDetection+x}" ]; then
F_motionDetection=$(printf '%b' "${F_motionDetection//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf motion_detection $F_motionDetection
echo "Motion detection set to $F_motionDetection<br/>"
fi
if [ -n "${F_motionSensitivity+x}" ]; then
F_motionSensitivity=$(printf '%b' "${F_motionSensitivity//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf motion_sensitivity $F_motionSensitivity
echo "Motion sensitivity set to $F_motionSensitivity<br/>"
fi
if [ -n "${F_motionIndicatorColor+x}" ]; then
F_motionIndicatorColor=$(printf '%b' "${F_motionIndicatorColor//%/\\x}")
color='white black red green blue cyan yellow purple'
rewrite_config /system/sdcard/config/motion.conf motion_indicator_color $F_motionIndicatorColor
if [ "$F_motionIndicatorColor" == "-1" ]; then
echo "Motion color indicator is deactivated<br/>"
else
echo -n "Motion color indicator set to "
echo -n $(echo $color | cut -d ' ' -f $(($F_motionIndicatorColor + 1)))
echo "<br />"
fi
fi
if [ -n "${F_motionTracking+x}" ]; then
F_motionTracking=$(printf '%b' "${F_motionTracking//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf motion_tracking $F_motionTracking
echo "Motion tracking set to $F_motionTracking<br/>"
fi
if [ -n "${F_motionTimeout+x}" ]; then
F_motionTimeout=$(printf '%b' "${F_motionTimeout//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf motion_timeout $F_motionTimeout
echo "Motion timeout set to $F_motionTimeout<br/>"
fi
if [ -n "${F_saveSnaphot+x}" ]; then
F_saveSnaphot=$(printf '%b' "${F_saveSnaphot//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf save_snapshot $F_saveSnaphot
echo "Save snapshot set to $F_saveSnaphot<br/>"
fi
if [ -n "${F_maxSnaphotDays+x}" ]; then
F_maxSnaphotDays=$(printf '%b' "${F_maxSnaphotDays//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf max_snapshot_days $F_maxSnaphotDays
echo "Maximun snapshot retention in days set to $F_maxSnaphotDays<br/>"
fi
if [ -n "${F_saveVideo+x}" ]; then
F_saveVideo=$(printf '%b' "${F_saveVideo//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf save_video $F_saveVideo
echo "Save video set to $F_saveVideo<br/>"
fi
if [ -n "${F_maxVideoDays+x}" ]; then
F_maxVideoDays=$(printf '%b' "${F_maxVideoDays//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf max_video_days $F_maxVideoDays
echo "Maximun video retention in days set to $F_maxVideoDays<br/>"
fi
if [ -n "${F_smbSnapshot+x}" ]; then
F_smbSnapshot=$(printf '%b' "${F_smbSnapshot//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf smb_snapshot $F_smbSnapshot
echo "Save snapshot to samba share set to $F_smbSnapshot<br/>"
fi
if [ -n "${F_smbVideo+x}" ]; then
F_smbVideo=$(printf '%b' "${F_smbVideo//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf smb_video $F_smbVideo
echo "Save video to samba share set to $F_smbVideo<br/>"
fi
if [ -n "${F_smbShare+x}" ]; then
F_smbShare=$(printf '%b' "${F_smbShare//%/\\x}" | sed 's/\//\\\//g')
rewrite_config /system/sdcard/config/motion.conf smb_share "\"$F_smbShare\""
echo "Samba share set to $F_smbShare<br/>"
fi
if [ -n "${F_smbUsername+x}" ]; then
F_smbUsername=$(printf '%b' "${F_smbUsername//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf smb_username "\"$F_smbUsername\""
echo "Samba username set to $F_smbUsername<br/>"
fi
if [ -n "${F_smbPassword+x}" ]; then
F_smbPassword=$(printf '%b' "${F_smbPassword//%/\\x}" | sed 's/\//\\\//g')
rewrite_config /system/sdcard/config/motion.conf smb_password "\"$F_smbPassword\""
echo "Samba passward set<br/>"
fi
if [ -n "${F_smbStillsDir+x}" ]; then
F_smbStillsDir=$(printf '%b' "${F_smbStillsDir//%/\\x}" | sed 's/\//\\\//g')
rewrite_config /system/sdcard/config/motion.conf smb_stills_path "\"$F_smbStillsDir\""
echo "Samba snapshot destination directory set to $F_smbStillsDir<br/>"
fi
if [ -n "${F_smbVideosDir+x}" ]; then
F_smbVideosDir=$(printf '%b' "${F_smbVideosDir//%/\\x}" | sed 's/\//\\\//g')
rewrite_config /system/sdcard/config/motion.conf smb_videos_path "\"$F_smbVideosDir\""
echo "Samba video destination directory set to $F_smbVideosDir<br/>"
fi
if [ -n "${F_ftpSnapshot+x}" ]; then
F_ftpSnapshot=$(printf '%b' "${F_ftpSnapshot//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf ftp_snapshot $F_ftpSnapshot
echo "Save snapshot to FTP set to set to $F_ftpSnapshot<br/>"
fi
if [ -n "${F_ftpVideo+x}" ]; then
F_ftpVideo=$(printf '%b' "${F_ftpVideo//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf ftp_video $F_ftpVideo
echo "Save video to FTP set to $F_ftpVideo<br/>"
fi
if [ -n "${F_ftpHost+x}" ]; then
F_ftpHost=$(printf '%b' "${F_ftpHost//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf ftp_host "\"$F_ftpHost\""
echo "FTP Host set to $F_ftpHost<br/>"
fi
if [ -n "${F_ftpPort+x}" ]; then
F_ftpPort=$(printf '%b' "${F_ftpPort//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf ftp_port $F_ftpPort
echo "FTP Port set to $F_ftpPort<br/>"
fi
if [ -n "${F_ftpUsername+x}" ]; then
F_ftpUsername=$(printf '%b' "${F_ftpUsername//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf ftp_username "\"$F_ftpUsername\""
echo "FTP username set to $F_ftpUsername<br/>"
fi
if [ -n "${F_ftpPassword+x}" ]; then
F_ftpPassword=$(printf '%b' "${F_ftpPassword//%/\\x}" | sed 's/\//\\\//g')
rewrite_config /system/sdcard/config/motion.conf ftp_password "\"$F_ftpPassword\""
echo "FTP password set<br/>"
fi
if [ -n "${F_ftpStillsDir+x}" ]; then
F_ftpStillsDir=$(printf '%b' "${F_ftpStillsDir//%/\\x}" | sed 's/\//\\\//g')
rewrite_config /system/sdcard/config/motion.conf ftp_stills_dir "\"$F_ftpStillsDir\""
echo "FTP snapshots directory set to $F_ftpStillsDir<br/>"
fi
if [ -n "${F_ftpVideosDir+x}" ]; then
F_ftpVideosDir=$(printf '%b' "${F_ftpVideosDir//%/\\x}" | sed 's/\//\\\//g')
rewrite_config /system/sdcard/config/motion.conf ftp_videos_dir "\"$F_ftpVideosDir\""
echo "FTP videos directory set to $F_ftpVideosDir<br/>"
fi
if [ -n "${F_motionTriggerLed+x}" ]; then
F_motionTriggerLed=$(printf '%b' "${F_motionTriggerLed//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf motion_trigger_led $F_motionTriggerLed
echo "Motion trigger led set to $F_motionTriggerLed<br/>"
fi
if [ -n "${F_mqttMessage+x}" ]; then
F_mqttMessage=$(printf '%b' "${F_mqttMessage//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf publish_mqtt_message $F_mqttMessage
echo "MQTT publish message on motion set to $F_mqttMessage<br/>"
fi
if [ -n "${F_mqttSnapshot+x}" ]; then
F_mqttSnapshot=$(printf '%b' "${F_mqttSnapshot//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf publish_mqtt_snapshot $F_mqttSnapshot
echo "MQTT publish image on motion set to $F_mqttSnapshot<br/>"
fi
if [ -n "${F_mqttVideo+x}" ]; then
F_mqttVideo=$(printf '%b' "${F_mqttVideo//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf publish_mqtt_video $F_mqttVideo
echo "MQTT publish video on motion set to $F_mqttVideo<br/>"
fi
if [ -n "${F_sendEmail+x}" ]; then
F_sendEmail=$(printf '%b' "${F_sendEmail//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf send_email $F_sendEmail
echo "Send mail on motion set to $F_sendEmail<br/>"
fi
if [ -n "${F_sendTelegram+x}" ]; then
F_sendTelegram=$(printf '%b' "${F_sendTelegram//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf send_telegram $F_sendTelegram
echo "Send Telegram on motion set to $F_sendTelegram<br/>"
fi
if [ -n "${F_telegramAlertType+x}" ]; then
F_telegramAlertType=$(printf '%b' "${F_telegramAlertType//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf telegram_alert_type $F_telegramAlertType
echo "Telegram alert type set to $F_telegramAlertType<br/>"
fi
if [ -n "${F_sendMatrix+x}" ]; then
F_sendMatrix=$(printf '%b' "${F_sendMatrix//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf send_matrix $F_sendMatrix
echo "Send Matrix on motion set to $F_sendMatrix<br/>"
fi
if [ -n "${F_regions+x}" ]; then
F_regions=$(printf '%b' "${F_regions//%/\\x}")
rewrite_config /system/sdcard/config/motion.conf region_of_interest $F_regions
echo "Regions set to $F_regions<br/>"
fi
if [ "$(rtsp_h264_server status)" = "ON" ]; then
echo "Restart H264 rtsp server"
rtsp_h264_server off
rtsp_h264_server on
fi
if [ "$(rtsp_mjpeg_server status)" = "ON" ]; then
echo "Restart MJPEG rtsp server"
rtsp_mjpeg_server off
rtsp_mjpeg_server on
fi
;;
*)
echo "Unsupported command '$F_cmd'"
;;
esac
fi
exit 0

View File

@@ -0,0 +1,219 @@
#!/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 ""
if [ -n "$F_cmd" ]; then
case "$F_cmd" in
get_config_mqtt)
if [ ! -f "/system/sdcard/config/mqtt.conf" ]; then
$(cp /system/sdcard/config/mqtt.conf.dist /system/sdcard/config/mqtt.conf)
fi
source /system/sdcard/config/mqtt.conf
echo "mqttUser#:#${USER}"
echo "mqttPass#:#${PASS}"
echo "mqttHost#:#${HOST}"
echo "mqttPort#:#${PORT}"
echo "mqttLocation#:#${LOCATION}"
echo "mqttDeviceName#:#${DEVICE_NAME}"
echo "mqttAutodiscoveryPrefix#:#${AUTODISCOVERY_PREFIX}"
echo "mqttStatusInterval#:#${STATUSINTERVAL}"
;;
get_config_mail)
if [ ! -f "/system/sdcard/config/sendmail.conf" ]; then
$(cp /system/sdcard/config/sendmail.conf.dist /system/sdcard/config/sendmail.conf)
fi
source /system/sdcard/config/sendmail.conf
echo "from#:#${FROM}"
echo "fromName#:#${FROMNAME}"
echo "auth#:#${AUTH}"
echo "pass#:#${PASS}"
echo "to#:#${TO}"
echo "server#:#${SERVER}"
echo "port#:#${PORT}"
echo "subject#:#${SUBJECT}"
echo "body#:#${BODY}"
echo "numberOfPictures#:#${NUMBEROFPICTURES}"
echo "timeBetweenSnapshot#:#${TIMEBETWEENSNAPSHOT}"
echo "quality#:#${QUALITY}"
;;
get_config_telegram)
if [ ! -f "/system/sdcard/config/telegram.conf" ]; then
$(cp /system/sdcard/config/telegram.conf.dist /system/sdcard/config/telegram.conf)
fi
source /system/sdcard/config/telegram.conf
echo "apiToken#:#${apiToken}"
echo "userChatID#:#${userChatId}"
;;
get_config_matrix)
if [ ! -f "/system/sdcard/config/matrix.conf" ]; then
$(cp /system/sdcard/config/matrix.conf.dist /system/sdcard/config/matrix.conf)
fi
source /system/sdcard/config/matrix.conf
echo "host#:#${host}"
echo "portM#:#${port}"
echo "roomID#:#${room_id}"
echo "sender#:#${sender}"
echo "accessToken#:#${access_token}"
;;
save_config_mqtt)
echo "Save mqtt"
if [ -n "${F_mqttUser+x}" ]; then
F_mqttUser=$(printf '%b' "${F_mqttUser//%/\\x}")
rewrite_config /system/sdcard/config/mqtt.conf USER $F_mqttUser
echo "MQTT user set to $F_mqttUser<br/>"
fi
if [ -n "${F_mqttPass+x}" ]; then
F_mqttPass=$(printf '%b' "${F_mqttPass//%/\\x}")
rewrite_config /system/sdcard/config/mqtt.conf PASS $F_mqttPass
echo "MQTT password set<br/>"
fi
if [ -n "${F_mqttHost+x}" ]; then
F_mqttHost=$(printf '%b' "${F_mqttHost//%/\\x}")
rewrite_config /system/sdcard/config/mqtt.conf HOST $F_mqttHost
echo "MQTT host set to $F_mqttHost<br/>"
fi
if [ -n "${F_mqttPort+x}" ]; then
F_mqttPort=$(printf '%b' "${F_mqttPort//%/\\x}")
rewrite_config /system/sdcard/config/mqtt.conf PORT $F_mqttPort
echo "MQTT port set to $F_mqttPort<br/>"
fi
if [ -n "${F_mqttLocation+x}" ]; then
F_mqttLocation=$(printf '%b' "${F_mqttLocation//%/\\x}")
rewrite_config /system/sdcard/config/mqtt.conf LOCATION "\"$F_mqttLocation\""
echo "MQTT location set to $F_mqttLocation<br/>"
fi
if [ -n "${F_mqttDeviceName+x}" ]; then
F_mqttDeviceName=$(printf '%b' "${F_mqttDeviceName//%/\\x}")
rewrite_config /system/sdcard/config/mqtt.conf DEVICE_NAME "\"$F_mqttDeviceName\""
echo "MQTT device name set to $F_mqttDeviceName<br/>"
fi
if [ -n "${F_mqttAutodiscoveryPrefix+x}" ]; then
F_mqttAutodiscoveryPrefix=$(printf '%b' "${F_mqttAutodiscoveryPrefix//%/\\x}")
rewrite_config /system/sdcard/config/mqtt.conf AUTODISCOVERY_PREFIX "\"$F_mqttAutodiscoveryPrefix\""
echo "MQTT autodiscovery topic set to $F_mqttAutodiscoveryPrefix<br/>"
fi
if [ -n "${F_mqttStatusInterval+x}" ]; then
F_mqttStatusInterval=$(printf '%b' "${F_mqttStatusInterval//%/\\x}")
rewrite_config /system/sdcard/config/mqtt.conf STATUSINTERVAL $F_mqttStatusInterval
echo "MQTT status interval set to $F_mqttStatusInterval<br/>"
fi
;;
save_config_mail)
if [ -n "${F_from+x}" ]; then
F_from=$(printf '%b' "${F_from//%/\\x}")
rewrite_config /system/sdcard/config/sendmail.conf FROM "\"$F_from\""
echo "Sendmail from address set to $F_from<br/>"
fi
if [ -n "${F_fromName+x}" ]; then
F_fromName=$(printf '%b' "${F_fromName//%/\\x}")
rewrite_config /system/sdcard/config/sendmail.conf FROMNAME "\"$F_fromName\""
echo "Sendmail from name set to $F_fromName<br/>"
fi
if [ -n "${F_auth+x}" ]; then
F_auth=$(printf '%b' "${F_auth//%/\\x}")
rewrite_config /system/sdcard/config/sendmail.conf AUTH "\"$F_auth\""
echo "Sendmail auth user set to $F_auth<br/>"
fi
if [ -n "${F_pass+x}" ]; then
F_pass=$(printf '%b' "${F_pass//%/\\x}")
rewrite_config /system/sdcard/config/sendmail.conf PASS "\"$F_pass\""
echo "Sendmail set password<br/>"
fi
if [ -n "${F_to+x}" ]; then
F_to=$(printf '%b' "${F_to//%/\\x}")
rewrite_config /system/sdcard/config/sendmail.conf TO "\"$F_to\""
echo "Sendmail destination address set to $F_to<br/>"
fi
if [ -n "${F_server+x}" ]; then
F_server=$(printf '%b' "${F_server//%/\\x}")
rewrite_config /system/sdcard/config/sendmail.conf SERVER $F_server
echo "Sendmail server hostname set to $F_server<br/>"
fi
if [ -n "${F_port+x}" ]; then
F_port=$(printf '%b' "${F_port//%/\\x}")
rewrite_config /system/sdcard/config/sendmail.conf PORT $F_port
echo "Sendmail server port set to $F_port<br/>"
fi
if [ -n "${F_subject+x}" ]; then
F_subject=$(printf '%b' "${F_subject//%/\\x}")
rewrite_config /system/sdcard/config/sendmail.conf SUBJECT "\"$F_subject\""
echo "Sendmail subject set to $F_subject<br/>"
fi
if [ -n "${F_body+x}" ]; then
F_body=$(printf '%b' "${F_body//%/\\x}")
rewrite_config /system/sdcard/config/sendmail.conf BODY "\"$F_body\""
echo "Sendmail body set to $F_body<br/>"
fi
if [ -n "${F_numberOfPictures+x}" ]; then
F_numberOfPictures=$(printf '%b' "${F_numberOfPictures//%/\\x}")
rewrite_config /system/sdcard/config/sendmail.conf NUMBEROFPICTURES $F_numberOfPictures
echo "Sendmail number of pictures set to $F_numberOfPictures<br/>"
fi
if [ -n "${F_timeBetweenSnapshot+x}" ]; then
F_timeBetweenSnapshot=$(printf '%b' "${F_timeBetweenSnapshot//%/\\x}")
rewrite_config /system/sdcard/config/sendmail.conf TIMEBETWEENSNAPSHOT $F_timeBetweenSnapshot
echo "Sendmail time betweend snapshot set to $F_timeBetweenSnapshot<br/>"
fi
if [ -n "${F_quality+x}" ]; then
F_quality=$(printf '%b' "${F_quality//%/\\x}")
rewrite_config /system/sdcard/config/sendmail.conf QUALITY $F_quality
echo "Sendmail quality of pictures set to $F_quality<br/>"
fi
;;
save_config_telegram)
if [ -n "${F_apiToken+x}" ]; then
F_apiToken=$(printf '%b' "${F_apiToken//%/\\x}")
rewrite_config /system/sdcard/config/telegram.conf apiToken "\"$F_apiToken\""
echo "Telegram api token set to $F_apiToken<br/>"
fi
if [ -n "${F_userChatID+x}" ]; then
F_userChatID=$(printf '%b' "${F_userChatID//%/\\x}")
rewrite_config /system/sdcard/config/telegram.conf userChatId "\"$F_userChatID\""
echo "Matrix server host set to $F_userChatID<br/>"
fi
;;
save_config_matrix)
if [ -n "${F_host+x}" ]; then
F_host=$(printf '%b' "${F_host//%/\\x}")
rewrite_config /system/sdcard/config/matrix.conf host $F_host
echo "Matrix server host set to $F_host<br/>"
fi
if [ -n "${F_portM+x}" ]; then
F_portM=$(printf '%b' "${F_portM//%/\\x}")
rewrite_config /system/sdcard/config/matrix.conf port $F_portM
echo "Matrix server port set to $F_portM<br/>"
fi
if [ -n "${F_roomID+x}" ]; then
F_roomID=$(printf '%b' "${F_roomID//%/\\x}")
rewrite_config /system/sdcard/config/matrix.conf room_id $F_roomID
echo "Matrix room ID set to $F_roomID<br/>"
fi
if [ -n "${F_sender+x}" ]; then
F_sender=$(printf '%b' "${F_sender//%/\\x}")
rewrite_config /system/sdcard/config/matrix.conf sender $F_sender
echo "Matrix server sender set to $F_sender<br/>"
fi
if [ -n "${F_accessToken+x}" ]; then
F_accessToken=$(printf '%b' "${F_accessToken//%/\\x}")
rewrite_config /system/sdcard/config/matrix.conf access_token $F_accessToken
echo "Matrix server access token set<br/>"
fi
;;
*)
echo "Unsupported command '$F_cmd'"
;;
esac
fi
exit 0

View File

@@ -0,0 +1,57 @@
#!/bin/sh
source ./func.cgi
source /system/sdcard/scripts/common_functions.sh
echo "Content-type: text"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
if [ -n "$F_cmd" ]; then
case "$F_cmd" in
events)
echo "["
find /system/sdcard/DCIM/${F_dir}/ -type f | xargs ls --full-time \
| awk '{sub(/\/system\/sdcard\/DCIM/, "viewer"); printf "{\"file\" : \"%s\", \"date\" : \"%s %s\"},", $9, $6, $7}' \
| head -c -1
echo "]"
;;
check_sdcard)
mount|grep "/system/sdcard"|grep "rw,">/dev/null
if [ $? == 1 ]; then
echo -n "nok"
else
echo -n "ok"
fi
;;
getFiles)
ip_addr=$(ip -o -4 addr show | sed 's/.* inet \([^/]*\).*/\1/' | grep -v "127.0.0.1")
for file in $(find /system/sdcard/DCIM/${F_dir}/ -type f)
do
if [[ -f $file ]]; then
file_size=$(ls -lh $file | awk '{print $5}')
file_url=$(ls -lh $file | awk '{print $9}' | sed 's/\/system\/sdcard\/DCIM/\/viewer/')
file_date=$(ls -lh $file | awk '{print $6 "-" $7 "-" $8}')
file_name=$(ls -lh $file | awk '{print $9}' | awk -F / '{print $(NF)}')
echo "${file_name}#:#${file_size}#:#${file_date}#:#${file_url}"
fi
done
return
;;
sdcardInfo)
echo "sdcardSize#:#$(df -h /system/sdcard | awk 'NR==2{print$4}')"
echo "sdcardUsed#:#$(df -h /system/sdcard | awk 'NR==2{print$3}')"
echo "sdcardUsedPercent#:#$(df -h /system/sdcard | awk 'NR==2{print$5}')"
;;
del_file)
F_file=$(echo ${F_file} | sed -e 's/%2F/\//g' | sed -e 's/viewer/system\/sdcard\/DCIM/')
echo "Remove ${F_file}"
rm $F_file
;;
*)
echo "Unsupported command '$F_cmd'"
;;
esac
fi

View File

@@ -0,0 +1,67 @@
#!/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 ""
if [ -n "$F_cmd" ]; then
case "$F_cmd" in
get_config)
echo "hostname#:#$(hostname)"
echo "theme#:#"
echo "ntp#:#$(cat /system/sdcard/config/ntp_srv.conf)"
echo "timezone#:#$(/system/sdcard/bin/busybox awk -F '\t' -v tzn="$(cat /system/sdcard/config/timezone.conf)" '{print "<option value=\""$1"\""; if ($1==tzn) print "selected"; print ">" $1 "</option>"}' /system/sdcard/www/json/timezones.tsv | tr -d '\n')"
echo "currenttime#:#Current time is $(date) - $(cat /etc/TZ)"
;;
save_config)
if [ -n ${F_hostname} ]; then
hst=$(printf '%b' "${F_hostname//%/\\x}")
if [ "$(cat /system/sdcard/config/hostname.conf)" != "$hst" ]; then
echo -n "<p>Setting hostname to '$hst' "
echo "$hst" > /system/sdcard/config/hostname.conf
if hostname "$hst"; then
echo "Success</p>"
else
echo "Failed</p>"
fi
fi
fi
if [ -n ${F_password} ]; then
password=$(printf '%b' "${F_password//%/\\x}")
echo "<p>Setting http password to : $password</p>"
http_password "$password"
fi
if [ -n ${F_timezone} ]; then
timezone_name=$(printf '%b' "${F_timezone//%/\\x}")
if [ "$(cat /system/sdcard/config/timezone.conf)" != "$timezone_name" ]; then
echo "<p>Setting time zone to '$timezone_name'</p>"
echo "$timezone_name" > /system/sdcard/config/timezone.conf
# Set system timezone from timezone name
set_timezone
fi
fi
if [ -n ${F_ntp} ]; then
ntp=$(printf '%b' "${F_ntp//%/\\x}")
if [ $ntp != $(cat /system/sdcard/config/ntp_srv.conf) ]; then
echo "<p>Setting NTP Server to ${ntp} "
echo "$ntp" > /system/sdcard/config/ntp_srv.conf
fi
fi
return
;;
*)
echo "Unsupported command '$F_cmd'"
;;
esac
fi
exit 0

View File

@@ -1,13 +0,0 @@
#!/bin/sh
echo "Content-type: text/html"
echo "Pragma: no-cache"
echo "Cache-Control: max-age=0, no-store, no-cache"
echo ""
cat << EOF
Update:
<pre>`/system/sdcard/autoupdate.sh -v -f -d /system/sdcard/ 2>&1`</pre>
</body>
</html>
EOF

View File

@@ -1,287 +0,0 @@
<!-- Use http://odyniec.net/projects/imgareaselect/ -->
<h1 class="is-size-4">Configure Motion Settings</h1>
<p>
Select motion detection region. Changing the region will restart the rtsp server.
</p>
<div id="motion_img_container" style="margin: 1em 0; position:relative;">
<img id="motion_picture" src="cgi-bin/currentpic.cgi" />
<span id="region_disabled" class="has-text-danger is-size-1" style="display: none; position: absolute; top: 10%; left: 30%; padding: 0.25em 0.5em; background-color: rgba(20, 20, 20, 0.5); border-radius: 0.25em;">
Region disabled
</span>
</div>
<div class="column is-two-thirds">
<form id="confMotionForm" action="cgi-bin/action.cgi?cmd=set_region_of_interest" method="post">
<input id="x0" name="x0" type="hidden" />
<input id="y0" name="y0" type="hidden" />
<input id="x1" name="x1" type="hidden" />
<input id="y1" name="y1" type="hidden" />
<input id="restart_server" name="restart_server" type="hidden" />
<div class="field">
<label class="label">Region Boundaries</label>
<div class="control">
<span id="region_xy"></span>
</div>
</div>
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" name="motion_detection" id="motion_detection"> Enable motion detection
</label>
</div>
</div>
<div class="field">
<label class="label">Set sensitivity</label>
<div class="control">
<div class="select">
<select name="motion_sensitivity" id="motion_sensitivity">
<option value="0">Very Low</option>
<option value="1">Low</option>
<option value="2">Moderate</option>
<option value="3">High</option>
<option value="4">Very High</option>
</select>
</div>
</div>
</div>
<div class="field">
<label class="label">Display motion indicator if motion is detected</label>
<div class="control">
<div class="select">
<select name="motion_indicator_color" id="motion_indicator_color">
<option value="-1">Deactivated</option>
<option value="0">White</option>
<option value="1">Black</option>
<option value="2">Red</option>
<option value="3">Green</option>
<option value="4">Blue</option>
<option value="5">Cyan</option>
<option value="6">Yellow</option>
<option value="7">Purple</option>
</select>
</div>
</div>
</div>
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" name="motion_tracking" id="motion_tracking" onchange="setTracking(this, false)"> Enable motion tracking (Custom set motion detection region will be ignored)
</label>
</div>
</div>
<div class="field">
<label class="label">Motion Timeout</label>
<div class="control">
<input class="input" id="motion_timeout" name="motion_timeout" type="number" size="6">
</div>
<p class="help">Restore camera position after x seconds, -1 to deactivate</p>
</div>
<div class="field">
<div class="control">
<input id="configMotionSubmit" class="button is-primary" type="submit" value="Configure motion" />
</div>
</div>
</form>
</div>
<script type="text/javascript">
var originalMotionInfo;
function preview(img, selection) {
if (!selection.width || !selection.height) {
return;
}
var image = $(img);
var naturalWidth = image.prop('naturalWidth');
var naturalHeight = image.prop('naturalHeight');
var renderedWidth = image.width();
var renderedHeight = image.height();
var x0 = Math.round((selection.x1 / renderedWidth) * naturalWidth);
var y0 = Math.round((selection.y1 / renderedHeight) * naturalHeight);
var x1 = Math.round((selection.x2 / renderedWidth) * naturalWidth);
var y1 = Math.round((selection.y2 / renderedHeight) * naturalHeight);
$('#x0').val(x0);
$('#y0').val(y0);
$('#x1').val(x1);
$('#y1').val(y1);
$('#region_xy').html('[ (' + x0 + ', ' + y0 + '), (' + x1 + ', ' + y1 + ') ]');
if (originalMotionInfo.region_of_interest[0] != x0 ||
originalMotionInfo.region_of_interest[1] != y0 ||
originalMotionInfo.region_of_interest[2] != x1 ||
originalMotionInfo.region_of_interest[3] != y1) {
// restart only if region has changed
$('#restart_server').val(1);
} else {
// user has set it back to original region
$('#restart_server').val(0);
}
}
function setTracking(obj, init) {
var picture = $('#motion_picture');
var region_disabled = $('#region_disabled');
var motion_timeout = $('#motion_timeout');
var ias = picture.imgAreaSelect({
instance: true
});
if ($(obj).prop("checked")) {
ias.setOptions({
hide: true
});
picture.css('opacity', 0.5);
region_disabled.show();
motion_timeout.prop('readonly', false);
motion_timeout.css('backgroundColor', '#fff');
} else {
ias.setOptions({
show: true
});
picture.css('opacity', 1);
region_disabled.hide();
// grey out and disable field
motion_timeout.prop('readonly', true);
motion_timeout.css('backgroundColor', '#ccc');
}
ias.update();
if (init == false) {
$('#restart_server').val(1);
}
}
$(document).ready(function () {
// get motion config info
$.ajax({
'url': 'cgi-bin/getMotionInfo.cgi',
'dataType': 'json'
}).done(function (motionInfo) {
originalMotionInfo = motionInfo;
var picture = $('#motion_picture');
var renderedWidth = picture.width();
var renderedHeight = picture.height();
var naturalWidth = picture.prop('naturalWidth');
var naturalHeight = picture.prop('naturalHeight');
picture.imgAreaSelect({
handles: true,
fadeSpeed: 200,
onSelectChange: preview,
movable: true,
persistent: true,
parent: '#motion_img_container'
});
var ias = picture.imgAreaSelect({
instance: true
});
var selection = [0, 0, 0, 0];
if (motionInfo.region_of_interest[0] + motionInfo.region_of_interest[1] +
motionInfo.region_of_interest[2] + motionInfo.region_of_interest[3] == 0 ||
(motionInfo.region_of_interest[0] > naturalWidth ||
motionInfo.region_of_interest[1] > naturalHeight ||
motionInfo.region_of_interest[2] > naturalWidth ||
motionInfo.region_of_interest[3] > naturalHeight)
) {
// if no region of interest set (0, 0, 0, 0)
// or if region of interest set is greater than the current image sizes
ias.setSelection(0, 0, naturalWidth, naturalHeight, true);
topLeft = [0, 0];
selection = [0, 0, naturalWidth, naturalHeight];
if (naturalWidth > renderedWidth) {
// scaled image
selection[2] = renderedWidth;
selection[3] = renderedHeight;
}
} else {
selection = motionInfo.region_of_interest;
if (naturalWidth > renderedWidth) {
// scaled image
selection = [
Math.round((motionInfo.region_of_interest[0] / naturalWidth) * renderedWidth),
Math.round((motionInfo.region_of_interest[1] / naturalHeight) * renderedHeight),
Math.round((motionInfo.region_of_interest[2] / naturalWidth) * renderedWidth),
Math.round((motionInfo.region_of_interest[3] / naturalHeight) * renderedHeight),
];
}
}
ias.setSelection(selection[0], selection[1], selection[2], selection[3], false);
$('#region_xy').html(
'[ (' + motionInfo.region_of_interest[0] + ', ' + motionInfo.region_of_interest[1] +
'), (' + motionInfo.region_of_interest[2] + ', ' + motionInfo.region_of_interest[3] + ') ]');
$('#x0').val(motionInfo.region_of_interest[0]);
$('#y0').val(motionInfo.region_of_interest[1]);
$('#x1').val(motionInfo.region_of_interest[2]);
$('#y1').val(motionInfo.region_of_interest[3]);
$('#restart_server').val(0);
$('#motion_indicator_color').val(motionInfo.motion_indicator_color).change();
$('#motion_sensitivity').val(motionInfo.motion_sensitivity).change();
$('#motion_detection').prop('checked', motionInfo.motion_detection);
$('#motion_tracking').prop('checked', motionInfo.motion_tracking);
$('#motion_timeout').val(motionInfo.motion_timeout).change();
setTracking($('#motion_tracking')[0], true);
});
$('#confMotionForm').submit(function (event) {
var b = $('#configMotionSubmit');
b.toggleClass('is-loading');
b.prop('disabled', !b.prop('disabled'));
var motion_tracking = '';
if ($('#motion_tracking').prop('checked')) {
motion_tracking = 'true';
}
var motion_detection = '';
if ($('#motion_detection').prop('checked')) {
motion_detection = 'true';
} else {
motion_detection = 'false';
}
var formData = {
'x0': $('input[name=x0]').val(),
'y0': $('input[name=y0]').val(),
'x1': $('input[name=x1]').val(),
'y1': $('input[name=y1]').val(),
'restart_server': $('input[name=restart_server]').val(),
'motion_sensitivity': $('select[name=motion_sensitivity]').val(),
'motion_indicator_color': $('select[name=motion_indicator_color]').val(),
'motion_tracking': motion_tracking,
'motion_detection': motion_detection,
'motion_timeout': $('input[name=motion_timeout]').val()
};
$.ajax({
type: 'POST',
url: $('#confMotionForm').attr('action'),
data: formData,
dataType: 'html',
encode: true
}).done(function (res) {
b.toggleClass('is-loading');
b.prop('disabled', !b.prop('disabled'));
showResult(res);
});
event.preventDefault();
});
});
</script>

View File

@@ -0,0 +1,75 @@
<!-- Control card -->
<div class="w3-panel w3-card">
<h1> Control System</h1>
<div class="w3-row">
<a href="javascript:void(0)" onclick="openTab(event, 'services');">
<div class="w3-quarter tablink w3-bottombar w3-hover-light-grey w3-padding w3-border-theme">Services</div>
</a>
<a href="javascript:void(0)" onclick="openTab(event, 'update');showupdatepage();">
<div class="w3-quarter tablink w3-bottombar w3-hover-light-grey w3-padding">Update</div>
</a>
<a href="javascript:void(0)" onclick="openTab(event, 'config');getFiles('config');">
<div class="w3-quarter tablink w3-bottombar w3-hover-light-grey w3-padding">Backup/Restore config</div>
</a>
<a href="javascript:void(0)" onclick="openTab(event, 'power');">
<div class="w3-quarter tablink w3-bottombar w3-hover-light-grey w3-padding">Power</div>
</a>
</div>
<!-- Services Tab-->
<div id="services" class="w3-container tab">
<p></p>
<table class="w3-table-all" id="tabServices">
<thead>
<tr class="w3-theme">
<th>Service Name</th>
<th>Control</th>
<th>Autostart</th>
</tr>
</thead>
<tbody></tbody>
</table>
<p></p>
</div>
<!-- Update Tab-->
<div id="update" class="w3-container tab" style="display:none">
<h2 id='updatemsg'>Seaching for updates ...</h2>
</div>
<!-- Backup/Restore Tab-->
<div id="config" class="w3-container tab" style="display:none">
<p id=><i class="fa fa-spinner w3-spin" style="font-size:64px"></i><br/>LOADING</p>
</div>
<!-- Power control Tab-->
<div id="power" class="w3-container tab" style="display:none">
<p></p>
<div class="w3-row-padding">
<div class="w3-half">
<button class="w3-btn w3-block w3-theme" type="text" onclick="system('reboot');">Reboot</button>
</div>
<div class="w3-half">
<button class="w3-btn w3-block w3-theme" type="text" onclick="system('shutdown');">Shutdown</button>
</div>
</div>
<p></p>
</div>
<!-- modal windows-->
<div id="modal_box" class="w3-modal">
<div class="w3-modal-content">
<header class="w3-container w3-theme">
<span onclick="document.getElementById('modal_box').style.display='none'"
class="w3-button w3-display-topright">&times;</span>
<h2 id="modal_title"></h2>
</header>
<div class="w3-container">
<p id="modal_content">Waiting ...</p>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/control.js"></script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

Some files were not shown because too many files have changed in this diff Show More