From: Jason Abele <[email protected]>

If the wifi interface is connected and a scan is requested via dbus, only
the channels from connectable services will be scanned.  This leaves few
options to fill out a UI with a fresh list of available services when
already connected.

Fix this by adding a new dbus method ScanFull() to request a full scan
of all channels.
---
Obviously this needs an entry in the API documentation, but I wanted to get
feedback on the idea before touching up those details.  Right now, I am just
looking for feedback regarding whether extending the dbus api for full scans is
acceptable and if this is roughly the right way to do it.

Is there a way to request a full scan while connected which I am missing?

$ connmanctl connect SERVICE
$ iw event -t &
$ gdbus call -y -d net.connman -o /net/connman/technology/wifi \
        -m net.connman.Technology.ScanFull
1415056830.095942: wlan0 (phy #0): scan started
1415056833.057016: wlan0 (phy #0): scan finished: 2412 2417 2422 2427 2432 2437 
2442 2447 2452 2457 2462 2467 2472 2484 5040 5060 5080 5170 5190 5210 5230 5180 
5200 5220 5240 5260 5280 5300 5320 5500 5520 5540 5560 5580 5600 5620 5640 5660 
5680 5700 5745 5765 5785 5805 5825, "SERVICE_SSID" ""
()

$ connmanctl connect SERVICE
$ iw event -t &
$ gdbus call -y -d net.connman -o /net/connman/technology/wifi \
        -m net.connman.Technology.Scan
1415056842.920538: wlan0 (phy #0): scan started
1415056842.971047: wlan0 (phy #0): scan finished: 5300, "SERVICE_SSID"
()

 plugins/wifi.c   |  4 ++++
 src/config.c     |  2 +-
 src/connman.h    |  3 ++-
 src/device.c     | 10 ++++++----
 src/technology.c |  7 ++++++-
 5 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 5ef4520..e3268a0 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1790,6 +1790,10 @@ static int wifi_scan(enum connman_service_type type,
                if (driver_max_ssids == 0)
                        return wifi_scan_simple(device);
 
+               if (user_data && g_str_equal((char *) user_data, "full")) {
+                       return wifi_scan_simple(device);
+               }
+
                do_hidden = false;
        } else {
                if (scanning && wifi->hidden && wifi->postpone_hidden)
diff --git a/src/config.c b/src/config.c
index e7d1671..4e44658 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1487,7 +1487,7 @@ int connman_config_provision_mutable_service(GKeyFile 
*keyfile)
        __connman_service_provision_changed(vfile);
 
        if (g_strcmp0(service_config->type, "wifi") == 0)
-               __connman_device_request_scan(CONNMAN_SERVICE_TYPE_WIFI);
+               __connman_device_request_scan(CONNMAN_SERVICE_TYPE_WIFI, NULL);
 
        return 0;
 
diff --git a/src/connman.h b/src/connman.h
index da01215..7b68bae 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -550,7 +550,8 @@ void __connman_device_list(DBusMessageIter *iter, void 
*user_data);
 
 enum connman_service_type __connman_device_get_service_type(struct 
connman_device *device);
 struct connman_device *__connman_device_find_device(enum connman_service_type 
type);
-int __connman_device_request_scan(enum connman_service_type type);
+int __connman_device_request_scan(enum connman_service_type type,
+                               void *user_data);
 int __connman_device_request_hidden_scan(struct connman_device *device,
                                const char *ssid, unsigned int ssid_len,
                                const char *identity, const char *passphrase,
diff --git a/src/device.c b/src/device.c
index c0683ab..6887619 100644
--- a/src/device.c
+++ b/src/device.c
@@ -604,7 +604,8 @@ bool connman_device_get_powered(struct connman_device 
*device)
 }
 
 static int device_scan(enum connman_service_type type,
-                               struct connman_device *device)
+                               struct connman_device *device,
+                               void *user_data)
 {
        if (!device->driver || !device->driver->scan)
                return -EOPNOTSUPP;
@@ -613,7 +614,7 @@ static int device_scan(enum connman_service_type type,
                return -ENOLINK;
 
        return device->driver->scan(type, device, NULL, 0,
-                                       NULL, NULL, NULL, NULL);
+                                       NULL, NULL, NULL, user_data);
 }
 
 int __connman_device_disconnect(struct connman_device *device)
@@ -1077,7 +1078,8 @@ void connman_device_regdom_notify(struct connman_device 
*device,
        __connman_technology_notify_regdom_by_device(device, result, alpha2);
 }
 
-int __connman_device_request_scan(enum connman_service_type type)
+int __connman_device_request_scan(enum connman_service_type type,
+               void *user_data)
 {
        bool success = false;
        int last_err = -ENOSYS;
@@ -1112,7 +1114,7 @@ int __connman_device_request_scan(enum 
connman_service_type type)
                                continue;
                }
 
-               err = device_scan(type, device);
+               err = device_scan(type, device, user_data);
                if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
                        success = true;
                } else {
diff --git a/src/technology.c b/src/technology.c
index d80d9e6..7ee3b9d 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -1041,15 +1041,19 @@ static DBusMessage *scan(DBusConnection *conn, 
DBusMessage *msg, void *data)
 {
        struct connman_technology *technology = data;
        int err;
+       char *scan_type = NULL;
 
        DBG("technology %p request from %s", technology,
                        dbus_message_get_sender(msg));
 
+       if (dbus_message_is_method_call(msg, &CONNMAN_TECHNOLOGY_INTERFACE, 
&"ScanFull"))
+               scan_type = "full";
+
        dbus_message_ref(msg);
        technology->scan_pending =
                g_slist_prepend(technology->scan_pending, msg);
 
-       err = __connman_device_request_scan(technology->type);
+       err = __connman_device_request_scan(technology->type, scan_type);
        if (err < 0)
                reply_scan_pending(technology, err);
 
@@ -1064,6 +1068,7 @@ static const GDBusMethodTable technology_methods[] = {
                        GDBUS_ARGS({ "name", "s" }, { "value", "v" }),
                        NULL, set_property) },
        { GDBUS_ASYNC_METHOD("Scan", NULL, NULL, scan) },
+       { GDBUS_ASYNC_METHOD("ScanFull", NULL, NULL, scan) },
        { },
 };
 
-- 
1.9.1

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to