Committer: Ronny Hansen <ronnyhan@gmail.com>
On branch SSL Changes to be committed: modified: include/mqtt.h modified: mqtt.c Implemented support for SSL/TLS. Uses config setting "CONFIG_MQTT_SECURITY_ON" to enable this feature. Breaking changes on client_connect() interface to support SSL, but shouldnt be an issue as this is an internal interface
This commit is contained in:
1 parent
c8687d04e4
commit
5a931e2fa3
2 files changed
+166
-29
No files matched your search
Regular → Executable
+20
@@ -7,6 +7,19 @@
|
||||
#include "ringbuf.h"
|
||||
|
||||
|
||||
#if defined(CONFIG_MQTT_SECURITY_ON) // ENABLE MQTT OVER SSL
|
||||
#include "openssl/ssl.h"
|
||||
|
||||
#define ClientRead(buf,num) SSL_read(client->ssl, buf, num)
|
||||
#define ClientWrite(buf,num) SSL_write(client->ssl, buf, num)
|
||||
|
||||
#else
|
||||
|
||||
#define ClientRead(buf,num) read(client->socket, buf, num)
|
||||
#define ClientWrite(buf,num) write(client->socket, buf, num)
|
||||
#endif
|
||||
|
||||
|
||||
typedef void (* mqtt_callback)(void *, void *);
|
||||
|
||||
typedef struct {
|
||||
@@ -62,6 +75,12 @@ typedef struct mqtt_state_t
|
||||
|
||||
typedef struct {
|
||||
int socket;
|
||||
|
||||
#if defined(CONFIG_MQTT_SECURITY_ON) // ENABLE MQTT OVER SSL
|
||||
SSL_CTX *ctx;
|
||||
SSL *ssl;
|
||||
#endif
|
||||
|
||||
mqtt_settings *settings;
|
||||
mqtt_state_t mqtt_state;
|
||||
mqtt_connect_info_t connect_info;
|
||||
@@ -71,6 +90,7 @@ typedef struct {
|
||||
} mqtt_client;
|
||||
|
||||
mqtt_client *mqtt_start(mqtt_settings *mqtt_info);
|
||||
void mqtt_stop();
|
||||
void mqtt_task(void *pvParameters);
|
||||
void mqtt_subscribe(mqtt_client *client, char *topic, uint8_t qos);
|
||||
void mqtt_publish(mqtt_client* client, char *topic, char *data, int len, int qos, int retain);
|
||||
|
||||
Reference in new issue
Block a user