Skip to content

Commit 17125cb

Browse files
committed
typo fixes
1 parent 0ca73bf commit 17125cb

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/ThingESPClient.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#pragma once
22

33
#if defined(ESP8266)
4-
#include <ESP8266WiFi.h>
4+
#include <ESP8266WiFi.h>
55
#elif defined(ESP32)
6-
#include <WiFi.h>
6+
#include <WiFi.h>
77
#endif
88

99
#ifndef _DISABLE_TLS_
10-
11-
#include <WiFiClientSecure.h>
12-
10+
#include <WiFiClientSecure.h>
1311
#endif
1412

1513
#include <stdint.h>
@@ -37,7 +35,7 @@ namespace thing_esp {
3735
projectName = _projectName;
3836
credentials = _credentials;
3937

40-
genMetaData();
38+
this->genMetaData();
4139
};
4240

4341
void initDevice() {
@@ -72,7 +70,7 @@ namespace thing_esp {
7270

7371
if (client.connect(outName.c_str(), outName.c_str(), credentials)) {
7472
LOG("SOCKET", "Connected to ThingESP successfully")
75-
client.subscribe(topic.c_str());
73+
client.subscribe(c_topic);
7674
publishMSG(get_rate_limits_msg());
7775
} else {
7876
LOG_VALUE("SOCKET", "Error connecting to ThingESP! Error code: ", client.state());
@@ -93,9 +91,7 @@ namespace thing_esp {
9391
/*
9492
* the callback function
9593
*/
96-
String (*callbackFunction)(String)
97-
98-
override;
94+
String (*callbackFunction)(String) override;
9995

10096

10197
/*
@@ -115,7 +111,7 @@ namespace thing_esp {
115111

116112

117113
void publishMSG(const char *_msg) override {
118-
client.publish(topic.c_str(), _msg);
114+
client.publish(c_topic, _msg);
119115
}
120116

121117
void callback(char *topic, byte *payload, unsigned int length) {

src/thingesp/Device.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#pragma once
2+
23
#include <Arduino.h>
34
#include <stdint.h>
45
#include <string.h>
6+
57
#include "../PubSubClient/PubSubClient.h"
8+
9+
610
namespace thing_esp {
711
class DeviceData {
812
public:
@@ -23,6 +27,7 @@ namespace thing_esp {
2327
void genMetaData() {
2428
this->outName = projectName + "@" + username;
2529
this->topic = projectName + "/" + username;
30+
this->c_topic = topic.c_str();
2631
}
2732

2833
String projectName;
@@ -31,6 +36,7 @@ namespace thing_esp {
3136

3237
String outName;
3338
String topic;
39+
const char* c_topic;
3440

3541
const char *ssid;
3642
const char *ssid_password;
@@ -41,10 +47,16 @@ namespace thing_esp {
4147
/*
4248
* Check if TLS Disabled or not
4349
*/
44-
#if !defined(_DISABLE_TLS_) && !defined(ESP32)
45-
unsigned int MQTT_PORT = 1899; // tls port
50+
#if !defined(_MQTT_PORT_)
51+
52+
#if !defined(_DISABLE_TLS_) && !defined(ESP32)
53+
unsigned int MQTT_PORT = 1899; // tls port
54+
#else
55+
unsigned int MQTT_PORT = 1893; // non-tls port
56+
#endif
57+
4658
#else
47-
unsigned int MQTT_PORT = 1893; // non-tls port
59+
unsigned int MQTT_PORT = _MQTT_PORT_;
4860
#endif
4961

5062

0 commit comments

Comments
 (0)