Skip to content

Commit f307bd7

Browse files
committed
Remove config until reset is stable
1 parent 6f63318 commit f307bd7

File tree

6 files changed

+72
-258
lines changed

6 files changed

+72
-258
lines changed

html/template.html

Lines changed: 5 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -204,69 +204,6 @@ <h1>Device Info - {device_id}</h1>
204204
</div>
205205
</div>
206206

207-
<div role="tabpanel" class="tab-pane" id="config">
208-
<div class="container-fluid">
209-
<div class="row">
210-
<div class="col-md-12">
211-
<form class="form-horizontal" action="/save" method="POST">
212-
<!-- split:main3 -->
213-
<!-- split:config_header -->
214-
<br />
215-
<h3>{title}</h3><hr/>
216-
<!-- split:config_header -->
217-
<!-- split:config_entry -->
218-
<div class="form-group">
219-
<label for="{key}" class="col-sm-2 control-label">{key}</label>
220-
<div class="col-sm-8">
221-
<input type="{type}" class="form-control" name="{key}" placeholder="" value="{value}">
222-
</div>
223-
</div>
224-
<!-- split:config_entry -->
225-
<div class="form-group">
226-
<label for="inputEmail3" class="col-sm-2 control-label">Password</label>
227-
<div class="col-sm-8">
228-
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
229-
</div>
230-
</div>
231-
</br>
232-
<h3>MQTT</h3><hr/>
233-
<div class="form-group">
234-
<label for="inputUsername" class="col-sm-2 control-label">Username</label>
235-
<div class="col-sm-8">
236-
<input type="text" class="form-control" id="inputUsername" placeholder="Username">
237-
</div>
238-
</div>
239-
<div class="form-group">
240-
<label for="inputPassword" class="col-sm-2 control-label">Password</label>
241-
<div class="col-sm-8">
242-
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
243-
</div>
244-
</div>
245-
246-
<!--
247-
</br>
248-
<h3>Other</h3><hr/>
249-
250-
<div class="form-group">
251-
<label for="inputFoo" class="col-sm-2 control-label">Foo</label>
252-
<div class="col-sm-8">
253-
<input type="text" class="form-control" id="inputFoo" placeholder="Foo">
254-
</div>
255-
</div>
256-
-->
257-
<!-- split:main4 -->
258-
<hr/>
259-
<div class="form-group">
260-
<div class="col-sm-offset-9 col-sm-2">
261-
<button type="submit" class="btn btn-default">Save</button>
262-
</div>
263-
</div>
264-
</form>
265-
</div>
266-
</div>
267-
</div>
268-
</div>
269-
270207
<div role="tabpanel" class="tab-pane" id="about">
271208
<br />
272209
<div class="container-fluid">
@@ -281,7 +218,7 @@ <h1>About</h1>
281218
<hr />
282219
<h3>MQTT API:</h3>
283220
<ul class="list-group">
284-
<!-- split:main4 -->
221+
<!-- split:main3 -->
285222
<li class="list-group-item">
286223
{path}
287224
<span class="badge">Set</span>
@@ -291,12 +228,12 @@ <h3>MQTT API:</h3>
291228
EasyMqtt/123456/model
292229
<span class="badge">Get</span>
293230
</li>
294-
<!-- split:main5 -->
231+
<!-- split:main4 -->
295232
</ul>
296233
<hr />
297234
<h3>Rest API:</h3>
298235
<ul class="list-group">
299-
<!-- split:main5 -->
236+
<!-- split:main4 -->
300237
<!-- split:api_doc -->
301238
<li class="list-group-item">
302239
{path}
@@ -316,7 +253,7 @@ <h3>Rest API:</h3>
316253
<span class="badge">GET</span>
317254
<span class="badge">POST</span>
318255
</li>
319-
<!-- split:main6 -->
256+
<!-- split:main5 -->
320257
</ul>
321258
</div>
322259
</div>
@@ -330,4 +267,4 @@ <h3>Rest API:</h3>
330267
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
331268
</body>
332269
</html>
333-
<!-- split:main6 -->
270+
<!-- split:main5 -->

src/ConfigEntry.h

Lines changed: 0 additions & 87 deletions
This file was deleted.

src/EasyMqtt.h

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,34 @@
55
#include <PubSubClient.h>
66
#include "MqttEntry.h"
77
#include "WebPortal.h"
8-
#include "ConfigEntry.h"
98

