The event number chances sometimes to 2,6 or 14, 174 (looks random) but most of the time it is 0 or 1.
My application has not changed, only the firmware was updated. The app publishes one event every 60 seconds, which works fine. The mysterious events are published ~3 seconds after my app event shows up in the stream, but not every time.
Hmm, not able to immediately reproduce this issue, can you provide any other details? Does it happen while your photon is running tinker? Are you publishing using a mutable string pointer anywhere in your app / can you share the code?
So you are using a stack allocated char array for the publish data. I think if you move the char publishString[128]; declaration to global context, that is above setup(), it will work better.
There can be a time lag between when a publish is queue for sending and when it is sent and if the char array is deallocated and that memory reused, you could easily get the confusing results you are seeing. With the char array in global memory (not stack) there is no danger of the string getting overwritten.
When this gets implemented as proposed a call to Particle.process(); would ensure that the event is completely published before the variable gets “invalidated”.
I belive the mysterious events are more related to the SOS crash (see TCPClient unstable in 0.4.6). After taking SparkFun Phant library and whit that the TCPClient out the application does not crash any more and the mysterious events are gone.
The Particle.publish("sensor",publishString); event was correctly fired all the time.
Nevertheless I changed the code and moved char publishString[128]; declaration to global scope. Think that is more memory efficient anyway since it does not allocate new memory with every method call. Right?