Emanuel Kuflik
/
smat_controller
Diff: main.cpp
- Revision:
- 1:7a2d97a8800e
- Parent:
- 0:f945f1ae269b
- Child:
- 2:f10d6fecb345
diff -r f945f1ae269b -r 7a2d97a8800e main.cpp --- a/main.cpp Wed Nov 27 02:45:11 2019 +0000 +++ b/main.cpp Wed Nov 27 17:14:24 2019 +0000 @@ -95,18 +95,13 @@ This function sends a message to the test topic. It returns a value of -1 if there is an issue */ -int send_message(MQTT::Client<MQTTNetwork, Countdown>* client) { +int send_message(MQTT::Client<MQTTNetwork, Countdown>* client, char* topic) { pc.printf("Sending a message!\r\n"); MQTT::Message message; char buf[100]; sprintf(buf, "Hello World! This is a test message!\r\n"); - message.qos = MQTT::QOS1; - message.retained = false; - message.dup = false; - message.payload = (void*)buf; - message.payloadlen = strlen(buf)+1; - int rc = client->publish("MQTT_test", message); + int rc = client->publish(topic, (char*) buf, strlen(buf)+1, MQTT::QOS1); if (rc != 0) { return -1; @@ -147,7 +142,7 @@ pc.printf("Subscribed!\r\n"); } - rc = send_message(client); + rc = send_message(client, topic); if (rc != 0) { pc.printf("There was a problem sending the message: %d\r\n", rc);