#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 600
#End Region
Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
Private wificli As WiFiSocket
Private astream As AsyncStreams
Private EOL() As Byte = Array As Byte(13, 10)
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
If wifi.Connect2("MADHU","xxxxxxxx") Then
Log("Connected to router.")
Else
Log("Failed to connect to router.")
Return
End If
'HttpJob.Initialize("Example")
'HttpJob.Download("https://www.example.com")
wificli.ConnectHost("api.thingspeak.com",80)
If wificli.Connected Then
Log("Connected to Thingspeak Successfully!!!") <=== Here the message is coming as success
Else
Log("Failed To connect Thingspeak!!")
End If
Send_data
End Sub
'Sub JobDone (Job As JobResult)
' Log("*******************************")
' Log("JobName: ", Job.JobName)
' If Job.Success Then
' Dim bc As ByteConverter
' Log("Response: ", bc.SubString2(Job.Response, 0, Min(200, Job.Response.Length))) 'truncate to 200 characters
' If Job.JobName = "Example" Then
' 'send another request
' 'This time it is a POST request and we set the Content-Type header
' HttpJob.Initialize("Example2")
' 'add headers before calling Post or Download (this is different than the standard HttpUtils2).
' HttpJob.AddHeader("Content-Type", "application/x-www-form-urlencoded")
' HttpJob.Post("https://www.b4x.com/print.php?key1=value1", "PostKey1=PostValue2&abc=def")
' 'HttpJob.Download("https://api.thingspeak.com/update?api_key=L74M50W92G0TPRDZ&field1=39")
'
' End If
' Else
' Log("ErrorMessage: ", Job.ErrorMessage)
' Log("Status: ", Job.Status)
' Log(Job.Response)
' End If
'End Sub
Private Sub Send_data
astream.Write("https://api.thingspeak.com/update?api_key=L74M50W92G0TPRDZ&field1=39").Write(EOL)
End Sub