Use mg_str, not pointers, in mg_mqtt_{sub,pub}

This commit is contained in:
Sergey Lyubka committed 2022-01-19 09:57:27 +00:00
1 parent fe813ee247
commit 226917e1cd
9 files changed
+45 -48

No files matched your search

+2 -2
View File
@@ -43,10 +43,10 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
struct mg_str subt = mg_str(s_sub_topic);
struct mg_str pubt = mg_str(s_pub_topic), data = mg_str("hello");
LOG(LL_INFO, ("CONNECTED to %s", s_url));
mg_mqtt_sub(c, &subt, s_qos);
mg_mqtt_sub(c, subt, s_qos);
LOG(LL_INFO, ("SUBSCRIBED to %.*s", (int) subt.len, subt.ptr));
mg_mqtt_pub(c, &pubt, &data, s_qos, false);
mg_mqtt_pub(c, pubt, data, s_qos, false);
LOG(LL_INFO, ("PUBSLISHED %.*s -> %.*s", (int) data.len, data.ptr,
(int) pubt.len, pubt.ptr));
} else if (ev == MG_EV_MQTT_MSG) {