Skip to content

Commit a070d8f

Browse files
committed
First Commit - NOT WORKING
0 parents  commit a070d8f

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

StreamlabsArduinoAlerts.ino

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include <Arduino.h>
2+
#include <Esp.h>
3+
#include <SocketIoClient.h>
4+
#include <ESP8266WiFi.h>
5+
#include "config.h"
6+
7+
SocketIoClient webSocket;
8+
9+
10+
void event(const char * payload, size_t length) {
11+
Serial.print("got message: ");
12+
Serial.println(payload);
13+
}
14+
15+
void handler(const char * payload, size_t length) {
16+
Serial.print("Connected: ");
17+
Serial.println(payload);
18+
}
19+
20+
void handlerDisc(const char * payload, size_t length) {
21+
Serial.print("Disconnected: ");
22+
Serial.println(payload);
23+
}
24+
25+
void setup() {
26+
27+
Serial.begin(115200);
28+
delay(1000);
29+
30+
31+
WiFi.begin(ssid, wifiPwd);
32+
int i = 0;
33+
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
34+
delay(1000);
35+
Serial.print(++i); Serial.print(' ');
36+
}
37+
38+
Serial.println('\n');
39+
Serial.println("Connection established!");
40+
Serial.print("IP address:\t");
41+
Serial.println(WiFi.localIP());
42+
43+
String a = "/socket.io/?transport=websocket&EIO=3&token=" + access_token;
44+
char queryParameters[400];
45+
a.toCharArray(queryParameters, 400, 0);
46+
47+
Serial.println("Non ce la farai mai");
48+
49+
webSocket.on("event", event);
50+
webSocket.begin("aws-io.streamlabs.com", 443, queryParameters);//, "CF DC 28 BA 68 80 F0 E5 9E CC 81 6F AB 0A AB 66 AE D9 68 1C"); //"E7:93:77:36:DA:D4:15:0F:C1:C1:8F:14:D5:2A:C8:72:93:D0:6F:2A");
51+
Serial.println("begin finito");
52+
}
53+
54+
void loop() {
55+
webSocket.loop();
56+
}

config.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "arduino.h"
2+
3+
#define CLIENT_ID ""
4+
#define CLIENT_SECRET ""
5+
6+
7+
String access_token="";
8+
String ssid="";
9+
String wifiPwd="";

0 commit comments

Comments
 (0)