Hello, I am getting an error when attempting to upload the following code to my esp32cam board. The goal is to leverage an Asynchronous webserver along with a websocket to control the cam via wifi. I have attached the error message and code as follows:
main.cpp:
#include <Arduino.h>
#include <esp32cam.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <WiFi.h>
#define ssid "***"
#define password "***"
AsyncWebServer server(80);
AsyncWebSocket ws("/ws");
void notifyClients() {
}
void handleWebSocketMessage(void* arg, uint8_t* data, size_t len) {
AwsFrameInfo* info = (AwsFrameInfo*)arg;
if (info->final && info->index == 0 && info->len == len && info->opcode == WS_TEXT) {
data[len] = 0;
if (strcmp((char*)data, "w") == 0) { }
else if (strcmp((char*)data, "a") == 0) { }
}
}
void onEvent(AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, void* arg, uint8_t* data, size_t len) {
switch(type) {
case WS_EVT_CONNECT:
break;
case WS_EVT_DISCONNECT:
break;
case WS_EVT_DATA:
handleWebSocketMessage(arg, data, len);
break;
case WS_EVT_PONG:
case WS_EVT_ERROR:
break;
}
}
void initWebSocket() {
ws.onEvent(onEvent);
server.addHandler(&ws);
}
void setup() {
auto res = esp32cam::Resolution::find(1024, 768);
esp32cam::Config cfg;
cfg.setPins(esp32cam::pins::AiThinker);
cfg.setResolution(res);
cfg.setJpeg(80);
esp32cam::Camera.begin(cfg);
WiFi.begin(ssid, password);
initWebSocket();
server.on("/", esp32cam::asyncweb::handleMjpeg);
server.begin();
}
void loop() {
ws.cleanupClients();
}
platform.ini:
[env:esp-wrover-kit]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.20/platform-espressif32.zip
board = esp32cam
framework = arduino
lib_deps =
yoursunny/esp32cam@^0.0.20250112
C:\Users\enver\Downloads\AsyncTCP-master.zip
C:\Users\enver\Downloads\ESPAsyncWebServer-master.zip
Thanks for the help!