How would perform this action, HTTP client?
The easiest way to do that is to use built in Particle functions for this. I suggest checking out the documentation for Particle Publish and Particle Subscribe, they should cover most of the info you need then let me know if you have any follow up questions.
So I can use publish with a webhook to get the data sent to the webpage, but how do I get the response back to the device?
Subscribe on-device to the webhook response. That will contain the response from calling the external server.
I can’t find an example of this other than success or failure, not the actual results from the server.
This link shows how to subscribe to the response.
I found this very useful.
When setting up a webhook it gives examples of how to subscribe, but the handler function doesn’t show an example of how to process that data.
An example would probably help people understand a little better.
Here are two I built:
void lightHandler(const char *event, const char *data) {
sscanf(data, “%02d%02d%02d%01d%01d”, &red, &green, &blue, &flashit, &buzzit);
}
void lcdHandler(const char *event, const char *data) {
//display something
display.clearDisplay();
display.setCursor(0,0);
display.println(String(data));
display.display();
}
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.