Message ID | CAG17S_MPuJ9ehB-3Ki0MKhbyz4VRM=u_VQRzem4N4mq4mEsJVg@mail.gmail.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | Request for help integrating iwd ap mode scan | expand |
Please disregard this request. The dbus messages are substantially different. Implementation would be a headache and it is definitely a corner case. In the end I figured out a better way. Keith On Fri, Dec 22, 2023 at 4:07 PM KeithG <ys3al35l@gmail.com> wrote: > > 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
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)