Git Product home page Git Product logo

bojanjurca / multitasking-esp32-http-ftp-telnet-servers-for-arduino Goto Github PK

View Code? Open in Web Editor NEW
81.0 11.0 16.0 3.13 MB

ESP32 with HTTP server, Telnet server, file system, FTP server FTP client, SMTP client, cron daemon and user management

License: Other

C++ 64.00% C 26.07% HTML 9.49% Batchfile 0.01% VBScript 0.43%
esp32-arduino ftp-server telnet-server web-server real-time-clock oscilloscope user-management websockets tcp-server tcp-client

multitasking-esp32-http-ftp-telnet-servers-for-arduino's People

Contributors

bojanjurca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multitasking-esp32-http-ftp-telnet-servers-for-arduino's Issues

Error in European DST calculation

Sometimes the time change happens a week too early.

Please correct two #definitions in time_functions.h to look like this:

#define PAST_EUROPE_SPRING_TIME_CHANGE (tStr.tm_mon > 2 /* Apr-Dec */ || (tStr.tm_mon == 2 /* Mar */ && tStr.tm_mday - tStr.tm_wday >= 25 /* last Sun or latter */ && (tStr.tm_wday > 0 /* Mon-Sat */ || (tStr.tm_wday == 0 /* Sun */ && tStr.tm_hour >= 1 /* >= 1:00 GMT */))))

#define PAST_EUROPE_AUTUMN_TIME_CHANGE (tStr.tm_mon > 9 /* Nov-Dec */ || (tStr.tm_mon == 9 /* Oct */ && tStr.tm_mday - tStr.tm_wday >= 25 /* last Sun or latter */ && (tStr.tm_wday > 0 /* Mon-Sat */ || (tStr.tm_wday == 0 /* Sun */ && tStr.tm_hour >= 1 /* >= 1:00 GMT */))))

pool.ntp.org is not available when FAT used, but SPIFFS was good to see WIFI connected

ntp_error
hi, thanks for this great codepiece.
we have seen the STA connected succefully when SPIFFS is used, however FAT and selected, STA disconnected immedeately and not NTP is capable, any idea to address this issue?

here is the log of FAT and NTP failed,

14:14:04.765 -> [ 86] [file system] mounted.
14:14:04.813 -> [ 143] [cronDaemon] started.
14:14:04.908 -> [ 264] [network] starting WiFi
14:14:04.908 -> [ 265] [network] [STA] connecting STAtion to router using DHCP.
14:14:05.146 -> [ 468] [network] [STA] WiFi client started.
14:14:05.146 -> [ 479] [network] [AP] initializing access point: MyESP32Server/YOUR_AP_PASSWORD, 10.0.1.3, 10.0.1.3, 255.255.255.0
14:14:05.146 -> [ 481] [network] [AP] WiFi access point started.
14:14:05.146 -> E (1014) wifi:sta is connecting, return error
14:14:05.146 -> [ 507] [httpServer] started on 0.0.0.0:80.
14:14:05.193 -> [ 519] [ftpServer] started on 0.0.0.0:21 with firewall.
14:14:05.193 -> [ 531] [telnetServer] started on 0.0.0.0:23.
14:14:05.193 -> [ 532] [loop] free heap: 197620 bytes.
14:14:07.564 -> [ 2927] [network] [STA] disconnected from WiFi.
14:14:10.174 -> [ 5532] [example 08] started.
14:14:19.798 -> [ 15145] 1.si.pool.ntp.org is not available.
14:14:19.798 -> [ 15147] 2.si.pool.ntp.org is not available.
14:14:19.798 -> [ 15149] 3.si.pool.ntp.org is not available.
14:14:20.177 -> [ 15532] [example 08] couldn't get current time from NTP servers (yet)
14:14:20.177 -> [ 15532] [example 09] started.
14:14:20.224 -> [ 15554] [example 09] HTTP/1.1 200 OK

Some ESP32 boards do not support FAT partition schemes (FAT file system)

