Skip to content

Commit ea32695

Browse files
committed
Minor fixes
1 parent 241c45b commit ea32695

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void setup() {
1818
mqtt.mqtt("host", 1883, "user", "pass");
1919

2020

21-
mqtt["foo"] << [](){ return "bar"; };
21+
mqtt["foo"] << [](){ return String("bar"); };
2222
}
2323

2424
void loop() {

examples/basic/basic.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void setup() {
66
mqtt.wifi("ssid", "pass");
77
mqtt.mqtt("server", 1883, "user", "password");
88

9-
mqtt["foo"] << []() { return "bar"; };
9+
mqtt["foo"] << []() { return String("bar"); };
1010
}
1111

1212
void loop() {

src/EasyMqtt.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ class EasyMqtt : public MqttMap {
2424
*/
2525
void mqttReconnect() {
2626
while (!mqttClient.connected()) {
27-
if (mqttClient.connect(deviceId.c_str(), mqtt_username, mqtt_password), get("system")["connected"].getTopic().c_str(), 2, 0, "false") {
27+
if (mqttClient.connect(deviceId.c_str(), mqtt_username, mqtt_password)) {
2828
debug("Connected to MQTT");
2929
subscribe();
30-
get("system")["connected"].publish("true");
3130
} else {
3231
Serial.print("failed, rc=");
3332
Serial.print(mqttClient.state());
@@ -46,7 +45,7 @@ class EasyMqtt : public MqttMap {
4645
return String(ESP.getFreeHeap());
4746
};
4847
get("system")["uptime"] << []() {
49-
return String(millis());
48+
return String(millis() / 1000);
5049
};
5150
get("system")["reset"] >> [](String value) {
5251
ESP.reset();
@@ -70,7 +69,7 @@ class EasyMqtt : public MqttMap {
7069
Serial.print(".");
7170
}
7271
Serial.println("WiFi connected");
73-
Serial.println("IP address: ");
72+
Serial.print("IP address: ");
7473
Serial.println(WiFi.localIP());
7574

7675
Serial.print("Chip ID : ");
@@ -99,6 +98,9 @@ class EasyMqtt : public MqttMap {
9998
mqttClient.setServer(host, port);
10099
mqtt_username = username;
101100
mqtt_password = password;
101+
102+
Serial.print("Topic: ");
103+
Serial.println(getTopic());
102104
}
103105

104106
/**

src/MqttMap.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ class MqttMap {
6464
*/
6565
void subscribe() {
6666
if (outFunction != NULL) {
67-
String topic = getTopic();
68-
client->subscribe(topic.c_str());
67+
client->subscribe(getTopic().c_str());
6968
}
7069
MqttMap* child = children;
7170
while (child != NULL) {

0 commit comments

Comments
 (0)