-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp.bak
55 lines (50 loc) · 1.26 KB
/
main.cpp.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <Arduino.h>
#include <SocketIOclient.h>
#include <WiFiManager.h>
#include <ArduinoJson.h>
WiFiManager wm;
SocketIOclient io;
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)
io.send(sIOtype_CONNECT, "/");
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()
{
Serial.begin(74880);
wm.autoConnect("IoT Socket Demo");
io.begin("192.168.0.10", 3000, "/socket.io/?EIO=3&transport=websocket");
io.onEvent(socketIOEvent);
}
void loop()
{
io.loop();
}