Download the latest source files (from repository) where you can choose between FAT and LittleFS file systems. You can run FAT file system only when one of FAT partition schemes is selected (Tools | Partition scheme | ...) and LittleFS only when one of SPIFFS partition schemes is selected (Tools | Partition scheme | ...  ).

Use:

#define FILE_SYSTEM FILE_SYSTEM_LITTLEFS // or (default) FILE_SYSTEM_FAT

prior to

#include "./servers/file_system.h"

ESP32 stream function is working conditionally with different browser

hi, ESP32 stream function is working conditionally with different browser
Firefox is not working, Win10 Edge ok, Android chrome ok, any idea whether server side issue or the browser variance ?

revised_index

here is screen shot with win10 machine, on the left EDGE is ok, on the right firefox used was ver 86. 32 bit, error?
firefox_NG_Edge_OK

use SD card instead of flash

The flash is too small,only 4MB.I'm wondering if we can use SD card filesystem,but i can't make it.Do you have any plans to support SD filesystem. :)

Memory problems: memory leak, memory fragmentation, instability at heavy load

There are actually three separate problems identified so far. I'm still working on all of them.

  1. Memory leak is caused by sendBufferSemaphore = xSemaphoreCreateMutex in oscilloscope.h which creates a new semaphore on the heap each time oscilloscope is run. This will be replaced by xSemaphoreCreateBinaryStatic which creates semaphore on the stack.

  2. Memory fragmentation is caused by placing dmesg String messages on the heap. Entire dmesg message queue will be replaced by C strings which reside on the stack.

  3. Instability at heavy load is actually caused by compiler - it crashes ESP32 when there is not enough memory left to create a new object instance or a new task stack. This issue will be bypassed by checking if max free memory block is big enough, before creating a new instance or starting a new task.

WebSocket binary endianness

Javascript does not comply with TCP rule of sending data over network in network byte order, which is big endian. Most of computers out there are little endian machines just like ESP32 so communication works just fine without considering byte reordering. But as soon as WebSocket client is not little endian machine, binary data exchange will not work anymore without doing some extra work.

Writing a generic solution that works in all cases could be difficult. Personally, I do not have different types of machines at my disposal so I am not in position to do the testing myself. But here are some ideas:

  • Stay at text data exchange. It is insensitive to endianness but less efficient then binary data exchange.
  • Develop application so that exchanges data with server on 1-byte basis. 1 byte is, like text, insensitive to endianness. 1 byte corresponds with int8_t or uint8_t C data types and Int8Array or Uint8Array typed Javascript arrays.
  • If 1 byte information is not enough and you have to use 2 bytes which correspond to with int16_t or uint16_t C data types and Int16Array or Uint16Array typed Javascript arrays, you can use some sort of handshake at the beginning of communication. Javascript could send 1 element Uint16Array with hexadecimal value AABB for example to ESP32 server. The server can check the unsigned integer that arrived.
    • If it is AABB then Javascript client runs on little endian machine like ESP32 itself so no byte reordering is necessary.
    • If it is BBAA then Javascript client runs on big endian machine and ESP32 server should do byte reordering for all incoming and outgoing data:
uint16_t *a = (uint16_t *) buffer;
int n = bytesRead / sizeof (uint16_t);
for (int i = 0; i < n; i ++) a [i] = ntohs (a [i]); // use htons () for outgoing data instead or ntohs () again – it doesn’t really matter
  • In case of elementary data type of 4 bytes which correspond to int32_t or uint32_t or also float C data types and Int32Array or Uint32Array or also Float32Array typed Javascript arrays Javascript could send 1 element Uint32Array with hexadecimal value AABBCCDD for example to ESP32 server. The tings on the ESP32 server side now get even more complicated. If it reads:
    • AABBCCDD then Javascript client runs on little endian machine,
    • DDCCBBAA then Javascript client runs on big endian machine,
    • CCDDAABB then Javascript client runs on mid-big endian machine,
    • BBAADDCC then Javascript client runs on mid-little endian machine.

warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

