If it’s possible, please mention some guide how to install/create hw button to turn on/off wifi in case it’s not needed (night/sleeping radiation). Thank you
Hints for the functional part:
For the hardware part there is an extension connector. Connecting buttons to it is possible. Adding these to the system may require changes to boot files (Device Tree).
Omnia already have HW button.
Care to elaborate?
Is the button you are stating to be present a dedicated button to turn on/off the WiFi? And / or is it programmable?
How do you know this (any source documentation you could refer to)?
What about to assign toggle wifi on/off function to a long press of the button for adjusting LEDs brightness? Is there some easy way how to do that?
I was looking for existing solution how to turning on and off wifi, but wasn’t successful. So I decided to make it myself. OpenWRT wiki helped me so much, especialy https://wiki.openwrt.org/doc/hardware/port.gpio#script_blink. Here is result:
Controller is compound of button and LED. I have used 1state button, which is connected to GPIO56. LED is used only for current wifi status - connected to GPIO51. Scheme of soldering (sorry, I am not electrician):
2state button (switch) would work better (and GPIO51 could be spared). My solution has one advantage - I could measure button-press time and use only one button for more actions and LED could indicate different status (than wifi).
I wrote script, that check if button is pressed and then turn on or off wifi. Script was added into /etc/rc.local (so button works after Omnia reboot).
#which GPIOs are used BUTTON_GPIO=56 LED_GPIO=51 #init GPIOs if [ -e /sys/class/gpio/gpio$BUTTON_GPIO ]; then echo "GPIO$BUTTON_GPIO has been initialized yet" else echo "Initializing GPIO$BUTTON_GPIO" echo "$BUTTON_GPIO" > /sys/class/gpio/export echo "in" > /sys/class/gpio/gpio$BUTTON_GPIO/direction fi if [ -e /sys/class/gpio/gpio$LED_GPIO ]; then echo "GPIO$LED_GPIO has been initialized yet" else echo "Initializing GPIO$LED_GPIO" echo "$LED_GPIO" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio$LED_GPIO/direction fi while true; do #check GPIOs state in=`cat /sys/class/gpio/gpio$BUTTON_GPIO/value` out=`cat /sys/class/gpio/gpio$LED_GPIO/value` #if button is pressed if [ $in -gt 0 ] ; then #and LED (and wifi) is off if [ $out -lt 1 ] ; then # then turn on LED and wifi echo "1" > /sys/class/gpio/gpio$LED_GPIO/value wifi else # else turn wifi off (so as LED) echo "0" > /sys/class/gpio/gpio$LED_GPIO/value wifi down fi fi sleep 1 done
There are glitch of course - LED doesn’t glow after reboot (altough wifi is working), - so wifi status could be find out from wifi utility, etc. Hope this helps someone.
My idea is to have a secured SSH access to my router and thus send toggle commands. This way I can even toggle it on/off when on the go or on the way home. I will be trying to flesh out this idea in the near future and post results here.
Is future version of turris going to fix this? Will it have some HW button to turn off wifi? If yes, when it can go out? If not, why? Thanx for cool device and good luck with similar projects!
I think this button isn’t that important at all. What does a button do? Initiate a SOFTWARE command. That’s it. I THINK a script like @j0n4s82 said is more of a solution then a hardware button.
on one side i fully agree. especially it is easy to turn it off by this way. but consider turning it on… wifi is off. what choices are you left?
hahahah, i am trying to think of ways and every time i stop because it uses WiFi XD. The only solution is having a computer that is connected by cable.
And what about tweaking the existing LED button (e.g. long press would toogle wifi down/wifi up command)? I’m just beginner but there should be a way to do that based on what I’ve read so far.
When you have secured remote SSH access to your router and a phone with mobile internet you can switch it on and off as often as you like from wherever you like.
There is a scriptfile called
root@turris:/etc/config# opkg info wifitoggle Package: wifitoggle Version: 1-5 Depends: libc Status: install user installed Section: utils Architecture: mvebu Maintainer: Nuno Goncalves <email@example.com> MD5Sum: d72a5431212b0101fd6251add38ce25c Size: 2676 Filename: wifitoggle_1-5_mvebu.ipk Conffiles: /etc/config/wifitoggle bdec7eb3b8288ed93a30c556b8f2d37347dfc3f8cb836bc16cf2395e99d7d688 Source: feeds/packages/utils/wifitoggle Description: Very versatile script to toggle Wi-Fi with a button. Allows to set timeouts, persist changes after boot, and set LEDs according to the state. Installed-Time: 1481782577
For this to work, however, you have to identify the button label to put in the script and if you want to use the backbutton of the router, you need to change its default behavior to a save setup that won’t let you accidentally reboot or reset the router.
Secure SSH is no problem.
I have 4 heavy weight devices - all connected by cable, but headless (servers) or to “heavy” (PCs) to start just because to ssh to router. Then I have 3 devices connected by wifi. Unluckily, no mobile net connected device. The wifi devices are on pretty seldom. (thats why I need wifi off separately)
Well my wife (unlike me) have some kind of smarter dumb phone, which I will be able to borrow to turn the wifi on (If I buy her data tariff). A bit of fun isn’t it?-)
So there is excuse on my side(not heaving mobile net) and excuse on otherside (not heaving on/off hw switch). Maybe you can start sold the button separately I would get one
Why not build it yourself? See abe’s post above for more information.
yup. led button (which is very cool!) missuse or similarly on/off/reboot button misuse is well acceptable. maybe next turris can hsve two or more no-op-bydefault, programmable buttons?
thats worthy to look into.ty!
You are welcome. If you happen to come up with a working solution using that script, let me know. I haven’t had the time and patience to tinker with it.