Hey guys.
I’m new to web hooks and looking for some help with a Subscribe() issue.
I’ve set up a web hook “command” with a GET request to adafruit IO, and set up a small piece of test code more or less cut-and-paste from the reference.
int i = 0;
void myHandler(const char *event, const char *data)
{
i++;
Serial.print(i);
Serial.print(event);
Serial.print(", data: ");
if (data)
Serial.println(data);
else
Serial.println("NULL");
}
void setup() {
Particle.subscribe("command", myHandler);
Serial.begin(115200);
Serial.println(); Serial.println();
Serial.println(F("Initialized"));
}
void loop() {
//pingsensor.turnOnffRx();
Serial.println(F("Publish Command"));
Particle.publish("command");
Serial.println(F("finsihed"));
delay(20000);
}
The myHandler function is just printing “NULL” to the terminal, but in the console it looks like I’m getting a good response, “78” is the data I’m looking for.
Terminal:
Console:
I have tried removing the if statement and just print data but it’s still NULL. Also tried casting to string with no luck.
Anyone who can tell me what I’m doing wrong?
-Marius