@@ -30,6 +30,9 @@ class EasyMqtt : public MqttEntry {
30
30
String sSsid = config ().getString (" wifi.ssid" , " " );
31
31
char ssid[sSsid .length () + 1 ];
32
32
strcpy (ssid, sSsid .c_str ());
33
+
34
+ String name = config ().getString (" device.name" , deviceId);
35
+ // WiFi.hostname("WebPool"); // Set the name of the device
33
36
34
37
String sPass = config ().getString (" wifi.password" , " " );
35
38
char pass[sPass .length () + 1 ];
@@ -110,34 +113,23 @@ class EasyMqtt : public MqttEntry {
110
113
}
111
114
}
112
115
113
- void debug (String msg) {
114
- #ifdef DEBUG
115
- Serial.println (msg);
116
- #endif
117
- if (mqttClient.connected ()) {
118
- get (" system/debug" ).publish (msg);
119
- }
120
- }
121
-
122
- void debug (String key, String value) {
123
- debug (key + " = " + value);
124
- }
125
-
126
116
public:
127
117
EasyMqtt () : MqttEntry(" easyMqtt" , mqttClient) {
128
118
#ifdef DEBUG
129
119
Serial.begin (115200 );
130
120
#endif
131
121
deviceId = String (ESP.getChipId ());
132
122
133
- debug (" test" );
134
123
configEntry = new ConfigEntry (mqttClient, *this );
135
124
addChild (configEntry);
136
125
137
126
get (" system" ).setInterval (30 );
138
127
get (" system" )[" deviceId" ] << [this ]() {
139
128
return deviceId;
140
129
};
130
+ get (" system" )[" name" ] << [this ]() {
131
+ return config ().getString (" device.name" , deviceId);
132
+ };
141
133
get (" system" )[" mem" ][" heap" ] << []() {
142
134
return String (ESP.getFreeHeap ());
143
135
};
@@ -169,6 +161,19 @@ class EasyMqtt : public MqttEntry {
169
161
};
170
162
}
171
163
164
+ void debug (String msg) {
165
+ #ifdef DEBUG
166
+ Serial.println (msg);
167
+ #endif
168
+ if (mqttClient.connected ()) {
169
+ get (" system/debug" ).publish (msg);
170
+ }
171
+ }
172
+
173
+ void debug (String key, String value) {
174
+ debug (key + " = " + value);
175
+ }
176
+
172
177
ConfigEntry & config () {
173
178
return *configEntry;
174
179
}
0 commit comments