@@ -16,7 +16,7 @@ void EasyMqtt::connectWiFi() {
16
16
debug (" Connecting to wifi" );
17
17
WiFi.mode (WIFI_STA);
18
18
19
- WiFi.begin (wifi_ssid, wifi_password );
19
+ WiFi.begin (config (). get ( " wifi.ssid " , " " ), config (). get ( " wifi.password " , " " ) );
20
20
21
21
#ifdef DEBUG
22
22
WiFi.printDiag (Serial);
@@ -38,7 +38,7 @@ void EasyMqtt::connectWiFi() {
38
38
debug (" IP address" , WiFi.softAPIP ().toString ());
39
39
}
40
40
debug (" devideId" , deviceId);
41
- webPortal.setup (* this , config (), ntp ());
41
+ webPortal.setup (this , & config (), & ntp ());
42
42
}
43
43
}
44
44
@@ -64,9 +64,9 @@ void EasyMqtt::connectMqtt() {
64
64
});
65
65
});
66
66
67
- mqttClient.setServer (mqtt_host, mqtt_port );
67
+ mqttClient.setServer (config (). get ( " mqtt.host " , " " ), config (). getInt ( " mqtt.port " , 1883 ) );
68
68
69
- if (mqttClient.connect (deviceId.c_str (), mqtt_username, mqtt_password ), get (" $system" )[" online" ].getTopic ().c_str (), 1 , 1 , " OFF" ) {
69
+ if (mqttClient.connect (deviceId.c_str (), config (). get ( " mqtt.username " , " " ), config (). get (" mqtt.password " , " " ), get ( " $system" )[" online" ].getTopic ().c_str (), 1 , 1 , " OFF" ) ) {
70
70
debug (" Connected to MQTT" );
71
71
72
72
setPublishFunction ([&](Entry* entry, String message){
@@ -186,8 +186,6 @@ NTPClient & EasyMqtt::ntp() {
186
186
void EasyMqtt::wifi (const char * ssid, const char * password) {
187
187
config ().get (" wifi.ssid" , ssid);
188
188
config ().get (" wifi.password" , password);
189
- wifi_ssid = ssid;
190
- wifi_password = password;
191
189
}
192
190
193
191
/* *
@@ -199,10 +197,6 @@ void EasyMqtt::mqtt(const char* host, int port, const char* username, const char
199
197
config ().get (" mqtt.port" , String (port).c_str ());
200
198
config ().get (" mqtt.username" , username);
201
199
config ().get (" mqtt.password" , password);
202
- mqtt_host = host;
203
- mqtt_port = port;
204
- mqtt_username = username;
205
- mqtt_password = password;
206
200
}
207
201
208
202
/* *
0 commit comments