Uci-defaults: What is safe to automate with respect to WiFi?


In the uci-defaults page on the wiki (https://openwrt.org/docs/guide-developer/uci-defaults), I see that I can set the disabled status of the device and the SSID of the interface itself. What other settings can I safely change for WiFi? On my currently setup router, uci shows much more than just the SSID on the interface, for example. (e.g. device (radio0), encryption, etc.).

I think the encryption and mode can be set by the user via uci-defaults, but I am especially concerned about the device itself. (e.g. type, channel, hwmode, path, htmode, etc.)

I intend to use this knowledge to create scripts to automate my router setup in the future, especially that I'm a bit overdue on upgrades and I might do a clean slate.


Welcome to this forum.
There are different routers with different wifi hardware, so the command iw [dev] info will give all options of the hardware.
Example on my 2.4GHz, 4 channel router:

# iw phy0 info
Wiphy phy0
        wiphy index: 0
        max # scan SSIDs: 4
        max scan IEs length: 2257 bytes
        max # sched scan SSIDs: 0
        max # match sets: 0
        Retry short long limit: 2
        Coverage class: 0 (up to 0m)
        Available Antennas: TX 0 RX 0
        Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * AP/VLAN
                 * monitor
                 * mesh point
        Band 1:
                Capabilities: 0x2fe
                        SM Power Save disabled
                        RX Greenfield
                        RX HT20 SGI
                        RX HT40 SGI
                        TX STBC
                        RX STBC 2-streams
                        Max AMSDU length: 3839 bytes
                        No DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: 2 usec (0x04)
                HT TX/RX MCS rate indexes supported: 0-15, 32
                        * 2412 MHz [1] (20.0 dBm)
                        * 2417 MHz [2] (20.0 dBm)
                        * 2422 MHz [3] (20.0 dBm)
                        * 2427 MHz [4] (20.0 dBm)
                        * 2432 MHz [5] (20.0 dBm)
                        * 2437 MHz [6] (20.0 dBm)
                        * 2442 MHz [7] (20.0 dBm)
                        * 2447 MHz [8] (20.0 dBm)
                        * 2452 MHz [9] (20.0 dBm)
                        * 2457 MHz [10] (20.0 dBm)
                        * 2462 MHz [11] (20.0 dBm)
                        * 2467 MHz [12] (20.0 dBm)
                        * 2472 MHz [13] (20.0 dBm)
                        * 2484 MHz [14] (20.0 dBm)
        valid interface combinations:
                 * #{ managed, AP, mesh point } <= 8,
                   total <= 8, #channels <= 1
        HT Capability overrides:
                 * MCS: ff ff ff ff ff ff ff ff ff ff
                 * maximum A-MSDU length
                 * supported channel width
                 * short GI for 40 MHz
                 * max A-MPDU length exponent
                 * min MPDU start spacing
        max # scan plans: 1
        max scan plan interval: -1
        max scan plan iterations: 0
        Supported extended features:
                * [ RRM ]: RRM
                * [ FILS_STA ]: STA FILS (Fast Initial Link Setup)
                * [ CQM_RSSI_LIST ]: multiple CQM_RSSI_THOLD records
                * [ CONTROL_PORT_OVER_NL80211 ]: control port over nl80211
                * [ SCAN_RANDOM_SN ]: use random sequence numbers in scans
                * [ SCAN_MIN_PREQ_CONTENT ]: use probe request with only rate IEs in scans
                * [ CONTROL_PORT_NO_PREAUTH ]: disable pre-auth over nl80211 control port support
                * [ DEL_IBSS_STA ]: deletion of IBSS station support
                * [ SCAN_FREQ_KHZ ]: scan on kHz frequency support
                * [ CONTROL_PORT_OVER_NL80211_TX_STATUS ]: tx status for nl80211 control port support

Options outside this scope will produce errors.
Hopefully you have a start to go further.


1 Like

You can use config_load/config_foreach to iterate over all radios in your uci-defaults script and configure them like that:

setup_radio() {
	local radio="$1"
	uci -q del "wireless.${radio}.disabled"
	uci set "wireless.${radio}.channel=auto"
	uci set "wireless.${radio}.country=XX"
	uci set "wireless.default_${radio}.key=..."
	uci set "wireless.default_${radio}.encryption=psk2+ccmp"
	uci set "wireless.default_${radio}.bursting=1"
	uci set "wireless.default_${radio}.compression=1"
	uci set "wireless.default_${radio}.legacy_rates=0"
	uci set "wireless.default_${radio}.disassoc_low_ack=0"
	uci set "wireless.default_${radio}.ff=1"
	uci set "wireless.default_${radio}.skip_inactivity_poll=1"
	uci set "wireless.default_${radio}.turbo=1"
	uci set "wireless.default_${radio}.wpa_group_rekey=3600"
	uci set "wireless.default_${radio}.wps_pushbutton=0"
	uci set "wireless.default_${radio}.wpa_disable_eapol_key_retries=1"
	if [ "$(uci -q get wireless."${radio}".hwmode)" = "11a" ]; then
		uci set "wireless.${radio}.htmode=VHT80"
		uci set "wireless.${radio}.txpower=23"
		uci set "wireless.default_${radio}.ssid=..."
		uci set "wireless.${radio}.htmode=HT40+"
		uci set "wireless.${radio}.noscan=1"
		uci set "wireless.${radio}.txpower=30"
		uci set "wireless.default_${radio}.ssid=..."
. /lib/functions.sh; config_load 'wireless'; 
config_foreach setup_radio 'wifi-device';
uci commit wireless
1 Like

Thank you very much - I will prod around that command and see what I can configure.

@stangri Thank you for your advice as well.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.