How to elegantly engage/disengage AP mode

KeithG <[email protected]>
Newsgroups dev.linux.lists.connman,dev.linux.lists.iwd
Message-ID <CAG17S_Nkb6jH_aBfAzWiqVqY7PUZ5rQJsHo3WzvfPtBa0E57iA@mail.gmail.com>
Hi. I am soliciting ideas on how to elegantly engage/disengage AP mode
when configuration is needed on a headless device.

What we do now: We use connman as our connection manager with iwd
handling wlan duties. At first boot our headless RPi based appliance
checks to see if it has a valid ethernet address on either the wlan or
the ethernet. If not, it creates an AP on a made up MAC address and
launches (with either IWD or Hostapd) an AP to allow a connection to
configure the internet. This works fine and we can use this to
configure the RPi and when we select a valid SSID with connman and
type in the password, it brings the AP down and connects to the SSID.
All good.

The problem: What happens if the SSID goes away either because we
moved the Pi or the SSID goes away? What we would like is it to scan
for a known SSID and reconnect if it finds one, (which it already
does) and if ones does not appear, to restart AP mode so we can
connect to it. If it finds an SSID while we are connecting, continue
to set up, but if the SSID reappears and no-one has connected, to then
shut down AP and re-connect to the SSID.

Question: Are there any elegant ways of doing this? We currently use
scripts and such to look at connmanctl and iwctl, but could start
digging into dbus, to monitor what is going on if needed. We thought
this may have been solved previously and wanted to ask here.

Any ideas? This seems like something that would be useful for just
about any headless internet connected device.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.