I'm trying to add a new device to OpenWRT, the ZyXel NBG6503.
I am close to having everything working, but WIFI on/off button is giving me some problems.
This button is a latching switch (when pressed it stays pressed even when you take your finger off the button, and when released it stays released).
When I look at /etc/rc.button/rfkill it only does something when ACTION=pressed.
Ideally I would enable wifi when ACTION=pressed, and disable wifi on ACITON=released.
What's the best way to implement this?
Also, can I get OpenWRT to check the status this button on boot (so wifi status matches the button)?
a latching switch releases when pressed a second time
Exactly. I was trying to explain how it worked in case anyone was in doubt. Maybe I didn't do a good job at that.
I just wanna know how to properly implement this on a latching switch. Surely I can't be the first to encounter this problem..
store the state in /tmp and case the hotplug action dependant on 'laststate' ( with a handler for 'nostate' condition aka bootup )
Thanks, makes sense.
Does this require me to write my own /etc/rc.buttons/rfkill script?
If so, how do i make sure it gets added to the image I build for my device (and not for every device out there) ?
What's the best way to have the rfkill script run on boot ?
It's only a problem if it's defined as a 'button'... you may wish to modify your dts to something more suitable;
linux,code = <KEY_RFKILL>;
linux,input-type = <EV_SW>;
when building add it to './files/etc/rc.button/' ( non-official support )...
for official support you'd fix dts and expand the rc.button if needed... ( rfkill has switch support so I'm not sure why this isn't working for you )
Same thing with the NBG6817.
EV_SW is definitely the right thing to do, but it only solves half of the issue: e.g. if you enable / disable WiFi via WebGUI, the switch and actual state of WiFi are not in sync anymore. It's pretty much a hardware-limitation, but at the same time, I'd expect the WiFi to stay disabled, when the WiFi is disabled and the user pushes WiFi switch to "Disable WiFi" position.
It would be a trivial fix, if we had e.g.
KEY_WIFI_ENABLE, emitting seperately at switch ON / OFF positions. Instead, we have a toggle-style