libwebsockets
Lightweight C library for HTML5 websockets
lws-mqtt.h File Reference

Go to the source code of this file.

Data Structures

union  lws_mqtt_fixed_hdr_t
 
struct  lws_mqtt_client_connect_param_s
 
struct  lws_mqtt_publish_param_s
 
struct  topic_elem
 
struct  lws_mqtt_fixed_hdr_t.flags
 
struct  lws_mqtt_client_connect_param_s.will_param
 
struct  lws_mqtt_client_connect_param_s.birth_param
 

Macros

#define MQTT_VER_3_1_1   4
 
#define LWS_MQTT_FINAL_PART   1
 
#define LWS_MQTT_MAX_AWSIOT_TOPICLEN   256
 
#define LWS_MQTT_MAX_TOPICLEN   65535
 
#define LWS_MQTT_MAX_CIDLEN   128
 
#define LWS_MQTT_RANDOM_CIDLEN
 
#define LWS_MQTT_SHADOW_MAX_THING_LEN   128
 
#define LWS_MQTT_SHADOW_MAX_SHADOW_LEN   64
 
#define LWS_MQTT_SHADOW_UPDATE_STR   "/update"
 
#define LWS_MQTT_SHADOW_DELETE_STR   "/delete"
 
#define LWS_MQTT_SHADOW_GET_STR   "/get"
 
#define LWS_MQTT_SHADOW_RESP_ACCEPTED_STR   "/accepted"
 
#define LWS_MQTT_SHADOW_RESP_REJECTED_STR   "/rejected"
 
#define LWS_MQTT_SHADOW_RESP_DELTA_STR   "/delta"
 
#define LWS_MQTT_SHADOW_RESP_DOCUMENT_STR   "/documents"
 
#define LWS_MQTT_SHADOW_UPDATE_ACCEPTED_STR   LWS_MQTT_SHADOW_UPDATE_STR LWS_MQTT_SHADOW_RESP_ACCEPTED_STR
 
#define LWS_MQTT_SHADOW_UPDATE_REJECTED_STR   LWS_MQTT_SHADOW_UPDATE_STR LWS_MQTT_SHADOW_RESP_REJECTED_STR
 
#define LWS_MQTT_SHADOW_UPDATE_DELTA_STR   LWS_MQTT_SHADOW_UPDATE_STR LWS_MQTT_SHADOW_RESP_DELTA_STR
 
#define LWS_MQTT_SHADOW_UPDATE_DOCUMENT_STR   LWS_MQTT_SHADOW_UPDATE_STR LWS_MQTT_SHADOW_RESP_DOCUMENT_STR
 
#define LWS_MQTT_SHADOW_DELETE_ACCEPTED_STR   LWS_MQTT_SHADOW_DELETE_STR LWS_MQTT_SHADOW_RESP_ACCEPTED_STR
 
#define LWS_MQTT_SHADOW_DELETE_REJECTED_STR   LWS_MQTT_SHADOW_DELETE_STR LWS_MQTT_SHADOW_RESP_REJECTED_STR
 
#define LWS_MQTT_SHADOW_GET_ACCEPTED_STR   LWS_MQTT_SHADOW_GET_STR LWS_MQTT_SHADOW_RESP_ACCEPTED_STR
 
#define LWS_MQTT_SHADOW_GET_REJECTED_STR   LWS_MQTT_SHADOW_GET_STR LWS_MQTT_SHADOW_RESP_REJECTED_STR
 
#define LWS_MQTT_SHADOW_PREFIX_FORMAT   "$aws/things/%s"
 
#define LWS_MQTT_SHADOW_NAMED_SHADOW_TOPIC_FORMAT   LWS_MQTT_SHADOW_PREFIX_FORMAT "/shadow/name/%s%s"
 
#define LWS_MQTT_SHADOW_UNNAMED_SHADOW_TOPIC_FORMAT   LWS_MQTT_SHADOW_PREFIX_FORMAT "/shadow%s"
 
#define LWS_MQTT_SHADOW_UNNAMED_TOPIC_MATCH   "$aws/things/+/shadow/+"
 
#define LWS_MQTT_SHADOW_NAMED_TOPIC_MATCH   "$aws/things/+/shadow/name/+/+"
 

Typedefs

typedef struct _lws_mqtt_related lws_mqtt_related_t
 
typedef struct lws_mqtt_str_st lws_mqtt_str_t
 
typedef struct lws_mqtt_client_connect_param_s lws_mqtt_client_connect_param_t
 
typedef struct lws_mqtt_publish_param_s lws_mqtt_publish_param_t
 
typedef struct topic_elem lws_mqtt_topic_elem_t
 
typedef struct lws_mqtt_subscribe_param_s lws_mqtt_subscribe_param_t
 

Enumerations

enum  lws_mqtt_qos_levels_t {
  QOS0 , QOS1 , QOS2 , RESERVED_QOS_LEVEL ,
  FAILURE_QOS_LEVEL = 0x80
}
 
enum  lws_mqtt_control_packet_t {
  LMQCP_RESERVED , LMQCP_CTOS_CONNECT , LMQCP_STOC_CONNACK , LMQCP_PUBLISH ,
  LMQCP_PUBACK , LMQCP_PUBREC , LMQCP_PUBREL , LMQCP_PUBCOMP ,
  LMQCP_CTOS_SUBSCRIBE , LMQCP_STOC_SUBACK , LMQCP_CTOS_UNSUBSCRIBE , LMQCP_STOC_UNSUBACK ,
  LMQCP_CTOS_PINGREQ , LMQCP_STOC_PINGRESP , LMQCP_DISCONNECT , LMQCP_AUTH
}
 
enum  lws_mqtt_connect_flags_t {
  LMQCFT_USERNAME_NOFREE = (1 << 10) , LMQCFT_PASSWORD_NOFREE = (1 << 9) , LMQCFT_CLIENT_ID_NOFREE = (1 << 8) , LMQCFT_USERNAME = (1 << 7) ,
  LMQCFT_PASSWORD = (1 << 6) , LMQCFT_WILL_RETAIN = (1 << 5) , LMQCFT_WILL_QOS = (1 << 3) , LMQCFT_WILL_FLAG = (1 << 2) ,
  LMQCFT_CLEAN_START = (1 << 1) , LMQCFT_RESERVED = (1 << 0) , LMQCFT_WILL_QOS_MASK = (3 << 3)
}
 
