ESP32 Websockets

Hi, looking for simple project to essentially regurgitate the serial data I am sending via
USB-UART to a simple list on a webpage.

Tried ~ 6 different projects, hours of work finding correct libs and their versions,
no success. Got most to compile, none to work due to cryptic messages about reset.

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:4916

load:0x40078000,len:16436

load:0x40080400,len:4

ho 8 tail 4 room 4

load:0x40080404,len:3524

entry 0x400805b8

IP Address: 192.168.1.90

assert failed: tcp_alloc /IDF/components/lwip/lwip/src/core/tcp.c:1851 (Required to lock TCPIP core functionality!)

Backtrace: 0x40082475:0x3ffb1fe0 0x4008c2b9:0x3ffb2000 0x4009256e:0x3ffb2020 0x400f4683:0x3ffb2150 0x400f47f9:0x3ffb2170 0x400d5890:0x3ffb2190 0x400dd371:0x3ffb21e0 0x400d2afe:0x3ffb2200 0x400e2297:0x3ffb2270 0x4008d002:0x3ffb2290

/*
  --------------
  WebSerial Demo
  --------------
  
  Skill Level: Beginner

  This example provides with a bare minimal app with WebSerial functionality.

  Github: https://github.com/ayushsharma82/WebSerial
  Wiki: https://docs.webserial.pro

  Works with following hardware:
  - ESP8266
  - ESP32

  WebSerial terminal will be accessible at your microcontroller's <IPAddress>/webserial URL.

  Checkout WebSerial Pro: https://webserial.pro
*/

#include <Arduino.h>
#define ESP32
#if defined(ESP8266)
  #include <ESP8266WiFi.h>
  #include <ESPAsyncTCP.h>
#elif defined(ESP32)
  #include <WiFi.h>
  #include <AsyncTCP.h>
#endif
//#include <ESPAsyncWebSrv.h>
#include <ESPAsyncWebServer.h>
#include <WebSerial.h>

AsyncWebServer server(80);

const char* ssid = ""; // Your WiFi SSID
const char* password = ""; // Your WiFi Password

unsigned long last_print_time = millis();

void setup() {
  Serial.begin(115200);
  delay(100);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  delay(200);
  if (WiFi.waitForConnectResult() != WL_CONNECTED) {
      Serial.printf("WiFi Failed!\n");
      return;
  }
  
  // Once connected, print IP
  Serial.print("IP Address: ");
  Serial.println(WiFi.localIP());

  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(200, "text/plain", "Hi! This is WebSerial demo. You can access webserial interface at http://" + WiFi.localIP().toString() + "/webserial");
  });

  // WebSerial is accessible at "<IP Address>/webserial" in browser
  WebSerial.begin(&server);

  /* Attach Message Callback */
  WebSerial.onMessage([&](uint8_t *data, size_t len) {
    Serial.printf("Received %u bytes from WebSerial: ", len);
    Serial.write(data, len);
    Serial.println();
    WebSerial.println("Received Data...");
    String d = "";
    for(size_t i=0; i < len; i++){
      d += char(data[i]);
    }
    WebSerial.println(d);
  });

  // Start server
  server.begin();
}

void loop() {
  // Print every 2 seconds (non-blocking)
  if ((unsigned long)(millis() - last_print_time) > 2000) {
    WebSerial.print(F("IP address: "));
    WebSerial.println(WiFi.localIP());
    WebSerial.printf("Uptime: %lums\n", millis());
    WebSerial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());
    last_print_time = millis();
  }

  WebSerial.loop();
}

Arduino IDE 2.3.4

Used 2 different ESP modules, checked with scope Vdd stable no wacko glitches on
it. Have used them to run other code.

Any assist greatly appreciated.

A Google search for that error message leads you to

which points to

The fix being a downgrade to an older version.

This fix, using the "ESP32" named lib from Expressif, and downgraded
to 3.0.7 does work.

Thanks for the help.

Regards, Dana.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.