Automatically close WiFi AP

Hi,

I am using a RPi for monitoring a remote ethernet device.
Everything works fine but I would like to improve one point :

The RPi opens a WiFi Access Point for configuration purpose. I would like to automatically disable the access point after some time (1 hour for instance).

I tried with this cron :

@reboot sleep 3600 && uci set wireless.wifinet0.disabled='1' && uci commit wireless && wifi reload

without success... The AP remains opened.

So, if you have any idea, I will try.

Thank you and good day

The @reboot in cron is not implemented. You can use /etc/rc.local for startup scripts.
However the way you do it, next time the rpi boots it will be disabled.

1 Like

That's what I want : if the rpi reboots, the wifi is opened for 1 hour.

I will try your solution asap.

I also have a uci default file which create the AP.
May I add this line after creating the AP:

uci set wireless.wifinet0=wifi-iface
uci set wireless.wifinet0.device='radio0'
uci set wireless.wifinet0.mode='ap'
uci set wireless.wifinet0.ssid="monitor"
uci set wireless.wifinet0.encryption='psk2'
uci set wireless.wifinet0.key="monitor"
uci set wireless.wifinet0.network='lan'
uci set wireless.wifinet0.disabled='0'
uci commit wireless
wifi reload
sleep 3600 && uci set wireless.wifinet0.disabled='1' && uci commit wireless && wifi reload &

...

// never return 0, this script should always be executed
exit 1

?

I think you have overcomplicated the whole thing.
wifi down will bring down the wifi and that's all you need till the next reboot.
Let it wait for an hour and then run the wifi down

2 Likes

Hi

@trendy It could, be sometime, it should go into wifi client mode (and rpi3 does not well support AP+STA).

So last word : issue was @reboot not being supported.
Moved code into uci-default file works great. Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.