SELKIELogger
1.0.0
|
Go to the source code of this file.
Functions | |
mqtt_conn * | mqtt_openConnection (const char *host, const int port, mqtt_queue_map *qm) |
Open and configure a connection to an MQTT server. More... | |
void | mqtt_closeConnection (mqtt_conn *conn) |
Close MQTT server connection. More... | |
bool | mqtt_subscribe_batch (mqtt_conn *conn, mqtt_queue_map *qm) |
Subscribe to all topics configured in a mqtt_queue_map. More... | |
void | mqtt_enqueue_messages (mqtt_conn *conn, void *userdat_qm, const struct mosquitto_message *inmsg) |
MQTT callback: Accept incoming messages and process. More... | |
bool | mqtt_victron_keepalive (mqtt_conn *conn, mqtt_queue_map *qm, char *sysid) |
Send MQTT keepalive commands required by Victron systems. More... | |
MQTT connection handling
Definition in file MQTTConnection.h.
void mqtt_closeConnection | ( | mqtt_conn * | conn | ) |
Close MQTT server connection.
Disconnects from server (if still connected), stops the mosquitto event loop and frees resources associated with the connection.
[in,out] | conn | Connection to close out |
Definition at line 76 of file MQTTConnection.c.
void mqtt_enqueue_messages | ( | mqtt_conn * | conn, |
void * | userdat_qm, | ||
const struct mosquitto_message * | inmsg | ||
) |
MQTT callback: Accept incoming messages and process.
Registered with mosquitto as a message callback by mqtt_openConnection and called by the mosquitto event loop for every message matching our subscriptions.
If mqtt_queue_map.dumpall is true, messages not matching a configured topic will be queued under SLCHAN_RAW as strings with the format "topic: payload". Otherwise they will be ignored.
Zero length messages are never queued.
[in] | conn | Pointer to MQTT Connection structure |
[in] | userdat_qm | mqtt_queue_map - passed as void pointer by mosquitto library |
[in] | inmsg | Incoming message |
Definition at line 136 of file MQTTConnection.c.
mqtt_conn* mqtt_openConnection | ( | const char * | host, |
const int | port, | ||
mqtt_queue_map * | qm | ||
) |
Open and configure a connection to an MQTT server.
Connects to the specified host and port, then configures it based on the configuration in an mqtt_queue_map instance. Sets mqtt_enqueue_messages as the callback for new messages and starts the mosquitto event loop.
[in] | host | Hostname or IP address (as string) |
[in] | port | Port number |
[in] | qm | mqtt_queue_map instance to use for configuration |
Definition at line 38 of file MQTTConnection.c.
bool mqtt_subscribe_batch | ( | mqtt_conn * | conn, |
mqtt_queue_map * | qm | ||
) |
Subscribe to all topics configured in a mqtt_queue_map.
Subscribes to all configured topics in an mqtt_queue_map using mosquitto_subscribe_multiple (if available) or by falling back to placing multiple individual subscription requests if not.
[in] | conn | Pointer to MQTT Connection structure |
[in] | qm | Pointer to mqtt_queue_map |
Definition at line 90 of file MQTTConnection.c.
bool mqtt_victron_keepalive | ( | mqtt_conn * | conn, |
mqtt_queue_map * | qm, | ||
char * | sysid | ||
) |
Send MQTT keepalive commands required by Victron systems.
Sends a keepalive request for all configured topics in the format required for Victron MQTT systems.
[in] | conn | Pointer to MQTT Connection structure |
[in] | qm | Pointer to mqtt_queue_map |
[in] | sysid | System serial number |
Definition at line 191 of file MQTTConnection.c.