Jump to content
Sign in to follow this  

Reset Router with POST

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 = ""
$LocalIP = ""
$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
        $ResetBool = True
        $ResetBool = False
    Sleep(60 * 1000) ; wait one minute
    ;Check Wireless Connection
    $RemoteConnectionOK = CheckRemoteRouter($RemoteIP, $TelnetPort)
    If Not $RemoteConnectionOK Then
    ;Put Program To Sleep

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)
    $socket = TCPConnect($IP, $Port)
    If $socket = -1 Then
        Return False ;connection bad
        Return True ;connection good
EndFunc   ;==>CheckRemoteRouter

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



Share this post

Link to post
Share on other sites

Pretty cool there mate. I like. Ever hear of or use Tomato, another alternate firmware for router devices? It's very nice.

Share this post

Link to post
Share on other sites

Share this post

Link to post
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 ?!

Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...