mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-07-05 21:58:53 +00:00
Merge f465cdced5
into b3468b4f01
This commit is contained in:
commit
c757460e17
4 changed files with 154 additions and 88 deletions
8
.gitmodules
vendored
8
.gitmodules
vendored
|
@ -1,6 +1,6 @@
|
||||||
[submodule "lib/ArtNet"]
|
[submodule "lib/ArtNet"]
|
||||||
path = lib/ArtNet
|
path = lib/ArtNet
|
||||||
url = https://github.com/psxde/ArtNet.git
|
url = https://github.com/psxde/ArtNet.git
|
||||||
[submodule "lib/AsyncWebServer_ESP32_W5500"]
|
[submodule "lib/AsyncWebServer_ESP32_W5500"]
|
||||||
path = lib/AsyncWebServer_ESP32_W5500
|
path = lib/AsyncWebServer_ESP32_W5500
|
||||||
url = https://github.com/psxde/AsyncWebServer_ESP32_W5500.git
|
url = https://github.com/psxde/AsyncWebServer_ESP32_W5500.git
|
||||||
|
|
57
src/log.cpp
Normal file
57
src/log.cpp
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
const char *getLogLevelString(log_level level)
|
||||||
|
{
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case EMERGENCY:
|
||||||
|
return "EMRG";
|
||||||
|
case ALERT:
|
||||||
|
return "ALRT";
|
||||||
|
case CRITICAL:
|
||||||
|
return "CRIT";
|
||||||
|
case ERROR:
|
||||||
|
return "EROR";
|
||||||
|
case WARNING:
|
||||||
|
return "WRNG";
|
||||||
|
case NOTICE:
|
||||||
|
return "NOTI";
|
||||||
|
case INFO:
|
||||||
|
return "INFO";
|
||||||
|
case DEBUG:
|
||||||
|
return "DEBG";
|
||||||
|
default:
|
||||||
|
return "UKWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupLogger()
|
||||||
|
{
|
||||||
|
Serial.begin(9600);
|
||||||
|
while (!Serial)
|
||||||
|
{
|
||||||
|
// updateLed();
|
||||||
|
}
|
||||||
|
// delay(5000);
|
||||||
|
Serial.println("Logger initialized");
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeSerialLog(const log_level level, const char *tag, const unsigned long timestamp, const char *formattedMessage)
|
||||||
|
{
|
||||||
|
Serial.printf("[%s][%s](%d)> %s\n", getLogLevelString(level), tag, timestamp, formattedMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
void logMessage(const log_level level, const char *tag, const char *message, ...)
|
||||||
|
{
|
||||||
|
const unsigned long timestamp = millis();
|
||||||
|
va_list args;
|
||||||
|
va_start(args, message);
|
||||||
|
int size = vsnprintf(nullptr, 0, message, args);
|
||||||
|
char *messageBuffer = new char[size + 1];
|
||||||
|
vsnprintf(messageBuffer, size + 1, message, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
writeSerialLog(level, tag, timestamp, messageBuffer);
|
||||||
|
|
||||||
|
delete[] messageBuffer;
|
||||||
|
}
|
27
src/log.h
Normal file
27
src/log.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
enum log_level
|
||||||
|
{
|
||||||
|
EMERGENCY,
|
||||||
|
ALERT,
|
||||||
|
CRITICAL,
|
||||||
|
ERROR,
|
||||||
|
WARNING,
|
||||||
|
NOTICE,
|
||||||
|
INFO,
|
||||||
|
DEBUG
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace tag
|
||||||
|
{
|
||||||
|
const char *const SYSTEM = "SYS";
|
||||||
|
const char *const DMX = "DMX";
|
||||||
|
const char *const ARTNET = "ART";
|
||||||
|
const char *const SERVER = "SVR";
|
||||||
|
const char *const WIFI = "WIF";
|
||||||
|
const char *const ETHERNET = "ETH";
|
||||||
|
const char *const CONFIG = "CNF";
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupLogger();
|
||||||
|
void logMessage(const log_level level, const char *tag, const char *message, ...);
|
150
src/main.cpp
150
src/main.cpp
|
@ -21,6 +21,7 @@
|
||||||
#include <esp_dmx.h>
|
#include <esp_dmx.h>
|
||||||
|
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
|
#include "log.h"
|
||||||
#include "websocket.h"
|
#include "websocket.h"
|
||||||
#include "routes/config.h"
|
#include "routes/config.h"
|
||||||
#include "routes/networks.h"
|
#include "routes/networks.h"
|
||||||
|
@ -159,31 +160,30 @@ void onButtonPress()
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
setupLogger();
|
||||||
setStatus(Status::Starting);
|
setStatus(Status::Starting);
|
||||||
pinMode(PIN_LED, OUTPUT);
|
pinMode(PIN_LED, OUTPUT);
|
||||||
updateLed();
|
updateLed();
|
||||||
|
logMessage(INFO, tag::SYSTEM, "Interface starting...");
|
||||||
Serial.begin(9600);
|
|
||||||
|
|
||||||
// Get ETH mac
|
// Get ETH mac
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
esp_efuse_mac_get_default(mac);
|
esp_efuse_mac_get_default(mac);
|
||||||
|
|
||||||
esp_read_mac(mac, ESP_MAC_ETH);
|
esp_read_mac(mac, ESP_MAC_ETH);
|
||||||
Serial.printf("%02x:%02x:%02x:%02x:%02x:%02x ESP MAC ETH\n",
|
logMessage(DEBUG, tag::CONFIG, "%02x:%02x:%02x:%02x:%02x:%02x ESP MAC ETH",
|
||||||
mac[0], mac[1], mac[2],
|
mac[0], mac[1], mac[2],
|
||||||
mac[3], mac[4], mac[5]);
|
mac[3], mac[4], mac[5]);
|
||||||
|
|
||||||
esp_read_mac(mac, ESP_MAC_WIFI_SOFTAP);
|
esp_read_mac(mac, ESP_MAC_WIFI_SOFTAP);
|
||||||
Serial.printf("%02x:%02x:%02x:%02x:%02x:%02x ESP MAC SOFTAP\n",
|
logMessage(DEBUG, tag::CONFIG, "%02x:%02x:%02x:%02x:%02x:%02x ESP MAC SOFTAP",
|
||||||
mac[0], mac[1], mac[2],
|
mac[0], mac[1], mac[2],
|
||||||
mac[3], mac[4], mac[5]);
|
mac[3], mac[4], mac[5]);
|
||||||
|
|
||||||
esp_read_mac(mac, ESP_MAC_WIFI_STA); // ESP_MAC_BASE
|
esp_read_mac(mac, ESP_MAC_WIFI_STA); // ESP_MAC_BASE
|
||||||
Serial.printf("%02x:%02x:%02x:%02x:%02x:%02x ESP MAC BASE\n",
|
logMessage(DEBUG, tag::CONFIG, "%02x:%02x:%02x:%02x:%02x:%02x ESP MAC BASE",
|
||||||
mac[0], mac[1], mac[2],
|
mac[0], mac[1], mac[2],
|
||||||
mac[3], mac[4], mac[5]);
|
mac[3], mac[4], mac[5]);
|
||||||
|
|
||||||
// LED
|
// LED
|
||||||
config.begin("dmx", true);
|
config.begin("dmx", true);
|
||||||
|
@ -204,7 +204,7 @@ void setup()
|
||||||
}
|
}
|
||||||
if (digitalRead(PIN_BUTTON) == LOW)
|
if (digitalRead(PIN_BUTTON) == LOW)
|
||||||
{
|
{
|
||||||
Serial.println("Reset config");
|
logMessage(NOTICE, tag::CONFIG, "Resetting config");
|
||||||
config.begin("dmx", false);
|
config.begin("dmx", false);
|
||||||
config.clear();
|
config.clear();
|
||||||
config.end();
|
config.end();
|
||||||
|
@ -225,14 +225,6 @@ void setup()
|
||||||
|
|
||||||
attachInterrupt(PIN_BUTTON, onButtonPress, FALLING);
|
attachInterrupt(PIN_BUTTON, onButtonPress, FALLING);
|
||||||
|
|
||||||
// wait for serial monitor
|
|
||||||
unsigned long startTime = millis();
|
|
||||||
while (millis() - startTime <= 5000)
|
|
||||||
{
|
|
||||||
updateLed();
|
|
||||||
}
|
|
||||||
Serial.println("Starting DMX-Interface...");
|
|
||||||
|
|
||||||
config.begin("dmx", true);
|
config.begin("dmx", true);
|
||||||
|
|
||||||
universe1 = config.getUInt("universe-1", DEFAULT_UNIVERSE1);
|
universe1 = config.getUInt("universe-1", DEFAULT_UNIVERSE1);
|
||||||
|
@ -241,8 +233,8 @@ void setup()
|
||||||
direction1 = static_cast<Direction>(config.getUInt("direction-1", DEFAULT_DIRECTION1));
|
direction1 = static_cast<Direction>(config.getUInt("direction-1", DEFAULT_DIRECTION1));
|
||||||
direction2 = static_cast<Direction>(config.getUInt("direction-2", DEFAULT_DIRECTION2));
|
direction2 = static_cast<Direction>(config.getUInt("direction-2", DEFAULT_DIRECTION2));
|
||||||
|
|
||||||
Serial.printf("Port A: Universe %d %s\n", universe1, (direction1 == Input) ? "DMX -> Art-Net" : "Art-Net -> DMX");
|
logMessage(INFO, tag::CONFIG, "Port A: Universe %d %s", universe1, (direction1 == Input) ? "DMX -> Art-Net" : "Art-Net -> DMX");
|
||||||
Serial.printf("Port B: Universe %d %s\n", universe2, (direction2 == Input) ? "DMX -> Art-Net" : "Art-Net -> DMX");
|
logMessage(INFO, tag::CONFIG, "Port B: Universe %d %s", universe2, (direction2 == Input) ? "DMX -> Art-Net" : "Art-Net -> DMX");
|
||||||
|
|
||||||
Connection connection = static_cast<Connection>(config.getUInt("connection", DEFAULT_CONNECTION));
|
Connection connection = static_cast<Connection>(config.getUInt("connection", DEFAULT_CONNECTION));
|
||||||
IpMethod ipMethod = static_cast<IpMethod>(config.getUInt("ip-method"), DEFAULT_IP_METHOD);
|
IpMethod ipMethod = static_cast<IpMethod>(config.getUInt("ip-method"), DEFAULT_IP_METHOD);
|
||||||
|
@ -250,8 +242,7 @@ void setup()
|
||||||
char hostname[30];
|
char hostname[30];
|
||||||
snprintf(hostname, sizeof(hostname), "ChaosDMX-%02X%02X", mac[4], mac[5]);
|
snprintf(hostname, sizeof(hostname), "ChaosDMX-%02X%02X", mac[4], mac[5]);
|
||||||
DEFAULT_SSID = hostname;
|
DEFAULT_SSID = hostname;
|
||||||
Serial.print("Hostname: ");
|
logMessage(INFO, tag::CONFIG, "Hostname: %s", hostname);
|
||||||
Serial.println(hostname);
|
|
||||||
|
|
||||||
String ssid = config.getString("ssid", DEFAULT_SSID);
|
String ssid = config.getString("ssid", DEFAULT_SSID);
|
||||||
String pwd = config.getString("password", DEFAULT_PASSWORD);
|
String pwd = config.getString("password", DEFAULT_PASSWORD);
|
||||||
|
@ -266,33 +257,32 @@ void setup()
|
||||||
switch (connection)
|
switch (connection)
|
||||||
{
|
{
|
||||||
case WiFiSta:
|
case WiFiSta:
|
||||||
Serial.println("Initialize as WiFi Station");
|
logMessage(DEBUG, tag::SYSTEM, "Initialize as WiFi Station");
|
||||||
WiFi.setHostname(hostname);
|
WiFi.setHostname(hostname);
|
||||||
WiFi.begin(ssid, pwd);
|
WiFi.begin(ssid, pwd);
|
||||||
Serial.println("SSID: " + ssid + ", pwd: " + pwd);
|
logMessage(INFO, tag::CONFIG, "SSID: %s; PWD: %s", ssid, pwd);
|
||||||
if (ipMethod == Static)
|
if (ipMethod == Static)
|
||||||
{
|
{
|
||||||
WiFi.config(ip, gateway, subnet);
|
WiFi.config(ip, gateway, subnet);
|
||||||
Serial.println("IP: " + ip.toString() + ", gateway: " + gateway + ", subnet: " + subnet);
|
logMessage(INFO, tag::CONFIG, "IP: %s; gateway: %s; subnet: %s", ip.toString(), gateway, subnet);
|
||||||
}
|
}
|
||||||
|
logMessage(DEBUG, tag::WIFI, "Connecting...");
|
||||||
while (WiFi.status() != WL_CONNECTED)
|
while (WiFi.status() != WL_CONNECTED)
|
||||||
{
|
{
|
||||||
Serial.print(".");
|
delay(50);
|
||||||
delay(500);
|
updateLed();
|
||||||
}
|
}
|
||||||
|
logMessage(INFO, tag::WIFI, "Connected!");
|
||||||
broadcastIp = String(WiFi.broadcastIP().toString().c_str());
|
broadcastIp = String(WiFi.broadcastIP().toString().c_str());
|
||||||
Serial.println("");
|
logMessage(INFO, tag::WIFI, "IP: %s", WiFi.localIP().toString());
|
||||||
Serial.print("WiFi connected, IP = ");
|
logMessage(INFO, tag::WIFI, "MAC: %X", WiFi.macAddress());
|
||||||
Serial.println(WiFi.localIP());
|
logMessage(INFO, tag::WIFI, "Broadcast IP: %s", broadcastIp);
|
||||||
Serial.print("MAC address: ");
|
|
||||||
Serial.println(WiFi.macAddress());
|
|
||||||
Serial.print("Broadcast IP: ");
|
|
||||||
Serial.println(broadcastIp);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Ethernet:
|
case Ethernet:
|
||||||
{
|
{
|
||||||
Serial.println("Initialize as ETH");
|
logMessage(DEBUG, tag::SYSTEM, "Initialize as ETH");
|
||||||
ESP32_W5500_onEvent();
|
ESP32_W5500_onEvent();
|
||||||
|
|
||||||
if (ETH.begin(ETH_MISO, ETH_MOSI, ETH_SCK, ETH_SS, ETH_INT, ETH_SPI_CLOCK_MHZ, SPI2_HOST, mac))
|
if (ETH.begin(ETH_MISO, ETH_MOSI, ETH_SCK, ETH_SS, ETH_INT, ETH_SPI_CLOCK_MHZ, SPI2_HOST, mac))
|
||||||
|
@ -300,64 +290,56 @@ void setup()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("Failed to configure Ethernet");
|
logMessage(CRITICAL, tag::ETHERNET, "Failed to configure Ethernet");
|
||||||
}
|
}
|
||||||
ETH.setHostname(hostname);
|
ETH.setHostname(hostname);
|
||||||
|
|
||||||
// ESP32_W5500_waitForConnect();
|
// ESP32_W5500_waitForConnect();
|
||||||
uint8_t timeout = 5; // in s
|
uint8_t timeout = 5; // in s
|
||||||
Serial.print("Wait for connect");
|
logMessage(DEBUG, tag::ETHERNET, "Wait for connect");
|
||||||
|
// TODO: use millis
|
||||||
while (!ESP32_W5500_eth_connected && timeout > 0)
|
while (!ESP32_W5500_eth_connected && timeout > 0)
|
||||||
{
|
{
|
||||||
delay(1000);
|
delay(1000);
|
||||||
timeout--;
|
timeout--;
|
||||||
Serial.print(".");
|
|
||||||
}
|
}
|
||||||
Serial.println();
|
|
||||||
if (ESP32_W5500_eth_connected)
|
if (ESP32_W5500_eth_connected)
|
||||||
{
|
{
|
||||||
Serial.println("DHCP OK!");
|
logMessage(DEBUG, tag::ETHERNET, "DHCP OK!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("Set static IP");
|
logMessage(DEBUG, tag::ETHERNET, "Set static IP");
|
||||||
ETH.config(ip, gateway, subnet);
|
ETH.config(ip, gateway, subnet);
|
||||||
}
|
}
|
||||||
|
logMessage(DEBUG, tag::ETHERNET, "Ethernet Successfully Initialized");
|
||||||
|
|
||||||
broadcastIp = ETH.broadcastIP().toString();
|
broadcastIp = ETH.broadcastIP().toString();
|
||||||
|
|
||||||
Serial.print("Local IP : ");
|
logMessage(INFO, tag::ETHERNET, "Local IP: %s", ETH.localIP().toString());
|
||||||
Serial.println(ETH.localIP());
|
logMessage(INFO, tag::ETHERNET, "Subnet Mask: %s", ETH.subnetMask().toString());
|
||||||
Serial.print("Subnet Mask : ");
|
logMessage(INFO, tag::ETHERNET, "Gateway IP: %s", ETH.gatewayIP().toString());
|
||||||
Serial.println(ETH.subnetMask());
|
logMessage(DEBUG, tag::ETHERNET, "DNS Server: %s", ETH.dnsIP().toString());
|
||||||
Serial.print("Gateway IP : ");
|
logMessage(DEBUG, tag::ETHERNET, "MAC address: %X", ETH.macAddress());
|
||||||
Serial.println(ETH.gatewayIP());
|
logMessage(DEBUG, tag::ETHERNET, "Broadcast IP: %s", broadcastIp);
|
||||||
Serial.print("DNS Server : ");
|
|
||||||
Serial.println(ETH.dnsIP());
|
|
||||||
Serial.print("MAC address : ");
|
|
||||||
Serial.println(ETH.macAddress());
|
|
||||||
Serial.print("Broadcast IP: ");
|
|
||||||
Serial.println(broadcastIp);
|
|
||||||
Serial.println("Ethernet Successfully Initialized");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
Serial.println("Initialize as WiFi AccessPoint");
|
logMessage(DEBUG, tag::SYSTEM, "Initialize as WiFi AccessPoint");
|
||||||
WiFi.softAPsetHostname(hostname);
|
WiFi.softAPsetHostname(hostname);
|
||||||
WiFi.softAP(ssid, pwd);
|
WiFi.softAP(ssid, pwd);
|
||||||
// AP always with DHCP
|
// AP always with DHCP
|
||||||
// WiFi.softAPConfig(ip, gateway, subnet);
|
// WiFi.softAPConfig(ip, gateway, subnet);
|
||||||
broadcastIp = WiFi.softAPBroadcastIP().toString();
|
broadcastIp = WiFi.softAPBroadcastIP().toString();
|
||||||
Serial.print("WiFi AP enabled, IP = ");
|
logMessage(DEBUG, tag::WIFI, "WiFi AP enabled");
|
||||||
Serial.println(WiFi.softAPIP());
|
logMessage(INFO, tag::CONFIG, "IP: %s", WiFi.softAPIP().toString());
|
||||||
Serial.print("MAC address: ");
|
logMessage(DEBUG, tag::CONFIG, "MAC address: %X", WiFi.softAPmacAddress());
|
||||||
Serial.println(WiFi.softAPmacAddress());
|
logMessage(DEBUG, tag::CONFIG, "Broadcast IP: %s", broadcastIp);
|
||||||
Serial.print("Broadcast IP: ");
|
|
||||||
Serial.println(broadcastIp);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize DMX ports
|
// Initialize DMX ports
|
||||||
Serial.println("Initialize DMX...");
|
logMessage(DEBUG, tag::DMX, "Initialize DMX...");
|
||||||
|
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32S2
|
#ifdef CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
|
||||||
|
@ -370,19 +352,20 @@ void setup()
|
||||||
dmx_driver_install(dmx2, &dmx_config, personalities, personality_count);
|
dmx_driver_install(dmx2, &dmx_config, personalities, personality_count);
|
||||||
dmx_set_pin(dmx2, 17, 18, -1);
|
dmx_set_pin(dmx2, 17, 18, -1);
|
||||||
|
|
||||||
Serial.printf("DMX driver 1 installed: %d\n", dmx_driver_is_installed(dmx1));
|
logMessage(DEBUG, tag::DMX, "DMX driver 1 installed: %d", dmx_driver_is_installed(dmx1));
|
||||||
Serial.printf("DMX driver 2 installed: %d\n", dmx_driver_is_installed(dmx2));
|
logMessage(DEBUG, tag::DMX, "DMX driver 2 installed: %d", dmx_driver_is_installed(dmx2));
|
||||||
|
|
||||||
Serial.printf("DMX driver 1 enabled: %d\n", dmx_driver_is_enabled(dmx1));
|
logMessage(DEBUG, tag::DMX, "DMX driver 1 enabled: %d", dmx_driver_is_enabled(dmx1));
|
||||||
Serial.printf("DMX driver 2 enabled: %d\n", dmx_driver_is_enabled(dmx2));
|
logMessage(DEBUG, tag::DMX, "DMX driver 2 enabled: %d", dmx_driver_is_enabled(dmx2));
|
||||||
|
|
||||||
#else
|
#else
|
||||||
dmx1.init(21, 33, Serial1);
|
dmx1.init(21, 33, Serial1);
|
||||||
dmx2.init(17, 18, Serial2);
|
dmx2.init(17, 18, Serial2);
|
||||||
#endif
|
#endif
|
||||||
|
logMessage(DEBUG, tag::DMX, "DMX initialized");
|
||||||
|
|
||||||
// Initialize Art-Net
|
// Initialize Art-Net
|
||||||
Serial.println("Initialize Art-Net...");
|
logMessage(DEBUG, tag::ARTNET, "Initialize Art-Net...");
|
||||||
artnet.begin();
|
artnet.begin();
|
||||||
|
|
||||||
// if Artnet packet comes to this universe, this function is called
|
// if Artnet packet comes to this universe, this function is called
|
||||||
|
@ -403,10 +386,12 @@ void setup()
|
||||||
dmx_send(dmx2);
|
dmx_send(dmx2);
|
||||||
dmx_wait_sent(dmx2, DMX_TIMEOUT_TICK); });
|
dmx_wait_sent(dmx2, DMX_TIMEOUT_TICK); });
|
||||||
}
|
}
|
||||||
|
logMessage(DEBUG, tag::ARTNET, "Initialized Art-Net");
|
||||||
|
|
||||||
if (!LittleFS.begin(true))
|
if (!LittleFS.begin(true))
|
||||||
{
|
{
|
||||||
Serial.println("An Error has occurred while mounting LittleFS");
|
setStatus(Status::Critical);
|
||||||
|
logMessage(CRITICAL, tag::SYSTEM, "An Error has occurred while mounting LittleFS");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,14 +417,14 @@ void setup()
|
||||||
{
|
{
|
||||||
if (request->url() == "/config" && request->method() == HTTP_PUT) {
|
if (request->url() == "/config" && request->method() == HTTP_PUT) {
|
||||||
onPutConfig(request, data, len, index, total);
|
onPutConfig(request, data, len, index, total);
|
||||||
Serial.println("restarting ESP...");
|
logMessage(INFO, tag::SYSTEM, "Restarting ESP...");
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
} });
|
} });
|
||||||
|
|
||||||
initWebSocket(&server);
|
initWebSocket(&server);
|
||||||
|
|
||||||
server.begin();
|
server.begin();
|
||||||
Serial.println("Server started!");
|
logMessage(DEBUG, tag::SERVER, "Webserver started!");
|
||||||
|
|
||||||
// scan networks and cache them
|
// scan networks and cache them
|
||||||
WiFi.scanNetworks(true);
|
WiFi.scanNetworks(true);
|
||||||
|
@ -447,20 +432,17 @@ void setup()
|
||||||
setStatus(Status::Normal);
|
setStatus(Status::Normal);
|
||||||
|
|
||||||
// Internal temperature RP2040
|
// Internal temperature RP2040
|
||||||
/*float tempC = analogReadTemp(); // Get internal temperature
|
// float tempC = analogReadTemp(); // Get internal temperature
|
||||||
Serial.print("Temperature Celsius (ºC): ");
|
// logIT(DEBUG, SYSTEM, "Temperature Celsius: %d °C", tempC);
|
||||||
Serial.println(tempC);*/
|
|
||||||
// Internal temperature ESP32 https://www.espboards.dev/blog/esp32-inbuilt-temperature-sensor/
|
// Internal temperature ESP32 https://www.espboards.dev/blog/esp32-inbuilt-temperature-sensor/
|
||||||
Serial.print("Temperature: ");
|
|
||||||
float result = 0;
|
float result = 0;
|
||||||
temp_sensor_read_celsius(&result);
|
temp_sensor_read_celsius(&result);
|
||||||
Serial.print(result);
|
logMessage(DEBUG, tag::SYSTEM, "Temperature: %.2f °C", result);
|
||||||
Serial.println(" °C");
|
|
||||||
|
|
||||||
Serial.printf("Internal Total heap %d, internal Free Heap %d\n", ESP.getHeapSize(), ESP.getFreeHeap());
|
logMessage(DEBUG, tag::SYSTEM, "Internal Total heap: %d; internal Free Heap: %d", ESP.getHeapSize(), ESP.getFreeHeap());
|
||||||
Serial.printf("SPIRam Total heap %d, SPIRam Free Heap %d\n", ESP.getPsramSize(), ESP.getFreePsram());
|
logMessage(DEBUG, tag::SYSTEM, "SPIRam Total heap: %d; SPIRam Free Heap: %d", ESP.getPsramSize(), ESP.getFreePsram());
|
||||||
Serial.printf("ChipRevision %d, Cpu Freq %d, SDK Version %s\n", ESP.getChipRevision(), ESP.getCpuFreqMHz(), ESP.getSdkVersion());
|
logMessage(DEBUG, tag::SYSTEM, "ChipRevision: %d; Cpu Freq: %d; SDK Version: %s", ESP.getChipRevision(), ESP.getCpuFreqMHz(), ESP.getSdkVersion());
|
||||||
Serial.printf("Flash Size %d, Flash Speed %d\n", ESP.getFlashChipSize(), ESP.getFlashChipSpeed());
|
logMessage(DEBUG, tag::SYSTEM, "Flash Size: %d; Flash Speed: %d", ESP.getFlashChipSize(), ESP.getFlashChipSpeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
void transmitDmxToArtnet(dmx_port_t dmxPort, byte *dmx_data, uint8_t artnetUniverse)
|
void transmitDmxToArtnet(dmx_port_t dmxPort, byte *dmx_data, uint8_t artnetUniverse)
|
||||||
|
@ -486,7 +468,7 @@ void transmitDmxToArtnet(dmx_port_t dmxPort, byte *dmx_data, uint8_t artnetUnive
|
||||||
connect or disconnect your DMX devices. If you are consistently getting
|
connect or disconnect your DMX devices. If you are consistently getting
|
||||||
DMX errors, then something may have gone wrong with your code or
|
DMX errors, then something may have gone wrong with your code or
|
||||||
something is seriously wrong with your DMX transmitter. */
|
something is seriously wrong with your DMX transmitter. */
|
||||||
Serial.printf("A DMX error occurred on port %d.\n", dmxPort);
|
logMessage(ERROR, tag::DMX, "A DMX error occurred on port %d", dmxPort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue