Skip to content

Instantly share code, notes, and snippets.

@Jeshii
Created March 6, 2026 06:56
Show Gist options
  • Select an option

  • Save Jeshii/b3e053406177b09bbeef0c9afe0b2433 to your computer and use it in GitHub Desktop.

Select an option

Save Jeshii/b3e053406177b09bbeef0c9afe0b2433 to your computer and use it in GitHub Desktop.
Toggle Download Mode on Buffalo WSR-3200AX4S via WPS button

Buffalo WSR-3200AX4S running OpenWRT would crash when cloning large git repos. I found that SQM with layer_cake would fix this, but was unstable over the long term. So I tied a toggle script to the WPS button so I could switch between download mode and regular mode.

#!/bin/sh
# Save to /root/download_toggle.sh and make executable (chmod +x /root/download_toggle.sh)
# Check the currently active SQM script
CURRENT_SCRIPT=$(uci -q get sqm.map.script)
if [ "$CURRENT_SCRIPT" = "layer_cake.qos" ]; then
# Currently in Download Mode -> Switch to Normal Mode
uci set sqm.map.qdisc='fq_codel'
uci set sqm.map.script='simplest.qos'
logger -t SQM_TOGGLE "Switched SQM to Normal Mode (fq_codel / simplest.qos)"
else
# Currently in Normal Mode (or unknown) -> Switch to Download Mode
uci set sqm.map.qdisc='cake'
uci set sqm.map.script='layer_cake.qos'
logger -t SQM_TOGGLE "Switched SQM to Download Mode (cake / layer_cake.qos)"
fi
# Ensure your bandwidth limits remain strictly applied
uci set sqm.map.linklayer='none'
uci set sqm.map.download='224000'
uci set sqm.map.upload='320000'
# Save and restart SQM
uci commit sqm
/etc/init.d/sqm restart
#!/bin/sh
# Save to /etc/rc.button/wps (without the .sh extension) and make executable (chmod +x /etc/rc.button/wps)
# Only trigger when the button is released
if [ "$ACTION" = "released" ]; then
/root/download_toggle.sh &
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment