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:
2023-10-18 06:18:37 -06:00
parent 8d51e36ce4
commit c9fec07fc3
7 changed files with 86 additions and 10 deletions

View File

@@ -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