Hello! Posting here as it's both the most recent and most precise topic about that issue.
I've managed to make two shell scripts to switch between Access Point and client mode for wifi.
I hope I haven't forgotten any other settings I've tweaked elsewhere on the system.
I'm not using nmcli/tui for creating the AccessPoint since the load option of the module makes this a bit tricky.
Instead this is standard hostapd for AP settings + dnsmasq for serving DHCP.
As stated in the files, this needs testing as well as checking regarding how to deal exactly with systemd services.
Save as stamode.sh, chmod +x stamode.sh and ./stamode
#! /bin/sh
# Switch from Access Point mode to station mode (client mode to a wifi network) for AP6212.
#TODO: Help, review and testers needed, especially for dealing with stopping/killing systemd services and process.
# Stop running process for the AP
/bin/systemctl stop hostapd
kill $(cat /var/run/dnsmasq.pid)
# Remove and re-add the wifi module, that time in station mode.
rmmod dhd
modprobe dhd
# Update symlinks for interfaces
rm /etc/network/interfaces
ln -s interfaces.network-manager /etc/network/interfaces
# Start normal network services provided by NM.
/bin/systemctl start networking.service
/bin/systemctl enable NetworkManager
/bin/systemctl start NetworkManager
# NM needs to be told to use that interface again
/usr/bin/nmcli d set wlan0 managed yes
# Wait for wifi to come up and show a list of networks in range
sleep 8
/usr/bin/nmcli device wifi list
Save as apmode.sh, chmod +x apmode.sh and ./stamode
#! /bin/sh
# Switch from station mode (client mode to a wifi network) to Acess Point mode for AP6212.
# Configuration of hostapd is found in /etc/hostapd/hostapd.conf or wherever the line "DAEMON_CONF" in /etc/default/hostapd points to.
# Do not forget to uncomment the line mentioned above in /etc/default/hostapd
# Edit /etc/network/interfaces with static IP for wlan0, example conf:
# auto wlan0
# iface wlan0 inet static
# address 192.168.101.1
# netmask 255.255.255.0
# dns-nameservers 192.168.101.1
# Configuration for DHCP server (using dnsmasq) is found in /etc/dnsmasq.conf, example conf:
# dhcp-range=192.168.101.20,192.168.101.120,72h
#TODO: Help, review and testers needed, especially for dealing with stopping/killing systemd services and process.
# Stop and disable nm. If it's enabled it locks at boot for 5 minutes.
# The dnsmasq processes aren't killed when nm stops and keep dhcp from working, kill them!
/bin/systemctl stop NetworkManager
/bin/systemctl disable NetworkManager
kill $(cat /var/run/NetworkManager/dnsmasq.pid)
kill $(cat /run/dnsmasq.br0.pid)
# Remove and re-add the wifi module, that time in AP mode
rmmod dhd
modprobe dhd op_mode=2
# Update symlinks for interfaces
rm /etc/network/interfaces
ln -s interfaces.hostapd /etc/network/interfaces
# Start using systemd and manually. Hostapd manages the interface, auth etc. and dnsmasq serves a DHCP server for clients connecting to the AP.
/bin/systemctl start hostapd
/usr/sbin/dnsmasq