libwebsockets
Lightweight C library for HTML5 websockets
|
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_subscribe_param_s |
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 |
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 |
union lws_mqtt_fixed_hdr_t |
Definition at line 75 of file lws-mqtt.h.
Data Fields | ||
---|---|---|
struct lws_mqtt_fixed_hdr_t | flags | |
uint8_t | bits |
struct lws_mqtt_client_connect_param_s |
Definition at line 90 of file lws-mqtt.h.
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 |
struct lws_mqtt_publish_param_s |
Definition at line 125 of file lws-mqtt.h.
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 |
struct topic_elem |
Definition at line 142 of file lws-mqtt.h.
Data Fields | ||
---|---|---|
const char * | name | |
lws_mqtt_qos_levels_t | qos | |
uint8_t | acked |
struct lws_mqtt_subscribe_param_s |
Definition at line 153 of file lws-mqtt.h.
Data Fields | ||
---|---|---|
uint32_t | num_topics | |
lws_mqtt_topic_elem_t * | topic | |
uint16_t | packet_id |
struct lws_mqtt_fixed_hdr_t.flags |
struct lws_mqtt_client_connect_param_s.will_param |
Definition at line 103 of file lws-mqtt.h.
Data Fields | ||
---|---|---|
const char * | topic | |
const char * | message | |
lws_mqtt_qos_levels_t | qos | |
uint8_t | retain |
struct lws_mqtt_client_connect_param_s.birth_param |
Definition at line 110 of file lws-mqtt.h.
Data Fields | ||
---|---|---|
const char * | topic | |
const char * | message | |
lws_mqtt_qos_levels_t | qos | |
uint8_t | retain |
#define MQTT_VER_3_1_1 4 |
Definition at line 35 of file lws-mqtt.h.
#define LWS_MQTT_FINAL_PART 1 |
Definition at line 37 of file lws-mqtt.h.
#define LWS_MQTT_MAX_AWSIOT_TOPICLEN 256 |
Definition at line 39 of file lws-mqtt.h.
#define LWS_MQTT_MAX_TOPICLEN 65535 |
Definition at line 40 of file lws-mqtt.h.
#define LWS_MQTT_MAX_CIDLEN 128 |
Definition at line 41 of file lws-mqtt.h.
#define LWS_MQTT_RANDOM_CIDLEN |
Definition at line 42 of file lws-mqtt.h.
#define LWS_MQTT_SHADOW_MAX_THING_LEN 128 |
Definition at line 44 of file lws-mqtt.h.
#define LWS_MQTT_SHADOW_MAX_SHADOW_LEN 64 |
Definition at line 45 of file lws-mqtt.h.
#define LWS_MQTT_SHADOW_UPDATE_STR "/update" |
Definition at line 46 of file lws-mqtt.h.
#define LWS_MQTT_SHADOW_DELETE_STR "/delete" |
Definition at line 47 of file lws-mqtt.h.
#define LWS_MQTT_SHADOW_GET_STR "/get" |
Definition at line 48 of file lws-mqtt.h.
#define LWS_MQTT_SHADOW_RESP_ACCEPTED_STR "/accepted" |
Definition at line 49 of file lws-mqtt.h.
#define LWS_MQTT_SHADOW_RESP_REJECTED_STR "/rejected" |
Definition at line 50 of file lws-mqtt.h.
#define LWS_MQTT_SHADOW_RESP_DELTA_STR "/delta" |
Definition at line 51 of file lws-mqtt.h.
#define LWS_MQTT_SHADOW_RESP_DOCUMENT_STR "/documents" |
Definition at line 52 of file lws-mqtt.h.
#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.
#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.
#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.
#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.
#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.
#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.
#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.
#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.
#define LWS_MQTT_SHADOW_PREFIX_FORMAT "$aws/things/%s" |
Definition at line 61 of file lws-mqtt.h.
#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.
#define LWS_MQTT_SHADOW_UNNAMED_SHADOW_TOPIC_FORMAT LWS_MQTT_SHADOW_PREFIX_FORMAT "/shadow%s" |
Definition at line 63 of file lws-mqtt.h.
#define LWS_MQTT_SHADOW_UNNAMED_TOPIC_MATCH "$aws/things/+/shadow/+" |
Definition at line 64 of file lws-mqtt.h.
#define LWS_MQTT_SHADOW_NAMED_TOPIC_MATCH "$aws/things/+/shadow/name/+/+" |
Definition at line 65 of file lws-mqtt.h.
typedef struct _lws_mqtt_related lws_mqtt_related_t |
Definition at line 1 of file lws-mqtt.h.
typedef struct lws_mqtt_str_st lws_mqtt_str_t |
Definition at line 1 of file lws-mqtt.h.
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 |
Enumerator | |
---|---|
QOS0 | |
QOS1 | |
QOS2 | |
RESERVED_QOS_LEVEL | |
FAILURE_QOS_LEVEL |
Definition at line 67 of file lws-mqtt.h.
Definition at line 161 of file lws-mqtt.h.
Definition at line 181 of file lws-mqtt.h.
enum lws_mqtt_reason_t |
Definition at line 202 of file lws-mqtt.h.
enum lws_mqtt_property |
Definition at line 255 of file lws-mqtt.h.
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_t* lws_mqtt_str_create | ( | uint16_t | lim | ) |
LWS_VISIBLE LWS_EXTERN lws_mqtt_str_t* lws_mqtt_str_create_init | ( | uint8_t * | buf, |
uint16_t | len, | ||
uint16_t | lim | ||
) |
LWS_VISIBLE LWS_EXTERN lws_mqtt_str_t* lws_mqtt_str_create_cstr_dup | ( | const char * | buf, |
uint16_t | lim | ||
) |
LWS_VISIBLE LWS_EXTERN uint8_t* lws_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_mqtt_client_send_publish() - lws_write a publish packet
wsi | the mqtt child wsi |
pub | additional information on what we're publishing |
buf | payload to send |
len | length of data in buf |
final | flag 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_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
wsi | the mqtt child wsi |
sub | which 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_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
wsi | the mqtt child wsi |
sub | which 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.