Loxone support added (#1185)

* A separate socket for UDP api has been added. This uses the same API as HTML. Commands for Loxone were added to the API.

* html files for udp api newly generated

* codm pixel controller board configurations added to platformio.ini file

* Parser for LX/LY commands adapted. Calculation of the values corrected. Segment handling for LX/LY removed.

* Lox parser moved to own file. Lox parser added to the JSON api. Within a segment LX and LY are now supported.

* serial port removed

* F() macro added

Co-authored-by: Marius Groos <marius.groos@codm.de>
This commit is contained in:
m0fa 2020-09-27 11:37:16 +02:00 committed by GitHub
parent cac974b8e1
commit b10ab358da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1910 additions and 1660 deletions

View File

@ -375,3 +375,43 @@ build_flags = ${common.build_flags_esp8266} ${common.debug_flags} ${common.build
extends = env:esp32dev
build_type = debug
build_flags = ${common.build_flags_esp32} ${common.debug_flags} ${common.build_flags_all_features}
# ------------------------------------------------------------------------------
# codm pixel controller board configurations
# ------------------------------------------------------------------------------
[env:codm-controller-0.4]
board = esp_wroom_02
platform = ${common.platform_wled_default}
board_build.ldscript = ${common.ldscript_2m1m}
build_flags = ${common.build_flags_esp8266} -D LEDPIN=3
[env:codm-controller-0.4-WS2801]
board = esp_wroom_02
platform = ${common.platform_latest}
board_build.ldscript = ${common.ldscript_2m1m}
build_flags = ${common.build_flags_esp8266} -D USE_WS2801 -D CLKPIN=13 -D DATAPIN=3
[env:codm-controller-0.4-APA102]
board = esp_wroom_02
platform = ${common.platform_latest}
board_build.ldscript = ${common.ldscript_2m1m}
build_flags = ${common.build_flags_esp8266} -D USE_APA102 -D CLKPIN=13 -D DATAPIN=3
[env:codm-controller-0.5]
board = esp_wroom_02
platform = ${common.platform_wled_default}
board_build.ldscript = ${common.ldscript_2m1m}
build_flags = ${common.build_flags_esp8266}
[env:codm-controller-0.5-WS2801]
board = esp_wroom_02
platform = ${common.platform_latest}
board_build.ldscript = ${common.ldscript_2m1m}
build_flags = ${common.build_flags_esp8266} -D USE_WS2801 #-D CLKPIN=0 -D DATAPIN=2
[env:codm-controller-0.5-APA102]
board = esp_wroom_02
platform = ${common.platform_latest}
board_build.ldscript = ${common.ldscript_2m1m}
build_flags = ${common.build_flags_esp8266} -D USE_APA102 #-D CLKPIN=0 -D DATAPIN=2

View File

@ -38,6 +38,10 @@ Send Alexa notifications: <input type="checkbox" name="SA"><br>
Send Philips Hue change notifications: <input type="checkbox" name="SH"><br>
Send Macro notifications: <input type="checkbox" name="SM"><br>
Send notifications twice: <input type="checkbox" name="S2">
<h3>UDP Api</h3>
Enable UDP Api: <input type="checkbox" name="UAE"><br>
Port: <input name="UAP" type="number" min="1" max="65535" class="d5"><br>
<i>Reboot required to apply changes. </i>
<h3>Realtime</h3>
Receive UDP realtime: <input type="checkbox" name="RD"><br><br>
<i>Network DMX input</i><br>

View File

@ -223,4 +223,7 @@ void sappend(char stype, const char* key, int val);
void sappends(char stype, const char* key, char* val);
void getSettingsJS(byte subPage, char* dest);
//lx_parser.cpp
bool parseLx(int lxValue, int rgbw[4]);
#endif

View File

@ -167,163 +167,163 @@ const char PAGE_settings_dmx[] PROGMEM = R"=====()=====";
// Autogenerated from wled00/data/settings_ui.htm, do not edit!!
const char PAGE_settings_ui[] PROGMEM = R"=====(<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport"
content="width=500"><title>UI Settings</title><script>var d = document;
var initial_ds, initial_st;
var sett = null;
var l = {
"comp":{
"labels":"Show button labels",
"colors":{
"LABEL":"Color selection methods",
"picker": "Color Wheel",
"rgb": "RGB sliders",
"quick": "Quick color selectors",
"hex": "HEX color input"
},
"pcmbot": "Show bottom tab bar in PC mode"
},
"theme":{
"alpha": {
"bg":"Background opacity",
"tab":"Button opacity"
},
"bg":{
"url":"BG image URL"
},
"color":{
"bg":"BG HEX color"
}
}
var initial_ds, initial_st;
var sett = null;
var l = {
"comp":{
"labels":"Show button labels",
"colors":{
"LABEL":"Color selection methods",
"picker": "Color Wheel",
"rgb": "RGB sliders",
"quick": "Quick color selectors",
"hex": "HEX color input"
},
"pcmbot": "Show bottom tab bar in PC mode"
},
"theme":{
"alpha": {
"bg":"Background opacity",
"tab":"Button opacity"
},
"bg":{
"url":"BG image URL"
},
"color":{
"bg":"BG HEX color"
}
}
};
function gId(s)
{
return d.getElementById(s);
}
function isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item));
}
function set(path, obj, val) {
var tar = obj;
var pList = path.split('_');
var len = pList.length;
for(var i = 0; i < len-1; i++) {
var elem = pList[i];
if( !tar[elem] ) tar[elem] = {}
tar = tar[elem];
}
};
function gId(s)
{
return d.getElementById(s);
}
function isObject(item) {
return (item && typeof item === 'object' && !Array.isArray(item));
}
function set(path, obj, val) {
var tar = obj;
var pList = path.split('_');
var len = pList.length;
for(var i = 0; i < len-1; i++) {
var elem = pList[i];
if( !tar[elem] ) tar[elem] = {}
tar = tar[elem];
}
tar[pList[len-1]] = val;
}
tar[pList[len-1]] = val;
}
function addRec(s, path = "", label = null)
{
var str = "";
for (i in s)
{
var fk = path + (path?'_':'') + i;
if (isObject(s[i])) {
if (label && label[i] && label[i]["LABEL"]) str += `<h3>${label[i]["LABEL"]}</h3>`;
str += addRec(s[i], fk, label? label[i] : null);
} else {
var lb = fk;
if (label && label[i]) lb = label[i];
else if (s[i+'LABEL']) lb = s[i+'LABEL'];
if (i.indexOf('LABEL') > 0) continue;
var t = typeof s[i];
if (gId(fk)) { //already exists
if(t === 'boolean')
{
gId(fk).checked = s[i];
} else {
gId(fk).value = s[i];
}
if (gId(fk).previousElementSibling.matches('.l')) {
gId(fk).previousElementSibling.innerHTML = lb;
}
} else {
if(t === 'boolean')
{
str += `${lb}: <input class="agi cb" type="checkbox" id=${fk} ${s[i]?"checked":""}><br>`;
} else if (t === 'number')
{
str += `${lb}: <input class="agi" type="number" id=${fk} value=${s[i]}><br>`;
} else if (t === 'string')
{
str += `${lb}:<br><input class="agi" id=${fk} value=${s[i]}><br>`;
}
}
}
}
return str;
}
function addRec(s, path = "", label = null)
{
var str = "";
for (i in s)
{
var fk = path + (path?'_':'') + i;
if (isObject(s[i])) {
if (label && label[i] && label[i]["LABEL"]) str += `<h3>${label[i]["LABEL"]}</h3>`;
str += addRec(s[i], fk, label? label[i] : null);
} else {
var lb = fk;
if (label && label[i]) lb = label[i];
else if (s[i+'LABEL']) lb = s[i+'LABEL'];
if (i.indexOf('LABEL') > 0) continue;
var t = typeof s[i];
if (gId(fk)) { //already exists
if(t === 'boolean')
{
gId(fk).checked = s[i];
} else {
gId(fk).value = s[i];
}
if (gId(fk).previousElementSibling.matches('.l')) {
gId(fk).previousElementSibling.innerHTML = lb;
}
} else {
if(t === 'boolean')
{
str += `${lb}: <input class="agi cb" type="checkbox" id=${fk} ${s[i]?"checked":""}><br>`;
} else if (t === 'number')
{
str += `${lb}: <input class="agi" type="number" id=${fk} value=${s[i]}><br>`;
} else if (t === 'string')
{
str += `${lb}:<br><input class="agi" id=${fk} value=${s[i]}><br>`;
}
}
}
}
return str;
}
function genForm(s) {
var str = "";
str = addRec(s,"",l);
gId('gen').innerHTML = str;
}
function GetLS()
{
sett = localStorage.getItem('wledUiCfg');
if (!sett) gId('lserr').style.display = "inline";
try {
sett = JSON.parse(sett);
} catch (e) {
sett = {};
gId('lserr').style.display = "inline";
gId('lserr').innerHTML = "&#9888; Settings JSON parsing failed. (" + e + ")";
}
genForm(sett);
gId('dm').checked = (gId('theme_base').value === 'light');
}
function SetLS()
{
var l = d.querySelectorAll('.agi');
for (var i = 0; i < l.length; i++) {
var e = l[i];
var val = e.classList.contains('cb') ? e.checked : e.value;
set(e.id, sett, val);
console.log(`${e.id} set to ${val}`);
}
try {
localStorage.setItem('wledUiCfg', JSON.stringify(sett));
gId('lssuc').style.display = "inline";
} catch (e) {
gId('lssuc').style.display = "none";
gId('lserr').style.display = "inline";
gId('lserr').innerHTML = "&#9888; Settings JSON saving failed. (" + e + ")";
}
}
function Save() {
SetLS();
if (d.Sf.DS.value != initial_ds || d.Sf.ST.checked != initial_st) d.Sf.submit();
}
function S()
{
GetV();
initial_ds = d.Sf.DS.value;
initial_st = d.Sf.ST.checked;
GetLS();
}
function H()
{
window.open("https://github.com/Aircoookie/WLED/wiki/Settings#user-interface-settings");
}
function B()
{
window.open("/settings","_self");
}
function UI()
{
gId('idonthateyou').style.display = (gId('dm').checked) ? 'inline':'none';
var f = gId('theme_base');
if (f) f.value = (gId('dm').checked) ? 'light':'dark';
}
function GetV() {var d=document;
function genForm(s) {
var str = "";
str = addRec(s,"",l);
gId('gen').innerHTML = str;
}
function GetLS()
{
sett = localStorage.getItem('wledUiCfg');
if (!sett) gId('lserr').style.display = "inline";
try {
sett = JSON.parse(sett);
} catch (e) {
sett = {};
gId('lserr').style.display = "inline";
gId('lserr').innerHTML = "&#9888; Settings JSON parsing failed. (" + e + ")";
}
genForm(sett);
gId('dm').checked = (gId('theme_base').value === 'light');
}
function SetLS()
{
var l = d.querySelectorAll('.agi');
for (var i = 0; i < l.length; i++) {
var e = l[i];
var val = e.classList.contains('cb') ? e.checked : e.value;
set(e.id, sett, val);
console.log(`${e.id} set to ${val}`);
}
try {
localStorage.setItem('wledUiCfg', JSON.stringify(sett));
gId('lssuc').style.display = "inline";
} catch (e) {
gId('lssuc').style.display = "none";
gId('lserr').style.display = "inline";
gId('lserr').innerHTML = "&#9888; Settings JSON saving failed. (" + e + ")";
}
}
function Save() {
SetLS();
if (d.Sf.DS.value != initial_ds || d.Sf.ST.checked != initial_st) d.Sf.submit();
}
function S()
{
GetV();
initial_ds = d.Sf.DS.value;
initial_st = d.Sf.ST.checked;
GetLS();
}
function H()
{
window.open("https://github.com/Aircoookie/WLED/wiki/Settings#user-interface-settings");
}
function B()
{
window.open("/settings","_self");
}
function UI()
{
gId('idonthateyou').style.display = (gId('dm').checked) ? 'inline':'none';
var f = gId('theme_base');
if (f) f.value = (gId('dm').checked) ? 'light':'dark';
}
function GetV() {var d=document;
%CSS%%SCSS%</head><body onload="S()">
<form id="form_s" name="Sf" method="post"><div
style="position:sticky;top:0;background-color:#222"><div class="helpB"><button
@ -377,21 +377,24 @@ type="checkbox" name="RX">Effects<br>Send notifications on direct change: <input
type="checkbox" name="SB"><br>Send Alexa notifications: <input type="checkbox"
name="SA"><br>Send Philips Hue change notifications: <input type="checkbox"
name="SH"><br>Send Macro notifications: <input type="checkbox" name="SM"><br>
Send notifications twice: <input type="checkbox" name="S2"><h3>Realtime</h3>
Receive UDP realtime: <input type="checkbox" name="RD"><br><br><i>
Network DMX input</i><br>Type: <select name="DI" onchange="SP(),adj()"><option
value="5568">E1.31 (sACN)</option><option value="6454">Art-Net</option><option
value="0" selected="selected">Custom port</option></select><br><div id="xp">
Port: <input name="EP" type="number" min="1" max="65535" value="5568"
class="d5" required><br></div>Multicast: <input type="checkbox" name="EM"><br>
Start universe: <input name="EU" type="number" min="0" max="63999" required><br>
<i>Reboot required.</i> Check out <a href="https://github.com/ahodges9/LedFx"
target="_blank">LedFx</a>!<br>Skip out-of-sequence packets: <input
type="checkbox" name="ES"><br>DMX start address: <input name="DA" type="number"
min="0" max="510" required><br>DMX mode: <select name="DM"><option value="0">
Disabled</option><option value="1">Single RGB</option><option value="2">
Single DRGB</option><option value="3">Effect</option><option value="4">Multi RGB
</option><option value="5">Dimmer + Multi RGB</option></select><br><a
Send notifications twice: <input type="checkbox" name="S2"><h3>UDP Api</h3>
Enable UDP Api: <input type="checkbox" name="UAE"><br>Port: <input name="UAP"
type="number" min="1" max="65535" class="d5"><br><i>
Reboot required to apply changes.</i><h3>Realtime</h3>Receive UDP realtime:
<input type="checkbox" name="RD"><br><br><i>Network DMX input</i><br>Type:
<select name="DI" onchange="SP(),adj()"><option value="5568">E1.31 (sACN)
</option><option value="6454">Art-Net</option><option value="0"
selected="selected">Custom port</option></select><br><div id="xp">Port: <input
name="EP" type="number" min="1" max="65535" value="5568" class="d5" required>
<br></div>Multicast: <input type="checkbox" name="EM"><br>Start universe: <input
name="EU" type="number" min="0" max="63999" required><br><i>Reboot required.
</i> Check out <a href="https://github.com/ahodges9/LedFx" target="_blank">LedFx
</a>!<br>Skip out-of-sequence packets: <input type="checkbox" name="ES"><br>
DMX start address: <input name="DA" type="number" min="0" max="510" required>
<br>DMX mode: <select name="DM"><option value="0">Disabled</option><option
value="1">Single RGB</option><option value="2">Single DRGB</option><option
value="3">Effect</option><option value="4">Multi RGB</option><option value="5">
Dimmer + Multi RGB</option></select><br><a
href="https://github.com/Aircoookie/WLED/wiki/E1.31-DMX" target="_blank">
E1.31 info</a><br>Timeout: <input name="ET" type="number" min="1" max="65000"
required> ms<br>Force max brightness: <input type="checkbox" name="FB"><br>

File diff suppressed because it is too large Load Diff

View File

@ -55,6 +55,58 @@ void deserializeSegment(JsonObject elem, byte it)
}
}
}
// lx parser
int lx = elem[F("lx")] | -1;
if (lx > 0) {
DEBUG_PRINT(F("LX: Lox primary = "));
DEBUG_PRINTLN(lx);
int rgbw[] = {0,0,0,0};
if (parseLx(lx, rgbw)) {
if (bri == 0) {
DEBUG_PRINTLN(F("LX: turn on"));
toggleOnOff();
}
bri = 255;
nightlightActive = false; //always disable nightlight when toggling
if (id == strip.getMainSegmentId()) {
DEBUG_PRINTLN(F("LX: main segment"));
col[0] = rgbw[0];
col[1] = rgbw[1];
col[2] = rgbw[2];
col[3] = rgbw[3];
} else {
DEBUG_PRINT(F("LX: segment "));
DEBUG_PRINTLN(id);
seg.colors[0] = ((rgbw[3] << 24) | ((rgbw[0]&0xFF) << 16) | ((rgbw[1]&0xFF) << 8) | ((rgbw[2]&0xFF)));
}
}
}
int ly = elem[F("ly")] | -1;
if (ly > 0) {
DEBUG_PRINT(F("LY: Lox secondary = "));
Serial.println(ly);
int rgbw[] = {0,0,0,0};
if (parseLx(ly, rgbw)) {
if (bri == 0) {
DEBUG_PRINTLN(F("LY: turn on"));
toggleOnOff();
}
bri = 255;
nightlightActive = false; //always disable nightlight when toggling
if (id == strip.getMainSegmentId()) {
DEBUG_PRINTLN(F("LY: main segment"));
colSec[0] = rgbw[0];
colSec[1] = rgbw[1];
colSec[2] = rgbw[2];
colSec[3] = rgbw[3];
} else {
DEBUG_PRINT(F("LY: segment "));
DEBUG_PRINTLN(id);
seg.colors[1] = ((rgbw[3] << 24) | ((rgbw[0]&0xFF) << 16) | ((rgbw[1]&0xFF) << 8) | ((rgbw[2]&0xFF)));
}
}
}
//if (pal != seg.palette && pal < strip.getPaletteCount()) strip.setPalette(pal);
seg.setOption(SEG_OPTION_SELECTED, elem[F("sel")] | seg.getOption(SEG_OPTION_SELECTED));

