|
| 1 | +/* |
| 2 | + * StreamlabsArduinoAlerts.ino |
| 3 | + * |
| 4 | + * Created on: 02/10/2020 |
| 5 | + * Author: Luca Taddeo |
| 6 | + * |
| 7 | + */ |
| 8 | + |
| 9 | +#include <Arduino.h> |
| 10 | +#include <Esp.h> |
| 11 | +#include <ESP8266WiFi.h> |
| 12 | +#include <StreamlabsAPI.h> |
| 13 | + |
| 14 | +#define SSID "ssid" |
| 15 | +#define PASSWORD "password" |
| 16 | +#define SOCKET_TOKEN "token" |
| 17 | + |
| 18 | +StreamlabsAPI streamlabsAPI; |
| 19 | + |
| 20 | +void followerEvent(const char * payload) { |
| 21 | + Serial.print("got followerEvent message: "); |
| 22 | + Serial.println(payload); |
| 23 | +} |
| 24 | + |
| 25 | +void subscriptionEvent(const char * payload) { |
| 26 | + Serial.print("got subscriptionEvent message: "); |
| 27 | + Serial.println(payload); |
| 28 | +} |
| 29 | + |
| 30 | +void bitsEvent(const char * payload) { |
| 31 | + Serial.print("got bitsEvent message: "); |
| 32 | + Serial.println(payload); |
| 33 | +} |
| 34 | + |
| 35 | +void donationsEvent(const char * payload) { |
| 36 | + Serial.print("got donationsEvent message: "); |
| 37 | + Serial.println(payload); |
| 38 | +} |
| 39 | + |
| 40 | +void setup() { |
| 41 | + |
| 42 | + Serial.begin(115200); |
| 43 | + delay(1000); |
| 44 | + |
| 45 | + |
| 46 | + WiFi.begin(SSID, PASSWORD); |
| 47 | + int i = 0; |
| 48 | + while (WiFi.status() != WL_CONNECTED) { |
| 49 | + delay(1000); |
| 50 | + Serial.print(++i); Serial.print(' '); |
| 51 | + } |
| 52 | + |
| 53 | + Serial.println('\n'); |
| 54 | + Serial.println("Connection established!"); |
| 55 | + Serial.print("IP address:\t"); |
| 56 | + Serial.println(WiFi.localIP()); |
| 57 | + |
| 58 | + streamlabsAPI.followTwitchEvent(followerEvent); |
| 59 | + streamlabsAPI.subscriptionsTwitchEvent(subscriptionEvent); |
| 60 | + streamlabsAPI.bitsTwitchEvent(bitsEvent); |
| 61 | + streamlabsAPI.donationEvent(donationsEvent); |
| 62 | + streamlabsAPI.connect(SOCKET_TOKEN); |
| 63 | +} |
| 64 | + |
| 65 | +void loop() { |
| 66 | + streamlabsAPI.loop(); |
| 67 | +} |
0 commit comments