[PATCH] Connman : Allow connmanctl to trigger Wi-Fi scan

Shailesh Rathod/LGSI Connectivity Team <[email protected]> Fri, 11 Jul 2025 09:31:32 +0000
Newsgroups dev.linux.lists.connman
Message-ID <SE1P216MB264730620165FFEBF76CD1B9F04BA@SE1P216MB2647.KORP216.PROD.OUTLOOK.COM>
From 7a587f647db2d86404bd1a578ee90447b5e2ce26 Mon Sep 17 00:00:00 2001
From: shailesh <[email protected]>
Date: Thu, 10 Jul 2025 04:32:13 +0000
Subject: [PATCH] Allow connmanctl to trigger Wi-Fi scan

Due to P2P Scan feature connmanctl couldn't do Wi-Fi Scan.
This patch enables the use of connmanctl to
manually trigger a Wi-Fi scan.
---
 src/device.c     | 14 +++++++-------
 src/technology.c | 19 +++++++------------
 2 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/src/device.c b/src/device.c
index 3ab5268..2b75026 100644
--- a/src/device.c
+++ b/src/device.c
@@ -644,7 +644,7 @@ bool connman_device_get_powered(struct connman_device *device)
 
 static int device_scan(enum connman_service_type type,
                struct connman_device *device,
-               bool priority)
+               bool scan_type)
 {
    struct connman_device_scan_params params;
 
@@ -656,8 +656,8 @@ static int device_scan(enum connman_service_type type,
 
    memset(&params, 0, sizeof(params));
    params.type = type;
-   params.force_full_scan = priority;
-   if(priority)
+   params.force_full_scan = true;
+   if(scan_type)
        return device->driver->scan_p2p(type, device);
    else
        return device->driver->scan(device, &params);
@@ -1106,7 +1106,7 @@ void connman_device_regdom_notify(struct connman_device *device,
 }
 
 static int connman_device_request_scan(enum connman_service_type type,
-                   bool priority)
+                   bool scan_type)
 {
    bool success = false;
    int last_err = -ENOSYS;
@@ -1134,7 +1134,7 @@ static int connman_device_request_scan(enum connman_service_type type,
        if (!device_has_service_type(device, type))
            continue;
 
-       err = device_scan(type, device, priority);
+       err = device_scan(type, device, scan_type);
        if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
            success = true;
        } else {
@@ -1154,9 +1154,9 @@ int __connman_device_request_scan(enum connman_service_type type)
    return connman_device_request_scan(type, false);
 }
 
-int __connman_device_request_scan_full(enum connman_service_type type,bool priority)
+int __connman_device_request_scan_full(enum connman_service_type type,bool scan_type)
 {
-   return connman_device_request_scan(type, priority);
+   return connman_device_request_scan(type, scan_type);
 }
 
 int __connman_device_request_hidden_scan(struct connman_device *device,
diff --git a/src/technology.c b/src/technology.c
index 98c98b2..fcb5f2b 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -1415,7 +1415,7 @@ static DBusMessage *scan(DBusConnection *conn, DBusMessage *msg, void *data)
    struct connman_technology *technology = data;
    int err;
    DBusMessageIter iter;
-   bool priority = false;
+   dbus_bool_t scan_type = FALSE;
 
    DBG("technology %p request from %s", technology,
            dbus_message_get_sender(msg));
@@ -1424,21 +1424,16 @@ static DBusMessage *scan(DBusConnection *conn, DBusMessage *msg, void *data)
                !technology->enabled)
        return __connman_error_permission_denied(msg);
 
-   if (!dbus_message_iter_init(msg, &iter))
-       return __connman_error_invalid_arguments(msg);
-
-   if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BOOLEAN)
-       return __connman_error_invalid_arguments(msg);
-
-   dbus_message_iter_get_basic(&iter, &priority);
-
    dbus_message_ref(msg);
    technology->scan_pending =
        g_slist_prepend(technology->scan_pending, msg);
 
-   DBG("technology scan set priority = %s", priority?"HIGH":"LOW");
+   if(technology->type == CONNMAN_SERVICE_TYPE_P2P)
+       scan_type = TRUE;
+
+   DBG("technology scan = %s", scan_type?"p2p":"wifi");
 
-   err = __connman_device_request_scan_full(technology->type,priority);
+   err = __connman_device_request_scan_full(technology->type,scan_type);
    if (err < 0)
        reply_scan_pending(technology, err);
 
@@ -1452,7 +1447,7 @@ static const GDBusMethodTable technology_methods[] = {
    { GDBUS_ASYNC_METHOD("SetProperty",
            GDBUS_ARGS({ "name", "s" }, { "value", "v" }),
            NULL, set_property) },
-   { GDBUS_ASYNC_METHOD("Scan", GDBUS_ARGS({ "priority", "b" }), NULL, scan) },
+   { GDBUS_ASYNC_METHOD("Scan", NULL, NULL, scan) },
    { },
 };