Jump to content

Reset Router with POST


mikeytown2
 Share

Recommended Posts

I have a very cheap Access Point/Router (Trendnet - TEW-432BRP). The wireless gateway stops working after some time, reseting it works. I have a wireless link between this and my Linksys WRT54G running DD-WRT. Using this script I reset my Trendnet router when the wireless link fails.

;Load http.au3
#include "HTTP.au3"

;Set Parameters
$RemoteIP = "192.168.3.2"
$LocalIP = "192.168.3.1"
$TelnetPort = 23
$SleepTime = 15 * 60 * 1000 ;15 minutes
$ResetTime = 5 ;reset router at 5am
$ResetBool = False
Opt("TrayIconHide", 1)
Opt("TrayIconDebug", 1) 

;Run Loop
While 1
    ;Reset Router at the time set no matter what
    If @HOUR == $ResetTime And $ResetBool == False Then
        ResetRouter($LocalIP)
        $ResetBool = True
    Else
        $ResetBool = False
    EndIf
    Sleep(60 * 1000) ; wait one minute
    
    ;Check Wireless Connection
    $RemoteConnectionOK = CheckRemoteRouter($RemoteIP, $TelnetPort)
    If Not $RemoteConnectionOK Then
        ResetRouter($LocalIP)
    EndIf
    
    ;Put Program To Sleep
    Sleep($SleepTime)
WEnd


Func ResetRouter($IP)
    $host = "http://" & $IP & "/"
    $page = "/restart.cgi"
    $data = "restart=Restart"
    $socket = _HTTPConnect($IP)
    _HTTPPost($host, $page, $socket, $data, "admin", "admin")
EndFunc   ;==>ResetRouter

Func CheckRemoteRouter($IP, $Port)
    TCPStartup()
    $socket = TCPConnect($IP, $Port)
    TCPShutdown()
    If $socket = -1 Then
        Return False ;connection bad
    Else
        Return True ;connection good
    EndIf
EndFunc   ;==>CheckRemoteRouter

Get #include "HTTP.au3" from here, with my mod at the last post.

http://www.autoitscript.com/forum/index.php?showtopic=29631

http://www.autoitscript.com/forum/index.ph...mp;#entry601371

Link to comment
Share on other sites

Link to comment
Share on other sites

Link to comment
Share on other sites

nice, I'll add it to my Reconnection utility.... :mellow:

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...