khoih-prog / EthernetWebServer

This is simple yet complete WebServer library for AVR, AVR Dx, Portenta_H7, Teensy, SAM DUE, SAMD21/SAMD51, nRF52, STM32, RP2040-based, etc. boards running Ethernet shields. The functions are similar and compatible to ESP8266/ESP32 WebServer libraries to make life much easier to port sketches from ESP8266/ESP32. Coexisting now with `ESP32 WebServer` and `ESP8266 ESP8266WebServer` libraries. Ethernet_Generic library is used as default for W5x00 with custom SPI
MIT License
178 stars 49 forks source link

ESP32 keeps rebooting when trying to use pointers. #52

Closed Vitor1827 closed 2 years ago

Vitor1827 commented 2 years ago

Hello,

It's possible to use pointers when creating the EthernetWebServer class object, to change port number on setup?

I can compile the code using sometihng like this...

EthernetWebServer *server

void setup() {
  server = new EthernetWebServer(desiredPortNumber);
  server->begin();

But when I turn on the board, it keeps rebooting non stop.

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:12804
ho 0 tail 12 room 4
load:0x40080400,len:3032
entry 0x400805e4
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x400d3c1b  PS      : 0x00060f30  A0      : 0x800d3f49  A1      : 0x3ffb26c0  
A2      : 0x3ffb26fc  A3      : 0x00000060  A4      : 0x0000000b  A5      : 0x0000ff00  
A6      : 0x00ff0000  A7      : 0xff000000  A8      : 0x3ffb9410  A9      : 0x3ffb93f8  
A10     : 0x3ffb9410  A11     : 0x00001800  A12     : 0x00000000  A13     : 0x00000000  
A14     : 0x00001004  A15     : 0x3ffb0874  SAR     : 0x00000010  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000068  LBEG    : 0x400863a9  LEND    : 0x400863cb  LCOUNT  : 0xffffffff  

Backtrace:0x400d3c18:0x3ffb26c00x400d3f46:0x3ffb26e0 0x400d3fa1:0x3ffb2730 0x400d4101:0x3ffb2770 0x400d4640:0x3ffb27c0 0x400dc4aa:0x3ffb2820 

ELF file SHA256: 0000000000000000

That's what happens when I turn on the board...

Can you give me some advice about what to do to solve this, or, any other way to change port number on another part of the code?

khoih-prog commented 2 years ago

You must have done something wrong in your code.

Try the new AdvancedWebServer_Ptr example and learn how to use pointer.


https://github.com/khoih-prog/EthernetWebServer/blob/e49b06a27bdb668de4936bed3c8063e3e0a725b4/examples/AdvancedWebServer_Ptr/AdvancedWebServer_Ptr.ino#L46-L48

https://github.com/khoih-prog/EthernetWebServer/blob/e49b06a27bdb668de4936bed3c8063e3e0a725b4/examples/AdvancedWebServer_Ptr/AdvancedWebServer_Ptr.ino#L407-L417


To connect W550 to ESP32

- MOSI: 23
- MISO: 19
- SCK: 18
- CS/SS: 22

The Terminal output

Starting AdvancedWebServer_Ptr on ESP32 with W5x00 using EthernetLarge Library
EthernetWebServer v2.0.0
[EWS] =========== USE_ETHERNET_LARGE ===========
[EWS] Default SPI pinout:
[EWS] MOSI: 23
[EWS] MISO: 19
[EWS] SCK: 18
[EWS] SS: 5
[EWS] =========================
[EWS] ESP32 setCsPin: 22
_pinCS = 0
W5100 init, using SS_PIN_DEFAULT = 22, new ss_pin = 10, W5100Class::ss_pin = 22
W5100::init: W5500, SSIZE =8192
=========================
Currently Used SPI pinout:
MOSI:23
MISO:19
SCK:18
SS:5
=========================
Using mac index = 18
Connected! IP address: 192.168.2.114
HTTP EthernetWebServer is @ IP : 192.168.2.114
..[EWS] String Len = 0, extend to 2048
........ ...

Selection_108