mirror of
https://github.com/KeymonSoft/Monitor-Keymon.git
synced 2026-04-17 21:06:19 +00:00
18/10/23 - Se agregó que el monitor haga un ping a la IP 8.8.8.8 e indique el resultado
This commit is contained in:
@@ -446,3 +446,31 @@ Sub notiLowReturn(title As String, Body As String, id As Int) As Notification 'i
|
||||
Return notification
|
||||
End Sub
|
||||
|
||||
Sub ping
|
||||
Private ph As Phone
|
||||
Wait For (ph.ShellAsync("ping", Array As String("-c 1","-W 5", "8.8.8.8"))) Complete (Success As Boolean, ExitValue As Int, StdOut As String, StdErr As String)
|
||||
If Success Then
|
||||
' Log("ExitValue:" & ExitValue)
|
||||
' Log("StdError:" & StdErr)
|
||||
Private res() As String = Regex.Split(",", StdOut)
|
||||
For i = 0 To res.Length - 1
|
||||
If res(i).Contains("1 received") Then
|
||||
If Starter.logger Then LogColor(">>> HAY CONEXION", Colors.Green)
|
||||
Starter.ping = True
|
||||
Else If res(i).Contains("0 received") Then
|
||||
If Starter.logger Then LogColor(">>> NO HAY CONEXION", Colors.Red)
|
||||
Starter.ping = False
|
||||
End If
|
||||
' Log(res(i))
|
||||
Next
|
||||
' LogColor("StdOut: " & res, Colors.Blue)
|
||||
If B4XPages.IsInitialized Then B4XPages.MainPage.cb_internet.Checked = Starter.ping
|
||||
If Not(Starter.ping) Then
|
||||
If Starter.logger Then Log("Sin conexión a Google!!!")
|
||||
notiLowReturn("SIN INTERNET ❌", "NO hay conexion a Google.", Monitor.nid)
|
||||
If B4XPages.IsInitialized Then B4XPages.MainPage.l_status.Text = "NO hay conexión a Google!!"
|
||||
End If
|
||||
Else
|
||||
Log("Error: " & LastException)
|
||||
End If
|
||||
End Sub
|
||||
Reference in New Issue
Block a user