Jump to content



Photo

Reset Router with POST


  • Please log in to reply
3 replies to this topic

#1 mikeytown2

mikeytown2

    Polymath

  • Active Members
  • PipPipPipPip
  • 210 posts

Posted 07 November 2008 - 12:12 AM

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.

AutoIt         
;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
  • syk3s likes this







#2 spudw2k

spudw2k

    i dunno what i'm doing

  • Active Members
  • PipPipPipPipPipPip
  • 1,154 posts

Posted 07 November 2008 - 12:37 AM

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

#3 mikeytown2

mikeytown2

    Polymath

  • Active Members
  • PipPipPipPip
  • 210 posts

Posted 07 November 2008 - 01:45 AM

yeah I gave the latest version of Tomato a try, but i couldn't get it to connect to my TEW-432BRP. Anyway the DD-WRT wiki is very helpful and answers just about any how to question.

#4 Armand

Armand

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 541 posts

Posted 12 November 2008 - 07:36 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users