40#include <DoubleList.h>
79#define SMQTTE_SOCKET -1
83#define SMQTTE_ERRORBASE -10000
87#define SMQTTE_TIMEOUT -10001
91#define SMQTTE_PONGTIMEOUT -10002
95#define SMQTTE_PROTOCOL_ERROR -10003
100#define SMQTTE_OVERFLOW -10005
104#define SMQTTE_ALREADYCON -10006
109#define SMQTTE_CONREFUSED -10007
118#define SMQTTE_SERVERNOTTRUSTED -10008
134#define SMQTT_TIMEOUT -20000
139#define SMQTT_SUBACK -20001
144#define SMQTT_UNSUBACK -20002
188 DoubleList sendQueue;
202 U16 recPackHeaderLen;
249#define SharkMQTT_setCtx(o, ctx) SOCKET_constructor(&(o)->sock, ctx)
262#define SharkMQTT_msgConsumed(o) (((o)->packetLen - (o)->bytesRead) == 0)
278#define SharkMQTT_connackCode(o) (o)->recPackHeader[3]
290#define SharkMQTT_sessionPresent(o) ((o)->recPackHeader[2] & 1)
297#define SharkMQTT_trustInfo(o) ((SharkSslConTrust)(o)->packetLen)
334 const char* address, U16 port,
397 SharkMQTT* o,
const char* topic, U8 qos,
int* maxMsgLen);
409#define SharkMQTT_pub0(o, topic, msg, msgLen) \
410 SharkMQTT_publish(o, topic, msg, msgLen, FALSE, 0)
431 const void* msg,
int msgLen, U8 retain, U8 qos);
439#define SharkMQTT_packetId(o) (o)->recPacketId
452#define SharkMQTT_subAckCode(o) ((U16)(o)->recPackHeader[4])
461#define SharkMQTT_dup(o) (((o)->recPackHeader[0] & 8) ? TRUE : FALSE)
468#define SharkMQTT_QOS(o) (((o)->recPackHeader[0] >> 1) & 3)
475#define SharkMQTT_retain(o) ((o)->recPackHeader[0] & 1)
481#define SharkMQTT_topic(o) ((const char*)((o)->recPackHeader+1))
U8 * SharkMQTT_zeroCopyPub(SharkMQTT *o, const char *topic, U8 qos, int *maxMsgLen)
Prepare a zero copy publish by fetching the SharkSSL send buffer pointer and offset the pointer to th...
void SharkMQTT_destructor(SharkMQTT *o)
Terminate a SharkMQTT instance.
void SharkMQTT_constructor(SharkMQTT *o, U8 *buf, U16 bufLen)
Create a SharkMQTT client instance.
int SharkMQTT_unsubscribe(SharkMQTT *o, const char *topic, U16 *packetId)
Requests the broker to unsubscribe the client from a topic.
int SharkMQTT_subscribe(SharkMQTT *o, const char *topic, U8 qos, U16 *packetId)
Subscribe to topic.
void SharkMQTT_disconnect(SharkMQTT *o)
Send a disconnect command to the broker and gracefully close the connection.
int SharkMQTT_getMessage(SharkMQTT *o, U8 **msg)
Wait for messages sent from the broker.
int SharkMQTT_connect(SharkMQTT *o, SharkSslCon *scon, const char *address, U16 port, const char *clientId, MqttCredentials *cred, BaBool cleanSession, MqttWillMsg *wm)
Establish (or re-establish) an MQTT session.
int SharkMQTT_publish(SharkMQTT *o, const char *topic, const void *msg, int msgLen, U8 retain, U8 qos)
Publish messages to a topic.
struct SharkSslCon SharkSslCon
SharkSslCon is an opaque handle returned by function SharkSsl_createCon.
Definition: SharkSSL.h:553
#define SOCKET
Infinite wait time option for socket read functions.
Definition: selib.h:102
Optional credentials used when calling function SharkMQTT_connect.
Definition: SharkMQTT.h:167
const char * username
Optional User Name (utf-8).
Definition: SharkMQTT.h:169
U16 pwdlen
You must provide a password length if 'password' is non NULL.
Definition: SharkMQTT.h:176
const U8 * password
Optional Password (binary).
Definition: SharkMQTT.h:174
MqttInFlightMsg.
Definition: SharkMQTT.h:57
Optional MQTT Will Message; used when calling function SharkMQTT_connect.
Definition: SharkMQTT.h:152
BaBool retain
Specifies if the Will Message is to be Retained when it is published.
Definition: SharkMQTT.h:160
const U8 * message
Definition: SharkMQTT.h:154
U8 qos
Definition: SharkMQTT.h:156
const char * topic
Definition: SharkMQTT.h:153
U16 msgLen
Definition: SharkMQTT.h:155
SharkMQTT structure.
Definition: SharkMQTT.h:184
U32 timeout
Timeout in milliseconds to wait in functions waiting for server data.
Definition: SharkMQTT.h:227
S32 pingTmo
Time interval in seconds for MQTT PING messages sent to the server.
Definition: SharkMQTT.h:196
U32 packetLen
MQTT packet length.
Definition: SharkMQTT.h:208
U32 bytesRead
Read packet data using SharkMQTT_getMessage until: packetLen-bytesRead == 0.
Definition: SharkMQTT.h:214
U32 msgLen
MQTT message length.
Definition: SharkMQTT.h:218