From 47e7917bed8c23b1d2a92ea225aaee371bc8964a Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Sun, 5 Dec 2021 10:43:34 +0100
Subject: [PATCH 38/38] base-files: add wifi scanning radio support to
 board_detect

Signed-off-by: John Crispin <john@phrozen.org>
---
 package/base-files/files/bin/board_detect              |  1 +
 package/base-files/files/lib/functions/uci-defaults.sh | 10 ++++++++++
 package/base-files/files/sbin/wifi                     |  2 ++
 3 files changed, 13 insertions(+)

diff --git a/package/base-files/files/bin/board_detect b/package/base-files/files/bin/board_detect
index 840bd0178d..dd28bc44dd 100755
--- a/package/base-files/files/bin/board_detect
+++ b/package/base-files/files/bin/board_detect
@@ -12,3 +12,4 @@ CFG=$1
 }
 
 [ -s "$CFG" ] || return 1
+wifi config
diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index 02882f43ca..ff3433a0a2 100644
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -617,6 +617,16 @@ ucidef_set_hostname() {
 	json_select ..
 }
 
+ucidef_set_wifi_scanning() {
+	local path="$1"
+
+	json_select_object wifi
+		json_select_object $path
+			json_add_boolean scanning 1 
+		json_select ..
+	json_select ..
+}
+
 ucidef_set_ntpserver() {
 	local server
 
diff --git a/package/base-files/files/sbin/wifi b/package/base-files/files/sbin/wifi
index 6b9662fe93..b080e22770 100755
--- a/package/base-files/files/sbin/wifi
+++ b/package/base-files/files/sbin/wifi
@@ -1,6 +1,8 @@
 #!/bin/sh
 # Copyright (C) 2006 OpenWrt.org
 
+[ -f /etc/board.json ] || exit 0
+
 . /lib/functions.sh
 . /usr/share/libubox/jshn.sh
 
-- 
2.25.1

