problem: recently updated to OS 2.0.0 with JSONParserGeneratorRK(0.1.3) and I’m having trouble grabbing the key “name” from the “hook-response/InitialParamWrite” getKeyHandler publish event. As you can see in the picture, my Integration is working correctly, doing the initial write and firing the webhook response but it’s like my getKeyHandler function never fires… in my logs, I get the TWO log-info from InitialParametersWrite() but never get the Log.info from getKeyHandler.
I’m not sure what to try at this point, any guidance would be appreciated.
thanks,
Brian
Particle.subscribe("hook-response/InitialParamsWrite", getKeyHandler);
void InitialParametersWrite() {
char qPP[512];
snprintf(qPP, sizeof(qPP), "{\"key\":\"%s\",\"ndex\":%d,\"Cyc\":%d,\"PB\":%d,\"PMode\":%d,\"PTog\":%.1f,\"Td\":%d,\"Ti\":%d,\"fan\":%s,\"ign\":%s,\"aug\":%s,\"mode\":\"%s\",\"pgm\":%s,\"target\":%d,\"u\":%.2f,\"n\":\"%s\"}",
controller, ndex, Cyc, PB, PMode, PTog, Td, Ti, fan ? "true" : "false", ign ? "true" : "false", aug ? "true" : "false", mode, pgm ? "true" : "false", target, u, deviceName.c_str());
Particle.publish(INITIAL_PARAMS_WRITE, qPP, 60, PRIVATE);
// remember this publish event triggers the web-hook response for the parameters Key that is returned from Firebase... so very important!
Log.info("%s %.3f InitialParametersWrite: c:%s ndex:%d C:%d PB:%d PM:%d PT:%.0f Td:%d Ti:%d\r\n", Time.timeStr().c_str(), getTimeWithMillis(), controller, ndex, Cyc, PB, PMode, PTog, Td, Ti);
Log.info("%s %.3f InitialParametersWrite: F:%s I:%s A:%s M:%s Pg:%s TT:%d u:%.2f\r\n", Time.timeStr().c_str(), getTimeWithMillis(), fan ? "true" : "false", ign ? "true" : "false", aug ? "true" : "false", mode, pgm ? "true" : "false", target, u);
}
void getKeyHandler(const char *event, const char *data) {
JsonParserStatic<32, 60> keyParser;
keyParser.clear();
keyParser.addString(data);
String newKey;
keyParser.getOuterValueByKey("name", newKey);
strcpy(key, newKey);
strcpy(postKey, newKey);
Log.info("%s %.3f getKeyhandler: Parameters key from Parameters write web-hook:[%s]. postkey is:[%s]", Time.timeStr().c_str(), getTimeWithMillis(), key, postKey);
}