Enable/disable Wi-fi hotspot programmatically on pi zero?

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Post Reply
russellyazbeck
Posts: 3
Joined: Thu Jun 25, 2020 7:58 pm

Enable/disable Wi-fi hotspot programmatically on pi zero?

Post by russellyazbeck »

Is it possible to interface with dietpi-config programmatically? So that I can enable and then disable the wifi hotspot? (it seems this requires ethernet, but the pi zero doesn't have ethernet, so how do you use hotspot on dietpi with pi zero?)

If not through dietpi-config, is there another way?

I suppose I could write a bash script to handle it, but curious if there's an easier way before I spend hours building a custom solution.
russellyazbeck
Posts: 3
Joined: Thu Jun 25, 2020 7:58 pm

Re: Enable/disable Wi-fi hotspot programmatically on pi zero?

Post by russellyazbeck »

Looks like I may be able to use this, which I just confirmed works.

https://github.com/lukicdarkoo/rpi-wifi

Remove line 191 from the configure file.

Then I can modify /bin/rpi-wifi.sh to take in 'up' or 'down' to start and stop the AP when needed.
russellyazbeck
Posts: 3
Joined: Thu Jun 25, 2020 7:58 pm

Re: Enable/disable Wi-fi hotspot programmatically on pi zero?

Post by russellyazbeck »

I'm not great at Linux, still a lot to learn.

I did some digging around the dietpi funcs and realized it was overwriting some of the config from the rpi-wifi I ran, so I did some light editing to dietpi-config and seems to work great.

Now I can just ifdown the ap0 interface and ifup when I'm ready to use it.
User avatar
Joulinar
Posts: 2022
Joined: Sat Nov 16, 2019 12:49 am

Re: Enable/disable Wi-fi hotspot programmatically on pi zero?

Post by Joulinar »

Hi,

many thanks for sharing your problem as well as solution. As you already find out, DietPi is not supporting simultaneous AP and Managed Mode Wifi on one interface. But rpi-wifi tool seems to close the gap. But yeah dietpi-config will clean your /etc/network/interfaces if used, because it's not expecting something like ap0. Maybe youlike to share the changes you have done on dietpi-config to overcome this situation.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 2262
Joined: Sat Nov 18, 2017 6:21 pm

Re: Enable/disable Wi-fi hotspot programmatically on pi zero?

Post by MichaIng »

dietpi-config btw does not override /etc/network/interfaces, but it might not detect or being able to apply changes to this file correctly anymore as it depends on a fixed content... Rework is in pipeline to allow a flexible per-interface configuration.

What is already possible now is to apply custom changes via new files in /etc/network/interfaces.d/your_conf to have them independent from any changes to the main files. With the rework, the new dietpi-network will use drop-on per-interface configs itself and will allow configuration via command line options as well.
Post Reply