-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathBasicExample.ino
46 lines (33 loc) · 985 Bytes
/
BasicExample.ino
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
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <SocketIoClient.h>
#define USE_SERIAL Serial
ESP8266WiFiMulti WiFiMulti;
SocketIoClient webSocket;
void event(const char * payload, size_t length) {
USE_SERIAL.printf("got message: %s\n", payload);
}
void setup() {
USE_SERIAL.begin(115200);
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", "passpasspass");
while(WiFiMulti.run() != WL_CONNECTED) {
delay(100);
}
webSocket.on("event", event);
webSocket.begin("my.socket-io.server");
// use HTTP Basic Authorization this is optional remove if not needed
webSocket.setAuthorization("username", "password");
}
void loop() {
webSocket.loop();
}