“You, thunderstorm, threaten, and we hold on to each other!” - tale about how I saved the ADSL modem
"The modem is on, The provider is crying. But he could not do otherwise. Thunder rattles ... "
Thunderstorm! Element! Guard! Sometimes it is hard to predict how much damage it can do to home electronics ... Fortunately, it can be prevented, thereby eliminating the possibility of failure of, say, home routers and modems - they are usually primarily affected by violent phenomena of nature.
')
Over the past summer, I have buried two modems at all - the sharp drops in the power supply network caused them to die. In the same year, I finally had the courage to break this vicious circle and try to save poor D-Link from premature death!
The most rational solution would be to just occasionally glance in the window and in case of a thunderstorm approach, disconnect the modem from the power supply network in advance; but what if sometimes you have to leave your house for a long time, and your relatives don’t know what to do, where to press and what to switch in case of a thunderstorm?
That's it! That's why I thought that it would be nice to build some kind of EAS (Emergency Alert System) for the house, with a squeak, a warning on TV and other trinkets.
For a start, I sketched out two simple little sheets that could be used to realize my plans. The first is how to get the current weather code for the EAS client; the second is what should be displayed on the TV screen.
First
and
The second
But, as they say in one well-known proverb, “soon the fairy tale is affected, but it is not done soon”. I thought for a long time, how will I get an alert on TV; continually postponing the implementation of the project for later, but then “later” it came unexpectedly — in the head, an extremely simple idea arose of how to deal with this problem.
The solution was to turn the Raspberry Pi B + into an EAS client by launching the epiphany browser in kiosk mode. The browser clings to the local web server, which, in turn, returns the following code:
... <scripttype="text/javascript"> setInterval('window.location.reload()', 60000); </script> ... <?phpif( !is_available( $home_server ) ) { echo'<center><div class="center"><h1>The EAS server is offline...</h1><center><p>An attempt to reconnect to the server will be performed in 60 seconds</p></center></div></center>'; } else { echo'<iframe src="http://podivilov.local/api/method/EAS.getCode/" style="position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;">Iframe does not supported by this browser...</iframe>'; } ?> ...
Thus, thanks to the simple js-script and the iframe tag, we created a crutch and burdened ourselves with unnecessary problems made our lives easier; because if the home server is unavailable due to the fact that it was turned off before a thunderstorm, the browser will not issue a standard error, they say, “alas, there’s no more access to the network” (and will wait for a long time until someone deigns to poke a mouse button "refresh page"), but just continue to update the page every minute and try to load the contents of the iframe.
But let's not get so far ahead, let's see how the EAS-client works from the inside; to be more precise, how does the download:
Start OS (raspbian)
Accessing the /etc/rc.local script
Initializing X's with xinit
Browser launch
Connect to server
Receive and output data
The /etc/rc.local script differs from the original one single line:
And the /home/eas/eas.boot script is responsible for launching the browser:
#!/bin/sh ## DPMS xset -dpms ## xset s off ## xset s noblank ## matchbox-window-manager -use_titlebar no & ## unclutter -idle 0.01 -root & ## kiosk- WEBKIT_DISABLE_TBS=1 epiphany-browser -a http://podivilov.local/ --profile /home/eas/.config
Our browser accesses the home server, denoted as podivilov.local; the same, in turn, requests weather data from the external server, default and extra codes (default is an integer, zero or one; null - EAS is not activated, one is activated; extra is a weather code obtained from the weather forecast site, required for debugging).
The extra-code received by the server is processed by passing through several conditions, and at the output we get a code that can already be used to prevent potential burning out of the modem and other household appliances.
Depending on the weather conditions and the received code, our system displays various sets of numbers: for example, if a strong thunderstorm is expected and you should turn off the No. 1 plugs (router / modem) together with No. 2 (other household appliances), and also manually release the ADSL- port on the modem (in order to prevent possible burnout of the port), the EAS-system displays the code 12 (plug number 1 and number 2).
Traffic jams are numbered;the decryption of codes hangs on the switchboard
In addition, every half hour on home computers, the task manager runs the following script (it polls the server if a thunderstorm is expected; if the answer is positive, a program is launched warning of a possible cataclysm):
dim xHttp: Set xHttp = createobject("MSXML2.ServerXMLHTTP") xHttp.Open "GET", "https://***.podivilov.ru/api/method/weather.getCode/?token=*****", False xHttp.setOption 2, 13056 xHttp.Send If xHttp.responseText = "1"ThenSet objShell = CreateObject("WScript.Shell") objShell.Run """C:\\\\EAS.exe"""Set objShell = NothingElse WScript.Quit EndIf
But, you see, it is better to see once than to hear a thousand times. Actually, before you is the result of what the story was told above:
Here and the fairy tale is over, and who listened - well done ... Take care of yourself and your modems!