ConnMan network manager
 help / color / mirror / Atom feed
From: KeithG <ys3al35l@gmail.com>
To: connman@lists.linux.dev
Subject: Request for help integrating iwd ap mode scan
Date: Fri, 22 Dec 2023 16:07:27 -0600	[thread overview]
Message-ID: <CAG17S_MPuJ9ehB-3Ki0MKhbyz4VRM=u_VQRzem4N4mq4mEsJVg@mail.gmail.com> (raw)

I am back on the project. I feel it would be a great add to connman.
What it is: Feature to allow connman to scan for ssids while iwd is in ap mode
Background: I know connman can tether and we have done that, but this
has 2 issues. 1) it creates another interface called tether which is
confusing to some users as we are using conman in a headless audio
player 2) tether will not allow us to set a preferred IP address.

The iwd team added this functionality a while back where if iwd is in
ap mode, it can still scan for networks. iwd allows us to set the wlan
adapter into ap mode with a preferred IP and keeps the same adapter
listed (wlan0 in our case). I would love to see connman be able to do
this as well. With this functionality, we could use iwd/connman for
'wireless setup' of our audio player. We are currently using hostapd
and it is balky, disconnects and is slow.

Daniel Wagner created this patch to iwd.c back in January 2023 which I
incorporated and built into a current (git from head, source built)
connman package. The resulting binary works fine in station mode with
iwd, but it still will not allow 'connmanctl scan wifi' when iwd is in
ap mode though iwd can do it.

When iwd is in ap mode, if you issue a command 'iwctl ap wlan0 scan'
then 'iwctl ap wlan0 get-networks' it returns the available networks
similarly as it does in station mode.

if iwd is in ap mode and 'connmanctl scan wifi' is sent, connman takes
a long time and finally returns. The log of the iwd plugin when I did
this is:

https://pastebin.com/AHq2XkUs

The patch from Daniel Wagner is here:
---

Only compile tested :)

 plugins/iwd.c | 54 ++++++++++++++++++++++++++++++
++++++++++++++++-----
 1 file changed, 49 insertions(+), 5 deletions(-)

diff --git a/plugins/iwd.c b/plugins/iwd.c
index 2fe49a23316b..491a0e41da89 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -633,15 +633,28 @@ static void cm_device_scan_cb(DBusMessage
*message, void *user_data)
        }
 }

-static int cm_device_scan(struct connman_device *device,
-                               struct connman_device_scan_params *params)
+static void cm_ap_scan_cb(DBusMessage *message, void *user_data)
+{
+       const char *path = user_data;
+       struct iwd_ap *iwdap;
+
+       iwdap = g_hash_table_lookup(access_points, path);
+       if (!iwdap)
+               return;
+
+       if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
+               const char *dbus_error = dbus_message_get_error_name(message);
+
+               DBG("%s scan failed: %s", path, dbus_error);
+       }
+}
+
+static int cm_station_scan(struct connman_device *device,
+                               struct connman_device_scan_params *param)
 {
        struct iwd_device *iwdd = connman_device_get_data(device);
        struct iwd_station *iwds;

-       if (strcmp(iwdd->mode, "station"))
-               return -EINVAL;
-
        iwds = g_hash_table_lookup(stations, iwdd->path);
        if (!iwds)
                return -EIO;
@@ -653,6 +666,37 @@ static int cm_device_scan(struct connman_device *device,
        return -EINPROGRESS;
 }

+static int cm_ap_scan(struct connman_device *device,
+                               struct connman_device_scan_params *param)
+{
+       struct iwd_device *iwdd = connman_device_get_data(device);
+       struct iwd_ap *iwdap;
+
+       iwdap = g_hash_table_lookup(access_points, iwdd->path);
+       if (!iwdap)
+               return -EIO;
+
+       if (!g_dbus_proxy_method_call(iwdap->proxy, "Scan",
+                       NULL, cm_ap_scan_cb, g_strdup(iwdap->path), g_free))
+               return -EIO;
+
+       return -EINPROGRESS;
+}
+
+static int cm_device_scan(struct connman_device *device,
+                               struct connman_device_scan_params *params)
+{
+       struct iwd_device *iwdd = connman_device_get_data(device);
+
+       if (!strcmp(iwdd->mode, "station"))
+               return cm_station_scan(device, params);
+
+       if (!strcmp(iwdd->mode, "ap"))
+               return cm_ap_scan(device, params);
+
+       return -EINVAL;
+}
+
 static struct connman_device_driver device_driver = {
        .name           = "iwd",
        .type           = CONNMAN_DEVICE_TYPE_WIFI,
--
2.39.0

             reply	other threads:[~2023-12-22 22:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-22 22:07 KeithG [this message]
2024-01-18 18:56 ` Request for help integrating iwd ap mode scan KeithG

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAG17S_MPuJ9ehB-3Ki0MKhbyz4VRM=u_VQRzem4N4mq4mEsJVg@mail.gmail.com' \
    --to=ys3al35l@gmail.com \
    --cc=connman@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).