78
wled00/lx_parser.cpp Normal file
View File

@ -0,0 +1,78 @@
#include "wled.h"
bool parseLx(int lxValue, int rgbw[4])
{
bool ok = false;
float lxRed = 0;
float lxGreen = 0;
float lxBlue = 0;
if (lxValue < 200000000) {
// Loxone RGB
ok = true;
lxRed = round((lxValue % 1000) * 2.55);
lxGreen = round(((lxValue / 1000) % 1000) * 2.55);
lxBlue = round(((lxValue / 1000000) % 1000) * 2.55);
} else if ((lxValue >= 200000000) && (lxValue <= 201006500)) {
// Loxone Lumitech
ok = true;
float tmpBri = floor((lxValue - 200000000) / 10000); ;
uint16_t ct = (lxValue - 200000000) - (((uint8_t)tmpBri) * 10000);
float temp = 0;
tmpBri *= 2.55;
if (tmpBri < 0) {
tmpBri = 0;
} else if (tmpBri > 255) {
tmpBri = 255;
}
if (ct < 2700) {
ct = 2700;
} else if (ct > 6500) {
ct = 6500;
}
temp = ct / 100;
if (temp <= 66) {
lxRed = 255;
lxGreen = round(99.4708025861 * log(temp) - 161.1195681661);
if (temp <= 19) {
lxBlue = 0;
} else {
lxBlue = round(138.5177312231 * log((temp - 10)) - 305.0447927307);
}
} else {
lxRed = round(329.698727446 * pow((temp - 60), -0.1332047592));
lxGreen = round(288.1221695283 * pow((temp - 60), -0.0755148492));
lxBlue = 255;
}
lxRed *= (tmpBri/255);
lxGreen *= (tmpBri/255);
lxBlue *= (tmpBri/255);
}
if (ok) {
if (lxRed > 255) {
lxRed = 255;
} else if (lxRed < 0) {
lxRed = 0;
}
if (lxGreen > 255) {
lxGreen = 255;
} else if (lxGreen < 0) {
lxGreen = 0;
}
if (lxBlue > 255) {
lxBlue = 255;
} else if (lxBlue < 0) {
lxBlue = 0;
}
rgbw[0] = (uint8_t)lxRed;
rgbw[1] = (uint8_t)lxGreen;
rgbw[2] = (uint8_t)lxBlue;
rgbw[3] = 0;
return true;
}
return false;
}