enum  lws_mqtt_connack_flags_t { LMQCFT_SESSION_PRESENT = (1 << 0) }
 
enum  lws_mqtt_reason_t {
  LMQCP_REASON_SUCCESS = 0x00 , LMQCP_REASON_NORMAL_DISCONNECTION = 0x00 , LMQCP_REASON_GRANTED_QOS0 = 0x00 , LMQCP_REASON_GRANTED_QOS1 = 0x01 ,
  LMQCP_REASON_GRANTED_QOS2 = 0x02 , LMQCP_REASON_DISCONNECT_WILL = 0x04 , LMQCP_REASON_NO_MATCHING_SUBSCRIBER = 0x10 , LMQCP_REASON_NO_SUBSCRIPTION_EXISTED = 0x11 ,
  LMQCP_REASON_CONTINUE_AUTHENTICATION = 0x18 , LMQCP_REASON_RE_AUTHENTICATE = 0x19 , LMQCP_REASON_UNSPECIFIED_ERROR = 0x80 , LMQCP_REASON_MALFORMED_PACKET = 0x81 ,
  LMQCP_REASON_PROTOCOL_ERROR = 0x82 , LMQCP_REASON_IMPLEMENTATION_SPECIFIC_ERROR = 0x83 , LMQCP_REASON_UNSUPPORTED_PROTOCOL = 0x84 , LMQCP_REASON_CLIENT_ID_INVALID = 0x85 ,
  LMQCP_REASON_BAD_CREDENTIALS = 0x86 , LMQCP_REASON_NOT_AUTHORIZED = 0x87 , LMQCP_REASON_SERVER_UNAVAILABLE = 0x88 , LMQCP_REASON_SERVER_BUSY = 0x89 ,
  LMQCP_REASON_BANNED = 0x8a , LMQCP_REASON_SERVER_SHUTTING_DOWN = 0x8b , LMQCP_REASON_BAD_AUTHENTICATION_METHOD = 0x8c , LMQCP_REASON_KEEPALIVE_TIMEOUT = 0x8d ,
  LMQCP_REASON_SESSION_TAKEN_OVER = 0x8e , LMQCP_REASON_TOPIC_FILTER_INVALID = 0x8f , LMQCP_REASON_TOPIC_NAME_INVALID = 0x90 , LMQCP_REASON_PACKET_ID_IN_USE = 0x91 ,
  LMQCP_REASON_PACKET_ID_NOT_FOUND = 0x92 , LMQCP_REASON_MAX_RX_EXCEEDED = 0x93 , LMQCP_REASON_TOPIC_ALIAS_INVALID = 0x94 , LMQCP_REASON_PACKET_TOO_LARGE = 0x95 ,
  LMQCP_REASON_RATELIMIT = 0x96 , LMQCP_REASON_QUOTA_EXCEEDED = 0x97 , LMQCP_REASON_ADMINISTRATIVE_ACTION = 0x98 , LMQCP_REASON_PAYLOAD_FORMAT_INVALID = 0x99 ,
  LMQCP_REASON_RETAIN_NOT_SUPPORTED = 0x9a , LMQCP_REASON_QOS_NOT_SUPPORTED = 0x9b , LMQCP_REASON_USE_ANOTHER_SERVER = 0x9c , LMQCP_REASON_SERVER_MOVED = 0x9d ,
  LMQCP_REASON_SHARED_SUBSCRIPTIONS_NOT_SUPPORTED = 0x9e , LMQCP_REASON_CONNECTION_RATE_EXCEEDED = 0x9f , LMQCP_REASON_MAXIMUM_CONNECT_TIME = 0xa0 , LMQCP_REASON_SUBSCRIPTION_IDS_NOT_SUPPORTED = 0xa1 ,
  LMQCP_REASON_WILDCARD_SUBSCRIPTIONS_NOT_SUPPORTED = 0xa2
}
 
enum  lws_mqtt_property {
  LMQPROP_INVALID , LMQPROP_PAYLOAD_FORMAT_INDICATOR = 0x01 , LMQPROP_MESSAGE_EXPIRY_INTERVAL = 0x02 , LMQPROP_CONTENT_TYPE = 0x03 ,
  LMQPROP_RESPONSE_TOPIC = 0x08 , LMQPROP_CORRELATION_DATA = 0x09 , LMQPROP_SUBSCRIPTION_IDENTIFIER = 0x0b , LMQPROP_SESSION_EXPIRY_INTERVAL = 0x11 ,
  LMQPROP_ASSIGNED_CLIENT_IDENTIFIER = 0x12 , LMQPROP_SERVER_KEEP_ALIVE = 0x13 , LMQPROP_AUTHENTICATION_METHOD = 0x15 , LMQPROP_AUTHENTICATION_DATA = 0x16 ,
  LMQPROP_REQUEST_PROBLEM_INFORMATION = 0x17 , LMQPROP_WILL_DELAY_INTERVAL = 0x18 , LMQPROP_REQUEST_RESPONSE_INFORMATION = 0x19 , LMQPROP_RESPONSE_INFORMATION = 0x1a ,
  LMQPROP_SERVER_REFERENCE = 0x1c , LMQPROP_REASON_STRING = 0x1f , LMQPROP_RECEIVE_MAXIMUM = 0x21 , LMQPROP_TOPIC_ALIAS_MAXIMUM = 0x22 ,
  LMQPROP_TOPIC_ALIAS = 0x23 , LMQPROP_MAXIMUM_QOS = 0x24 , LMQPROP_RETAIN_AVAILABLE = 0x25 , LMQPROP_USER_PROPERTY = 0x26 ,
  LMQPROP_MAXIMUM_PACKET_SIZE = 0x27 , LMQPROP_WILDCARD_SUBSCRIPTION_AVAIL = 0x28 , LMQPROP_SUBSCRIPTION_IDENTIFIER_AVAIL = 0x29 , LMQPROP_SHARED_SUBSCRIPTION_AVAIL = 0x2a
}
 

