This is just an idea to add setFreq to access point. Can
you comment on it?

Signed-off-by: Michael Trimarchi <[email protected]>
---
 include/technology.h |  4 ++--
 plugins/bluetooth.c  |  2 +-
 plugins/neard.c      |  3 ++-
 plugins/wifi.c       | 11 +++++++----
 src/technology.c     | 44 +++++++++++++++++++++++++++++++++++++++++---
 5 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/include/technology.h b/include/technology.h
index 22df04d..1983719 100644
--- a/include/technology.h
+++ b/include/technology.h
@@ -43,7 +43,7 @@ void connman_technology_regdom_notify(struct 
connman_technology *technology,
                                                        const char *alpha2);
 
 bool connman_technology_get_wifi_tethering(const char **ssid,
-                                                       const char **psk);
+                                                       const char **psk, int 
*freq);
 bool connman_technology_is_tethering_allowed(enum connman_service_type type);
 
 struct connman_technology_driver {
@@ -59,7 +59,7 @@ struct connman_technology_driver {
                                                                int index);
        int (*set_tethering) (struct connman_technology *technology,
                                const char *identifier, const char *passphrase,
-                               const char *bridge, bool enabled);
+                               const char *bridge, bool enabled, int freq);
        int (*set_regdom) (struct connman_technology *technology,
                                                const char *alpha2);
 };
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 59e6dba..30d5269 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -844,7 +844,7 @@ static void bluetooth_tech_remove(struct connman_technology 
*technology)
 
 static int bluetooth_tech_set_tethering(struct connman_technology *technology,
                const char *identifier, const char *passphrase,
-               const char *bridge, bool enabled)
+               const char *bridge, bool enabled, int freq)
 {
        GHashTableIter hash_iter;
        gpointer key, value;
diff --git a/plugins/neard.c b/plugins/neard.c
index 1a0fc1c..77a6e70 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -222,10 +222,11 @@ static DBusMessage *create_request_oob_reply(DBusMessage 
*message)
        DBusMessageIter iter;
        DBusMessageIter dict;
        const char *ssid, *psk;
+       int freq;
        uint8_t *tlv_msg;
        int length;
 
-       if (!connman_technology_get_wifi_tethering(&ssid, &psk))
+       if (!connman_technology_get_wifi_tethering(&ssid, &psk, &freq))
                return get_reply_on_error(message, ENOTSUP);
 
        tlv_msg = encode_to_tlv(ssid, psk, &length);
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 533d6df..5dfa701 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1969,7 +1969,7 @@ struct wifi_tethering_info {
        GSupplicantSSID *ssid;
 };
 
-static GSupplicantSSID *ssid_ap_init(const char *ssid, const char *passphrase)
+static GSupplicantSSID *ssid_ap_init(const char *ssid, const char *passphrase, 
int freq)
 {
        GSupplicantSSID *ap;
 
@@ -1981,7 +1981,10 @@ static GSupplicantSSID *ssid_ap_init(const char *ssid, 
const char *passphrase)
        ap->ssid = ssid;
        ap->ssid_len = strlen(ssid);
        ap->scan_ssid = 0;
-       ap->freq = 2412;
+       if (freq)
+               ap->freq = freq;
+       else
+               ap->freq = 2412;
 
        if (!passphrase || strlen(passphrase) == 0) {
                ap->security = G_SUPPLICANT_SECURITY_NONE;
@@ -2074,7 +2077,7 @@ static void sta_remove_callback(int result,
 
 static int tech_set_tethering(struct connman_technology *technology,
                                const char *identifier, const char *passphrase,
-                               const char *bridge, bool enabled)
+                               const char *bridge, bool enabled, int freq)
 {
        GList *list;
        GSupplicantInterface *interface;
@@ -2127,7 +2130,7 @@ static int tech_set_tethering(struct connman_technology 
*technology,
                info->wifi = wifi;
                info->technology = technology;
                info->wifi->bridge = bridge;
-               info->ssid = ssid_ap_init(identifier, passphrase);
+               info->ssid = ssid_ap_init(identifier, passphrase, freq);
                if (!info->ssid) {
                        g_free(info);
                        continue;
diff --git a/src/technology.c b/src/technology.c
index 28f0ff4..a82efc4 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -66,6 +66,7 @@ struct connman_technology {
                                              */
        char *tethering_ident;
        char *tethering_passphrase;
+       int tethering_freq;
 
        bool enable_persistent; /* Save the tech state */
 
@@ -264,7 +265,12 @@ static void technology_save(struct connman_technology 
*technology)
        if (technology->tethering_passphrase)
                g_key_file_set_string(keyfile, identifier,
                                        "Tethering.Passphrase",
-                                       technology->tethering_passphrase);
+                               technology->tethering_passphrase);
+
+       g_key_file_set_integer(keyfile, identifier,
+                               "Tethering.Freq",
+                               technology->tethering_freq);
+
 
 done:
        g_free(identifier);
@@ -320,10 +326,12 @@ static int set_tethering(struct connman_technology 
*technology,
        int result = -EOPNOTSUPP;
        int err;
        const char *ident, *passphrase, *bridge;
+       int freq;
        GSList *tech_drivers;
 
        ident = technology->tethering_ident;
        passphrase = technology->tethering_passphrase;
+       freq = technology->tethering_freq;
 
        __sync_synchronize();
        if (!technology->enabled)
@@ -345,7 +353,7 @@ static int set_tethering(struct connman_technology 
*technology,
                        continue;
 
                err = driver->set_tethering(technology, ident, passphrase,
-                               bridge, enabled);
+                               bridge, enabled, freq);
 
                if (result == -EINPROGRESS)
                        continue;
@@ -430,7 +438,7 @@ static struct connman_technology *technology_find(enum 
connman_service_type type
 }
 
 bool connman_technology_get_wifi_tethering(const char **ssid,
-                                                       const char **psk)
+                                                       const char **psk, int 
*freq)
 {
        struct connman_technology *technology;
 
@@ -448,6 +456,7 @@ bool connman_technology_get_wifi_tethering(const char 
**ssid,
 
        *ssid = technology->tethering_ident;
        *psk = technology->tethering_passphrase;
+       *freq = technology->tethering_freq;
 
        return true;
 }
@@ -513,6 +522,9 @@ static void technology_load(struct connman_technology 
*technology)
 
        technology->tethering_passphrase = g_key_file_get_string(keyfile,
                                identifier, "Tethering.Passphrase", NULL);
+
+       technology->tethering_freq = g_key_file_get_integer(keyfile,
+                               identifier, "Tethering.Freq", NULL);
 done:
        g_free(identifier);
 
@@ -612,6 +624,11 @@ static void append_properties(DBusMessageIter *iter,
                                        DBUS_TYPE_STRING,
                                        &technology->tethering_passphrase);
 
+       if (technology->tethering_freq)
+               connman_dbus_dict_append_basic(&dict, "TetheringFreq",
+                                       DBUS_TYPE_INT32,
+                                       &technology->tethering_freq);
+
        connman_dbus_dict_close(iter, &dict);
 }
 
@@ -912,6 +929,27 @@ static DBusMessage *set_property(DBusConnection *conn,
                                        DBUS_TYPE_STRING,
                                        &technology->tethering_passphrase);
                }
+       } else if (g_str_equal(name, "TetheringFreq")) {
+               dbus_int32_t freq;
+
+               dbus_message_iter_get_basic(&value, &freq);
+
+               if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
+                       return __connman_error_not_supported(msg);
+
+               if (type != DBUS_TYPE_INT32)
+                       return __connman_error_invalid_arguments(msg);
+
+               if (freq >= 0) {
+                       technology->tethering_freq = freq;
+                       technology_save(technology);
+
+                       connman_dbus_property_changed_basic(technology->path,
+                                       CONNMAN_TECHNOLOGY_INTERFACE,
+                                       "TetheringFreq",
+                                       DBUS_TYPE_INT32,
+                                       &technology->tethering_freq);
+               }
        } else if (g_str_equal(name, "Powered")) {
                dbus_bool_t enable;
 
-- 
1.8.1.2

-- 
| Michael Nazzareno Trimarchi                     Amarula Solutions BV |
| COO  -  Founder                                      Cruquiuskade 47 |
| +31(0)851119172                                 Amsterdam 1018 AM NL |
|                  [`as] http://www.amarulasolutions.com               |
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to