Mesh.publish() successful but returns false even though gateway receives message

Tags: #<Tag:0x00007fe21ff166d0>


bool isSuccess = Mesh.publish(event, data);

is returning false yet the publish has been successful. Am I missing something?


Mesh.publish returns a system error code, so 0 is success.

I just realized as the documentation was copy/pasted from Particle.publish, and it’s not correct.


So SYSTEM_ERROR_NONE is the enumeration? Wow, incredible that hasn’t been spotted before!

I better stop for the evening and go and celebrate New Year - have a good New Year celebration and thanks for your help in 2018.

Edit: When you are on a roll! I noticed that if I send a Mesh message when the LED is flashing green the result code is still 0 and the message is not sent (not surprising) - is it likely that this always returns 0 success even though it isn’t?


I’m seeing the same thing as you with my device. The result of Mesh.publish is always 0, even when it fails.


It probably because mesh.publish uses UDP and as such there is no way to determine if a UDP packet reached its destination. Particle.publish is TCP based which does allow for confirmation of reciept


I don’t use the returned bool from Mesh.publish() precisely because it is wrong.



Mesh.publish() uses CHECK and CHECK_TRUE macros (defined in, which can return values other than SYSTEM_ERROR_NONE. Therefore my original message (below) was incorrect.

Original message

It seems at least as of that this is still returning success no matter the actual result.

@rickkas7, think there might be some bandwidth to update the documentation? It looks like there are some hard problems to solve before the function can return meaningful results.

I propose the following replacement

old version–>

Returns: 0 = success, non-zero = system error code)

Note that the return value for Mesh.publish is 0 (SYSTEM_ERROR_NONE) for success, where the return value for Particle.publish is true (1) for success.

new version–>

Returns (int): 0 

Return Code on Mesh.Publish

The errors SYSTEM_ERROR_TOO_LARGE and SYSTEM_ERROR_INVALID_ARGUMENT in the CHECK_TRUE macro can be returned. Also, the CHECK macro can return non-zero error codes from the checked value.


Thanks for the clarification, it wasn’t obvious through Github that CHECK_TRUE and CHECK were macros which wrap a return.