Skip to content

Latest commit

 

History

History
79 lines (46 loc) · 1.97 KB

api.md

File metadata and controls

79 lines (46 loc) · 1.97 KB

class BackgroundPublish

Background publish class. You typically instantiate one of these as a global variable.

Members


void BackgroundPublish::start()

Start the background publish thread. Required!

void start()

You typically call this from setup() using:

BackgroundPublish::instance().start();

void BackgroundPublish::stop()

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)

Parameters

  • 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 use PRIVATE | WITH_ACK but can also use PRIVATE | 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.


void BackgroundPublish::lock()

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.


void BackgroundPublish::unlock()

Used internally to mutex lock to safely access data structures from multiple threads.

void unlock()

Generated by Moxygen