23 #include <sol-common-buildopts.h>
142 #ifndef SOL_NO_API_VERSION
143 #define SOL_MQTT_MESSAGE_API_VERSION (1)
180 #ifndef SOL_NO_API_VERSION
181 #define SOL_MQTT_HANDLERS_API_VERSION (1)
272 #ifndef SOL_NO_API_VERSION
273 #define SOL_MQTT_CONFIG_API_VERSION (1)
411 #ifndef SOL_NO_API_VERSION
419 #define SOL_MQTT_MESSAGE_CHECK_API_VERSION(msg_, ...) \
420 if (SOL_UNLIKELY((msg_)->api_version != \
421 SOL_MQTT_MESSAGE_API_VERSION)) { \
422 SOL_ERR("Unexpected API version (message is %" PRIu16 ", expected %" PRIu16 ")", \
423 (msg_)->api_version, SOL_MQTT_MESSAGE_API_VERSION); \
424 return __VA_ARGS__; \
427 #define SOL_MQTT_MESSAGE_CHECK_API_VERSION(msg_, ...)
const struct sol_mqtt_handlers handlers
Handlers to be used with this connection.
Definition: sol-mqtt.h:346
const char * client_id
NULL terminated string that should be used as client ID.
Definition: sol-mqtt.h:301
struct sol_mqtt_message sol_mqtt_message
MQTT Message.
const struct sol_mqtt_message * will
A message that the broker should send when the client disconnects.
Definition: sol-mqtt.h:316
bool clean_session
If set, the broker will drop all messages and subscriptions when the client disconnects.
Definition: sol-mqtt.h:284
Broker unavailable at provided host.
Definition: sol-mqtt.h:118
uint16_t api_version
Should always be set to SOL_MQTT_MESSAGE_API_VERSION.
Definition: sol-mqtt.h:147
uint16_t api_version
Should always be set to SOL_MQTT_CONFIG_API_VERSION.
Definition: sol-mqtt.h:277
char * topic
The topic which the message was/will be posted to.
Definition: sol-mqtt.h:153
void(* subscribe)(void *data, struct sol_mqtt *mqtt)
On subscribe callback.
Definition: sol-mqtt.h:253
Client ID rejected by the broker.
Definition: sol-mqtt.h:113
int sol_mqtt_reconnect(struct sol_mqtt *mqtt)
Reestablish the connection to the MQTT broker.
struct sol_cert sol_cert
Certificate handler.
Definition: sol-certificate.h:48
int sol_mqtt_publish(const struct sol_mqtt *mqtt, struct sol_mqtt_message *message)
Send the Broker a message to be published in a given topic.
MQTT callback handlers.
Definition: sol-mqtt.h:179
const char * password
NULL terminated string with the password.
Definition: sol-mqtt.h:311
bool retain
If true, the message will be retained by the broker.
Definition: sol-mqtt.h:173
sol_mqtt_conn_status
Connection status.
Definition: sol-mqtt.h:94
These are routines that Soletta provides for its buffer implementation.
static struct sol_mqtt_message message
Definition: mqtt-publish.c:35
struct sol_mqtt_config sol_mqtt_config
Server Configuration.
sol_mqtt_qos qos
The message Quality of service.
Definition: sol-mqtt.h:168
struct sol_buffer * payload
The message payload.
Definition: sol-mqtt.h:158
const struct sol_cert * client_cert
Client certificate for SSL connections.
Definition: sol-mqtt.h:326
void(* connect)(void *data, struct sol_mqtt *mqtt)
On connect callback.
Definition: sol-mqtt.h:198
const char * host
The host address of the MQTT broker.
Definition: sol-mqtt.h:341
int id
The message Id.
Definition: sol-mqtt.h:163
uint16_t port
The host port to connect.
Definition: sol-mqtt.h:289
struct sol_mqtt * sol_mqtt_connect(const struct sol_mqtt_config *config)
Connect to a MQTT broker.
void sol_mqtt_disconnect(struct sol_mqtt *mqtt)
Disconnect from MQTT Broker.
void(* publish)(void *data, struct sol_mqtt *mqtt)
On publish callback.
Definition: sol-mqtt.h:223
int sol_mqtt_subscribe(const struct sol_mqtt *mqtt, const char *topic, sol_mqtt_qos qos)
Ask the Broker to be subscribed to a given topic.
const struct sol_cert * private_key
Private key for SSL connections.
Definition: sol-mqtt.h:331
Disconnected due to unexpected reasons.
Definition: sol-mqtt.h:98
MQTT protocol rejected by the broker.
Definition: sol-mqtt.h:108
These routines are used for Soletta's certificate handling.
sol_mqtt_qos
MQTT QOS level for message delivery.
Definition: sol-mqtt.h:64
This is the highest quality of service, for use when neither loss nor duplication of messages are acc...
Definition: sol-mqtt.h:86
const void * data
User data provided to the callbacks.
Definition: sol-mqtt.h:336
struct sol_mqtt_handlers sol_mqtt_handlers
MQTT callback handlers.
const struct sol_cert * ca_cert
CA Certificate for SSL connections.
Definition: sol-mqtt.h:321
void(* disconnect)(void *data, struct sol_mqtt *mqtt)
On disconnect callback.
Definition: sol-mqtt.h:211
time_t keep_alive
Time interval between PING messages that should be sent by the broker to the client in miliseconds...
Definition: sol-mqtt.h:295
int sol_mqtt_get_connection_status(const struct sol_mqtt *mqtt)
Get connection status.
static char * topic
Definition: mqtt-publish.c:34
void(* message)(void *data, struct sol_mqtt *mqtt, const struct sol_mqtt_message *message)
On message callback.
Definition: sol-mqtt.h:241
void(* unsubscribe)(void *data, struct sol_mqtt *mqtt)
On unsubscribe callback.
Definition: sol-mqtt.h:265
This quality of service ensures that the message arrives at the receiver at least once...
Definition: sol-mqtt.h:79
The message is delivered according to the capabilities of the underlying network. ...
Definition: sol-mqtt.h:71
A sol_buffer is a dynamic array, that can be resized if needed.
Definition: sol-buffer.h:130
Successfully connected to the broker.
Definition: sol-mqtt.h:103
struct sol_mqtt sol_mqtt
MQTT Object.
Definition: sol-mqtt.h:133
MQTT Message.
Definition: sol-mqtt.h:141
Server Configuration.
Definition: sol-mqtt.h:271
uint16_t api_version
Should always be set to SOL_MQTT_HANDLERS_API_VERSION.
Definition: sol-mqtt.h:185
const char * username
NULL terminated string with the username.
Definition: sol-mqtt.h:306