109
class EasyMqtt : public MqttEntry {
1110
private:
1211
WiFiClient wifiClient;
1312
PubSubClient mqttClient;
1413
WebPortal webPortal;
1514

16-
ConfigEntry* configEntry;
17-
1815
String deviceId = "deviceId";
1916
long mqttDelay = 0;
2017

18+
const char* wifi_ssid = "N/A";
19+
const char* wifi_password = "N/A";
20+
21+
const char* mqtt_host = "N/A";
22+
int mqtt_port = 1883;
23+
const char* mqtt_username = "N/A";
24+
const char* mqtt_password = "N/A";
25+
2126
protected:
2227
/**
2328
Handle connections to mqtt
2429
*/
2530
void connectWiFi() {
2631
if(WiFi.status() == WL_DISCONNECTED) {
27-
debug("Connecting to wifi: " + config().getString("wifi.ssid", ""));
32+
debug("Connecting to wifi");
2833
WiFi.mode(WIFI_STA);
2934

30-
WiFi.begin(config().getCString("wifi.ssid", ""), config().getCString("wifi.password", ""));
35+
WiFi.begin(wifi_ssid, wifi_password);
3136

3237
#ifdef DEBUG
3338
WiFi.printDiag(Serial);
@@ -45,7 +50,7 @@ class EasyMqtt : public MqttEntry {
4550
} else {
4651
debug("WiFi connection timeout - Setup AP");
4752
WiFi.mode(WIFI_AP);
48-
WiFi.softAP(config().getCString("wifi.ap", "EasyMqtt"), "123456");
53+
WiFi.softAP("EasyMqtt", "123456");
4954
debug("IP address", WiFi.softAPIP().toString());
5055
}
5156
debug("devideId", deviceId);
@@ -63,9 +68,9 @@ class EasyMqtt : public MqttEntry {
6368
});
6469
});
6570

66-
mqttClient.setServer(config().getCString("mqtt.host", ""), config().getInt("mqtt.port", 1883));
71+
mqttClient.setServer(mqtt_host, mqtt_port);
6772

68-
if (mqttClient.connect(deviceId.c_str(), config().getCString("mqtt.username", ""), config().getCString("mqtt.password", ""))) {
73+
if (mqttClient.connect(deviceId.c_str(), mqtt_username, mqtt_password)) {
6974
debug("Connected to MQTT");
7075

7176
setPublishFunction([&](MqttEntry* entry, String message){
@@ -95,16 +100,12 @@ class EasyMqtt : public MqttEntry {
95100
#endif
96101
deviceId = String(ESP.getChipId());
97102

98-
configEntry = new ConfigEntry(mqttClient, *this);
99-
addChild(configEntry);
103+
setInterval(10);
100104

101105
get("system").setInterval(30);
102106
get("system")["deviceId"] << [this]() {
103107
return deviceId;
104108
};
105-
get("system")["name"] << [this]() {
106-
return config().getString("device.name", deviceId);
107-
};
108109
get("system")["mem"]["heap"] << []() {
109110
return String(ESP.getFreeHeap());
110111
};
@@ -140,11 +141,6 @@ class EasyMqtt : public MqttEntry {
140141
ESP.restart();
141142
}
142143
};
143-
get("system")["config"]["reset"] >> [this](String value) {
144-
if(value == "reset") {
145-
config().reset();
146-
}
147-
};
148144
}
149145

150146
void debug(String msg) {
@@ -160,10 +156,6 @@ class EasyMqtt : public MqttEntry {
160156
debug(key + " = " + value);
161157
}
162158

163-
ConfigEntry & config() {
164-
return *configEntry;
165-
}
166-
167159
void debug(String msg) {
168160
#ifdef DEBUG
169161
Serial.println(msg);
@@ -190,19 +182,19 @@ class EasyMqtt : public MqttEntry {
190182
Deprecated
191183
*/
192184
void wifi(const char* ssid, const char* password) {
193-
config().set("wifi.ssid", ssid);
194-
config().set("wifi.password", password);
185+
wifi_ssid = ssid;
186+
wifi_password = password;
195187
}
196188

197189
/**
198190
Configure mqtt
199191
Deprecated
200192
*/
201193
void mqtt(const char* host, int port, const char* username, const char* password) {
202-
config().set("mqtt.host", host);
203-
config().set("mqtt.port", String(port));
204-
config().set("mqtt.username", username);
205-
config().set("mqtt.password", password);
194+
mqtt_host = host;
195+
mqtt_port = port;
196+
mqtt_username = username;
197+
mqtt_password = password;
206198
}
207199

208200
/**

0 commit comments

Comments
 (0)