-->
Page 1 of 2

Trying to check if my provider's modem hangs ....

PostPosted: Mon Aug 22, 2016 8:19 pm
by aphawk
Sometimes, my modem hangs, and I loose Internet connection. Only turning it off and on again makes the connection start.

I'm writing a small program to put in my ESP8266 to check if the modem hangs, trying to get access to some site, or service, or anything else that can be checked. Then my ESP8266 will turn off the modem, and turn on again to correct the situation.

First, I try to use the ThinkSpeak, but when my modem is hanged the program waits forever for the answer ..... this obviously don't works well.

Someone can give me some idea ?

Something that returns information that I can test to know if I have Internet connection or not...
I'm using 3.0 Branch.

Thanks a lot !

Paulo

Re: Trying to check if my provider's modem hangs ....

PostPosted: Fri Aug 26, 2016 12:18 am
by forlotto
You could use wget to get a web page and check it for page cannot be displayed error and restart if true or posssibly javascript and an iframe to do the same thing.

Re: Trying to check if my provider's modem hangs ....

PostPosted: Sun Aug 28, 2016 6:58 am
by aphawk
My program runs ok, but only for some hours.... then the output goes OFF, and the program stops .... I don't know why .... maybe a memory bug ?

The purpose is checks communication at each 20 seconds. At each time the result is posted in browser as a debug. If fails 3 consecutive times, the relay power goes OFF for some seconds, then goes ON again, and wait for some minutes to start the tests again.

What I'm making wrong here ?

Code: Select allmemclear
cls
io(po,2,0)
p = 0
error = 0
onoff = 0
timer 20000, [testa]
button "ON", [liga]
button "OFF", [desliga]
wprint "<br>"
wait

[testa]
Traw = wget("tycho.usno.navy.mil/timer.html")
p = instr(Traw,"Universal Time")
if p = 0 then
  error= error + 1
else
  error = 0
end if
if error > 2 then
  timer 0
  io(po,2,1)
  delay 3000
  io(po,2,0)
  onoff = onoff + 1
  wprint "<br>"
  wprint "Reboot : "
  wprint onoff
  wprint "<br>"
  delay 180000
  timer 20000, [testa]
end if
if error = 0 then
  wprint " Ok "
else
  if error < 3 then
    wprint " Error : "
    wprint error
    wprint " "
  endif
endif
if error > 2 then
  error=0
endif
wait

[liga]
io(po,2,0)
wprint " Power ON "
wait

[desliga]
io(po,2,1)
wprint " Power OFF "
wait

end



Paulo

Re: Trying to check if my provider's modem hangs ....

PostPosted: Sun Aug 28, 2016 12:48 pm
by aphawk
I modified a little the program, to show how many times the program runs before stops.

Follow the code :

Code: Select allmemclear
cls
io(po,2,0)
p = 0
tests = 0
error = 0
onoff = 0
timer 20000, [testa]
button "ON", [liga]
button "OFF", [desliga]
wprint "<br>"
wait

[testa]
tests = tests + 1
Traw = wget("tycho.usno.navy.mil/timer.html")
p = instr(Traw,"Universal Time")
if p = 0 then
  error= error + 1
else
  error = 0
end if
if error > 2 then
  timer 0
  io(po,2,1)
  delay 3000
  io(po,2,0)
  onoff = onoff + 1
  wprint "<br>"
  wprint "Reboot : "
  wprint onoff
  wprint "<br>"
  delay 180000
  timer 20000, [testa]
end if
if error = 0 then
  wprint " Ok-"
  wprint tests
  wprint " "
else
  if error < 3 then
    wprint " Error : "
    wprint error
    wprint " "
    wprint tests
    wprint " "
  endif
endif
if error > 2 then
  error=0
endif
wait

[liga]
io(po,2,0)
wprint " Power ON "
wait

[desliga]
io(po,2,1)
wprint " Power OFF "
wait

end


For 3 times, the program stops when complete 312 times the testings..

Maybe some bug in memory management ?

Paulo