Functions

int lws_read_mqtt (struct lws *wsi, unsigned char *buf, lws_filepos_t len)
 
LWS_VISIBLE LWS_EXTERN int lws_mqtt_bindata_cmp (const lws_mqtt_str_t *bd1, const lws_mqtt_str_t *bd2)
 
LWS_VISIBLE LWS_EXTERN void lws_mqtt_str_init (lws_mqtt_str_t *s, uint8_t *buf, uint16_t lim, char nf)
 
LWS_VISIBLE LWS_EXTERN lws_mqtt_str_tlws_mqtt_str_create (uint16_t lim)
 
LWS_VISIBLE LWS_EXTERN lws_mqtt_str_tlws_mqtt_str_create_init (uint8_t *buf, uint16_t len, uint16_t lim)
 
LWS_VISIBLE LWS_EXTERN lws_mqtt_str_tlws_mqtt_str_create_cstr_dup (const char *buf, uint16_t lim)
 
LWS_VISIBLE LWS_EXTERN uint8_tlws_mqtt_str_next (lws_mqtt_str_t *s, uint16_t *budget)
 
LWS_VISIBLE LWS_EXTERN int lws_mqtt_str_advance (lws_mqtt_str_t *s, int n)
 
LWS_VISIBLE LWS_EXTERN void lws_mqtt_str_free (lws_mqtt_str_t **s)
 
LWS_VISIBLE LWS_EXTERN int lws_mqtt_client_send_publish (struct lws *wsi, lws_mqtt_publish_param_t *pub, const void *buf, uint32_t len, int final)
 
LWS_VISIBLE LWS_EXTERN int lws_mqtt_client_send_subcribe (struct lws *wsi, lws_mqtt_subscribe_param_t *sub)
 
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_mqtt_client_send_unsubcribe (struct lws *wsi, const lws_mqtt_subscribe_param_t *unsub)
 

Data Structure Documentation

◆ lws_mqtt_fixed_hdr_t

union lws_mqtt_fixed_hdr_t

Definition at line 75 of file lws-mqtt.h.

+ Collaboration diagram for lws_mqtt_fixed_hdr_t:
Data Fields
struct lws_mqtt_fixed_hdr_t flags
uint8_t bits

◆ lws_mqtt_client_connect_param_s

struct lws_mqtt_client_connect_param_s

Definition at line 90 of file lws-mqtt.h.

+ Collaboration diagram for lws_mqtt_client_connect_param_s:
Data Fields
const char * client_id
uint16_t keep_alive
uint8_t clean_start:1
uint8_t client_id_nofree:1

do not free the client id

uint8_t username_nofree:1

do not free the username

uint8_t password_nofree:1

do not free the password

struct lws_mqtt_client_connect_param_s will_param
struct lws_mqtt_client_connect_param_s birth_param
const char * username
const char * password
uint8_t aws_iot

◆ lws_mqtt_publish_param_s

struct lws_mqtt_publish_param_s

Definition at line 125 of file lws-mqtt.h.

+ Collaboration diagram for lws_mqtt_publish_param_s:
Data Fields
char * topic
uint16_t topic_len
const void * payload
uint32_t payload_len
uint32_t payload_pos
lws_mqtt_qos_levels_t qos
uint16_t packet_id
uint8_t dup:1
uint8_t retain:1

◆ topic_elem

struct topic_elem

Definition at line 142 of file lws-mqtt.h.

+ Collaboration diagram for topic_elem:
Data Fields
const char * name
lws_mqtt_qos_levels_t qos
uint8_t acked

◆ lws_mqtt_subscribe_param_s

struct lws_mqtt_subscribe_param_s

Definition at line 153 of file lws-mqtt.h.

+ Collaboration diagram for lws_mqtt_subscribe_param_s:
Data Fields
uint32_t num_topics
lws_mqtt_topic_elem_t * topic
uint16_t packet_id

◆ lws_mqtt_fixed_hdr_t.flags

struct lws_mqtt_fixed_hdr_t.flags

Definition at line 76 of file lws-mqtt.h.

+ Collaboration diagram for lws_mqtt_fixed_hdr_t.flags:
Data Fields
uint8_t retain:1
uint8_t qos:2
uint8_t dup:1
uint8_t ctrl_pkt_type:4

◆ lws_mqtt_client_connect_param_s.will_param

struct lws_mqtt_client_connect_param_s.will_param

Definition at line 103 of file lws-mqtt.h.

+ Collaboration diagram for lws_mqtt_client_connect_param_s.will_param:
Data Fields
const char * topic
const char * message
lws_mqtt_qos_levels_t qos
uint8_t retain

◆ lws_mqtt_client_connect_param_s.birth_param

struct lws_mqtt_client_connect_param_s.birth_param

Definition at line 110 of file lws-mqtt.h.

+ Collaboration diagram for lws_mqtt_client_connect_param_s.birth_param:
Data Fields
const char * topic
const char * message
lws_mqtt_qos_levels_t qos
uint8_t retain

Macro Definition Documentation

◆ MQTT_VER_3_1_1

#define MQTT_VER_3_1_1   4

Definition at line 35 of file lws-mqtt.h.

◆ LWS_MQTT_FINAL_PART

#define LWS_MQTT_FINAL_PART   1

Definition at line 37 of file lws-mqtt.h.

◆ LWS_MQTT_MAX_AWSIOT_TOPICLEN

#define LWS_MQTT_MAX_AWSIOT_TOPICLEN   256

Definition at line 39 of file lws-mqtt.h.

◆ LWS_MQTT_MAX_TOPICLEN

#define LWS_MQTT_MAX_TOPICLEN   65535

Definition at line 40 of file lws-mqtt.h.

◆ LWS_MQTT_MAX_CIDLEN

