Hello everyone, I am compiling a new project where I seek help from all of you. I need to modify the dependency where the configuration of the wireless ssid is saved, it must be "IPCOMS_ (on this space I want the mac address of my interface to appear). How can I modify the config file to make this happen. Thank you
https://openwrt.org/docs/guide-user/network/wifi/basic
https://openwrt.org/docs/guide-developer/uci-defaults
And the board-specific files to find out how the MAC is generated, often in
target/linux/<your-target>/base-files/etc/hotplug.d/firmware/
target/linux/<your-target>/base-files/etc/board.d/02_network
(or, perhaps easier, reading the MAC from the procfs)
1 Like
My apologies, they are under /sys
, for example
target/linux/ipq40xx/base-files/lib/preinit/05_set_iface_mac_ipq40xx.sh: base_mac=$(cat /sys/class/net/eth0/address)
Also, see commit 0340718863 (on master
)
$ git diff 0340718863^ 0340718863
diff --git a/package/base-files/files/lib/functions/system.sh b/package/base-files/files/lib/functions/system.sh
index 5084c0052b..3051ac8476 100644
--- a/package/base-files/files/lib/functions/system.sh
+++ b/package/base-files/files/lib/functions/system.sh
@@ -12,6 +12,16 @@ get_mac_binary() {
hexdump -v -n 6 -s $offset -e '5/1 "%02x:" 1/1 "%02x"' $path 2>/dev/null
}
+get_mac_label() {
+ local basepath="/proc/device-tree"
+ local macdevice="$(cat "$basepath/aliases/label-mac-device" 2>/dev/null)"
+ local macaddr
+
+ [ -n "$macdevice" ] && macaddr=$(get_mac_binary "$basepath/$macdevice/mac-address" 0 2>/dev/null)
+ [ -n "$macaddr" ] || macaddr=$(get_mac_binary "$basepath/$macdevice/local-mac-address" 0 2>/dev/null)
+ echo $macaddr
+}
+
After adding this function, is it possible to add get_mac_label on etc / config / wireless so that my MAC appears? , THANKS @jeff
If you're running a build off master
after that commit on a DTS-based platform that has been enhanced to include the DTS alias. It would have something like
aliases {
led-boot = &led_status;
led-failsafe = &led_status;
led-running = &led_status;
led-upgrade = &led_status;
label-mac-device = ð0;
};
present.
Otherwise, you'd have to do the similar thing by knowing the proper device yourself.