From 51176c7d2612bac2fcbd6bb2ec0d4870d0da1bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Sun, 29 Jun 2025 20:53:42 +0200 Subject: [PATCH 1/2] feature: wifi: Allow to set regulation setting (country-code) We was missing the firmware required for this, and for this to work cfg80211 needs to be as module since the rootfs is not loaded when it is loaded if compiled in kernel. And add iw since it very useful for debugging. --- package/feature-wifi/Config.in | 2 ++ package/feature-wifi/feature-wifi.mk | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package/feature-wifi/Config.in b/package/feature-wifi/Config.in index f12390bc..87ed3852 100644 --- a/package/feature-wifi/Config.in +++ b/package/feature-wifi/Config.in @@ -5,6 +5,8 @@ config BR2_PACKAGE_FEATURE_WIFI select BR2_PACKAGE_WPA_SUPPLICANT_DEBUG_SYSLOG select BR2_PACKAGE_WPA_SUPPLICANT_AUTOSCAN select BR2_PACKAGE_WPA_SUPPLICANT_CLI + select BR2_PACKAGE_WIRELESS_REGDB + select BR2_PACKAGE_IW help Enables WiFi in Infix. Enables all requried applications. diff --git a/package/feature-wifi/feature-wifi.mk b/package/feature-wifi/feature-wifi.mk index aa428bc7..90d5bdd3 100644 --- a/package/feature-wifi/feature-wifi.mk +++ b/package/feature-wifi/feature-wifi.mk @@ -10,8 +10,9 @@ FEATURE_WIFI_PACKAGE_LICENSE = MIT define FEATURE_WIFI_LINUX_CONFIG_FIXUPS $(call KCONFIG_ENABLE_OPT,CONFIG_WLAN) $(call KCONFIG_ENABLE_OPT,CONFIG_RFKILL) - $(call KCONFIG_ENABLE_OPT,CONFIG_MAC80211) - $(call KCONFIG_ENABLE_OPT,CONFIG_CFG80211) + $(call KCONFIG_SET_OPT,CONFIG_MAC80211,m) + $(call KCONFIG_SET_OPT,CONFIG_CFG80211,m) + $(if $(filter y,$(BR2_PACKAGE_FEATURE_WIFI_DONGLE_REALTEK)), $(call KCONFIG_ENABLE_OPT,CONFIG_WLAN_VENDOR_REALTEK) $(call KCONFIG_ENABLE_OPT,CONFIG_RTW88) From 0d03f874ee38c367480ebbe4452c67a439cb3e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Sun, 29 Jun 2025 21:04:00 +0200 Subject: [PATCH 2/2] confd: wifi: Fix several bugs in WiFi implemenation * Did not work to reconfigure * Was not possible to run from startup * Othe minor things. --- src/confd/src/infix-if-wifi.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/confd/src/infix-if-wifi.c b/src/confd/src/infix-if-wifi.c index 3f32517e..2ef7bfd2 100644 --- a/src/confd/src/infix-if-wifi.c +++ b/src/confd/src/infix-if-wifi.c @@ -12,7 +12,7 @@ static int wifi_gen_config(const char *ifname, const char *ssid, const char *cou char *encryption_str; int rc = SR_ERR_OK; - if (!secret || !ssid || !country || !encryption) { + if (!secret && (ssid && country && encryption)) { /* Not an error, updated from two ways, interface cb and keystore cb. */ return 0; } @@ -24,7 +24,12 @@ static int wifi_gen_config(const char *ifname, const char *ssid, const char *cou } fprintf(wpa, "# Generated by Infix confd\n"); + + fprintf(wpa, "if [ -f '/etc/finit.d/enabled/wifi@%s.conf' ];then\n", ifname); + fprintf(wpa, "initctl -bfqn touch wifi@%s\n", ifname); + fprintf(wpa, "else\n"); fprintf(wpa, "initctl -bfqn enable wifi@%s\n", ifname); + fprintf(wpa, "fi\n"); fclose(wpa); wpa_supplicant = fopenf("w", WPA_SUPPLICANT_CONF, ifname); @@ -32,7 +37,13 @@ static int wifi_gen_config(const char *ifname, const char *ssid, const char *cou rc = SR_ERR_INTERNAL; goto out; } - if (ssid) { + + if (!secret || !ssid || !country || !encryption) { + fprintf(wpa_supplicant, + "ctrl_interface=/run/wpa_supplicant\n" + "autoscan=periodic:10\n" + "ap_scan=1\n"); + } else { if (!strcmp(encryption, "disabled")) { asprintf(&encryption_str, "key_mgmt=NONE"); } else { @@ -48,14 +59,7 @@ static int wifi_gen_config(const char *ifname, const char *ssid, const char *cou "ssid=\"%s\"\n" "%s\n" "}\n", country, ssid, encryption_str); - free(encryption_str); - } else { - fprintf(wpa_supplicant, - "ctrl_interface=/run/wpa_supplicant\n" - "autoscan=periodic:10\n" - "ap_scan=1\n"); - - + free(encryption_str); } fclose(wpa_supplicant); @@ -75,11 +79,6 @@ int wifi_gen(struct lyd_node *dif, struct lyd_node *cif, struct dagger *net) return wifi_gen_config(ifname, NULL, NULL, NULL, NULL, net); } - if (dif && !lydx_get_child(dif, "wifi")) { - return SR_ERR_OK; - } - - enabled = lydx_get_bool(cif, "enabled"); wifi = lydx_get_child(cif, "wifi");