Skip to content

Commit

Permalink
AsyncTCP
Browse files Browse the repository at this point in the history
  • Loading branch information
cotestatnt committed Nov 20, 2024
1 parent 3751794 commit 4c96de3
Show file tree
Hide file tree
Showing 7 changed files with 454 additions and 202 deletions.
18 changes: 4 additions & 14 deletions examples/csvLogger/csvLogger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ struct tm ntpTime;
const char* basePath = "/csv";


//////////////////////////////// NTP Time /////////////////////////////////////////
void getUpdatedtime(const uint32_t timeout) {
uint32_t start = millis();
do {
time_t now = time(nullptr);
ntpTime = *localtime(&now);
delay(1);
} while (millis() - start < timeout && ntpTime.tm_year <= (1970 - 1900));
}


//////////////////////////////// Filesystem /////////////////////////////////////////
bool startFilesystem(){
if (LittleFS.begin()){
Expand All @@ -40,7 +29,8 @@ bool startFilesystem(){

//////////////////////////// Append a row to csv file ///////////////////////////////////
bool appenRow() {
getUpdatedtime(10);

getLocalTime(&ntpTime, 10);

char filename[24];
snprintf(filename, sizeof(filename),
Expand Down Expand Up @@ -132,9 +122,9 @@ void setup() {
#elif defined(ESP32)
configTzTime(MYTZ, "time.google.com", "time.windows.com", "pool.ntp.org");
#endif

// Wait for NTP sync (with timeout)
getUpdatedtime(5000);
getLocalTime(&ntpTime, 5000);


// Create csv logs folder if not exists
if (!LittleFS.exists(basePath)) {
Expand Down
2 changes: 1 addition & 1 deletion src/AsyncFsWebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ void AsyncFsWebServer::update_second(AsyncWebServerRequest *request) {

void AsyncFsWebServer::update_first(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
if (!m_contentLen) {
AsyncWebHeader* h = request->getHeader("Content-Length");
const AsyncWebHeader* h = request->getHeader("Content-Length");
if (h->value().length()) {
m_contentLen = h->value().toInt();
log_info("Firmware size: %d", m_contentLen);
Expand Down
2 changes: 1 addition & 1 deletion src/CaptivePortal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CaptiveRequestHandler : public AsyncWebHandler

const String targetURL;

bool canHandle(AsyncWebServerRequest *request) override
bool canHandle( AsyncWebServerRequest *request) override
{
// redirect if not in wifi client mode (through filter)
// and request for different host (due to DNS * response)
Expand Down
Loading

0 comments on commit 4c96de3

Please sign in to comment.