Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
softwarecrash authored Mar 22, 2021
1 parent 8f54a2f commit bdd4f30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
12 changes: 12 additions & 0 deletions src/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ class Settings
EEPROM.end();
}

void reset(){
_deviceName = "";
_mqttServer = "";
_mqttUser = "";
_mqttPassword = "";
_mqttTopic = "";
_mqttPort = 0;
_mqttRefresh = 0;
save();
delay(500);
}

Settings()
{
load();
Expand Down
24 changes: 2 additions & 22 deletions src/src.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
/* Changes by softwarecrash
/*************************************************************************************/

//TODO:
//make webpages better
// make eeprom work

#include <Wire.h>
#include <EEPROM.h>
#include <PubSubClient.h>
Expand All @@ -25,22 +21,9 @@
#include "webpages/settings.h" //settings page
#include "webpages/mqttsettings.h" //mqtt settings page

//--------------------------------- Wifi State
//#define CLIENT_NOTCONNECTED 0
//#define CLIENT_RECONNECT 1
//#define CLIENT_CONNECTING 2
//#define CLIENT_PRECONNECTED 3
//#define CLIENT_CONNECTED 4
//byte currentApMode = 0;
//byte requestApMode = WIFI_STA;
//byte clientConnectionState = CLIENT_NOTCONNECTED;
//bool clientReconnect = false;

//--------------------------------- IP connection
WiFiClient client;
Settings _settings;
TickCounter _tickCounter;
//int WIFI_COUNT = 0;

extern QpigsMessage _qpigsMessage;
extern P003GSMessage _P003GSMessage;
Expand All @@ -50,7 +33,6 @@ extern String _nextCommandNeeded;
extern String _setCommand;
extern String _otherBuffer;

//---------------------- MQTT
PubSubClient mqttclient(client);

// Interface types that can be used.
Expand Down Expand Up @@ -132,7 +114,7 @@ void setup()

bool res = wm.autoConnect("Solar-AP");

wm.setConnectTimeout(20); // how long to try to connect for before continuing
wm.setConnectTimeout(30); // how long to try to connect for before continuing
wm.setConfigPortalTimeout(120); // auto close configportal after n seconds

//save settings if wifi setup is fire up
Expand Down Expand Up @@ -192,23 +174,21 @@ void setup()

server.on("/livedata", HTTP_GET, []() {
server.sendHeader("Connection", "close");
//server.sendHeader("Refresh", "30");
server.send(200, "text/html", sendHTMLlive());
});

server.on("/reboot", HTTP_GET, []() {
server.sendHeader("Connection", "close");
server.sendHeader("Location", String("/"), true);
server.send(302, "text/plain", "");
delay(2000);
ESP.restart();
});

server.on("/reset", HTTP_GET, []() {
server.sendHeader("Connection", "close");
server.sendHeader("Location", String("/"), true);
server.send(302, "text/plain", "");
delay(2000);
_settings.reset();
ESP.eraseConfig();
ESP.restart();
});
Expand Down

0 comments on commit bdd4f30

Please sign in to comment.