[openwrt/openwrt] base-files: uci-defaults: allow setting wireless defaults

LEDE Commits lede-commits at lists.infradead.org
Wed Oct 2 06:48:06 PDT 2024


blogic pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/b9eadcf318f55215fbbac62e05b17ea7223eb6f8

commit b9eadcf318f55215fbbac62e05b17ea7223eb6f8
Author: Daniel Golle <daniel at makrotopia.org>
AuthorDate: Sat Nov 20 01:43:20 2021 +0000

    base-files: uci-defaults: allow setting wireless defaults
    
    Introduce new uci-default functions:
     - ucidef_set_wireless band ssid [encryption] [key]
     - ucidef_set_country cc
    
    They are supposed to be used in /etc/board.d/* scripts to define
    board-specific defaults for wireless.
    
    Signed-off-by: Daniel Golle <daniel at makrotopia.org>
    Signed-off-by: John Crispin <john at phrozen.org>
---
 .../base-files/files/lib/functions/uci-defaults.sh | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index b89cc8e9e3..ba7288c2c6 100644
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -642,6 +642,41 @@ ucidef_set_hostname() {
 	json_select ..
 }
 
+ucidef_set_wireless() {
+	local band="$1"
+	local ssid="$2"
+	local encryption="$3"
+	local key="$4"
+
+	case "$band" in
+	all|2g|5g|6g) ;;
+	*) return;;
+	esac
+	[ -z "$ssid" ] && return
+
+	json_select_object wlan
+		json_select_object defaults
+			json_select_object ssids
+				json_select_object "$band"
+					json_add_string ssid "$ssid"
+					[ -n "$encryption" ] && json_add_string encryption "$encryption"
+					[ -n "$key" ] && json_add_string key "$key"
+				json_select ..
+			json_select ..
+		json_select ..
+	json_select ..
+}
+
+ucidef_set_country() {
+	local country="$1"
+
+	json_select_object wlan
+		json_select_object defaults
+			json_add_string country "$country"
+		json_select ..
+	json_select ..
+}
+
 ucidef_set_ntpserver() {
 	local server
 




More information about the lede-commits mailing list