I want to config mac address last 4-digits into WiFi SSID.
I found the new wifi-scripts file is mac80211.uc, some related part:
set ${si}=wifi-iface
set ${si}.device='${name}'
set ${si}.network='lan'
set ${si}.mode='ap'
set ${si}.ssid='${defaults?.ssid || "OpenWrt"}' <====== here, I need it likes "OpenWrt-xxxx" according mac address
set ${si}.encryption='${defaults?.encryption || "none"}'
set ${si}.key='${defaults?.key || ""}'
how to do it, pls help or any other suggestions, thanks.
Take the detected mac of your choice (wan, lan, label, whatever), manipulate the string to get the format you desire, then call ucidef_set_wireless with appropriate parameters.
It's a shell cmd, I do not know how to combined the line into the ucode file. This is the new v24.10 problem to me. On openwrt v23.05 before, I did it:
I don't have any OpenWRT device to try it on, but this works "on paper" on a vanilla Linux box, and should work if added to rc.local, plus a network/wifi restart:
uci set wireless.@wifi-iface[0].ssid="OpenWrt-"$(cat /sys/class/net/wlan*/address| head -n 1 | tr -d ":" | tr -d "\n"| tail -c 4)
it's pretty much the same as the one you already linked to, command wise.
lantis1008's solution is prettier, because it'll only run once, but will probably get wiped during every upgrade, and I'm guessing the one you liked to will be too.
@lantis1008 you need to use the URL link button for the deep links to work, it's a recent forum feature.
I don't know where you put this. But again: Are you sure your command gets executed because they are surrounded by SINGLE quotes which normally prevents VARIABLE EXPANTION.
And just to ask this dumb question: Why can't you set your SSID "statically"?
The mesh11sd package does this autonomously by default.
You can find the code here: mesh11sd
You could use mesh11sd to do it for you, even if your aps are cabled, but that would probably be overkill.
Simplified, the code constructs an "SSID" string based on the default value in the config file:
Uses UCI to get the default SSID
Uses the ip utility to get the mac address of the bridge (br-lan)
Gets the last 4 digits of the mac address as a suffix string, using awk.
Uses UCI to get the wireless band (2g 5g etc), but you have not mentioned this so you would not bother.
Concatenates default SSID with Band and suffix and does; echo "set $ap.ssid='$ssid-$band-$suffix'" | uci batch where $ap identifies the wireless interface, would be something like wireless.default_radio1
In your version you would do uci commit wireless
In your case you would create a set of script commands and put them into the " Script to run on first boot (uci-defaults)" text box in the Firmware Selector and generate the firmware for the APs.
On first run, the /etc/config/wireless file will be updated with the required suffix based on the mac address, as you require.