ericpaulbishop / gargoyle

Gargoyle Router Management Utility
http://www.gargoyle-router.com
469 stars 221 forks source link

Add missing button handlers for Archer C5/C7 family #681

Closed d3fz closed 6 years ago

d3fz commented 6 years ago

Currently there are no button handlers (reboot/failsafe reset/wifi toggle) for the Archer C5/C7. Since that's a pretty well known router nowadays (i own one, btw) and works great with Gargoyle, that's a useful feature to have.

config button 'reboot_button'
   option button 'reset'
   option action 'released'
   option handler 'logger reboot ; /usr/lib/gargoyle/reboot.sh ;'
   option min '3'
   option max '10'

config button 'reset_button'
   option button 'reset'
   option action 'released'
   option handler 'logger restore defaults ; /sbin/firstboot -y; reboot ;'
   option min '11'
   option max '90'

config button 'wifi_on'
   option button 'rfkill'
   option action 'pressed'
   option handler 'logger wifi up ; wifi up ;'

config button 'wifi_off'
   option button 'rfkill'
   option action 'released'
   option handler 'logger wifi down ; wifi down ;'
lantis1008 commented 6 years ago

I didn’t think wifi down was valid anymore. I thought the command took no parameters and required you to set the Disabled option per iface. Hence the requirement for complicated wifitoggle scripts

d3fz commented 6 years ago

That's unfortunate. As per this thread, I thought that was a valid solution. Is there any workaround other than complicated scripts?

Not big of a problem if there's not. Reboot/Failsafe reset could be useful, though.

lantis1008 commented 6 years ago

I’d have to test it again but I thought it wasn’t anymore. Toggle scripts aren’t that hard to create, and including one in Gargoyle that is generic is probably a good idea.

lantis1008 commented 6 years ago

Looks like potentially “wifi down” works. But wifi up should just be “wifi”

d3fz commented 6 years ago

That's good news. Thanks for looking into it.

lantis1008 commented 6 years ago

can you post the contents of /proc/cpuinfo please?

d3fz commented 6 years ago

Sure.

system type     : Qualcomm Atheros QCA9558 ver 1 rev 0
machine         : TP-LINK Archer C7
processor       : 0
cpu model       : MIPS 74Kc V5.0
BogoMIPS        : 358.80
wait instruction    : yes
microsecond timers  : yes
tlb_entries     : 32
extra interrupt vector  : yes
hardware watchpoint : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa         : mips1 mips2 mips32r1 mips32r2
ASEs implemented    : mips16 dsp dsp2
shadow register sets    : 1
kscratch registers  : 0
package         : 0
core            : 0
VCED exceptions     : not available
VCEI exceptions     : not available
lantis1008 commented 6 years ago

Should be taken care of now. I didn't add wifi toggling for the moment. End user can add that for now. I have mimicked the behaviour gargoyle already had in place.

d3fz commented 6 years ago

That's great. Quick question though:

Archer C5/C7 doesn't have a WPS button, only RESET and RFKILL, as shown below by issuing cat /sys/kernel/debug/gpio

  GPIOs 0-23, ath79:
 gpio-12  (tp-link:blue:wlan2g ) out lo    
 gpio-13  (RFKILL switch       ) in  lo    
 gpio-14  (tp-link:blue:system ) out lo    
 gpio-15  (tp-link:blue:qss    ) out hi    
 gpio-16  (Reset button        ) in  hi    
 gpio-17  (tp-link:blue:wlan5g ) out lo    
 gpio-18  (tp-link:green:usb1  ) out lo    
 gpio-19  (tp-link:green:usb2  ) out lo    
 gpio-21  (USB2 power          ) out hi    
 gpio-22  (USB1 power          ) out hi    

Will the default script address both actions (reboot/failsafe reset) to the reset button?

For reference, this /etc/config/system on my WR842ND (running 1.10), which has both wps/reset buttons.

config button 'reboot_button'
   option button 'wps'
   option action 'released'
   option handler 'logger reboot ; /usr/lib/gargoyle/reboot.sh ;'
   option min '3'
   option max '90'

config button 'reset_button'
   option button 'reset'
   option action 'released'
   option handler 'logger restore defaults ; /sbin/firstboot -y; reboot ;'
   option min '3'
   option max '90'
lantis1008 commented 6 years ago

It handles rfkill properly 👍 and will split the tasks across the buttons

d3fz commented 6 years ago

Forgot to mention that on C7, RFKILL is actually a switch, not a button. That's why i asked about tasks distribution. However, on the C5, RFKILL is a button. TP-LINK, makeup your mind...

lantis1008 commented 6 years ago

By default it probably won’t do anything without fixing gpio pins. I don’t have a device to test switching with. It will still have a hi/lo so it should behave correctly.

lantis1008 commented 6 years ago

please test with latest code and we can maybe close this