From 32aa557a00d0202c1b514b729bab07890784729c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Thu, 14 Jul 2022 19:00:46 +0200 Subject: [PATCH] app: add Art-Net receiver --- application.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/application.c b/application.c index c842a7d..53b7d42 100644 --- a/application.c +++ b/application.c @@ -35,6 +35,7 @@ #include "terminal.h" // handle the terminal interface #include "menu.h" // menu utilities #include "font.h" // to draw text +#include "radio_esp8266.h" // to receive ARTnet #include "led_ws2812b.h" // control WS2812b LEDs /** watchdog period in ms */ @@ -1065,6 +1066,12 @@ void main(void) */ puts_debug("OK\n"); + puts_debug("setup ESP8266 Art-Net: "); + sleep_ms(1000); // wit for ESP to boot + radio_esp8266_setup(); // connect to WiFi network + radio_esp8266_listen(true, 6454); // open UDP Art-Net + puts_debug("OK"); + // setup terminal terminal_prefix = ""; // set default prefix terminal_process = &process_command; // set central function to process commands @@ -1126,6 +1133,15 @@ void main(void) puts("midnight reached\n"); } } + if (radio_esp8266_received_len) { + if (radio_esp8266_received_len >= 18 && 0 == memcmp((char*)radio_esp8266_received, "Art-Net", 7)) { + const uint16_t dmx_universe = radio_esp8266_received[14] + (radio_esp8266_received[15] << 8); + const uint16_t dmx_length = radio_esp8266_received[17] + (radio_esp8266_received[16] << 8); + printf("Art-Net packet (uni=%u, len=%u)\n", dmx_universe, dmx_length); + } + radio_esp8266_received_len = 0; // reset flag + action = true; // redo main loop + } if (action) { // go to sleep if nothing had to be done, else recheck for activity action = false; } else {