B4R Question Getting same response with http post method with my Esp8266 12E

embedded

Active Member
Licensed User
Longtime User
I am trying to on off a led from my webpage...so I write a PHP script which make changes in a JSON file "lightn" or "lightff" when I press on or off button from my webpage.
Here every thing is fine and works smoothly.
When I read JSON file using esp8266 every minute....I get response .But this response is repeated again and again..while I make change in JSON file by pressing button...which is also confirm by reading JSON file from browser.
If I power off esp8266...then after power up first response is ok...next response after a minute...same.
I think may be some problem with response cache which is set to 5000..How we clear this response cache when we start post method again.
Please help...
 

embedded

Active Member
Licensed User
Longtime User
Thanks peter. for reply..here is my code
http post esp8266:
#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
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…