Timer for key-switch VPN enable

I would like the key input on the FLEXY to enable VPN access for a defined period of time then automatically shut off.

I can achieve this by wiring the key switch to a physical off delay timer, but I’m wondering if this could be accomplished in FLEXY scripting alone.

@Roth_Brent

Yes you can absolutely handle the on-off status with the Flexy scripting engine. Essentially we would just need a timer and a tag that would watch for the digital input switch.

INIT Section:
d% = 600 REM 10 minutes (value in seconds)
ONCHANGE "Switch","goto DoSwitch"


EnableVPN:
rem  Enable VPN
if Switch@ <> 0 THEN
    TSET 1, d% 
    ONTIMER 1, "goto DisableVPN" REM call our disable vpn function after 10 minutes
    Setsys COM,"load"
    Setsys COM,"VPNCnxType","2"
    Setsys COM,"save"
    Print Time$;" Connection opened"
ENDIF

DisableVPN:
rem  Close vpn connection
Setsys COM,"load"
Setsys COM,"VPNCnxType","0"
Setsys COM,"save"
Print Time$;" Connection closed"
TSET 1, 0 REM disable our timer
3 Likes