add Xiaomi MJSXJ02HL

This commit is contained in:
cronyx
2023-12-10 01:08:49 +03:00
parent d79140919f
commit 90a410ad48
13 changed files with 639 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
#!/bin/sh
#
# Automatic LED control for Xiaomi MJSXJ02HL
streamerProcess="majestic"
serviceProcess="sysupgrade"
pollingInterval=1
show_help() {
echo "Usage: $0 [-p process] [-s process] [-i value] [-h]
-p process Name of the monitored streamer process (default = ${streamerProcess}).
-s process Name of the monitored service process (default = ${serviceProcess}).
-i value Polling interval in seconds (default = ${pollingInterval}).
-h Show this help."
exit 0
}
# override config values with command line arguments
while getopts H:L:i:h flag; do
case ${flag} in
p) streamerProcess=${OPTARG} ;;
s) serviceProcess=${OPTARG} ;;
i) pollingInterval=${OPTARG} ;;
h | *) show_help ;;
esac
done
echo "...................."
echo "Name of the monitored streamer process: ${streamerProcess}"
echo "Name of the monitored service process: ${serviceProcess}"
echo "Polling interval: ${pollingInterval} sec"
echo "...................."
led_state=0
/usr/sbin/led_control.sh -o 0 -b 0
echo "...................."
while true; do
if killall -q -0 $serviceProcess; then
if [ $led_state -ne 3 ]; then
echo "Process $serviceProcess is running, turn on the white LED"
/usr/sbin/led_control.sh -o 1 -b 1
led_state=3
echo "...................."
fi
else
if [ $led_state -ne 1 ] && ! killall -q -0 $streamerProcess; then
echo "Process $streamerProcess is not running, turn on the orange LED"
/usr/sbin/led_control.sh -o 1 -b 0
led_state=1
echo "...................."
elif [ $led_state -ne 2 ] && killall -q -0 $streamerProcess; then
echo "Process $streamerProcess is running, turn on the blue LED"
/usr/sbin/led_control.sh -o 0 -b 1
led_state=2
echo "...................."
fi
fi
sleep $pollingInterval
done

View File

@@ -0,0 +1,56 @@
#!/bin/sh
#
# Majestic settinfs for Xiaomi MJSXJ02HL
#
# nightMode:
# enabled: true
# irCutPin1: 70
# irCutPin2: 68
# backlightPin: 54
again_high_target=14000
again_low_target=2000
pollingInterval=5
show_help() {
echo "Usage: $0 [-H value] [-L value] [-i value] [-h]
-H value Again high target (default = ${again_high_target}).
-L value Again low target (default = ${again_low_target}).
-i value Polling interval (default = ${pollingInterval}).
-h Show this help."
exit 0
}
while getopts H:L:i:h flag; do
case ${flag} in
H) again_high_target=${OPTARG} ;;
L) again_low_target=${OPTARG} ;;
i) pollingInterval=${OPTARG} ;;
h | *) show_help ;;
esac
done
echo "...................."
echo "Watching at isp_again > ${again_high_target} to enable night mode"
echo "Watching at isp_again < ${again_low_target} to disable night mode"
echo "Polling interval: ${pollingInterval} sec"
echo "...................."
login=$(cat /etc/httpd.conf | grep cgi-bin | cut -d':' -f2)
pass=$(cat /etc/httpd.conf | grep cgi-bin | cut -d':' -f3)
while true; do
metrics=$(curl -s http://localhost/metrics)
isp_again=$(echo "${metrics}" | awk '/^isp_again/ {print $2}' | grep . || echo 0)
night_enabled=$(echo "${metrics}" | awk '/^night_enabled/ {print $2}' | grep . || echo 0)
if [ $night_enabled -ne 1 ] && [ $isp_again -gt $again_high_target ]; then
curl -s -u $login:$pass http://localhost/night/on
echo "Condition isp_again > ${again_high_target} was met (current value is ${isp_again}), turn on the night mode"
elif [ $night_enabled -ne 0 ] && [ $isp_again -lt $again_low_target ]; then
curl -s -u $login:$pass http://localhost/night/off
echo "Condition isp_again < ${again_low_target} was met (current value is ${isp_again}), turn off the night mode"
fi
sleep $pollingInterval
done

View File

@@ -0,0 +1,34 @@
#!/bin/sh
#
# LED control for Xiaomi MJSXJ02HL
show_help() {
echo "Usage: $0 [-o <0|1>] [-b <0|1>]
-o <0|1> Switch state for orange LED.
-b <0|1> Switch state for blue LED."
exit 0
}
led_control() {
echo "Switching LED with GPIO${1} to state ${2}"
if [ ! -d /sys/class/gpio/gpio${1}/ ]; then
echo ${1} > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio${1}/direction
fi
echo ${2} > /sys/class/gpio/gpio${1}/value
}
if [ $# -eq 0 ]; then show_help; fi
while getopts o:b: flag; do
case ${flag} in
o)
[ ${OPTARG} -eq 0 -o ${OPTARG} -eq 1 ] || show_help
led_control 52 ${OPTARG}
;;
b)
[ ${OPTARG} -eq 0 -o ${OPTARG} -eq 1 ] || show_help
led_control 53 ${OPTARG}
;;
*) show_help ;;
esac
done

View File

@@ -0,0 +1,36 @@
#!/bin/sh
#
# Perform basic settings on a known IP camera
#
#
# Set custom upgrade url
#
fw_setenv upgrade 'https://github.com/OpenIPC/builder/releases/download/latest/hi3518ev300_lite_xiaomi-mjsxj02hl-nor.tgz'
#
#
# Set custom majestic settings
#
cli -s .system.webAdmin disabled
cli -s .system.staticDir /var/www/majestic
cli -s .isp.iqProfile /etc/sensors/iq/f23.ini
cli -s .nightMode.enabled true
cli -s .nightMode.irCutPin1 70
cli -s .nightMode.irCutPin2 68
cli -s .nightMode.backlightPin 54
cli -s .audio.speakerPin 55
cli -s .video0.codec h264
#
#
# Set wlan device and credentials if need
#
fw_setenv wlandev rtl8189fs-mjsxj02hl
#fw_setenv wlanssid Router
#fw_setenv wlanpass 12345678
#
#
# Set osmem and rmem
#
fw_setenv bootargs 'mem=\${osmem} console=ttyAMA0,115200 panic=20 rootfstype=squashfs root=/dev/mtdblock3 init=/init mtdparts=\${mtdparts} mmz_allocator=hisi'
fw_setenv osmem 35M
#
exit 0