mirror of
https://github.com/wled/WLED.git
synced 2025-07-16 07:16:31 +00:00
Cleanup.
This commit is contained in:
parent
5dd8f0a0b7
commit
593e55af95
@ -445,7 +445,7 @@ void BobLightUsermod::pollBob() {
|
|||||||
//strip.setPixelColor(light_id, RGBW32(red, green, blue, 0));
|
//strip.setPixelColor(light_id, RGBW32(red, green, blue, 0));
|
||||||
setRealtimePixel(light_id, red, green, blue, 0);
|
setRealtimePixel(light_id, red, green, blue, 0);
|
||||||
} // currently no support for interpolation or speed, we just ignore this
|
} // currently no support for interpolation or speed, we just ignore this
|
||||||
} else if (input.startsWith(F("sync"))) {
|
} else if (input.startsWith("sync")) {
|
||||||
BobSync();
|
BobSync();
|
||||||
} else {
|
} else {
|
||||||
// Client sent gibberish
|
// Client sent gibberish
|
||||||
|
@ -67,8 +67,8 @@ class WireguardUsermod : public Usermod {
|
|||||||
JsonObject top = root.createNestedObject(F("WireGuard"));
|
JsonObject top = root.createNestedObject(F("WireGuard"));
|
||||||
top[F("host")] = endpoint_address;
|
top[F("host")] = endpoint_address;
|
||||||
top[F("port")] = endpoint_port;
|
top[F("port")] = endpoint_port;
|
||||||
top[F("ip")] = local_ip.toString();
|
top["ip"] = local_ip.toString();
|
||||||
top[F("psk")] = preshared_key;
|
top["psk"] = preshared_key;
|
||||||
top[F("pem")] = private_key;
|
top[F("pem")] = private_key;
|
||||||
top[F("pub")] = public_key;
|
top[F("pub")] = public_key;
|
||||||
top[F("tz")] = posix_tz;
|
top[F("tz")] = posix_tz;
|
||||||
@ -77,11 +77,11 @@ class WireguardUsermod : public Usermod {
|
|||||||
bool readFromConfig(JsonObject& root) {
|
bool readFromConfig(JsonObject& root) {
|
||||||
JsonObject top = root[F("WireGuard")];
|
JsonObject top = root[F("WireGuard")];
|
||||||
|
|
||||||
if (top["host"].isNull() || top["port"].isNull() || top["ip"].isNull() || top["pem"].isNull() || top["pub"].isNull() || top["tz"].isNull()) {
|
if (top[F("host")].isNull() || top[F("port")].isNull() || top["ip"].isNull() || top[F("pem")].isNull() || top[F("pub")].isNull() || top[F("tz")].isNull()) {
|
||||||
is_enabled = false;
|
is_enabled = false;
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
const char* host = top["host"];
|
const char* host = top[F("host")];
|
||||||
strncpy(endpoint_address, host, 100);
|
strncpy(endpoint_address, host, 100);
|
||||||
|
|
||||||
const char* ip_s = top["ip"];
|
const char* ip_s = top["ip"];
|
||||||
@ -89,16 +89,16 @@ class WireguardUsermod : public Usermod {
|
|||||||
sscanf(ip_s, "%u.%u.%u.%u", &ip[0], &ip[1], &ip[2], &ip[3]);
|
sscanf(ip_s, "%u.%u.%u.%u", &ip[0], &ip[1], &ip[2], &ip[3]);
|
||||||
local_ip = IPAddress(ip[0], ip[1], ip[2], ip[3]);
|
local_ip = IPAddress(ip[0], ip[1], ip[2], ip[3]);
|
||||||
|
|
||||||
const char* pem = top["pem"];
|
const char* pem = top[F("pem")];
|
||||||
strncpy(private_key, pem, 45);
|
strncpy(private_key, pem, 45);
|
||||||
|
|
||||||
const char* pub = top["pub"];
|
const char* pub = top[F("pub")];
|
||||||
strncpy(public_key, pub, 45);
|
strncpy(public_key, pub, 45);
|
||||||
|
|
||||||
const char* tz = top["tz"];
|
const char* tz = top[F("tz")];
|
||||||
strncpy(posix_tz, tz, 150);
|
strncpy(posix_tz, tz, 150);
|
||||||
|
|
||||||
endpoint_port = top["port"];
|
endpoint_port = top[F("port")];
|
||||||
|
|
||||||
if (!top["psk"].isNull()) {
|
if (!top["psk"].isNull()) {
|
||||||
const char* psk = top["psk"];
|
const char* psk = top["psk"];
|
||||||
|
@ -325,8 +325,8 @@ public:
|
|||||||
void addToConfig(JsonObject& root)
|
void addToConfig(JsonObject& root)
|
||||||
{
|
{
|
||||||
JsonObject modName = root.createNestedObject("id");
|
JsonObject modName = root.createNestedObject("id");
|
||||||
modName["mdns"] = "wled-word-clock";
|
modName[F("mdns")] = "wled-word-clock";
|
||||||
modName["name"] = "WLED WORD CLOCK";
|
modName[F("name")] = "WLED WORD CLOCK";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t getId()
|
uint16_t getId()
|
||||||
|
@ -2161,7 +2161,7 @@ function selGrp(g)
|
|||||||
var sel = gId(`segcont`).querySelectorAll(`div[data-set="${g}"]`);
|
var sel = gId(`segcont`).querySelectorAll(`div[data-set="${g}"]`);
|
||||||
var obj = {"seg":[]};
|
var obj = {"seg":[]};
|
||||||
for (let i=0; i<=lSeg; i++) if (gId(`seg${i}`)) obj.seg.push({"id":i,"sel":false});
|
for (let i=0; i<=lSeg; i++) if (gId(`seg${i}`)) obj.seg.push({"id":i,"sel":false});
|
||||||
if (sel) for (let s of sel||[]) {
|
for (let s of (sel||[])) {
|
||||||
let i = parseInt(s.id.substring(3));
|
let i = parseInt(s.id.substring(3));
|
||||||
obj.seg[i] = {"id":i,"sel":true};
|
obj.seg[i] = {"id":i,"sel":true};
|
||||||
}
|
}
|
||||||
|
@ -377,27 +377,27 @@ void updateFSInfo() {
|
|||||||
|
|
||||||
//Un-comment any file types you need
|
//Un-comment any file types you need
|
||||||
static String getContentType(AsyncWebServerRequest* request, String filename){
|
static String getContentType(AsyncWebServerRequest* request, String filename){
|
||||||
if(request->hasArg("download")) return "application/octet-stream";
|
if(request->hasArg(F("download"))) return SET_F("application/octet-stream");
|
||||||
else if(filename.endsWith(".htm")) return "text/html";
|
else if(filename.endsWith(F(".htm"))) return SET_F("text/html");
|
||||||
else if(filename.endsWith(".html")) return "text/html";
|
else if(filename.endsWith(F(".html"))) return SET_F("text/html");
|
||||||
else if(filename.endsWith(".css")) return "text/css";
|
else if(filename.endsWith(F(".css"))) return SET_F("text/css");
|
||||||
else if(filename.endsWith(".js")) return "application/javascript";
|
else if(filename.endsWith(F(".js"))) return SET_F("application/javascript");
|
||||||
else if(filename.endsWith(".json")) return "application/json";
|
else if(filename.endsWith(F(".json"))) return SET_F("application/json");
|
||||||
else if(filename.endsWith(".png")) return "image/png";
|
else if(filename.endsWith(F(".png"))) return SET_F("image/png");
|
||||||
else if(filename.endsWith(".gif")) return "image/gif";
|
else if(filename.endsWith(F(".gif"))) return SET_F("image/gif");
|
||||||
else if(filename.endsWith(".jpg")) return "image/jpeg";
|
else if(filename.endsWith(F(".jpg"))) return SET_F("image/jpeg");
|
||||||
else if(filename.endsWith(".ico")) return "image/x-icon";
|
else if(filename.endsWith(F(".ico"))) return SET_F("image/x-icon");
|
||||||
// else if(filename.endsWith(".xml")) return "text/xml";
|
// else if(filename.endsWith(F(".xml"))) return SET_F("text/xml");
|
||||||
// else if(filename.endsWith(".pdf")) return "application/x-pdf";
|
// else if(filename.endsWith(F(".pdf"))) return SET_F("application/x-pdf");
|
||||||
// else if(filename.endsWith(".zip")) return "application/x-zip";
|
// else if(filename.endsWith(F(".zip"))) return SET_F("application/x-zip");
|
||||||
// else if(filename.endsWith(".gz")) return "application/x-gzip";
|
// else if(filename.endsWith(F(".gz"))) return SET_F("application/x-gzip");
|
||||||
return "text/plain";
|
return "text/plain";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handleFileRead(AsyncWebServerRequest* request, String path){
|
bool handleFileRead(AsyncWebServerRequest* request, String path){
|
||||||
DEBUG_PRINTLN("WS FileRead: " + path);
|
DEBUG_PRINTLN("WS FileRead: " + path);
|
||||||
if(path.endsWith("/")) path += "index.htm";
|
if(path.endsWith("/")) path += "index.htm";
|
||||||
if(path.indexOf("sec") > -1) return false;
|
if(path.indexOf(F("sec")) > -1) return false;
|
||||||
String contentType = getContentType(request, path);
|
String contentType = getContentType(request, path);
|
||||||
/*String pathWithGz = path + ".gz";
|
/*String pathWithGz = path + ".gz";
|
||||||
if(WLED_FS.exists(pathWithGz)){
|
if(WLED_FS.exists(pathWithGz)){
|
||||||
|
@ -611,7 +611,7 @@ void serializeInfo(JsonObject root)
|
|||||||
root[F("vid")] = VERSION;
|
root[F("vid")] = VERSION;
|
||||||
root[F("cn")] = F(WLED_CODENAME);
|
root[F("cn")] = F(WLED_CODENAME);
|
||||||
|
|
||||||
JsonObject leds = root.createNestedObject("leds");
|
JsonObject leds = root.createNestedObject(F("leds"));
|
||||||
leds[F("count")] = strip.getLengthTotal();
|
leds[F("count")] = strip.getLengthTotal();
|
||||||
leds[F("pwr")] = BusManager::currentMilliamps();
|
leds[F("pwr")] = BusManager::currentMilliamps();
|
||||||
leds["fps"] = strip.getFps();
|
leds["fps"] = strip.getFps();
|
||||||
@ -622,7 +622,7 @@ void serializeInfo(JsonObject root)
|
|||||||
|
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
if (strip.isMatrix) {
|
if (strip.isMatrix) {
|
||||||
JsonObject matrix = leds.createNestedObject("matrix");
|
JsonObject matrix = leds.createNestedObject(F("matrix"));
|
||||||
matrix["w"] = Segment::maxWidth;
|
matrix["w"] = Segment::maxWidth;
|
||||||
matrix["h"] = Segment::maxHeight;
|
matrix["h"] = Segment::maxHeight;
|
||||||
}
|
}
|
||||||
@ -702,7 +702,7 @@ void serializeInfo(JsonObject root)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonObject wifi_info = root.createNestedObject("wifi");
|
JsonObject wifi_info = root.createNestedObject(F("wifi"));
|
||||||
wifi_info[F("bssid")] = WiFi.BSSIDstr();
|
wifi_info[F("bssid")] = WiFi.BSSIDstr();
|
||||||
int qrssi = WiFi.RSSI();
|
int qrssi = WiFi.RSSI();
|
||||||
wifi_info[F("rssi")] = qrssi;
|
wifi_info[F("rssi")] = qrssi;
|
||||||
|
@ -532,18 +532,18 @@ void serveSettings(AsyncWebServerRequest* request, bool post) {
|
|||||||
const String& url = request->url();
|
const String& url = request->url();
|
||||||
|
|
||||||
if (url.indexOf("sett") >= 0) {
|
if (url.indexOf("sett") >= 0) {
|
||||||
if (url.indexOf(".js") > 0) subPage = SUBPAGE_JS;
|
if (url.indexOf(F(".js")) > 0) subPage = SUBPAGE_JS;
|
||||||
else if (url.indexOf(".css") > 0) subPage = SUBPAGE_CSS;
|
else if (url.indexOf(F(".css")) > 0) subPage = SUBPAGE_CSS;
|
||||||
else if (url.indexOf("wifi") > 0) subPage = SUBPAGE_WIFI;
|
else if (url.indexOf(F("wifi")) > 0) subPage = SUBPAGE_WIFI;
|
||||||
else if (url.indexOf("leds") > 0) subPage = SUBPAGE_LEDS;
|
else if (url.indexOf(F("leds")) > 0) subPage = SUBPAGE_LEDS;
|
||||||
else if (url.indexOf("ui") > 0) subPage = SUBPAGE_UI;
|
else if (url.indexOf(F("ui")) > 0) subPage = SUBPAGE_UI;
|
||||||
else if (url.indexOf("sync") > 0) subPage = SUBPAGE_SYNC;
|
else if (url.indexOf( "sync") > 0) subPage = SUBPAGE_SYNC;
|
||||||
else if (url.indexOf("time") > 0) subPage = SUBPAGE_TIME;
|
else if (url.indexOf( "time") > 0) subPage = SUBPAGE_TIME;
|
||||||
else if (url.indexOf("sec") > 0) subPage = SUBPAGE_SEC;
|
else if (url.indexOf(F("sec")) > 0) subPage = SUBPAGE_SEC;
|
||||||
else if (url.indexOf("dmx") > 0) subPage = SUBPAGE_DMX;
|
else if (url.indexOf( "dmx") > 0) subPage = SUBPAGE_DMX;
|
||||||
else if (url.indexOf("um") > 0) subPage = SUBPAGE_UM;
|
else if (url.indexOf( "um") > 0) subPage = SUBPAGE_UM;
|
||||||
else if (url.indexOf("2D") > 0) subPage = SUBPAGE_2D;
|
else if (url.indexOf( "2D") > 0) subPage = SUBPAGE_2D;
|
||||||
else if (url.indexOf("lock") > 0) subPage = SUBPAGE_LOCK;
|
else if (url.indexOf(F("lock")) > 0) subPage = SUBPAGE_LOCK;
|
||||||
}
|
}
|
||||||
else if (url.indexOf("/update") >= 0) subPage = SUBPAGE_UPDATE; // update page, for PIN check
|
else if (url.indexOf("/update") >= 0) subPage = SUBPAGE_UPDATE; // update page, for PIN check
|
||||||
//else if (url.indexOf("/edit") >= 0) subPage = 10;
|
//else if (url.indexOf("/edit") >= 0) subPage = 10;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user