View File

@ -1,5 +1,6 @@
#include "wled.h"
/*
* Receives client input
*/
@ -196,6 +197,11 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
hueStoreAllowed = true;
reconnectHue();
#endif
// UDP Api
udpApiEnabled = request->hasArg("UAE");
t = request->arg("UAP").toInt();
if (t > 0) udpApiPort = t;
}
//TIME
@ -416,6 +422,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
byte main = strip.getMainSegmentId();
if (main != prevMain) setValuesFromMainSeg();
bool segGiven = false;
pos = req.indexOf(F("SS="));
if (pos > 0) {
byte t = getNumVal(&req, pos);
@ -507,6 +514,35 @@ bool handleSet(AsyncWebServerRequest *request, const String& req)
updateVal(&req, "B2=", &colSec[2]);
updateVal(&req, "W2=", &colSec[3]);
//lox parser
int rgbw[4] = {0,0,0,0};
pos = req.indexOf(F("LX=")); // Lox primary color
if (pos > 0) {
int lxValue = getNumVal(&req, pos);
if (parseLx(lxValue, rgbw)) {
col[0] = rgbw[0];
col[1] = rgbw[1];
col[2] = rgbw[2];
bri = 255;
nightlightActive = false; //always disable nightlight when toggling
DEBUG_PRINT(F("LX: Lox primary = "));
DEBUG_PRINTLN(lxValue);
}
}
pos = req.indexOf(F("LY")); // Lox secondary color
if (pos > 0) {
int lxValue = getNumVal(&req, pos);
if(parseLx(lxValue, rgbw)) {
colSec[0] = rgbw[0];
colSec[1] = rgbw[1];
colSec[2] = rgbw[2];
bri = 255;
nightlightActive = false; //always disable nightlight when toggling
DEBUG_PRINT(F("LY: Lox secondary = "));
DEBUG_PRINTLN(lxValue);
}
}
//set hue
pos = req.indexOf(F("HU="));
if (pos > 0) {

View File

@ -105,7 +105,7 @@ void handleNotifications()
if(udpConnected && notificationTwoRequired && millis()-notificationSentTime > 250){
notify(notificationSentCallMode,true);
}
if (e131NewData && millis() - strip.getLastShow() > 15)
{
e131NewData = false;
@ -129,25 +129,43 @@ void handleNotifications()
//hyperion / raw RGB
if (!packetSize && udpRgbConnected) {
packetSize = rgbUdp.parsePacket();
if (!receiveDirect) return;
if (packetSize > UDP_IN_MAXSIZE || packetSize < 3) return;
realtimeIP = rgbUdp.remoteIP();
DEBUG_PRINTLN(rgbUdp.remoteIP());
uint8_t lbuf[packetSize];
rgbUdp.read(lbuf, packetSize);
realtimeLock(realtimeTimeoutMs, REALTIME_MODE_HYPERION);
if (realtimeOverride) return;
uint16_t id = 0;
for (uint16_t i = 0; i < packetSize -2; i += 3)
{
setRealtimePixel(id, lbuf[i], lbuf[i+1], lbuf[i+2], 0);
id++; if (id >= ledCount) break;
}
strip.show();
return;
if (packetSize) {
if (!receiveDirect) return;
if (packetSize > UDP_IN_MAXSIZE || packetSize < 3) return;
realtimeIP = rgbUdp.remoteIP();
DEBUG_PRINTLN(rgbUdp.remoteIP());
uint8_t lbuf[packetSize];
rgbUdp.read(lbuf, packetSize);
realtimeLock(realtimeTimeoutMs, REALTIME_MODE_HYPERION);
if (realtimeOverride) return;
uint16_t id = 0;
for (uint16_t i = 0; i < packetSize -2; i += 3)
{
setRealtimePixel(id, lbuf[i], lbuf[i+1], lbuf[i+2], 0);
id++; if (id >= ledCount) break;
}
strip.show();
return;
}
}
// udp api
if (udpApiEnabled && !packetSize && udpApiConnected) {
packetSize = apiUdp.parsePacket();
if (packetSize) {
if (!receiveDirect) return;
if (packetSize > UDP_IN_MAXSIZE || packetSize < 3) return;
uint8_t lbuf[packetSize];
apiUdp.read(lbuf, packetSize);
lbuf[packetSize] = '\0';
String apireq = "win&";
apireq += (char*)lbuf;
handleSet(nullptr, apireq);
return;
}
}
//notifier and UDP realtime
if (!packetSize || packetSize > UDP_IN_MAXSIZE) return;
if (notifierUdp.remoteIP() == WiFi.localIP()) return; //don't process broadcasts we send ourselves

View File

@ -282,7 +282,10 @@ void WLED::initAP(bool resetAP)
if (udpRgbPort > 0 && udpRgbPort != ntpLocalPort && udpRgbPort != udpPort) {
udpRgbConnected = rgbUdp.begin(udpRgbPort);
}
if (udpApiEnabled && udpApiPort > 0 && udpApiPort != ntpLocalPort && udpApiPort != udpPort && udpApiPort != udpRgbPort) {
udpApiConnected = apiUdp.begin(udpApiPort);
}
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
dnsServer.start(53, "*", WiFi.softAPIP());
}
@ -408,6 +411,8 @@ void WLED::initInterfaces()
udpConnected = notifierUdp.begin(udpPort);
if (udpConnected && udpRgbPort != udpPort)
udpRgbConnected = rgbUdp.begin(udpRgbPort);
if (udpApiEnabled && udpConnected && udpApiPort != udpPort && udpApiPort != udpRgbPort)
udpApiConnected = apiUdp.begin(udpApiPort);
}
if (ntpEnabled)
ntpConnected = ntpUdp.begin(ntpLocalPort);

View File

@ -215,6 +215,7 @@ WLED_GLOBAL byte irEnabled _INIT(0); // Infrared receiver
WLED_GLOBAL uint16_t udpPort _INIT(21324); // WLED notifier default port
WLED_GLOBAL uint16_t udpRgbPort _INIT(19446); // Hyperion port
WLED_GLOBAL uint16_t udpApiPort _INIT(7000); // Udp api port
WLED_GLOBAL bool receiveNotificationBrightness _INIT(true); // apply brightness from incoming notifications
WLED_GLOBAL bool receiveNotificationColor _INIT(true); // apply color
@ -259,6 +260,8 @@ WLED_GLOBAL char mqttPass[41] _INIT(""); // optional: password
WLED_GLOBAL char mqttClientID[41] _INIT(""); // override the client ID
WLED_GLOBAL uint16_t mqttPort _INIT(1883);
WLED_GLOBAL bool udpApiEnabled _INIT(true);
WLED_GLOBAL bool huePollingEnabled _INIT(false); // poll hue bridge for light state
WLED_GLOBAL uint16_t huePollIntervalMs _INIT(2500); // low values (< 1sec) may cause lag but offer quicker response
WLED_GLOBAL char hueApiKey[47] _INIT("api"); // key token will be obtained from bridge
@ -377,7 +380,7 @@ WLED_GLOBAL byte effectIntensity _INIT(128);
WLED_GLOBAL byte effectPalette _INIT(0);
// network
WLED_GLOBAL bool udpConnected _INIT(false), udpRgbConnected _INIT(false);
WLED_GLOBAL bool udpConnected _INIT(false), udpRgbConnected _INIT(false), udpApiConnected _INIT(false);;
// ui style
WLED_GLOBAL bool showWelcomePage _INIT(false);
@ -493,7 +496,7 @@ WLED_GLOBAL AsyncClient* hueClient _INIT(NULL);
WLED_GLOBAL AsyncMqttClient* mqtt _INIT(NULL);
// udp interface objects
WLED_GLOBAL WiFiUDP notifierUdp, rgbUdp;
WLED_GLOBAL WiFiUDP notifierUdp, rgbUdp, apiUdp;
WLED_GLOBAL WiFiUDP ntpUdp;
WLED_GLOBAL ESPAsyncE131 e131 _INIT_N(((handleE131Packet)));
WLED_GLOBAL bool e131NewData _INIT(false);

View File

@ -284,6 +284,10 @@ void saveSettingsToEEPROM()
} // last used: 2549. maybe leave a few bytes for future expansion and go on with 2600 kthxbye.
#endif
EEPROM.write(2550, udpApiEnabled);
EEPROM.write(2551, udpApiPort & 0xFF);
EEPROM.write(2552, (udpApiPort >> 8) & 0xFF);
commit();
}
@ -538,6 +542,11 @@ void loadSettingsFromEEPROM(bool first)
}
#endif
if (lastEEPROMversion > 19) {
udpApiEnabled = EEPROM.read(2550);
udpApiPort = EEPROM.read(2551) + ((EEPROM.read(2552) << 8) & 0xFF00);
}
receiveDirect = !EEPROM.read(2200);
notifyMacro = EEPROM.read(2201);

View File

@ -316,6 +316,10 @@ void getSettingsJS(byte subPage, char* dest)
sappend('c',SET_F("SA"),notifyAlexa);
sappends('s',SET_F("BK"),(char*)((blynkEnabled)?SET_F("Hidden"):""));
// UDP Api
sappend('c',"UAE",udpApiEnabled);
sappend('v',"UAP",udpApiPort);
#ifdef WLED_ENABLE_MQTT
sappend('c',SET_F("MQ"),mqttEnabled);
sappends('s',SET_F("MS"),mqttServer);