I am working on a RPi radio project, and I'd like to be able to switch between a "setup mode" where the RPi acts as a Wi-Fi access point, allowing the user to send his/her home Wi-Fi credentials via a dedicated mobile app then write them into the wpa_supplicant file, and a "normal mode" where the board becomes a Wi-Fi client and connects to the Wi-Fi network the user specified while using the setup mode.

Is it possible?


1 Answer 1


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 hostapd and 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!

  • Thanks for your answer. That's what I was thinking of, but I am not that good with shell scripting. I'll try to find some examples, because I think I'll have to fiddle with dhcpd.conf, /etc/default/isc-dhcp-server and /etc/network/interfaces as suggested in this article link
    – Zbam
    Commented Mar 16, 2016 at 13:28
  • @Zbam need more info to help you out? Commented Mar 16, 2016 at 14:10
  • some insight on the way I could switch from one mode to the other would be great, because from what I've seen it involves many files
    – Zbam
    Commented Mar 16, 2016 at 17:23
  • @Zbam take a look at my edit, I've updated my answer Commented Mar 16, 2016 at 20:20
  • 1
    > after that by a link I've pointed upstrings make wpa_supplicant What do you mean by "upstrings"? Where is the link on how to make wpa_suppplicant a service? Commented Feb 20, 2017 at 23:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.