You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB
Arduino

6 years ago
#include <Artnet.h>
// WiFi stuff
const char* ssid = "your-ssid";
const char* pwd = "your-password";
const IPAddress ip(192, 168, 1, 201);
const IPAddress gateway(192, 168, 1, 1);
const IPAddress subnet(255, 255, 255, 0);
ArtnetWiFiReceiver artnet;
uint8_t universe1 = 1; // 0 - 15
uint8_t universe2 = 2; // 0 - 15
6 years ago
void callback(const uint8_t* data, const uint16_t size) {
6 years ago
// you can also use pre-defined callbacks
}
void setup() {
6 years ago
Serial.begin(115200);
// WiFi stuff
WiFi.begin(ssid, pwd);
WiFi.config(ip, gateway, subnet);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.print("WiFi connected, IP = ");
Serial.println(WiFi.localIP());
6 years ago
artnet.begin();
// artnet.subscribe_net(0); // optionally you can change
// artnet.subscribe_subnet(0); // optionally you can change
6 years ago
// if Artnet packet comes to this universe, this function (lambda) is called
artnet.subscribe(universe1, [&](const uint8_t* data, const uint16_t size) {
6 years ago
Serial.print("lambda : artnet data (universe : ");
Serial.print(universe1);
4 years ago
Serial.print(", size = ");
Serial.print(size);
Serial.print(") :");
for (size_t i = 0; i < size; ++i) {
Serial.print(data[i]);
Serial.print(",");
6 years ago
}
Serial.println();
});
// you can also use pre-defined callbacks
artnet.subscribe(universe2, callback);
}
void loop() {
artnet.parse(); // check if artnet packet has come and execute callback
6 years ago
}