It is possible, I suggest you to use a lighttpd with a webservice for your app. After that - just switch between hostapd(AP mode) and wpa_supplicant(client mode). It is as simple as stop one service and start another wia shell command.
UPDATE: Some tips. What is the simplest way is to use a systemd as a triggerhappy switcheroo, and let it be done like this :
- use wpa_supplicant as a service
- a hostapd is already a service in ubuntu/debian, so you don't have tо do anything about it.
Next, configure ISC-DHCPD and hostapd for your AP mode, check them to be working as AP, i.e. you can join a network and obtain an IP address, DNS from your DHCP is pingable from a device and working. After that use this cheatsheet on SystemD to make dhcpd and hostapd not start automatically on boot :
#systemctl disable hostapd.service
#systemctl disable isc-dhcp-server.service
and stop thoose SoB's ;) just like that :
#systemctl stop hostapd.service
#systemctl stop isc-dhcp-server.service
after that by a link I've pointed upstrings make wpa_supplicant ( install it like that :
apt-get install wpasupplicant ) a service too, and set it up to be working as you wish, i.e. your RPi associates with AP you're about to use, receives IP+DNS, can ping/wget, e.t.c. After that - disable and stop the service just like we did it upstrings :
#systemctl stop wpa_supplicant.service
#systemctl disable wpa_supplicant.service
After that here goes the magic :) to switch from mode to another just stop the services from a previous mode and start the needed ones(i.e. stop
wpa_supplicant and start
isc-dhcp-server) like this:
#systemctl stop wpa_supplicant.service && systemctl start hostapd.service && systemctl start isc-dhcp-service.service
Yes, in one single string. The secret here is in "&&" construction - it's a type of queue when the next element will be executed only if the previous one haven't failed. So wherever from you'll make a call for this pipe, check for exitcode 0. It will guarantee you that everything was OK switching the modes. That's it, feel free to ask questions if you need more help!