Particle.publish only works once sometimes

hi all

got again a weird problem: our code (on a P1 - 1.5.3 - system mode semiautomatic) uses Particle.publish to transmit state to the server. at startup there is always one publish (which always works) and then we usually execute a function on the device (Particle.function) which will cause another set of Particle.publishes. this first publish is actually in the Particle.function (which might be bad?!) and the second is not but triggered after the function is done.

the weird thing and the reason why i did not looked at this earlier is that after flashing “fresh” code to the device (and restarting) this all works fine. but when the device is just restarted it will not work (“not work” = publish does return “true” but are never received by the particle cloud)

i am going to rewrite this so that there are no publishes in the function (but this will take some time)

am i right to assume this is the problem (Particle.publish in Particle.function)? and blocking a further publishes?

thanks
frank

AFAIK there is no 1.5.3 - is it 1.5.2 or 1.5.4-rc.x?

Particle.publish() in setup() or a Particle.function() callback should not be any problem.
However, when you talk about a set of publishes, you may be running into the rate limit of 1 publish per second (with a burst of 4 followed by a 4sec cool down phase).

https://docs.particle.io/reference/device-os/firmware/photon/#particle-publish-

Also note this

When you can show your publish statements (with context) we may be able to spot something.

ah, yes, sorry, 1.5.2 (always get confused by 0.5.3 which we get from the factory)

thanks for your points - i will check them out and show them to you if i cannot get it fixed. sets is 2 or 3 here. should be ok.

so you are saying a particle.publish in a function (registered by partiucle.function and called from the cloud) should be okay?

odd things are:

  • without the function, the remaining publishes are fine
  • after flashing the device, it always seems to work just fine (n=6)

thanks
frank