Mesh Publish in Timer Callback Causes Hard Fault

I was doing some testing with my mesh network (1 Argon and 2 Xenons) using a timer callback to call mesh.publish which the xenon’s read and toggled the D7 leds. Above a 2 second period it worked pretty well although got the occasional hard fault and restarted. Below 2 seconds it immediately causes a hard fault. I changed it so that the callback now sets a flag that the loop reads and sends mesh.publish. This is working at 5 Hz and I am going to continue to test further. If this is obvious, oops, my bad. If not I hope it helps anyone trying to accomplish something similar.

You should not call Mesh.publish or Particle.publish from a software timer callback. Instead, set a global variable flag and do the publish from loop.

7 Likes

Is this documented somewhere? I ran into the same problem, following Tutorial #2 (Next Bus Alert) that has this very problem.