Questions about my project

Hi I’m having some questions of how to interact with the data that I already is in published in the console, this is my photon code.

void setup(){
Particle.function(“web”, num);
void loop()
int num(String command){
Particle.publish(“Console”, command);

the idea is that when I enter a data in a web page the number that is sent is registered in the console and also as a variable that can be added or subtracted afterwards. This code I already checked in other tutorials, but I get stuck in that part.

Hi @fufo

It is not safe to call Particle.publish from inside a Particle.function(). Eventually this will be made to work but now it mixes up the messages to/from the cloud. Instead you should copy the String (or better yet char array) to a global copy in your function and then set a flag so that next time your code gets to the loop() function is can do the publish from there and clear the flag.

1 Like

The published events are not only sent to the Particle Console, but you can subscribe to these SSEs with any software you like, but the Particle API JS (JavaScript SDK) would be the common and easiest way to do it.

But about this

There currently is no way to have access to historic events. If you didn’t catch it when it was thrown, you’ve missed the chance.

1 Like