Hi,
I'm not sure what this code is doing and is it necessary ?
Code:
while [ $C -gt 0 ]; do
printf "\x02" > /dev/gpio/out
sleep 1
printf "\x00" > /dev/gpio/out
sleep 1
I wrote myself a short code , which can be used also if you have enabled cron. In the /usr/local/sbin/ez-setup file I wrote simple code just to switch on/off the wireless. If you remove thecomments it is only 4-5 rows.
Code:
#!/bin/sh
WLAN=`wl isup`
time=`/bin/date '+%b %e %H:%M:%S'`
if [ "$WLAN" = "0" ]; then
echo "$time: Wireless was down, powering up!" >> /tmp/var/log/ez-setup.log && wl radio on
echo "$time : You have 5 minutes to connect to the router before wireless automatically shuts down" >> /tmp/var/log/ez-setup-pressed
sleep 300
echo "$time : End of 5 minutes" >> /tmp/var/log/ez-setup.log
rm /tmp/var/log/ez-setup-pressed
else
echo "$time: Wireless was up, powering down!" >> /tmp/var/log/ez-setup.log &&
wl radio off
fi
When I press the ez-setup, it starts/stops the wireless and creates "flag" file in order to mark that the button was pressed.
Then in the cron I start the following script to disable the wireless if it is not used. The purpose of the "flag" file is to assure that the wireless will be on for at least 5 minutes, so we can connect. Without it it may happen that we will switch on the wireless and in 10 seconds cron may stop it.
You may put this code in a script and start it every 5 minutes using cron.
Code:
#!/bin/sh
time=`/bin/date '+%b %e %H:%M:%S'`
WLAN=`wl isup`
if [ "$WLAN" = "0" ]; then
#echo "$time : Wireless is already down ! " >> /opt/var/log/ez-setup.log
exit
fi
if [ -f /tmp/var/log/ez-setup-pressed ]; then
#echo "$time : Stop file still exists" >> /opt/var/log/ez-setup.log
exit
fi
if [ $(wl assoclist | wc -l) -gt 0 ]; then
#echo "$time : Wireless devices still connected" >> /opt/var/log/ez-setup.log
exit
fi
echo "$time : Wireless automatically down " >> /tmp/var/log/ez-setup.log
wl radio off