Lab_interaccio/2019/GIGANTES-MERCE/Websocket-EchoExample/ArduinoWebsocketClient/examples/EchoExample/EchoExample.ino

25 lines
510 B
Arduino
Raw Normal View History

2025-02-25 21:29:42 +01:00
#include "Arduino.h"
#include <Ethernet.h>
#include <SPI.h>
#include <WebSocketClient.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
char server[] = "echo.websocket.org";
WebSocketClient client;
void setup() {
Serial.begin(9600);
Ethernet.begin(mac);
client.connect(server);
client.setDataArrivedDelegate(dataArrived);
client.send("Hello World!");
}
void loop() {
client.monitor();
}
void dataArrived(WebSocketClient client, String data) {
Serial.println("Data Arrived: " + data);
}