1

I'm using an ESP32 and it's fine, I have no issues at all. I was just curious that after flashing a new firmware via OTA, like this:

#include <ESPAsyncWebSrv.h>
#include <Update.h>

void http_page_flash(AsyncWebServerRequest* request) { if (!check_auth(request)) { return request->requestAuthentication(); }

request-&gt;send_P(200, &quot;text/html&quot;, flash_html, http_page_flash_processor);

}

void http_api_flash(AsyncWebServerRequest* request) { if (!check_auth(request)) { return request->requestAuthentication(); }

ESP.restart();

}

void http_api_flash_part(AsyncWebServerRequest* request, String filename, size_t index, uint8_t* data, size_t len, bool final) { if (!check_auth(request)) { return request->requestAuthentication(); }

if (index == 0) {
    if (!Update.begin(UPDATE_SIZE_UNKNOWN)) { //start with max available size
        Update.printError(Serial);
        request-&gt;redirect(&quot;/flash?status=error&amp;message=&quot; + String(Update.errorString()));
    }
}

if (len) {
    if (Update.write(data, len) != len) {
        Update.printError(Serial);
        request-&gt;redirect(&quot;/flash?status=error&amp;message=&quot; + String(Update.errorString()));
    }
}

if (final) {
    if (Update.end(true)) { //true to set the size to the current progress
        request-&gt;redirect(&quot;/flash?status=success&quot;);
    }
    else {
        Update.printError(Serial);
        request-&gt;redirect(&quot;/flash?status=error&amp;message=&quot; + String(Update.errorString()));
    }
}

}

time() result doesn't seem to re-set to 0. When accessing newly submitted entries which are time-based, they are timestamped as if the board never reset to 0, but all my entries are reset to 0 (so the memory is being reset):

void device_data::push(int co2_ppm, float rh, float temp_c, int sensor_status, unsigned long sequence_number) {
    unsigned long now = (unsigned long)time(NULL);
current_ventilation_state_co2 = determine_current_ventilation_state(current_ventilation_state_co2, co2_ppm, global_config_data.co2_ppm_low, global_config_data.co2_ppm_medium, global_config_data.co2_ppm_high);
current_ventilation_state_rh = determine_current_ventilation_state(current_ventilation_state_rh, rh, global_config_data.rh_low, global_config_data.rh_medium, global_config_data.rh_high);

latest_measurement.relative_time = now;
latest_measurement.set_co2(co2_ppm);
latest_measurement.set_rh(rh);
latest_measurement.set_temp(temp_c);
latest_measurement.sensor_status = sensor_status;
latest_measurement.sequence_number = sequence_number;
latest_measurement.state_at_this_time = get_highest_ventilation_state(current_ventilation_state_co2, current_ventilation_state_rh);

very_short_data.pushOverwrite(latest_measurement);
// ...

}

The data is completely reset as the ring buffer is back to being size=0, but now is not close to 0, it's just increased as if it completely survived the ESP.restart() call.

I'm just curious, is this by design? Is this a bug? Is time() somehow saved to flash? Or to some special restart-persistent memory? I use the flash to store my configuration, but I never store or restore the time in any of my configuration.

If it's some special static ram which is not flash storage, can I also access this for my own purposes?

Gizmo
  • 111
  • 2

0 Answers0