Fix #920 - add MQTT over Websocket client example

This commit is contained in:
Sergey Lyubka committed 2021-08-01 14:10:21 +01:00
1 parent 3ea4f1fda8
commit 568484f079
9 files changed
+717 -52

No files matched your search

+3 -3
View File
@@ -34,8 +34,8 @@ static void mg_send_u16(struct mg_connection *c, uint16_t value) {
mg_send(c, &value, sizeof(value));
}
static void mqtt_login(struct mg_connection *c, const char *url,
struct mg_mqtt_opts *opts) {
void mg_mqtt_login(struct mg_connection *c, const char *url,
struct mg_mqtt_opts *opts) {
uint32_t total_len = 7 + 1 + 2 + 2;
uint16_t flags = (uint16_t)(((uint16_t) opts->qos & 3) << 3);
struct mg_str user = mg_url_user(url);
@@ -263,7 +263,7 @@ struct mg_connection *mg_mqtt_connect(struct mg_mgr *mgr, const char *url,
if (c != NULL) {
struct mg_mqtt_opts empty;
memset(&empty, 0, sizeof(empty));
mqtt_login(c, url, opts == NULL ? &empty : opts);
mg_mqtt_login(c, url, opts == NULL ? &empty : opts);
c->pfn = mqtt_cb;
}
return c;