hi, seeing compiler warning like this,

warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
cronTabAdd ("0 0 0 1 1 * newYear'sGreetingsToProgrammer"); // triggers at the beginning of each year

cronTabAdd ( "* * * * * * gotTime"); // triggers only once - when ESP32 reads time from NTP servers for the first time cronTabAdd ( "0 0 0 1 1 * newYear'sGreetingsToProgrammer"); // triggers at the beginning of each year cronTabAdd ( "0 * * * * * onMinute"); // triggers each minute at 0 seconds

change to (char *), this will remove those warning,
cronTabAdd ((char *) "* * * * * * gotTime"); // triggers only once - when ESP32 reads time from NTP servers for the first time cronTabAdd ((char *) "0 0 0 1 1 * newYear'sGreetingsToProgrammer"); // triggers at the beginning of each year cronTabAdd ((char *) "0 * * * * * onMinute"); // triggers each minute at 0 seconds

W5500 Ethernet Support

Thanks for your great library. I wanted to use ESP32 Ethernet using W5500 chip instead of WiFi, but I had no chance. Even after implementing the W5500 with lwip, the socket function fails and reboots the esp32 again and again. Is there any chance to help me with that?

Compile with ESP-IDF

Can you please guide me to compile this project with ESP-IDF without Arduino component? I am using ESP-IDF v4.4.1.

Can't connect to access point (AP) from every client

Some clients fail to connect to ESP32 in AP (access point) mode. For example, Android phone establishes WiFi connection without a problem whereas HP / Windows laptop fails. This issue is already opened: espressif/arduino-esp32#2382. Until it is resolved (hopefully in the next version of Arduino core for ESP32, current version is 1.0.1) a workaround is described there that somewhat fixes the problem.

Compile issues

Looks very useful code. I am having issues compiling it. Following are some error messages at the end :

Arduino: 1.8.9 (Windows 7), Board: "LOLIN D32, Default, 80MHz, 921600, None"

c:\users\wincycle\appdata\local\temp\arduino_build_857363\sketch\servers\file_system.h: In function 'bool writeEntireFileWithoutSemaphore(String, char*)':

c:\users\wincycle\appdata\local\temp\arduino_build_857363\sketch\servers\file_system.h:114:3: error: control reaches end of non-void function [-Werror=return-type]

}

^

In file included from C:\Users\WinCycle\Documents\Arduino\Esp32_web_ftp_telnet_server_template\Esp32_web_ftp_telnet_server_template.ino:233:0:

c:\users\wincycle\appdata\local\temp\arduino_build_857363\sketch\servers\telnetserver.hpp: In static member function 'static bool telnetServer::pingRecv(telnetServer::pingDataStructure, TcpConnection, int)':

c:\users\wincycle\appdata\local\temp\arduino_build_857363\sketch\servers\telnetserver.hpp:883:7: error: control reaches end of non-void function [-Werror=return-type]

   }  

   ^

c:\users\wincycle\appdata\local\temp\arduino_build_857363\sketch\servers\telnetserver.hpp: In static member function 'static String telnetServer::curl(TcpConnection*, String, String)':

c:\users\wincycle\appdata\local\temp\arduino_build_857363\sketch\servers\telnetserver.hpp:1064:7: error: control reaches end of non-void function [-Werror=return-type]

   }

   ^

cc1plus.exe: some warnings being treated as errors

Using library WiFi at version 1.0 in folder: C:\Users\WinCycle\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
Using library SPIFFS at version 1.0 in folder: C:\Users\WinCycle\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SPIFFS
Using library FS at version 1.0 in folder: C:\Users\WinCycle\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS
exit status 1
format '%d' expects argument of type 'int', but argument 3 has type 'long unsigned int' [-Werror=format=]

after a while LED control was rendered malfunction

Testing perhaps 30 minutes or an hour or so, the LED control was no longer functional, unless reboot the ESP32. Any idea for debugging this?. It is latest screen capture of following and remain no control to LED. thanks.
buildin_LED_is_faded

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.