Skip to content

Commit ba24f6d

Browse files
committed
attempting to solve heap poisoning issue
1 parent 2b5e85d commit ba24f6d

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

src/config.esp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ bool loadConfiguration(Config &config)
33
File configFile = LittleFS.open("/config.json", "r");
44
if (!configFile)
55
{
6+
File configFile = LittleFS.open("/config.json", "w");
7+
configFile.close();
68
#ifdef DEBUG
79
Serial.println(F("[ WARN ] Failed to open config file!"));
810
#endif

src/ethernet.esp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void WiFiEvent(WiFiEvent_t event)
4949
}
5050
}
5151

52-
void setupEth(bool configured)
52+
void setupEth()
5353
{
5454
// Add a handler for network events. This is misnamed "WiFi" because the ESP32 is historically WiFi only,
5555
// but in our case, this will react to Ethernet events.

src/main.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ SOFTWARE.
2727

2828
#define VERSION "0.3.0"
2929

30-
bool eth_connected = false;
31-
3230
#include "Arduino.h"
3331
#include "Wire.h"
3432
#include <SPI.h>
@@ -54,12 +52,13 @@ IO2 io2 = IO2(); // set I2C address of MOD-IO2
5452
#include <Update.h>
5553
#include "magicnumbers.h"
5654
#include "config.h"
57-
Config config;
55+
5856
#include <WiegandNG.h>
5957

58+
Config config;
6059
File fsUploadFile;
61-
6260
WiegandNG wg;
61+
Desfire desfire;
6362

6463
// relay specific variables
6564
#if MAX_NUM_RELAYS == 4
@@ -79,8 +78,6 @@ bool activateRelay[MAX_NUM_RELAYS] = {false};
7978
bool deactivateRelay[MAX_NUM_RELAYS] = {false};
8079
#endif
8180

82-
Desfire desfire;
83-
8481
// The PICC master key.
8582
// This 3K3DES or AES key is the "god key".
8683
// It allows to format the card and erase ALL it's content (except the PICC master key itself).
@@ -151,6 +148,7 @@ unsigned long currentMillis = 0;
151148
unsigned long deltaTime = 0;
152149
bool doEnableWifi = false;
153150
bool doEnableEth = false;
151+
bool eth_connected = false;
154152
bool formatreq = false;
155153
const char *httpUsername = "admin";
156154
unsigned long keyTimer = 0;
@@ -287,10 +285,7 @@ void setup()
287285
bool configured = false;
288286
configured = loadConfiguration(config);
289287
// ethernet setup
290-
bool configuredeth = false;
291-
configuredeth = configured;
292-
eth_connected = false;
293-
setupEth(configuredeth);
288+
setupEth();
294289
config.ipAddressEth = ETH.localIP();
295290
config.gatewayIpEth = ETH.gatewayIP();
296291
config.subnetIpEth = ETH.subnetMask();
@@ -354,7 +349,6 @@ void IRAM_ATTR loop()
354349
}
355350

356351
// relay
357-
358352
for (int currentRelay = 0; currentRelay < config.numRelays; currentRelay++)
359353
{
360354
if (config.lockType[currentRelay] == LOCKTYPE_CONTINUOUS) // Continuous relay mode

src/wifi.esp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void setupWifi(bool configured)
226226
{
227227
if (!configured)
228228
{
229-
WiFi.hostname("esp32-actl");
229+
WiFi.hostname(config.deviceHostname);
230230
fallbacktoAPMode();
231231
}
232232
else

src/wsResponses.esp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ void sendStatus(AsyncWebSocketClient *client)
102102
{
103103
JsonDocument root;
104104
root["command"] = "status";
105-
bool ethenabled = false;
106-
ethenabled = true;
105+
bool ethenabled = true;
107106
root["ethernet"] = ethenabled;
108107
root["heap"] = ESP.getFreeHeap();
109108
root["heapsize"] = ESP.getHeapSize();

0 commit comments

Comments
 (0)