Open NielsvanDijk opened 4 months ago
Okay this helped me! : https://github.com/Links2004/arduinoWebSockets/issues/641
#include <ArduinoJson.h>
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiMulti.h>
#include <WiFiClientSecure.h>
#include <credentials.h>
#include <WebSocketsClient.h>
#include <SocketIOclient.h>
#ifdef DEBUG_ESP_PORT
#define DEBUG_MSG(...) DEBUG_ESP_PORT( __VA_ARGS__)
#else
#define DEBUG_MSG(...)
#endif
#define DEBUG_ESP_PORT Serial
const char* ssid = WIFI_SSID;
const char* password = WIFI_PASS;
WiFiMulti WiFiMulti;
WebSocketsClient webSocket;
SocketIOclient socketIO;
//WebSocketsClient socketIO;
#define USE_SERIAL Serial
void hexdump(const void *mem, uint32_t len, uint8_t cols = 16) {
const uint8_t* src = (const uint8_t*) mem;
USE_SERIAL.printf("\n[HEXDUMP] Address: 0x%08X len: 0x%X (%d)", (ptrdiff_t)src, len, len);
for(uint32_t i = 0; i < len; i++) {
if(i % cols == 0) {
USE_SERIAL.printf("\n[0x%0hola8X] 0x%08X: ", (ptrdiff_t)src, i);
}
USE_SERIAL.printf("%02X ", *src);
src++;
}
USE_SERIAL.printf("\n");
}
void socketIOEvent(socketIOmessageType_t type, uint8_t * payload, size_t length) {
switch(type) {
case sIOtype_DISCONNECT:
Serial.printf("[IOc] Disconnected!\n");
break;
case sIOtype_CONNECT:
Serial.printf("[IOc] Connected to url: %s\n", payload);
// join default namespace (no auto join in Socket.IO V3)
socketIO.send(sIOtype_CONNECT, "/");
// socketIO.send("hiiii");
break;
case sIOtype_EVENT:
Serial.printf("[IOc] get event: %s\n", payload);
break;
case sIOtype_ACK:
Serial.printf("[IOc] get ack: %u\n", length);
hexdump(payload, length);
break;
case sIOtype_ERROR:
Serial.printf("[IOc] get error: %u\n", length);
hexdump(payload, length);
break;
case sIOtype_BINARY_EVENT:
Serial.printf("[IOc] get binary: %u\n", length);
hexdump(payload, length);
break;
case sIOtype_BINARY_ACK:
Serial.printf("[IOc] get binary ack: %u\n", length);
hexdump(payload, length);
break;
}
}
void setup() {
USE_SERIAL.begin(115200);
delay(10);
USE_SERIAL.print("hola//////////////////////");
USE_SERIAL.setDebugOutput(true);
USE_SERIAL.println();
USE_SERIAL.println();
USE_SERIAL.println();
for(uint8_t t = 4; t > 0; t--) {
USE_SERIAL.printf("[SETUP] BOOT WAIT %d...\n", t);
USE_SERIAL.flush();
delay(1000);
}
WiFiMulti.addAP(ssid, password);
//WiFi.disconnect();
while(WiFiMulti.run() != WL_CONNECTED) {
Serial.println("reconectando...");
delay(100);
}
socketIO.setExtraHeaders("Authorization: 1234567890");
socketIO.begin("192.168.1.252", 9800, "/socket.io/?EIO=4");
// event handler
socketIO.onEvent(socketIOEvent);
// try ever 5000 again if connection has failed
//webSocket.setReconnectInterval(3000);
}
unsigned long messageTimestamp = 0;
void loop() {
socketIO.loop();
}
i get this error message:
I don't know any more what to do, can someone help?
This is the code expressJS: