[PATCH 4/4] wifi: set the country code from connman setting

jmassot at aldebaran-robotics.com jmassot at aldebaran-robotics.com
Fri Feb 10 01:47:08 PST 2012


From: Julien Massot <jmassot at aldebaran-robotics.com>

---
 plugins/wifi.c |   31 +++++++++++++++++++------------
 1 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 61a84ed..bec6601 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -49,6 +49,7 @@
 #include <connman/technology.h>
 #include <connman/log.h>
 #include <connman/option.h>
+#include <connman/setting.h>
 #include <connman/storage.h>
 
 #include <gsupplicant/gsupplicant.h>
@@ -207,11 +208,24 @@ static void wifi_remove(struct connman_device *device)
 	g_free(wifi);
 }
 
+static void regdom_callback(void *user_data)
+{
+	char *alpha2 = user_data;
+
+	DBG("");
+
+	if (wifi_technology == NULL)
+		return;
+
+	connman_technology_regdom_notify(wifi_technology, alpha2);
+}
+
 static void interface_create_callback(int result,
 					GSupplicantInterface *interface,
 							void *user_data)
 {
 	struct wifi_data *wifi = user_data;
+	const char *alpha2;
 
 	DBG("result %d ifname %s, wifi %p", result,
 				g_supplicant_interface_get_ifname(interface),
@@ -226,6 +240,11 @@ static void interface_create_callback(int result,
 	if (g_supplicant_interface_get_ready(interface) == FALSE)
 		return;
 
+	alpha2 = connman_setting_get_string("RegulatoryDomain");
+	if (alpha2 != NULL)
+		g_supplicant_interface_set_country(wifi->interface, alpha2,
+						regdom_callback, alpha2);
+
 	DBG("interface is ready wifi %p tethering %d", wifi, wifi->tethering);
 
 	if (wifi->device == NULL) {
@@ -1456,18 +1475,6 @@ static int tech_set_tethering(struct connman_technology *technology,
 	return -EOPNOTSUPP;
 }
 
-static void regdom_callback(void *user_data)
-{
-	char *alpha2 = user_data;
-
-	DBG("");
-
-	if (wifi_technology == NULL)
-		return;
-
-	connman_technology_regdom_notify(wifi_technology, alpha2);
-}
-
 static int tech_set_regdom(struct connman_technology *technology, const char *alpha2)
 {
 	GList *list;
-- 
1.7.5.4




More information about the connman mailing list