#define LWS_MQTT_MAX_CIDLEN   128

Definition at line 41 of file lws-mqtt.h.

◆ LWS_MQTT_RANDOM_CIDLEN

#define LWS_MQTT_RANDOM_CIDLEN
Value:
23 /* 3.1.3.1-5: Server MUST... between
1 and 23 chars... */

Definition at line 42 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_MAX_THING_LEN

#define LWS_MQTT_SHADOW_MAX_THING_LEN   128

Definition at line 44 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_MAX_SHADOW_LEN

#define LWS_MQTT_SHADOW_MAX_SHADOW_LEN   64

Definition at line 45 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_UPDATE_STR

#define LWS_MQTT_SHADOW_UPDATE_STR   "/update"

Definition at line 46 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_DELETE_STR

#define LWS_MQTT_SHADOW_DELETE_STR   "/delete"

Definition at line 47 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_GET_STR

#define LWS_MQTT_SHADOW_GET_STR   "/get"

Definition at line 48 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_RESP_ACCEPTED_STR

#define LWS_MQTT_SHADOW_RESP_ACCEPTED_STR   "/accepted"

Definition at line 49 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_RESP_REJECTED_STR

#define LWS_MQTT_SHADOW_RESP_REJECTED_STR   "/rejected"

Definition at line 50 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_RESP_DELTA_STR

#define LWS_MQTT_SHADOW_RESP_DELTA_STR   "/delta"

Definition at line 51 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_RESP_DOCUMENT_STR

#define LWS_MQTT_SHADOW_RESP_DOCUMENT_STR   "/documents"

Definition at line 52 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_UPDATE_ACCEPTED_STR

#define LWS_MQTT_SHADOW_UPDATE_ACCEPTED_STR   LWS_MQTT_SHADOW_UPDATE_STR LWS_MQTT_SHADOW_RESP_ACCEPTED_STR

Definition at line 53 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_UPDATE_REJECTED_STR

#define LWS_MQTT_SHADOW_UPDATE_REJECTED_STR   LWS_MQTT_SHADOW_UPDATE_STR LWS_MQTT_SHADOW_RESP_REJECTED_STR

Definition at line 54 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_UPDATE_DELTA_STR

#define LWS_MQTT_SHADOW_UPDATE_DELTA_STR   LWS_MQTT_SHADOW_UPDATE_STR LWS_MQTT_SHADOW_RESP_DELTA_STR

Definition at line 55 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_UPDATE_DOCUMENT_STR

#define LWS_MQTT_SHADOW_UPDATE_DOCUMENT_STR   LWS_MQTT_SHADOW_UPDATE_STR LWS_MQTT_SHADOW_RESP_DOCUMENT_STR

Definition at line 56 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_DELETE_ACCEPTED_STR

#define LWS_MQTT_SHADOW_DELETE_ACCEPTED_STR   LWS_MQTT_SHADOW_DELETE_STR LWS_MQTT_SHADOW_RESP_ACCEPTED_STR

Definition at line 57 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_DELETE_REJECTED_STR

#define LWS_MQTT_SHADOW_DELETE_REJECTED_STR   LWS_MQTT_SHADOW_DELETE_STR LWS_MQTT_SHADOW_RESP_REJECTED_STR

Definition at line 58 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_GET_ACCEPTED_STR

#define LWS_MQTT_SHADOW_GET_ACCEPTED_STR   LWS_MQTT_SHADOW_GET_STR LWS_MQTT_SHADOW_RESP_ACCEPTED_STR

Definition at line 59 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_GET_REJECTED_STR

#define LWS_MQTT_SHADOW_GET_REJECTED_STR   LWS_MQTT_SHADOW_GET_STR LWS_MQTT_SHADOW_RESP_REJECTED_STR

Definition at line 60 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_PREFIX_FORMAT

#define LWS_MQTT_SHADOW_PREFIX_FORMAT   "$aws/things/%s"

Definition at line 61 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_NAMED_SHADOW_TOPIC_FORMAT

#define LWS_MQTT_SHADOW_NAMED_SHADOW_TOPIC_FORMAT   LWS_MQTT_SHADOW_PREFIX_FORMAT "/shadow/name/%s%s"

Definition at line 62 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_UNNAMED_SHADOW_TOPIC_FORMAT

#define LWS_MQTT_SHADOW_UNNAMED_SHADOW_TOPIC_FORMAT   LWS_MQTT_SHADOW_PREFIX_FORMAT "/shadow%s"

Definition at line 63 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_UNNAMED_TOPIC_MATCH

#define LWS_MQTT_SHADOW_UNNAMED_TOPIC_MATCH   "$aws/things/+/shadow/+"

Definition at line 64 of file lws-mqtt.h.

◆ LWS_MQTT_SHADOW_NAMED_TOPIC_MATCH

#define LWS_MQTT_SHADOW_NAMED_TOPIC_MATCH   "$aws/things/+/shadow/name/+/+"

Definition at line 65 of file lws-mqtt.h.

Typedef Documentation

◆ lws_mqtt_related_t

typedef struct _lws_mqtt_related lws_mqtt_related_t

Definition at line 1 of file lws-mqtt.h.

◆ lws_mqtt_str_t

typedef struct lws_mqtt_str_st lws_mqtt_str_t

Definition at line 1 of file lws-mqtt.h.

◆ lws_mqtt_client_connect_param_t

◆ lws_mqtt_publish_param_t

◆ lws_mqtt_topic_elem_t

◆ lws_mqtt_subscribe_param_t

Enumeration Type Documentation

◆ lws_mqtt_qos_levels_t

Enumerator
QOS0 
QOS1 
QOS2 
RESERVED_QOS_LEVEL 
FAILURE_QOS_LEVEL 

Definition at line 67 of file lws-mqtt.h.

