Hi
I trying to implement a TCP Client on a WT32-ETH01 board. I want to use the RJ45 port. I have installed espressif´s board in board manager. if i use a example sketch ( Ethernet > LAN8720 ) i have connection to "the web" and it brings back site information.
BUT... thats not TCP, so i have found a library "WebSockets_Generic" by Khoi Hoang
[GitHub - khoih-prog/WebSockets_Generic: WebSocket / Socket.IO Server and Client for Arduino based on RFC6455. Now supporting Adafruit nRF52, Portenta_H7, STM32F/L/H/G/WB/MP1, Teensy, SAM DUE, SAMD21, SAMD51, Arduino SAMD21 (Nano 33 IoT), MKR1000 / MKR1010WiFi, RP2040-based boards using WiFi101, WiFiNINA, WiFi, Ethernet, WT32_ETH01, Teensy 4.1 NativeEthernet/QNEthernet or Portenta_H7 WiFi/Ethernet, etc. so that those boards can be voice-controlled by Alexa. Now supporting websocket only mode for Socket.IO. Ethernet_Generic library is used as default for W5x00]
( i have tried with others , and similar errors occur )
when i use the Example "Websockets_Generic>WT32_ETH01>WT32_ETH01_Websocket_Client"
/****************************************************************************************************************************
WT32_ETH01_WebSocketClient.ino
For WT32_ETH01
Based on and modified from WebSockets libarary https://github.com/Links2004/arduinoWebSockets
to support other boards such as SAMD21, SAMD51, Adafruit's nRF52 boards, etc.
Built by Khoi Hoang https://github.com/khoih-prog/WebSockets_Generic
Licensed under MIT license
Originally Created on: 24.05.2015
Original Author: Markus Sattler
*****************************************************************************************************************************/
#if !defined(ESP32)
#error This code is intended to run only on the ESP32 boards ! Please check your Tools->Board setting.
#endif
#define _WEBSOCKETS_LOGLEVEL_ 2
#include <WebServer_WT32_ETH01.h> // https://github.com/khoih-prog/WebServer_WT32_ETH01
#include <WebSocketsClient_Generic.h>
WebSocketsClient webSocket;
// Select the IP address according to your local network
IPAddress myIP(192, 168, 2, 232);
IPAddress myGW(192, 168, 2, 1);
IPAddress mySN(255, 255, 255, 0);
// Google DNS Server IP
IPAddress myDNS(8, 8, 8, 8);
#define USE_SSL false
#if USE_SSL
// Deprecated echo.websocket.org to be replaced
#define WS_SERVER "wss://echo.websocket.org"
#define WS_PORT 443
#else
// To run a local WebSocket Server
#define WS_SERVER "192.168.2.30"
#define WS_PORT 8080
#endif
void hexdump(const void *mem, const uint32_t& len, const uint8_t& cols = 16)
{
const uint8_t* src = (const uint8_t*) mem;
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)
{
Serial.printf("\n[0x%08X] 0x%08X: ", (ptrdiff_t)src, i);
}
Serial.printf("%02X ", *src);
src++;
}
Serial.printf("\n");
}
bool alreadyConnected = false;
void webSocketEvent(const WStype_t& type, uint8_t * payload, const size_t& length)
{
switch (type)
{
case WStype_DISCONNECTED:
if (alreadyConnected)
{
Serial.println("[WSc] Disconnected!");
alreadyConnected = false;
}
break;
case WStype_CONNECTED:
{
alreadyConnected = true;
Serial.print("[WSc] Connected to url: ");
Serial.println((char *) payload);
// send message to server when Connected
webSocket.sendTXT("Connected");
}
break;
case WStype_TEXT:
if (alreadyConnected)
{
Serial.printf("[WSc] get text: %s\n", payload);
// send message to server
//webSocket.sendTXT("message here");
}
break;
case WStype_BIN:
if (alreadyConnected)
{
Serial.printf("[WSc] get binary length: %u\n", length);
hexdump(payload, length);
// send data to server
webSocket.sendBIN(payload, length);
}
break;
case WStype_PING:
// pong will be send automatically
Serial.printf("[WSc] get ping\n");
break;
case WStype_PONG:
// answer to a ping we send
Serial.printf("[WSc] get pong\n");
break;
case WStype_ERROR:
case WStype_FRAGMENT_TEXT_START:
case WStype_FRAGMENT_BIN_START:
case WStype_FRAGMENT:
case WStype_FRAGMENT_FIN:
break;
default:
break;
}
}
void setup()
{
// Serial.begin(921600);
Serial.begin(115200);
while (!Serial);
Serial.print("\nStart WT32_ETH01_WebSocketClient on ");
Serial.print(ARDUINO_BOARD);
Serial.print(" with ");
Serial.println(SHIELD_TYPE);
Serial.println(WEBSERVER_WT32_ETH01_VERSION);
Serial.println(WEBSOCKETS_GENERIC_VERSION);
Serial.setDebugOutput(true);
// To be called before ETH.begin()
WT32_ETH01_onEvent();
//bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO,
// eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE);
//ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE);
ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER);
// Static IP, leave without this line to get IP via DHCP
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
ETH.config(myIP, myGW, mySN, myDNS);
WT32_ETH01_waitForConnect();
// Client address
Serial.print("WebSockets Client started @ IP address: ");
Serial.println(ETH.localIP());
// server address, port and URL
Serial.print("Connecting to WebSockets Server @ ");
Serial.println(WS_SERVER);
// server address, port and URL
#if USE_SSL
webSocket.beginSSL(WS_SERVER, WS_PORT);
#else
webSocket.begin(WS_SERVER, WS_PORT, "/");
#endif
// event handler
webSocket.onEvent(webSocketEvent);
// use HTTP Basic Authorization this is optional remove if not needed
//webSocket.setAuthorization("user", "Password");
// try ever 5000 again if connection has failed
webSocket.setReconnectInterval(5000);
// start heartbeat (optional)
// ping server every 15000 ms
// expect pong from server within 3000 ms
// consider connection disconnected if pong is not received 2 times
webSocket.enableHeartbeat(15000, 3000, 2);
// server address, port and URL
Serial.print("Connected to WebSockets Server @ IP address: ");
Serial.println(WS_SERVER);
}
void loop()
{
webSocket.loop();
}
i get theese errors, and i´m about to pull out all my hairs on my head, i have struggled 3 days now.
C:\Users\Cryptex\AppData\Local\Temp\.arduinoIDE-unsaved2024717-21880-j1lq17.agcvq\WT32_ETH01_WebSocketClient\WT32_ETH01_WebSocketClient.ino: In function 'void setup()':
C:\Users\Cryptex\AppData\Local\Temp\.arduinoIDE-unsaved2024717-21880-j1lq17.agcvq\WT32_ETH01_WebSocketClient\WT32_ETH01_WebSocketClient.ino:165:12: error: no matching function for call to 'ETHClass::begin(int, int)'
165 | ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from d:\OneDrive\Documents\Arduino\libraries\WebServer_WT32_ETH01\src/WebServer_WT32_ETH01.hpp:76,
from d:\OneDrive\Documents\Arduino\libraries\WebServer_WT32_ETH01\src/WebServer_WT32_ETH01.h:72,
from C:\Users\Cryptex\AppData\Local\Temp\.arduinoIDE-unsaved2024717-21880-j1lq17.agcvq\WT32_ETH01_WebSocketClient\WT32_ETH01_WebSocketClient.ino:21:
C:\Users\Cryptex\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\libraries\Ethernet\src/ETH.h:126:8: note: candidate: 'bool ETHClass::begin(eth_phy_type_t, int32_t, int, int, int, eth_clock_mode_t)'
126 | bool begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, int power, eth_clock_mode_t clk_mode);
| ^~~~~
C:\Users\Cryptex\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\libraries\Ethernet\src/ETH.h:126:8: note: candidate expects 6 arguments, 2 provided
C:\Users\Cryptex\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\libraries\Ethernet\src/ETH.h:129:8: note: candidate: 'bool ETHClass::begin(eth_phy_type_t, int32_t, int, int, int, SPIClass&, uint8_t)'
129 | bool begin(eth_phy_type_t type, int32_t phy_addr, int cs, int irq, int rst, SPIClass &spi, uint8_t spi_freq_mhz = ETH_PHY_SPI_FREQ_MHZ);
| ^~~~~
C:\Users\Cryptex\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\libraries\Ethernet\src/ETH.h:129:8: note: candidate expects 7 arguments, 2 provided
C:\Users\Cryptex\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\libraries\Ethernet\src/ETH.h:131:8: note: candidate: 'bool ETHClass::begin(eth_phy_type_t, int32_t, int, int, int, spi_host_device_t, int, int, int, uint8_t)'
131 | bool begin(
| ^~~~~
C:\Users\Cryptex\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\libraries\Ethernet\src/ETH.h:131:8: note: candidate expects 10 arguments, 2 provided
C:\Users\Cryptex\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\libraries\Ethernet\src/ETH.h:136:8: note: candidate: 'bool ETHClass::begin()'
136 | bool begin() {
| ^~~~~
C:\Users\Cryptex\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\libraries\Ethernet\src/ETH.h:136:8: note: candidate expects 0 arguments, 2 provided
Multiple libraries were found for "WiFi.h"
Used: C:\Users\Cryptex\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.0.4\libraries\WiFi
Not used: D:\OneDrive\Documents\Arduino\libraries\WiFiEspAT
exit status 1
Compilation error: no matching function for call to 'ETHClass::begin(int, int)'