Browse Source

WTF - ESP.getFreeHeap crashing the system for an specific light bulb...

fastled
Xose Pérez 7 years ago
parent
commit
489d62924c
5 changed files with 14 additions and 6 deletions
  1. +1
    -1
      code/espurna/espurna.ino
  2. +1
    -1
      code/espurna/settings.ino
  3. +9
    -1
      code/espurna/utils.ino
  4. +2
    -2
      code/espurna/web.ino
  5. +1
    -1
      code/espurna/ws.ino

+ 1
- 1
code/espurna/espurna.ino View File

@ -212,7 +212,7 @@ void welcome() {
DEBUG_MSG_P(PSTR("[INIT] Last reset reason: %s\n"), (char *) ESP.getResetReason().c_str());
}
DEBUG_MSG_P(PSTR("[INIT] Free heap: %u bytes\n"), ESP.getFreeHeap());
DEBUG_MSG_P(PSTR("[INIT] Free heap: %u bytes\n"), getFreeHeap());
#if ADC_VCC_ENABLED
DEBUG_MSG_P(PSTR("[INIT] Power: %d mV\n"), ESP.getVcc());
#endif


+ 1
- 1
code/espurna/settings.ino View File

@ -175,7 +175,7 @@ void settingsSetup() {
});
Embedis::command( F("HEAP"), [](Embedis* e) {
DEBUG_MSG_P(PSTR("Free HEAP: %d bytes\n"), ESP.getFreeHeap());
DEBUG_MSG_P(PSTR("Free HEAP: %d bytes\n"), getFreeHeap());
DEBUG_MSG_P(PSTR("+OK\n"));
});


+ 9
- 1
code/espurna/utils.ino View File

@ -33,6 +33,14 @@ String getCoreRevision() {
#endif
}
// WTF
// Calling ESP.getFreeHeap() is making the system crash on a specific
// AiLight bulb, but anywhere else...
unsigned int getFreeHeap() {
if (getSetting("wtfHeap", 0).toInt() == 1) return 9999;
return ESP.getFreeHeap();
}
String buildTime() {
const char time_now[] = __TIME__; // hh:mm:ss
@ -79,7 +87,7 @@ unsigned long getUptime() {
void heartbeat() {
unsigned long uptime_seconds = getUptime();
unsigned int free_heap = ESP.getFreeHeap();
unsigned int free_heap = getFreeHeap();
// -------------------------------------------------------------------------
// MQTT


+ 2
- 2
code/espurna/web.ino View File

@ -75,8 +75,8 @@ void _onHome(AsyncWebServerRequest *request) {
// Chunked response, we calculate the chunks based on free heap (in multiples of 32)
// This is necessary when a TLS connection is open since it sucks too much memory
DEBUG_MSG_P(PSTR("[MAIN] Free heap: %d bytes\n"), ESP.getFreeHeap());
size_t max = (ESP.getFreeHeap() / 3) & 0xFFE0;
DEBUG_MSG_P(PSTR("[MAIN] Free heap: %d bytes\n"), getFreeHeap());
size_t max = (getFreeHeap() / 3) & 0xFFE0;
AsyncWebServerResponse *response = request->beginChunkedResponse("text/html", [max](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {


+ 1
- 1
code/espurna/ws.ino View File

@ -333,7 +333,7 @@ void _wsStart(uint32_t client_id) {
root["network"] = getNetwork();
root["deviceip"] = getIP();
root["uptime"] = getUptime();
root["heap"] = ESP.getFreeHeap();
root["heap"] = getFreeHeap();
root["sketch_size"] = ESP.getSketchSize();
root["free_size"] = ESP.getFreeSketchSpace();


Loading…
Cancel
Save