68  {
69  QOS0,
70  QOS1,
71  QOS2, /* not supported */
73  FAILURE_QOS_LEVEL = 0x80
@ QOS2
Definition: lws-mqtt.h:70
@ QOS1
Definition: lws-mqtt.h:69
@ RESERVED_QOS_LEVEL
Definition: lws-mqtt.h:71
@ QOS0
Definition: lws-mqtt.h:68
@ FAILURE_QOS_LEVEL
Definition: lws-mqtt.h:72

◆ lws_mqtt_control_packet_t

Enumerator
LMQCP_RESERVED 
LMQCP_CTOS_CONNECT 
LMQCP_STOC_CONNACK 
LMQCP_PUBLISH 
LMQCP_PUBACK 
LMQCP_PUBREC 
LMQCP_PUBREL 
LMQCP_PUBCOMP 
LMQCP_CTOS_SUBSCRIBE 
LMQCP_STOC_SUBACK 
LMQCP_CTOS_UNSUBSCRIBE 
LMQCP_STOC_UNSUBACK 
LMQCP_CTOS_PINGREQ 
LMQCP_STOC_PINGRESP 
LMQCP_DISCONNECT 
LMQCP_AUTH 

Definition at line 161 of file lws-mqtt.h.

162  {
164  LMQCP_CTOS_CONNECT, /* Connection request */
165  LMQCP_STOC_CONNACK, /* Connection acknowledgment */
166  LMQCP_PUBLISH, /* Publish Message */
167  LMQCP_PUBACK, /* QoS 1: Publish acknowledgment */
168  LMQCP_PUBREC, /* QoS 2.1: Publish received */
169  LMQCP_PUBREL, /* QoS 2.2: Publish release */
170  LMQCP_PUBCOMP, /* QoS 2.3: Publish complete */
171  LMQCP_CTOS_SUBSCRIBE, /* Subscribe request */
172  LMQCP_STOC_SUBACK, /* Subscribe acknowledgment */
173  LMQCP_CTOS_UNSUBSCRIBE, /* Unsubscribe request */
174  LMQCP_STOC_UNSUBACK, /* Unsubscribe acknowledgment */
175  LMQCP_CTOS_PINGREQ, /* PING request */
176  LMQCP_STOC_PINGRESP, /* PONG response */
177  LMQCP_DISCONNECT, /* Disconnect notification */
178  LMQCP_AUTH /* Authentication exchange */
@ LMQCP_PUBREC
Definition: lws-mqtt.h:167
@ LMQCP_STOC_SUBACK
Definition: lws-mqtt.h:171
@ LMQCP_PUBACK
Definition: lws-mqtt.h:166
@ LMQCP_CTOS_CONNECT
Definition: lws-mqtt.h:163
@ LMQCP_STOC_UNSUBACK
Definition: lws-mqtt.h:173
@ LMQCP_CTOS_UNSUBSCRIBE
Definition: lws-mqtt.h:172
@ LMQCP_PUBCOMP
Definition: lws-mqtt.h:169
@ LMQCP_DISCONNECT
Definition: lws-mqtt.h:176
@ LMQCP_STOC_CONNACK
Definition: lws-mqtt.h:164
@ LMQCP_STOC_PINGRESP
Definition: lws-mqtt.h:175
@ LMQCP_RESERVED
Definition: lws-mqtt.h:162
@ LMQCP_AUTH
Definition: lws-mqtt.h:177
@ LMQCP_PUBREL
Definition: lws-mqtt.h:168
@ LMQCP_CTOS_PINGREQ
Definition: lws-mqtt.h:174
@ LMQCP_PUBLISH
Definition: lws-mqtt.h:165
@ LMQCP_CTOS_SUBSCRIBE
Definition: lws-mqtt.h:170

◆ lws_mqtt_connect_flags_t

Enumerator
LMQCFT_USERNAME_NOFREE 
LMQCFT_PASSWORD_NOFREE 
LMQCFT_CLIENT_ID_NOFREE 
LMQCFT_USERNAME 
LMQCFT_PASSWORD 
LMQCFT_WILL_RETAIN 
LMQCFT_WILL_QOS 
LMQCFT_WILL_FLAG 
LMQCFT_CLEAN_START 
LMQCFT_RESERVED 
LMQCFT_WILL_QOS_MASK 

Definition at line 181 of file lws-mqtt.h.

182  {
183  LMQCFT_USERNAME_NOFREE = (1 << 10),
184  LMQCFT_PASSWORD_NOFREE = (1 << 9),
185  LMQCFT_CLIENT_ID_NOFREE = (1 << 8),
186  /* only the low 8 are standardized and go out in the protocol */
187  LMQCFT_USERNAME = (1 << 7),
188  LMQCFT_PASSWORD = (1 << 6),
189  LMQCFT_WILL_RETAIN = (1 << 5),
190  LMQCFT_WILL_QOS = (1 << 3),
191  LMQCFT_WILL_FLAG = (1 << 2),
192  LMQCFT_CLEAN_START = (1 << 1),
193  LMQCFT_RESERVED = (1 << 0),
194 
195  LMQCFT_WILL_QOS_MASK = (3 << 3),
@ LMQCFT_USERNAME
Definition: lws-mqtt.h:186
@ LMQCFT_WILL_QOS_MASK
Definition: lws-mqtt.h:194
@ LMQCFT_PASSWORD
Definition: lws-mqtt.h:187
@ LMQCFT_WILL_FLAG
Definition: lws-mqtt.h:190
@ LMQCFT_CLIENT_ID_NOFREE
Definition: lws-mqtt.h:184
@ LMQCFT_WILL_RETAIN
Definition: lws-mqtt.h:188
@ LMQCFT_RESERVED
Definition: lws-mqtt.h:192
@ LMQCFT_PASSWORD_NOFREE
Definition: lws-mqtt.h:183
@ LMQCFT_WILL_QOS
Definition: lws-mqtt.h:189
@ LMQCFT_CLEAN_START
Definition: lws-mqtt.h:191
@ LMQCFT_USERNAME_NOFREE
Definition: lws-mqtt.h:182

◆ lws_mqtt_connack_flags_t

Enumerator
LMQCFT_SESSION_PRESENT 

Definition at line 198 of file lws-mqtt.h.

199  {
200  LMQCFT_SESSION_PRESENT = (1 << 0),
@ LMQCFT_SESSION_PRESENT
Definition: lws-mqtt.h:199

◆ lws_mqtt_reason_t

Enumerator
LMQCP_REASON_SUCCESS 
LMQCP_REASON_NORMAL_DISCONNECTION 
LMQCP_REASON_GRANTED_QOS0 
LMQCP_REASON_GRANTED_QOS1 
LMQCP_REASON_GRANTED_QOS2 
LMQCP_REASON_DISCONNECT_WILL 
LMQCP_REASON_NO_MATCHING_SUBSCRIBER 
LMQCP_REASON_NO_SUBSCRIPTION_EXISTED 
LMQCP_REASON_CONTINUE_AUTHENTICATION 
LMQCP_REASON_RE_AUTHENTICATE 
LMQCP_REASON_UNSPECIFIED_ERROR 
LMQCP_REASON_MALFORMED_PACKET 
LMQCP_REASON_PROTOCOL_ERROR 
LMQCP_REASON_IMPLEMENTATION_SPECIFIC_ERROR 
LMQCP_REASON_UNSUPPORTED_PROTOCOL 
LMQCP_REASON_CLIENT_ID_INVALID 
LMQCP_REASON_BAD_CREDENTIALS 
LMQCP_REASON_NOT_AUTHORIZED 
LMQCP_REASON_SERVER_UNAVAILABLE 
LMQCP_REASON_SERVER_BUSY 
LMQCP_REASON_BANNED 
LMQCP_REASON_SERVER_SHUTTING_DOWN 
LMQCP_REASON_BAD_AUTHENTICATION_METHOD 
LMQCP_REASON_KEEPALIVE_TIMEOUT 
LMQCP_REASON_SESSION_TAKEN_OVER 
LMQCP_REASON_TOPIC_FILTER_INVALID 
LMQCP_REASON_TOPIC_NAME_INVALID 
LMQCP_REASON_PACKET_ID_IN_USE 
LMQCP_REASON_PACKET_ID_NOT_FOUND 
LMQCP_REASON_MAX_RX_EXCEEDED 
LMQCP_REASON_TOPIC_ALIAS_INVALID 
LMQCP_REASON_PACKET_TOO_LARGE 
LMQCP_REASON_RATELIMIT 
LMQCP_REASON_QUOTA_EXCEEDED 
LMQCP_REASON_ADMINISTRATIVE_ACTION 
LMQCP_REASON_PAYLOAD_FORMAT_INVALID 
LMQCP_REASON_RETAIN_NOT_SUPPORTED 
LMQCP_REASON_QOS_NOT_SUPPORTED 
LMQCP_REASON_USE_ANOTHER_SERVER 
LMQCP_REASON_SERVER_MOVED 
LMQCP_REASON_SHARED_SUBSCRIPTIONS_NOT_SUPPORTED 
LMQCP_REASON_CONNECTION_RATE_EXCEEDED 
LMQCP_REASON_MAXIMUM_CONNECT_TIME 
LMQCP_REASON_SUBSCRIPTION_IDS_NOT_SUPPORTED 
LMQCP_REASON_WILDCARD_SUBSCRIPTIONS_NOT_SUPPORTED 

Definition at line 202 of file lws-mqtt.h.

203  {
204  LMQCP_REASON_SUCCESS = 0x00,
214 
219 
220  /* Begin - Error codes for CONNACK */
225  /* End - Error codes for CONNACK */
226 
229  LMQCP_REASON_BANNED = 0x8a,
241  LMQCP_REASON_RATELIMIT = 0x96,
@ LMQCP_REASON_USE_ANOTHER_SERVER
Definition: lws-mqtt.h:246
@ LMQCP_REASON_TOPIC_NAME_INVALID
Definition: lws-mqtt.h:234
@ LMQCP_REASON_RE_AUTHENTICATE
Definition: lws-mqtt.h:212
@ LMQCP_REASON_SERVER_BUSY
Definition: lws-mqtt.h:227
@ LMQCP_REASON_CONNECTION_RATE_EXCEEDED
Definition: lws-mqtt.h:249
@ LMQCP_REASON_NOT_AUTHORIZED
Definition: lws-mqtt.h:223
@ LMQCP_REASON_RETAIN_NOT_SUPPORTED
Definition: lws-mqtt.h:244
@ LMQCP_REASON_SUBSCRIPTION_IDS_NOT_SUPPORTED
Definition: lws-mqtt.h:251
@ LMQCP_REASON_TOPIC_FILTER_INVALID
Definition: lws-mqtt.h:233
@ LMQCP_REASON_NORMAL_DISCONNECTION
Definition: lws-mqtt.h:204
@ LMQCP_REASON_BAD_CREDENTIALS
Definition: lws-mqtt.h:222
@ LMQCP_REASON_UNSPECIFIED_ERROR
Definition: lws-mqtt.h:214
@ LMQCP_REASON_GRANTED_QOS0
Definition: lws-mqtt.h:205
@ LMQCP_REASON_PACKET_TOO_LARGE
Definition: lws-mqtt.h:239
@ LMQCP_REASON_QUOTA_EXCEEDED
Definition: lws-mqtt.h:241
@ LMQCP_REASON_SESSION_TAKEN_OVER
Definition: lws-mqtt.h:232
@ LMQCP_REASON_PACKET_ID_NOT_FOUND
Definition: lws-mqtt.h:236
@ LMQCP_REASON_PAYLOAD_FORMAT_INVALID
Definition: lws-mqtt.h:243
@ LMQCP_REASON_PACKET_ID_IN_USE
Definition: lws-mqtt.h:235
@ LMQCP_REASON_UNSUPPORTED_PROTOCOL
Definition: lws-mqtt.h:220
@ LMQCP_REASON_NO_MATCHING_SUBSCRIBER
Definition: lws-mqtt.h:209
@ LMQCP_REASON_SERVER_MOVED
Definition: lws-mqtt.h:247
@ LMQCP_REASON_BAD_AUTHENTICATION_METHOD
Definition: lws-mqtt.h:230
@ LMQCP_REASON_DISCONNECT_WILL
Definition: lws-mqtt.h:208
@ LMQCP_REASON_QOS_NOT_SUPPORTED
Definition: lws-mqtt.h:245
@ LMQCP_REASON_TOPIC_ALIAS_INVALID
Definition: lws-mqtt.h:238
@ LMQCP_REASON_KEEPALIVE_TIMEOUT
Definition: lws-mqtt.h:231
@ LMQCP_REASON_MAX_RX_EXCEEDED
Definition: lws-mqtt.h:237
@ LMQCP_REASON_MAXIMUM_CONNECT_TIME
Definition: lws-mqtt.h:250
@ LMQCP_REASON_MALFORMED_PACKET
Definition: lws-mqtt.h:215
@ LMQCP_REASON_NO_SUBSCRIPTION_EXISTED
Definition: lws-mqtt.h:210
@ LMQCP_REASON_CONTINUE_AUTHENTICATION
Definition: lws-mqtt.h:211
@ LMQCP_REASON_SERVER_SHUTTING_DOWN
Definition: lws-mqtt.h:229
@ LMQCP_REASON_GRANTED_QOS1
Definition: lws-mqtt.h:206
@ LMQCP_REASON_SHARED_SUBSCRIPTIONS_NOT_SUPPORTED
Definition: lws-mqtt.h:248
@ LMQCP_REASON_PROTOCOL_ERROR
Definition: lws-mqtt.h:216
@ LMQCP_REASON_SERVER_UNAVAILABLE
Definition: lws-mqtt.h:226
@ LMQCP_REASON_IMPLEMENTATION_SPECIFIC_ERROR
Definition: lws-mqtt.h:217
@ LMQCP_REASON_BANNED
Definition: lws-mqtt.h:228
@ LMQCP_REASON_ADMINISTRATIVE_ACTION
Definition: lws-mqtt.h:242
@ LMQCP_REASON_RATELIMIT
Definition: lws-mqtt.h:240
@ LMQCP_REASON_GRANTED_QOS2
Definition: lws-mqtt.h:207
@ LMQCP_REASON_SUCCESS
Definition: lws-mqtt.h:203
@ LMQCP_REASON_CLIENT_ID_INVALID
Definition: lws-mqtt.h:221
@ LMQCP_REASON_WILDCARD_SUBSCRIPTIONS_NOT_SUPPORTED
Definition: lws-mqtt.h:252

◆ lws_mqtt_property

Enumerator
LMQPROP_INVALID 
LMQPROP_PAYLOAD_FORMAT_INDICATOR 
LMQPROP_MESSAGE_EXPIRY_INTERVAL 
LMQPROP_CONTENT_TYPE 
LMQPROP_RESPONSE_TOPIC 
LMQPROP_CORRELATION_DATA 
LMQPROP_SUBSCRIPTION_IDENTIFIER 
LMQPROP_SESSION_EXPIRY_INTERVAL 
LMQPROP_ASSIGNED_CLIENT_IDENTIFIER 
LMQPROP_SERVER_KEEP_ALIVE 
LMQPROP_AUTHENTICATION_METHOD 
LMQPROP_AUTHENTICATION_DATA 
LMQPROP_REQUEST_PROBLEM_INFORMATION 
LMQPROP_WILL_DELAY_INTERVAL 
LMQPROP_REQUEST_RESPONSE_INFORMATION 
LMQPROP_RESPONSE_INFORMATION 
LMQPROP_SERVER_REFERENCE 
LMQPROP_REASON_STRING 
LMQPROP_RECEIVE_MAXIMUM 
LMQPROP_TOPIC_ALIAS_MAXIMUM 
LMQPROP_TOPIC_ALIAS 
LMQPROP_MAXIMUM_QOS 
LMQPROP_RETAIN_AVAILABLE 
LMQPROP_USER_PROPERTY 
LMQPROP_MAXIMUM_PACKET_SIZE 
LMQPROP_WILDCARD_SUBSCRIPTION_AVAIL 
LMQPROP_SUBSCRIPTION_IDENTIFIER_AVAIL 
LMQPROP_SHARED_SUBSCRIPTION_AVAIL 

Definition at line 255 of file lws-mqtt.h.

256  {
260  LMQPROP_CONTENT_TYPE = 0x03,
261  LMQPROP_RESPONSE_TOPIC = 0x08,
274  LMQPROP_REASON_STRING = 0x1f,
277  LMQPROP_TOPIC_ALIAS = 0x23,
278  LMQPROP_MAXIMUM_QOS = 0x24,
280  LMQPROP_USER_PROPERTY = 0x26,
@ LMQPROP_RESPONSE_INFORMATION
Definition: lws-mqtt.h:271
@ LMQPROP_RETAIN_AVAILABLE
Definition: lws-mqtt.h:278
@ LMQPROP_RECEIVE_MAXIMUM
Definition: lws-mqtt.h:274
@ LMQPROP_AUTHENTICATION_DATA
Definition: lws-mqtt.h:267
@ LMQPROP_RESPONSE_TOPIC
Definition: lws-mqtt.h:260
@ LMQPROP_SERVER_KEEP_ALIVE
Definition: lws-mqtt.h:265
@ LMQPROP_PAYLOAD_FORMAT_INDICATOR
Definition: lws-mqtt.h:257
@ LMQPROP_REQUEST_RESPONSE_INFORMATION
Definition: lws-mqtt.h:270
@ LMQPROP_REQUEST_PROBLEM_INFORMATION
Definition: lws-mqtt.h:268
@ LMQPROP_CORRELATION_DATA
Definition: lws-mqtt.h:261
@ LMQPROP_ASSIGNED_CLIENT_IDENTIFIER
Definition: lws-mqtt.h:264
@ LMQPROP_MESSAGE_EXPIRY_INTERVAL
Definition: lws-mqtt.h:258
@ LMQPROP_INVALID
Definition: lws-mqtt.h:256
@ LMQPROP_MAXIMUM_QOS
Definition: lws-mqtt.h:277
@ LMQPROP_SUBSCRIPTION_IDENTIFIER
Definition: lws-mqtt.h:262
@ LMQPROP_SESSION_EXPIRY_INTERVAL
Definition: lws-mqtt.h:263
@ LMQPROP_SERVER_REFERENCE
Definition: lws-mqtt.h:272
@ LMQPROP_MAXIMUM_PACKET_SIZE
Definition: lws-mqtt.h:280
@ LMQPROP_WILDCARD_SUBSCRIPTION_AVAIL
Definition: lws-mqtt.h:281
@ LMQPROP_AUTHENTICATION_METHOD
Definition: lws-mqtt.h:266
@ LMQPROP_CONTENT_TYPE
Definition: lws-mqtt.h:259
@ LMQPROP_SUBSCRIPTION_IDENTIFIER_AVAIL
Definition: lws-mqtt.h:282
@ LMQPROP_TOPIC_ALIAS_MAXIMUM
Definition: lws-mqtt.h:275
@ LMQPROP_SHARED_SUBSCRIPTION_AVAIL
Definition: lws-mqtt.h:283
@ LMQPROP_TOPIC_ALIAS
Definition: lws-mqtt.h:276
@ LMQPROP_WILL_DELAY_INTERVAL
Definition: lws-mqtt.h:269
@ LMQPROP_REASON_STRING
Definition: lws-mqtt.h:273
@ LMQPROP_USER_PROPERTY
Definition: lws-mqtt.h:279

Function Documentation

◆ lws_read_mqtt()

int lws_read_mqtt ( struct lws *  wsi,
unsigned char *  buf,
lws_filepos_t  len 
)

◆ lws_mqtt_bindata_cmp()

LWS_VISIBLE LWS_EXTERN int lws_mqtt_bindata_cmp ( const lws_mqtt_str_t bd1,
const lws_mqtt_str_t bd2 
)

◆ lws_mqtt_str_init()

LWS_VISIBLE LWS_EXTERN void lws_mqtt_str_init ( lws_mqtt_str_t s,
uint8_t buf,
uint16_t  lim,
char  nf 
)

◆ lws_mqtt_str_create()

LWS_VISIBLE LWS_EXTERN lws_mqtt_str_t* lws_mqtt_str_create ( uint16_t  lim)

◆ lws_mqtt_str_create_init()

LWS_VISIBLE LWS_EXTERN lws_mqtt_str_t* lws_mqtt_str_create_init ( uint8_t buf,
uint16_t  len,
uint16_t  lim 
)

◆ lws_mqtt_str_create_cstr_dup()

LWS_VISIBLE LWS_EXTERN lws_mqtt_str_t* lws_mqtt_str_create_cstr_dup ( const char *  buf,
uint16_t  lim 
)

◆ lws_mqtt_str_next()

LWS_VISIBLE LWS_EXTERN uint8_t* lws_mqtt_str_next ( lws_mqtt_str_t s,
uint16_t budget 
)

◆ lws_mqtt_str_advance()

LWS_VISIBLE LWS_EXTERN int lws_mqtt_str_advance ( lws_mqtt_str_t s,
int  n 
)

◆ lws_mqtt_str_free()

LWS_VISIBLE LWS_EXTERN void lws_mqtt_str_free ( lws_mqtt_str_t **  s)

◆ lws_mqtt_client_send_publish()

LWS_VISIBLE LWS_EXTERN int lws_mqtt_client_send_publish ( struct lws *  wsi,
lws_mqtt_publish_param_t pub,
const void *  buf,
uint32_t  len,
int  final 
)

lws_mqtt_client_send_publish() - lws_write a publish packet

Parameters
wsithe mqtt child wsi
pubadditional information on what we're publishing
bufpayload to send
lenlength of data in buf
finalflag indicating this is the last part

Issues part of, or the whole of, a PUBLISH frame. The first part of the frame contains the header, and uses the .qos and .payload_len parts of pub since MQTT requires the frame to specify the PUBLISH message length at the start. The len paramter may be less than pub.payload_len, in which case subsequent calls with more payload are needed to complete the frame.

Although the connection is stuck waiting for the remainder, in that it can't issue any other frames until the current one is completed, lws returns to the event loop normally and can continue the calls with additional payload even for huge frames as the data becomes available, consistent with timeout needs and latency to start any new frame (even, eg, related to ping / pong).

If you're sending large frames, the OS will typically not allow the data to be sent all at once to kernel side. So you should ideally cut the payload up into 1 or 2- mtu sized chunks and send that.

Final should be set when you're calling with the last part of the payload.

◆ lws_mqtt_client_send_subcribe()

LWS_VISIBLE LWS_EXTERN int lws_mqtt_client_send_subcribe ( struct lws *  wsi,
lws_mqtt_subscribe_param_t sub 
)

lws_mqtt_client_send_subcribe() - lws_write a subscribe packet

Parameters
wsithe mqtt child wsi
subwhich topic(s) we want to subscribe to

For topics other child streams have not already subscribed to, send a packet to the server asking to subscribe to them. If all topics listed are already subscribed to be the shared network connection, just trigger the LWS_CALLBACK_MQTT_SUBSCRIBED callback as if a SUBACK had come.

sub doesn't need to exist after the return from this function.

◆ lws_mqtt_client_send_unsubcribe()

LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_mqtt_client_send_unsubcribe ( struct lws *  wsi,
const lws_mqtt_subscribe_param_t unsub 
)

lws_mqtt_client_send_unsubcribe() - lws_write a unsubscribe packet

Parameters
wsithe mqtt child wsi
subwhich topic(s) we want to unsubscribe from

For topics other child streams are not subscribed to, send a packet to the server asking to unsubscribe from them. If all topics listed are already subscribed by other child streams on the shared network connection, just trigger the LWS_CALLBACK_MQTT_UNSUBSCRIBED callback as if a UNSUBACK had come.

unsub doesn't need to exist after the return from this function.