Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ on:
- "library.properties"
- "library.json"
pull_request:
branches:
- main
- develop
branches: ["**"]
paths-ignore:
- .git*
- "**.md"
Expand Down Expand Up @@ -399,9 +397,6 @@ jobs:
fail-fast: false
matrix:
board:
- vendor: esp8266
arch: esp8266
name: generic
- vendor: esp32
arch: esp32
name: esp32
Expand All @@ -412,9 +407,6 @@ jobs:
arch: esp32
name: esp32c3
include:
- index: https://arduino.esp8266.com/stable/package_esp8266com_index.json
board:
vendor: esp8266
- index: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
board:
vendor: esp32
Expand Down
19 changes: 11 additions & 8 deletions ArtnetETH.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include <WiFiUdp.h>
#include "Artnet/ReceiverTraits.h"

// ETH.h is a library for Ethernet PHY, but we should use WiFi library's apis for sever/client
Comment thread
hideakitai marked this conversation as resolved.
// So we define new type to avoid type confliction with WiFiUDP
Comment thread
hideakitai marked this conversation as resolved.
struct ETHUdp : public WiFiUDP {};

namespace art_net {

template <>
Expand Down Expand Up @@ -37,25 +41,25 @@ struct MacAddress<ETHClass>
};

template <>
IPAddress getLocalIP<WiFiUDP>()
IPAddress getLocalIP<ETHUdp>()
{
return LocalIP<ETHClass>::get(ETH);
}

template <>
IPAddress getSubnetMask<WiFiUDP>()
IPAddress getSubnetMask<ETHUdp>()
{
return SubnetMask<ETHClass>::get(ETH);
}

template <>
void getMacAddress<WiFiUDP>(uint8_t mac[6])
void getMacAddress<ETHUdp>(uint8_t mac[6])
{
MacAddress<ETHClass>::get(ETH, mac);
}

template <>
bool isNetworkReady<WiFiUDP>()
bool isNetworkReady<ETHUdp>()
{
return true;
}
Expand All @@ -64,9 +68,8 @@ bool isNetworkReady<WiFiUDP>()

#include "Artnet/Manager.h"

// ETH.h is a library for Ethernet PHY, but we should use WiFi library's apis for sever/client
using ArtnetETH = art_net::Manager<WiFiUDP>;
using ArtnetETHSender = art_net::Sender<WiFiUDP>;
using ArtnetETHReceiver = art_net::Receiver<WiFiUDP>;
using ArtnetETH = art_net::Manager<ETHUdp>;
using ArtnetETHSender = art_net::Sender<ETHUdp>;
using ArtnetETHReceiver = art_net::Receiver<ETHUdp>;

#endif // ARTNET_ETH_H
102 changes: 102 additions & 0 deletions examples/Multiple/send_receive_eth/send_receive_eth.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#include <ArtnetETH.h>
#include <ArtnetWiFi.h>

// WiFi stuff
const char* ssid = "your-ssid";
const char* pwd = "your-password";
const IPAddress ip_wifi(192, 168, 1, 201);
const IPAddress gateway(192, 168, 1, 1);
const IPAddress subnet(255, 255, 255, 0);
// Ethernet stuff
const IPAddress ip_ether(192, 168, 0, 201);
uint8_t mac[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB};

ArtnetETH artnet_ether;
ArtnetWiFi artnet_wifi;
const String target_ip = "192.168.1.200";
uint8_t universe = 1; // 0 - 15

const uint16_t size = 512;
uint8_t data[size];
uint8_t value = 0;

// if Artnet packet comes to this universe, this function is called
void onArtDmxUniverse(const uint8_t *data, uint16_t size, const ArtDmxMetadata& metadata, const ArtNetRemoteInfo& remote)
{
Serial.print("lambda : artnet data from ");
Serial.print(remote.ip);
Serial.print(":");
Serial.print(remote.port);
Serial.print(", universe = ");
Serial.print(universe);
Comment thread
hideakitai marked this conversation as resolved.
Serial.print(", size = ");
Serial.print(size);
Serial.print(") :");
for (size_t i = 0; i < size; ++i) {
Serial.print(data[i]);
Serial.print(",");
}
Serial.println();
Comment thread
hideakitai marked this conversation as resolved.
};

// if Artnet packet comes, this function is called to every universe
void onArtDmx(const uint8_t *data, uint16_t size, const ArtDmxMetadata& metadata, const ArtNetRemoteInfo& remote)
{
Serial.print("received ArtNet data from ");
Serial.print(remote.ip);
Serial.print(":");
Serial.print(remote.port);
Serial.print(", net = ");
Serial.print(metadata.net);
Serial.print(", subnet = ");
Serial.print(metadata.subnet);
Serial.print(", universe = ");
Serial.print(metadata.universe);
Serial.print(", sequence = ");
Serial.print(metadata.sequence);
Serial.print(", size = ");
Serial.print(size);
Serial.println(")");
};

void setup() {
Serial.begin(115200);

// WiFi stuff
WiFi.begin(ssid, pwd);
WiFi.config(ip_wifi, gateway, subnet);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.print("WiFi connected, IP = ");
Serial.println(WiFi.localIP());
// ArtnetWiFi
artnet_wifi.begin();
artnet_wifi.subscribeArtDmxUniverse(universe, onArtDmxUniverse);
artnet_wifi.subscribeArtDmx(onArtDmx);

// Ethernet stuff
ETH.begin();
ETH.config(ip_ether, gateway, subnet);
// ArtnetETH
artnet_ether.begin();
artnet_ether.subscribeArtDmxUniverse(universe, onArtDmxUniverse);
artnet_ether.subscribeArtDmx(onArtDmx);
}

void loop() {
// check if artnet packet has come and execute callback
artnet_wifi.parse();
artnet_ether.parse();

value = (millis() / 4) % 256;
memset(data, value, size);

artnet_wifi.setArtDmxData(data, size);
artnet_ether.setArtDmxData(data, size);

// automatically send set data in 40fps
artnet_wifi.streamArtDmxTo(target_ip, universe);
artnet_ether.streamArtDmxTo(target_ip, universe);
}
Loading