#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 2000
#End Region
Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
Public Fichero_P As String = "Parametros.CSV"
Dim bc As ByteConverter
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("****************************")
Log("Inicia Aplicacion")
Conecta_Wifi(0)
End Sub
Sub Conecta_Wifi(Nada As Byte)
wifi.ConnectAsync("", "", 0, Null, "wifi_Connected")
End Sub
Sub WiFi_Connected (Success As Boolean)
If Success = True Then
Log("Conectado !!!")
Else
Log("No conectado, se reintenta")
wifi.Disconnect
CallSubPlus("Conecta_Wifi",5000,0)
End If
If Success = True Then
HttpJob.Initialize("Paso_000")
HttpJob.Download("
http://ota-puerta.000webhostapp.com/")
End If
End Sub
Sub JobDone (Job As JobResult)
Log("*******************************")
Log("Nombre del Paso : ", Job.JobName)
If Job.Success Then
Log("Response: ", bc.SubString2(Job.Response, 0, Min(20, Job.Response.Length))) ' Limita a 20 Caracteres
If Job.JobName = "Paso_000" Then
HttpJob.AddHeader("Content-Type", "application/x-www-form-urlencoded")
HttpJob.Post("
http://www.b4x.com/print.php?key1=value1", "PostKey1=PostValue2&abc=def")
HttpJob.Initialize("Paso_001") ' Envia Fichero Parametros
End If
Else
Log("ErrorMessage: ", Job.ErrorMessage)
Log("Status: ", Job.Status)
Log(Job.Response)
End If
End Sub