Splines / raspi-captive-portal

⚡ A Captive Portal & Access Point setup for use with the Raspberry Pi (no Internet access)
https://dominicplein.medium.com/captive-portal-access-point-on-the-raspberry-pi-easy-setup-28a9bf72e998
MIT License
29 stars 7 forks source link

How to restart AP after toggling on/off wifi connection #12

Open ThetomekK opened 4 days ago

ThetomekK commented 4 days ago

Hi, thanks for the project, had no issues to get it installed, considering issue#10.

In my scenario, i`d like to be able to switch on regular wifi connection and connect to a wifi temporarily. But after closing wifi connection, the configured AP does not show up on regular cell phone anymore. Not even after reboot. A complete reinstall did the trick, but is not really a serious workaround. Any idea, what can block the start of the AP?

So far i´ve tried: sudo systemctl -d restart access-point-server (no success) sudo systemctl restart hostapd (no success, error) sudo hostapd /etc/hostapd/hostapd.conf (no success)

BR ThetomekK

Splines commented 3 days ago

Hey there, I didn't have this scenario in mind when putting everything together. Did I understand you correctly that you want to switch between

1) Using the RasPi with a "normal" WiFi connection (e.g. to surf in a browser on the RasPi) and 2) Turning it into a captive portal (without Internet access) to serve a webpage to other devices logging into the WiFi that the RasPi is providing in this case?

You wrote that

sudo systemctl restart hostpad

is giving an error. Could you please attach the logs for this?

ThetomekK commented 1 day ago

Hi, the output of sudo systemctl restart hostapd.

Job for hostapd.service failed because the control process exited with error code. See "systemctl status hostapd.service" and "journalctl -xeu hostapd.service" for details.

Manual restart sudo hostapd /etc/hostapd/hostapd.conf gives:

rfkill: WLAN soft blocked wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE Failed to set beacon parameters wlan0: Could not connect to kernel driver Interface initialization failed wlan0: interface state COUNTRY_UPDATE->DISABLED wlan0: AP-DISABLED wlan0: Unable to setup interface. wlan0: interface state DISABLED->DISABLED wlan0: AP-DISABLED wlan0: CTRL-EVENT-TERMINATING hostapd_free_hapd_data: Interface wlan0 wasn't started nl80211: deinit ifname=wlan0 disabled_11b_rates=0

But setting Wifi country to DE in sudo raspi-config did the trick. with sudo systemctl restart hostpad the AP appears in my phone, when doing a scan.

BR ThetomekK