Edited... Server Sent Events help needed on Particle.subscribe and Particle.publish


#1

I am trying get Server Sent Events SSE working so I can send temperature readings and parameters up to Firebase more frequently than the 10/minute limit with webhooks which I have all working today… frequently I get “…integration limits exceeded…” So, I have followed the instructions to setup a particle–>Firebase proxy per instructions here: https://github.com/jychuah/particle-firebase-proxy … I have my heroku proxy responding to a URL so I know my firebase connection is working…good there.

if you hit this link you’ll get my data payload for my parameters tree in Firebase

(https://mysterious-crag-77648.herokuapp.com/ControllerOwners/Pellet_Pirate_1/Parameters.json?device_id=400027001647353236343033&particle_token=65c338855e4478d309aaf0f239ea7be76d18d797)

My problem is I can’t write my temperatures out to Firebase… and I think my problem is my Particle.subscribe and Particle.publish code. I can’t figure out how to convert my current pure webhook to the SSE variant of the webhook the webhook. below). Here’s what I have for the webhook:

{
    "event": "TempsHookBody",
    "url": "https://mysterious-crag-77648.herokuapp.com/ControllerOwners/{{n}}/Temps.json&event_type=value",
    "requestType": "POST",
    "noDefaults": true,
    "rejectUnauthorized": true,
    "query": {
        "device_id": "400027001647353236343033",
        "particle_token": "65c338855e4478d309aaf0f239ea7be76d18d797"
    },
    "body": "{\"T1\": {{T1}}, \"T2\": {{T2}}, \"T3\": {{T3}}, \"TT\": {{TT}}, \"time\": {{time}} }"
}

In my variables area, I have the definition

const char *PUBLISH_TEMPS =“TempsHookBody”;

… after I read my 3 temps from my probes, I write them out via Particle.publish

   char qT[128];
   snprintf(qT, sizeof(qT), "{\"T1\":%.6f,\"T2\":%.6f,\"T3\":%.6f,\"TT\":%.0f,\"time\":%.0f,\"n\":\"%s\"}", T1, T2, T3, TT, time, deviceName.c_str());
   Particle.publish(PUBLISH_TEMPS, qT, PRIVATE);

So here’s where I need some guidance…
for SSE, I believe i need to code the:

Particle.subscribe("value", handlerFunction);

how would I go about coding the handlerFunction to generate the qT json string as my webhook code does above?

based on the webhook code above, I think my publish statement would be:
Particle.publish("TempsHookBody");

thanks or for any help,
Brian