#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 600
#End Region
Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
Private tmr As Timer
Private ledpin As Pin
Dim mystring(2) As String
'Dim mystring(1) As String
Dim num As UInt
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
mystring(0)="one"
mystring(1)="two"
num=0
ledpin.Initialize(13,ledpin.MODE_OUTPUT)
If wifi.Connect2("JioFi2","virus123") Then
Log("Connected to router.")
tmr.Initialize("tmr_Tick",30000)
tmr.Enabled=True
Else
Log("Failed to connect to router.")
Return
End If
End Sub
Sub tmr_Tick
Log("timer ticking")
If num=0 Then
HttpJob.Initialize("one")
num=1
HttpJob.Download("http://xxx.in.net/light.json")
Else
HttpJob.Initialize("two")
num=0
HttpJob.Download("http://xxx.in.net/light.json")
End If
tmr.Enabled=False
Log("timer disable")
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
Else
Log("ErrorMessage: ", Job.ErrorMessage)
Log("Status: ", Job.Status)
Log(Job.Response)
End If
tmr.Enabled=True
Log("timer enable")
End Sub