Barracuda Application Server C/C++ Reference
NO
|
SMQ C Library.
SMQ is an easy to use IoT (M2M) publish subscribe protocol. This documentation is for the non secure SMQ C client library. See SharkMQ for the secure version.
The code is not multithread safe. However, you may use the SMQ stack in a two thread environment, one for consuming data and one for producing data, if the code is compiled with the macro SMQ_ENABLE_SENDBUF. This macro separates the receiving and sending buffer management. Note that the buffer passed into the SMQ constructor should be twice the size when enabling SMQ_ENABLE_SENDBUF. The buffer is split in two, where one buffer is used for 'receiving' and the other buffer is used for 'sending' data.
The SMQ C library comes with a C++ wrapper API, which includes a brief description of the API. See the C API for the full documentation.
Modules | |
Error codes returned by function SMQ_getMessage | |
hello | |
Response codes returned by function SMQ_getMessage | |
C API | |
Classes | |
struct | SMQ |
SimpleMQ structure. More... | |
Typedefs | |
typedef struct SMQ | SMQ |
SimpleMQ structure. | |
Functions | |
SMQ::SMQ (U8 *buf, U16 bufLen) | |
Create a SimpleMQ client instance. More... | |
int | SMQ::init (const char *url, U32 *rnd) |
Initiate the SMQ server connection. More... | |
int | SMQ::connect (const char *uid, int uidLen, const char *credentials, U8 credLen, const char *info, int infoLen) |
Connect/establish a persistent SimpleMQ connection. More... | |
void | SMQ::disconnect () |
Gracefully close the connection. More... | |
SMQ::~SMQ () | |
Terminate a SimpleMQ instance. More... | |
int | SMQ::create (const char *topic) |
Create a topic an fetch the topic ID (tid). More... | |
int | SMQ::createsub (const char *subtopic) |
Create a sub-topic and fetch the subtopic ID. More... | |
int | SMQ::subscribe (const char *topic) |
The response to SMQ_subscribe is asynchronous and returned as status SMQ_SUBACK via SMQ_getMessage. More... | |
int | SMQ::unsubscribe (U32 tid) |
Requests the broker to unsubscribe the server from a topic. More... | |
int | SMQ::publish (const void *data, int len, U32 tid, U32 subtid) |
Publish messages to a topic and optionally to a sub-topic. More... | |
int | SMQ::wrtstr (const char *str) |
Publish a message in chunks and request the broker to assemble the message before publishing to the subscriber(s). More... | |
int | SMQ::write (const void *data, int len) |
Publish a message in chunks and request the broker to assemble the message before publishing to the subscriber(s). More... | |
int | SMQ::pubflush (U32 tid, U32 subtid) |
Flush the internal buffer and request the broker to assemble all stored fragments as one message. More... | |
int | SMQ::observe (U32 tid) |
Request the broker to provide change notification events when the number of subscribers to a specific topic changes. More... | |
int | SMQ::unobserve (U32 tid) |
Stop receiving change notifications for a topic ID or ephemeral topic ID. More... | |
int | SMQ::getMessage (U8 **msg) |
Wait for messages sent from the broker. More... | |
int | SMQ::getMsgSize () |
Returns the message size, which is SMQ::frameLen - 15. More... | |
int SMQ::connect | ( | const char * | uid, |
int | uidLen, | ||
const char * | credentials, | ||
U8 | credLen, | ||
const char * | info, | ||
int | infoLen | ||
) |
Connect/establish a persistent SimpleMQ connection.
int SMQ::create | ( | const char * | topic | ) |
Create a topic an fetch the topic ID (tid).
int SMQ::createsub | ( | const char * | subtopic | ) |
void SMQ::disconnect | ( | ) |
Gracefully close the connection.
int SMQ::getMessage | ( | U8 ** | msg | ) |
Wait for messages sent from the broker.
int SMQ::getMsgSize | ( | ) |
Returns the message size, which is SMQ::frameLen - 15.
int SMQ::observe | ( | U32 | tid | ) |
Request the broker to provide change notification events when the number of subscribers to a specific topic changes.
Ephemeral topic IDs can also be observed.
int SMQ::pubflush | ( | U32 | tid, |
U32 | subtid | ||
) |
Flush the internal buffer and request the broker to assemble all stored fragments as one message.
int SMQ::publish | ( | const void * | data, |
int | len, | ||
U32 | tid, | ||
U32 | subtid | ||
) |
Publish messages to a topic and optionally to a sub-topic.
Topic name must have previosly been been resolved by SMQ_create and sub-topic should preferably have been created by SMQ_createsub.
SMQ::SMQ | ( | U8 * | buf, |
U16 | bufLen | ||
) |
Create a SimpleMQ client instance.
int SMQ::subscribe | ( | const char * | topic | ) |
The response to SMQ_subscribe is asynchronous and returned as status SMQ_SUBACK via SMQ_getMessage.
int SMQ::unobserve | ( | U32 | tid | ) |
Stop receiving change notifications for a topic ID or ephemeral topic ID.
int SMQ::unsubscribe | ( | U32 | tid | ) |
Requests the broker to unsubscribe the server from a topic.
int SMQ::write | ( | const void * | data, |
int | len | ||
) |
Publish a message in chunks and request the broker to assemble the message before publishing to the subscriber(s).
int SMQ::wrtstr | ( | const char * | str | ) |
Publish a message in chunks and request the broker to assemble the message before publishing to the subscriber(s).
SMQ::~SMQ | ( | ) |
Terminate a SimpleMQ instance.