I have two Photons that need to talk to each other. I’m using Spark.publish and Spark.subscribe in both Photon for doing so. I’m sending a message of 10 bytes every two seconds.
This setup works for approx. 5 messages, then either they stop receiving or, once, they both crashed (red SOS blink).
@amicoleo, first, I would say that you need to treat a Spark.function() like an interrupt service routine and keep it as tight as possible, including not having Serial.print() call. In your function, you set a flag that is examined in loop(). Also, you may want to use strcpy(audioOutSequence, data) instead of the while(), assuming your declaration of audioOutSequence[] is sized large enough to handle the entire data!
@Carsten4207, it’s basically a callback from the system firmware. So user code gets interrupted for the duration of that call. If it delays too long, you’ll also lose your cloud connection!
not to be argumentative, but it seems like very little happening in the OP’s callback that would affect his communication (from my experience doing a lot more inside one of these functions).
OP may wish to try backing off to every 5 seconds and see if it stabilizes, it seems to me that perhaps normal Wifi/Internet latency may be part of the issue here.
@BulldogLowell, argumentative??? Dude, this is what these discussions are all about! I should have said that the code should not be an issue but the recommendations were good practice. However, the question still remains whether the audioOutSequence[] array was adequately sized or not.