Barracuda Application Server C/C++ Reference
NO

Detailed Description

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.

Collaboration diagram for SMQClient:

Modules

 Error codes returned by function SMQ_getMessage
 
 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...
 

Function Documentation

◆ connect()

int SMQ::connect ( const char *  uid,
int  uidLen,
const char *  credentials,
U8  credLen,
const char *  info,
int  infoLen 
)

Connect/establish a persistent SimpleMQ connection.

See also
SMQ_connect

◆ create()

int SMQ::create ( const char *  topic)

Create a topic an fetch the topic ID (tid).

See also
SMQ_create

◆ createsub()

int SMQ::createsub ( const char *  subtopic)

Create a sub-topic and fetch the subtopic ID.

See also
SMQ:createsub

◆ disconnect()

void SMQ::disconnect ( )

Gracefully close the connection.

See also
SMQ_disconnect

◆ getMessage()

int SMQ::getMessage ( U8 **  msg)

Wait for messages sent from the broker.

See also
SMQ_getMessage

◆ getMsgSize()

int SMQ::getMsgSize ( )

Returns the message size, which is SMQ::frameLen - 15.

See also
SMQ_getMsgSize

◆ init()

int SMQ::init ( const char *  url,
U32 *  rnd 
)

Initiate the SMQ server connection.

See also
SMQ_init

◆ observe()

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.

See also
SMQ_observe

◆ pubflush()

int SMQ::pubflush ( U32  tid,
U32  subtid 
)

Flush the internal buffer and request the broker to assemble all stored fragments as one message.

See also
SMQ_pubflush

◆ publish()

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.

See also
SMQ_publish

◆ SMQ()

SMQ::SMQ ( U8 *  buf,
U16  bufLen 
)

Create a SimpleMQ client instance.

See also
SMQ_constructor

◆ subscribe()

int SMQ::subscribe ( const char *  topic)

The response to SMQ_subscribe is asynchronous and returned as status SMQ_SUBACK via SMQ_getMessage.

See also
SMQ_subscribe

◆ unobserve()

int SMQ::unobserve ( U32  tid)

Stop receiving change notifications for a topic ID or ephemeral topic ID.

See also
SMQ_unobserve

◆ unsubscribe()

int SMQ::unsubscribe ( U32  tid)

Requests the broker to unsubscribe the server from a topic.

See also
SMQ_unsubscribe

◆ write()

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).

See also
SMQ_write

◆ wrtstr()

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).

See also
SMQ_wrtstr

◆ ~SMQ()

SMQ::~SMQ ( )

Terminate a SimpleMQ instance.

See also
SMQ_destructor