MQTT-C
|
An MQTT client. More...
#include <mqtt.h>
Data Fields | |
mqtt_pal_socket_handle | socketfd |
The socket connecting to the MQTT broker. | |
uint16_t | pid_lfsr |
The LFSR state used to generate packet ID's. | |
uint16_t | keep_alive |
The keep-alive time in seconds. | |
int | number_of_keep_alives |
A counter counting pings that have been sent to keep the connection alive. More... | |
mqtt_pal_time_t | time_of_last_send |
The timestamp of the last message sent to the buffer. More... | |
enum MQTTErrors | error |
The error state of the client. More... | |
int | response_timeout |
The timeout period in seconds. More... | |
int | number_of_timeouts |
A counter counting the number of timeouts that have occurred. | |
double | typical_response_time |
Approximately much time it has typically taken to receive responses from the broker. More... | |
void(* | publish_response_callback )(void **state, struct mqtt_response_publish *publish) |
The callback that is called whenever a publish is received from the broker. More... | |
void * | publish_response_callback_state |
A pointer to any publish_response_callback state information you need. More... | |
enum MQTTErrors(* | inspector_callback )(struct mqtt_client *) |
A user-specified callback, triggered on each mqtt_sync, allowing the user to perform state inspections (and custom socket error detection) on the client. More... | |
void(* | reconnect_callback )(struct mqtt_client *, void **) |
A callback that is called whenever the client is in an error state. More... | |
void * | reconnect_state |
A pointer to some state. A pointer to this member is passed to mqtt_client::reconnect_callback. | |
struct { | |
uint8_t * mem_start | |
The start of the receive buffer's memory. | |
size_t mem_size | |
The size of the receive buffer's memory. | |
uint8_t * curr | |
A pointer to the next writtable location in the receive buffer. | |
size_t curr_sz | |
The number of bytes that are still writable at curr. | |
} | recv_buffer |
The buffer where ingress data is temporarily stored. | |
mqtt_pal_mutex_t | mutex |
A variable passed to support thread-safety. More... | |
struct mqtt_message_queue | mq |
The sending message queue. | |
An MQTT client.
enum MQTTErrors mqtt_client::error |
The error state of the client.
error should be MQTT_OK for the entirety of the connection.
enum MQTTErrors(* mqtt_client::inspector_callback) (struct mqtt_client *) |
A user-specified callback, triggered on each mqtt_sync, allowing the user to perform state inspections (and custom socket error detection) on the client.
This callback is triggered on each call to mqtt_sync. If it returns MQTT_OK then mqtt_sync will continue normally (performing reads and writes). If it returns an error then mqtt_sync will not call reads and writes.
This callback can be used to perform custom error detection, namely platform specific socket error detection, and force the client into an error state.
This member is always initialized to NULL but it can be manually set at any time.
mqtt_pal_mutex_t mqtt_client::mutex |
A variable passed to support thread-safety.
A pointer to this variable is passed to MQTT_PAL_MUTEX_LOCK
, and MQTT_PAL_MUTEX_UNLOCK
.
int mqtt_client::number_of_keep_alives |
A counter counting pings that have been sent to keep the connection alive.
void(* mqtt_client::publish_response_callback) (void **state, struct mqtt_response_publish *publish) |
The callback that is called whenever a publish is received from the broker.
Any topics that you have subscribed to will be returned from the broker as mqtt_response_publish messages. All the publishes received from the broker will be passed to this function.
void* mqtt_client::publish_response_callback_state |
A pointer to any publish_response_callback state information you need.
void(* mqtt_client::reconnect_callback) (struct mqtt_client *, void **) |
A callback that is called whenever the client is in an error state.
This callback is responsible for: application level error handling, closing previous sockets, and reestabilishing the connection to the broker and session configurations (i.e. subscriptions).
int mqtt_client::response_timeout |
The timeout period in seconds.
If the broker doesn't return an ACK within response_timeout seconds a timeout will occur and the message will be retransmitted.
mqtt_pal_time_t mqtt_client::time_of_last_send |
The timestamp of the last message sent to the buffer.
This is used to detect the need for keep-alive pings.
double mqtt_client::typical_response_time |
Approximately much time it has typically taken to receive responses from the broker.