krzychb / EspScopeA0

On-line wave-forms of ESP8266's A0 in a web browser using web sockets
GNU Lesser General Public License v2.1
42 stars 13 forks source link

ESP8266 - Issues with SPIFFS and with the strtol #6

Open Tanathy opened 1 year ago

Tanathy commented 1 year ago

Hey there! I just tried your code and I found few bugs. I wouldn't recommend using SPIFFS as its deprecated already and may be removed in the later releases. Use LittleFS as the console says, too.

Changing the following lines in the code will resolve the SPIFFS issues: #include <FS.h> to #include <LittleFS.h> SPIFFS.begin(); to LittleFS.begin(); server.serveStatic("/", SPIFFS, "/", "no-cache"); to server.serveStatic("/", LittleFS, "/", "no-cache");.

You can use the following plugin to upload your files: https://github.com/earlephilhower/arduino-esp8266littlefs-plugin

I got an other weird error, too:

long strtol (const char *__restrict __n, char **__restrict __end_PTR, int __base); invalid conversion from 'char' to 'char**' [-fpermissive]

The issue starts on the line 151 because we are trying to pass invalid data. Changing the '\0' to NULL will resolve the problem. Here is the snippet:

        char* token = strtok((char*) &payload[2], " ");
        messageNumber = (unsigned long) strtol(token, NULL, 10);
        token = strtok(NULL, " ");
        sampleTreshold = (unsigned int) strtol(token, NULL, 10);
        token = strtok(NULL, " ");
        numberOfSamples = (unsigned int) strtol(token, NULL, 10);

Welcome!