Skip to content

Add multi-WiFi network support for slim version#470

Open
pawelma wants to merge 10 commits intoalienatedsec:masterfrom
pawelma:feature/multi-wifi
Open

Add multi-WiFi network support for slim version#470
pawelma wants to merge 10 commits intoalienatedsec:masterfrom
pawelma:feature/multi-wifi

Conversation

@pawelma
Copy link
Copy Markdown

@pawelma pawelma commented Apr 14, 2026

Allow the camera to connect to multiple pre-configured WiFi networks with automatic failover, useful for portable monitoring across locations.

New files:

  • etc/wpa_supplicant.conf: template config with multiple network blocks
  • script/wifi_connect.sh: replaces stock wpa_supplicant with multi-network config

Modified files:

  • system.sh: integrate multi-WiFi startup when WIFI_MULTI=yes
  • check_conf.sh: add WIFI_MULTI=no default parameter
  • system.conf: add WIFI_MULTI=no default
  • wd_rtsp.sh: add WiFi connectivity watchdog (check_wifi)
  • README.md: document the multi-WiFi feature and setup instructions

pawelma and others added 10 commits March 18, 2026 12:07
When DISABLE_CLOUD=yes, the cloud process still runs (required by rmm)
and repeatedly calls cloudAPI for time sync (cmd 136). Each call spawns
two shell processes: cloudAPI -> cloudAPI_fake, and the inner ntpd call
blocks indefinitely waiting for NTP response (no internet access).

This causes ~75 zombie/stuck processes in 17 minutes, leading to load
averages >6 on a single-core ARM device, memory exhaustion (656KB free
of 18.5MB), and eventual RTSP server crashes after 50-80 minutes.

Changes:
- cloudAPI: use 'exec' to replace shell process instead of spawning a
  child, halving the process count per invocation
- cloudAPI_fake: add 10-second timeout to ntpd sync call to prevent
  indefinite blocking when no internet is available
The watchdog unconditionally checks if mqttv4 is running and restarts
it every cycle. When MQTT=no in config, mqttv4 is never started and
doesn't exist, causing the watchdog to attempt restarts every ~2 seconds
in a tight loop. This wastes CPU cycles and floods the log with hundreds
of failed restart attempts per minute.

Gate the check_mqttv4 call on the MQTT configuration setting.
Increase net.core.rmem_max, wmem_max, rmem_default, and wmem_default
from 163840 (160KB) to 524288 (512KB). The small default buffers can
cause RTSP packet drops under load on this memory-constrained system.

This change was recommended by roleoroleo (yi-hack-MStar maintainer)
in roleoroleo/yi-hack-MStar#414
Check that h264grabber keeps the FIFO fd open, which validates the
data pipeline is intact.  rRTSPServer opens the FIFO lazily (only on
client connect), so we only verify the grabber side.

Uses 'ls -la /proc/PID/fd/ | grep FIFO_NAME' because busybox on this
device has no readlink applet.  Replaces the earlier nc-based RTSP
OPTIONS probe which always timed out on this busybox.
mqttv4 was launched unconditionally at startup regardless of the MQTT
config setting, wasting 3.3MB of RAM on devices that don't use MQTT.
Move the mqttv4 launch into the existing MQTT=yes conditional block.
Set default config to minimal RTSP-only mode: cloud disabled, HTTPD off,
MQTT off, swap enabled, SSH password set, snapshots off. Update README
with slim fork description, process table, and quick start guide.
Include nmap scan, router DHCP, and Yi Home app methods to find the
camera IP. Add stream URL table for high/low resolution endpoints.
Fix RTSP stream freeze and slim down for dedicated RTSP use
Allow the camera to connect to multiple pre-configured WiFi networks
with automatic failover, useful for portable monitoring across locations.

New files:
- etc/wpa_supplicant.conf: template config with multiple network blocks
- script/wifi_connect.sh: replaces stock wpa_supplicant with multi-network config

Modified files:
- system.sh: integrate multi-WiFi startup when WIFI_MULTI=yes
- check_conf.sh: add WIFI_MULTI=no default parameter
- system.conf: add WIFI_MULTI=no default
- wd_rtsp.sh: add WiFi connectivity watchdog (check_wifi)
- README.md: document the multi-WiFi feature and setup instructions
# Conflicts:
#	src/static/static/home/yi-hack-v5/script/wd_rtsp.sh

Co-authored-by: pawelma <1849200+pawelma@users.noreply.github.com>
@pawelma pawelma closed this May 4, 2026
@alienatedsec
Copy link
Copy Markdown
Owner

@pawelma sorry I have missed this. Have you had a chance to test it?

@alienatedsec alienatedsec reopened this May 4, 2026
@pawelma
Copy link
Copy Markdown
Author

pawelma commented May 4, 2026

I did, it's polluted with the changes from the fork of mine where I disabled default configs like webUI, I can clean it up to keep original defaults if you want to merge it. It does work with 3 different locations as a pet monitor without an issue.

@alienatedsec
Copy link
Copy Markdown
Owner

Please update the pull request by commiting to your branch and I'll test it at some point. Thanks for your contribution.

1 similar comment
@alienatedsec
Copy link
Copy Markdown
Owner

Please update the pull request by commiting to your branch and I'll test it at some point. Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants