iOS Question httpJob GET events

Status
Not open for further replies.

alizeti

Member
Licensed User
I'm having issues with the httpJob library

I have no problems in reading variables from the cloud using GET and call function from the cloud using POST.

The problem is when I want to get EVENTS from the cloud. Can’t make it work.
I use the same function as for reading variable (GET) but it doesn’t work.

This is what I send using the GET :
http = "https://api.particle.io/v1/devices/DEVICE_ID/events?access_token=MY_TOKEN"
jobGet.Download(http)

From Particle io reference documentation :
Definition
GET /v1/events/:eventPrefix

Example request :
curl "https://api.particle.io/v1/events/temp?access_token=1234"

Example Response:
GET /v1/events/temp
HTTP/1.1 200 OK
:eek:k

event: temperature
data: {"data":"25.34","ttl":"60","published_at":"2015-07-18T00:12:18.174Z","coreid":"0123456789abcdef01234567"}


If I do it on terminal, it works.
On B4I, i doen't work.

Any idea?

If I execute the exact same command on my windows terminal, it works. I see my event when it occurs.
 

alizeti

Member
Licensed User
By the way, doing some test and I have another problem.

I I do like you guys suggest me for the jobDone callback to not be global, it does not work any more in release mode.
If I go into debug mode, it work only if I put a brake point anywhere in the manualControl function. Otherwise, nothing happens and not even the "job failed" log.
It just don't do anything.

B4X:
Private Sub manualControl (zone As String, controlPin As String, state As Int)
   
    Dim jobPost As HttpJob
   
    jobPost.Initialize("jobPost", Me)
   
    currentState = MANUAL_MODE
    If state == 1 Then
        'not activate, so need to activate
        jobPost.PostString("https://api.particle.io/v1/devices/" & deviceName & "/zoneCtrlId", "access_token=" & accessToken & "&params=" & controlPin & "," & ON)
        manControlFlag = True
    Else If state == 0 Then
        'not activate, so need to activate
        jobPost.PostString("https://api.particle.io/v1/devices/" & deviceName & "/zoneCtrlId", "access_token=" & accessToken & "&params=" & controlPin & "," & OFF)
        manControlFlag = False
    End If
   
   
    Wait For (jobPost) JobDone(jobPost As HttpJob)
    If jobPost.Success = True Then
        Log(jobPost.GetString)
        cloudRx = jobPost.GetString
        updateState
        Log("result from Post is : " & result)
    Else
        Log("job failed")
    End If
   
    jobPost.Release
End Su
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
In the IDE, select "Clean project" under the Tools menu. Also, change
B4X:
jobPost.Initialize("jobPost", Me)
to
B4X:
jobPost.Initialize("", Me)
and see if anything changes.
 
Upvote 0
Status
Not open for further replies.
Top