Background publish class. You typically instantiate one of these as a global variable.
Start the background publish thread. Required!
void start()
You typically call this from setup() using:
BackgroundPublish::instance().start();
Stop the background publish thread.
void stop()
Normally you start it and never stop it, but this method is provided for special cases.
bool BackgroundPublish::publish(const char * name, const char * data, PublishFlags flags, PublishCompletedCallback cb, const void * context)
Publish method. Use this instead of Particle.publish().
bool publish(const char * name, const char * data, PublishFlags flags, PublishCompletedCallback cb, const void * context)
-
name
Event name to publish (required) -
data
Event data (optional). Must be a c-string (null-terminated) if non-NULL. Maximum length varies by Device OS, currently 622 bytes. Note that the data must be UTF-8; you cannot send arbitrary binary data! -
flags
The publish flash. Default = PRIVATE. You will often usePRIVATE | WITH_ACK
but can also usePRIVATE | NO_ACK
. -
cb
The callback function to call when the publish completes. Optional. Pass NULL or omit the parameter if you don't need a callback. It can be a C function or a C++11 lambda. -
context
Optional parameter passed to the callback. You can store a C++ object instance or a state structure pointer here.
Used internally to mutex lock to safely access data structures from multiple threads.
void lock()
You do not need to use this under normal circumstances as publish() handles this internally.
Used internally to mutex lock to safely access data structures from multiple threads.
void unlock()
Generated by Moxygen