mirror of
https://github.com/gtxaspec/wz_mini_hacks.git
synced 2024-11-09 15:08:21 +00:00
Added auto bind feature for offline / cloud-less setup (#303)
* Added auto bind feature for offline / cloud-less setup Automatically sets bindOk=1 when WiFi settings are detected without needing the camera to interact with the Wyze cloud. This feature can be enabled when ENABLE_AUTO_BIND=true is set in wz_mini.conf * Added 'WiFi Connected' audio message when QR code is valid * Fixed the auto bind script improperly checking WiFi status /configs isn't mounted during the init phase from the SD card and as a result, the checks for whether bindOk=0 done by the init script was ineffective. The script now mounts it if necessary before checking. * Updated autobind feature to use ENABLE_SELFHOSTED_MODE option The feature to update the bindOk value will now use the same `ENABLE_SELFHOSTED_MODE` option as the self-hosted iCamera patch. This feature should only be used by advanced users in isolated networks or when the user does not intend to use the Wyze App or cloud services. * Updated ENABLE_SELFHOSTED_MODE to false by default The default should be to rely on Wyze servers. Ooops.
This commit is contained in:
parent
fe4c982796
commit
4d6c1d8651
67
SD_ROOT/wz_mini/etc/init.d/S20initsetup
Normal file
67
SD_ROOT/wz_mini/etc/init.d/S20initsetup
Normal file
@ -0,0 +1,67 @@
|
||||
#!/bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides:
|
||||
# Short-Description: Setup bindOk=1 once WiFi settings are detected when in self-hosted mode
|
||||
# Description: Update .user_config so bindOk=1 when QR code containing WiFi settings are scanned. Allows for WiFi to work on next reboot without needing Wyze App/Cloud initial setup.
|
||||
### END INIT INFO
|
||||
|
||||
. /opt/wz_mini/wz_mini.conf
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
|
||||
echo "#####$(basename "$0")#####"
|
||||
|
||||
# If not enabled or on T20 which is unsupported by this script
|
||||
if [[ "$ENABLE_SELFHOSTED_MODE" != "true" ]] || [ ! -f /opt/wz_mini/tmp/.T31 ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Note: At the time of this boot stage, /configs isn't mounted. If it's not mounted, we have to mount it to check the wifi status
|
||||
if mount | grep -q /configs ; then
|
||||
# Is it already set?
|
||||
if grep -q bindOk=1 /configs/.user_config ; then
|
||||
echo "Initial setup is done. Nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
mount -t jffs2 /dev/mtdblock6 /configs
|
||||
|
||||
# Is it already set?
|
||||
if grep -q bindOk=1 /configs/.user_config ; then
|
||||
echo "Initial setup is done. Nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
umount /configs
|
||||
fi
|
||||
|
||||
echo "Initial setup not completed yet."
|
||||
|
||||
# Wait until these wifi settings are set in /configs later on.
|
||||
# Note that /configs will be mounted eventually by the second stage boot.
|
||||
while true ; do
|
||||
if [ -f /configs/.wifipasswd ] && [ -s /configs/.wifipasswd ] && [ -f /configs/.wifissid ] && [ -s /configs/.wifissid ] ; then
|
||||
echo "Detected WiFi configs. "
|
||||
if wpa_cli -p /var/run/wpa_supplicant -i wlan0 STATUS | grep -q wpa_state=COMPLETED ; then
|
||||
echo "WiFi connection seems Good. Updating bindOk=1."
|
||||
sed -i 's/bindOk=0/bindOk=1/g' /configs/.user_config
|
||||
|
||||
/opt/wz_mini/bin/cmd aplay /usr/share/notify/CN/connect_wifi_ok.wav 60
|
||||
|
||||
grep bindOk /configs/.user_config
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Waiting for WiFi settings from QR code..."
|
||||
sleep 5
|
||||
done &
|
||||
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user