mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-29 14:16:40 +00:00
Fix PWM bug
This commit is contained in:
parent
096f5c01ca
commit
444a2b5d03
17
src/hasp.cpp
17
src/hasp.cpp
@ -967,15 +967,28 @@ void haspLoadPage(String pages)
|
|||||||
|
|
||||||
bool haspGetConfig(const JsonObject & settings)
|
bool haspGetConfig(const JsonObject & settings)
|
||||||
{
|
{
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
if(haspStartPage != settings[FPSTR(F_CONFIG_STARTPAGE)].as<uint8_t>()) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_STARTPAGE)] = haspStartPage;
|
settings[FPSTR(F_CONFIG_STARTPAGE)] = haspStartPage;
|
||||||
|
|
||||||
|
if(haspStartDim != settings[FPSTR(F_CONFIG_STARTDIM)].as<uint8_t>()) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_STARTDIM)] = haspStartDim;
|
settings[FPSTR(F_CONFIG_STARTDIM)] = haspStartDim;
|
||||||
|
|
||||||
|
if(haspThemeId != settings[FPSTR(F_CONFIG_THEME)].as<uint8_t>()) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_THEME)] = haspThemeId;
|
settings[FPSTR(F_CONFIG_THEME)] = haspThemeId;
|
||||||
|
|
||||||
|
if(haspThemeHue != settings[FPSTR(F_CONFIG_HUE)].as<uint8_t>()) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_HUE)] = haspThemeHue;
|
settings[FPSTR(F_CONFIG_HUE)] = haspThemeHue;
|
||||||
|
|
||||||
|
if(strcmp(haspZiFontPath, settings[FPSTR(F_CONFIG_ZIFONT)].as<String>().c_str()) != 0) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_ZIFONT)] = haspZiFontPath;
|
settings[FPSTR(F_CONFIG_ZIFONT)] = haspZiFontPath;
|
||||||
|
|
||||||
|
if(strcmp(haspPagesPath, settings[FPSTR(F_CONFIG_PAGES)].as<String>().c_str()) != 0) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_PAGES)] = haspPagesPath;
|
settings[FPSTR(F_CONFIG_PAGES)] = haspPagesPath;
|
||||||
|
|
||||||
configOutput(settings);
|
if(changed) configOutput(settings);
|
||||||
return true;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set HASP Configuration.
|
/** Set HASP Configuration.
|
||||||
|
@ -30,10 +30,11 @@
|
|||||||
#include <FS.h> // Include the SPIFFS library
|
#include <FS.h> // Include the SPIFFS library
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define BACKLIGHT_CHANNEL 15 // pwm channek 0-15
|
||||||
|
|
||||||
/* ---------- Screenshot Variables ---------- */
|
/* ---------- Screenshot Variables ---------- */
|
||||||
File pFileOut;
|
File pFileOut;
|
||||||
uint8_t guiSnapshot = 0;
|
uint8_t guiSnapshot = 0;
|
||||||
size_t guiVDBsize = 0;
|
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
@ -385,8 +386,19 @@ boolean Touch_getXY(uint16_t * x, uint16_t * y, boolean showTouch)
|
|||||||
{
|
{
|
||||||
static const int coords[] = {3800, 500, 300, 3800}; // portrait - left, right, top, bottom
|
static const int coords[] = {3800, 500, 300, 3800}; // portrait - left, right, top, bottom
|
||||||
static const int XP = 27, XM = 15, YP = 4, YM = 14; // default ESP32 Uno touchscreen pins
|
static const int XP = 27, XM = 15, YP = 4, YM = 14; // default ESP32 Uno touchscreen pins
|
||||||
static TouchScreen ts = TouchScreen(XP, aYP, aXM, YM, 300);
|
static TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
|
||||||
TSPoint p = ts.getPoint();
|
TSPoint p = ts.getPoint();
|
||||||
|
int z1 = analogRead(aXM);
|
||||||
|
int z2 = analogRead(aYP);
|
||||||
|
Serial.print(p.x);
|
||||||
|
Serial.print(" - ");
|
||||||
|
Serial.print(p.y);
|
||||||
|
Serial.print(" - ");
|
||||||
|
Serial.print(p.z);
|
||||||
|
Serial.print(" - ");
|
||||||
|
Serial.print(z1);
|
||||||
|
Serial.print(" - ");
|
||||||
|
Serial.println(z2);
|
||||||
|
|
||||||
pinMode(aYP, OUTPUT); // restore shared pins
|
pinMode(aYP, OUTPUT); // restore shared pins
|
||||||
pinMode(aXM, OUTPUT);
|
pinMode(aXM, OUTPUT);
|
||||||
@ -397,6 +409,7 @@ boolean Touch_getXY(uint16_t * x, uint16_t * y, boolean showTouch)
|
|||||||
#define MAXPRESSURE 1000
|
#define MAXPRESSURE 1000
|
||||||
bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
|
bool pressed = (p.z > MINPRESSURE && p.z < MAXPRESSURE);
|
||||||
if(pressed) {
|
if(pressed) {
|
||||||
|
|
||||||
switch(guiRotation) {
|
switch(guiRotation) {
|
||||||
case 0: // portrait
|
case 0: // portrait
|
||||||
*x = map(p.x, coords[0], coords[1], 0, tft.width());
|
*x = map(p.x, coords[0], coords[1], 0, tft.width());
|
||||||
@ -494,7 +507,9 @@ void guiSetup()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initialize the Virtual Device Buffers */
|
/* Initialize the Virtual Device Buffers */
|
||||||
|
size_t guiVDBsize = 0;
|
||||||
lv_init();
|
lv_init();
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
/* allocate on iram (or psram ?) */
|
/* allocate on iram (or psram ?) */
|
||||||
guiVDBsize = 16 * 1024u; // 32 KBytes * 2
|
guiVDBsize = 16 * 1024u; // 32 KBytes * 2
|
||||||
@ -531,11 +546,11 @@ void guiSetup()
|
|||||||
Log.verbose(F("LVGL: Backlight: Pin %d"), guiBacklightPin);
|
Log.verbose(F("LVGL: Backlight: Pin %d"), guiBacklightPin);
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
|
// pinMode(guiBacklightPin, OUTPUT);
|
||||||
// configure LED PWM functionalitites
|
// configure LED PWM functionalitites
|
||||||
ledcSetup(100, 1000, 10);
|
ledcSetup(BACKLIGHT_CHANNEL, 1000, 10);
|
||||||
// attach the channel to the GPIO to be controlled
|
// attach the channel to the GPIO to be controlled
|
||||||
pinMode(guiBacklightPin, OUTPUT);
|
ledcAttachPin(guiBacklightPin, BACKLIGHT_CHANNEL);
|
||||||
ledcAttachPin(guiBacklightPin, 99);
|
|
||||||
#else
|
#else
|
||||||
pinMode(guiBacklightPin, OUTPUT);
|
pinMode(guiBacklightPin, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
@ -578,7 +593,7 @@ void guiSetup()
|
|||||||
indev_drv.read_cb = my_touchpad_read;
|
indev_drv.read_cb = my_touchpad_read;
|
||||||
lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);
|
lv_indev_t * mouse_indev = lv_indev_drv_register(&indev_drv);
|
||||||
|
|
||||||
if(guiShowPointer || true) {
|
if(guiShowPointer) {
|
||||||
lv_obj_t * label = lv_label_create(lv_layer_sys(), NULL);
|
lv_obj_t * label = lv_label_create(lv_layer_sys(), NULL);
|
||||||
lv_label_set_text(label, "<");
|
lv_label_set_text(label, "<");
|
||||||
lv_indev_set_cursor(mouse_indev, label); // connect the object to the driver
|
lv_indev_set_cursor(mouse_indev, label); // connect the object to the driver
|
||||||
@ -646,7 +661,7 @@ void guiSetBacklight(bool lighton)
|
|||||||
if(guiBacklightPin >= 0) {
|
if(guiBacklightPin >= 0) {
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
ledcWrite(99, lighton ? map(guiDimLevel, 0, 100, 0, 1023) : 0); // ledChannel and value
|
ledcWrite(BACKLIGHT_CHANNEL, lighton ? map(guiDimLevel, 0, 100, 0, 1023) : 0); // ledChannel and value
|
||||||
#else
|
#else
|
||||||
analogWrite(guiBacklightPin, lighton ? map(guiDimLevel, 0, 100, 0, 1023) : 0);
|
analogWrite(guiBacklightPin, lighton ? map(guiDimLevel, 0, 100, 0, 1023) : 0);
|
||||||
#endif
|
#endif
|
||||||
@ -664,7 +679,7 @@ void guiSetDim(int8_t level)
|
|||||||
|
|
||||||
if(guiBacklightIsOn) { // The backlight is ON
|
if(guiBacklightIsOn) { // The backlight is ON
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
ledcWrite(99, map(guiDimLevel, 0, 100, 0, 1023)); // ledChannel and value
|
ledcWrite(BACKLIGHT_CHANNEL, map(guiDimLevel, 0, 100, 0, 1023)); // ledChannel and value
|
||||||
#else
|
#else
|
||||||
analogWrite(guiBacklightPin, map(guiDimLevel, 0, 100, 0, 1023));
|
analogWrite(guiBacklightPin, map(guiDimLevel, 0, 100, 0, 1023));
|
||||||
#endif
|
#endif
|
||||||
@ -683,20 +698,46 @@ int8_t guiGetDim()
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
bool guiGetConfig(const JsonObject & settings)
|
bool guiGetConfig(const JsonObject & settings)
|
||||||
{
|
{
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
if(guiTickPeriod != settings[FPSTR(F_GUI_TICKPERIOD)].as<uint8_t>()) changed = true;
|
||||||
settings[FPSTR(F_GUI_TICKPERIOD)] = guiTickPeriod;
|
settings[FPSTR(F_GUI_TICKPERIOD)] = guiTickPeriod;
|
||||||
|
|
||||||
|
if(guiSleepTime1 != settings[FPSTR(F_GUI_IDLEPERIOD1)].as<uint16_t>()) changed = true;
|
||||||
settings[FPSTR(F_GUI_IDLEPERIOD1)] = guiSleepTime1;
|
settings[FPSTR(F_GUI_IDLEPERIOD1)] = guiSleepTime1;
|
||||||
|
|
||||||
|
if(guiSleepTime2 != settings[FPSTR(F_GUI_IDLEPERIOD2)].as<uint16_t>()) changed = true;
|
||||||
settings[FPSTR(F_GUI_IDLEPERIOD2)] = guiSleepTime2;
|
settings[FPSTR(F_GUI_IDLEPERIOD2)] = guiSleepTime2;
|
||||||
|
|
||||||
|
if(guiBacklightPin != settings[FPSTR(F_GUI_BACKLIGHTPIN)].as<uint8_t>()) changed = true;
|
||||||
settings[FPSTR(F_GUI_BACKLIGHTPIN)] = guiBacklightPin;
|
settings[FPSTR(F_GUI_BACKLIGHTPIN)] = guiBacklightPin;
|
||||||
|
|
||||||
|
if(guiRotation != settings[FPSTR(F_GUI_ROTATION)].as<uint8_t>()) changed = true;
|
||||||
settings[FPSTR(F_GUI_ROTATION)] = guiRotation;
|
settings[FPSTR(F_GUI_ROTATION)] = guiRotation;
|
||||||
|
|
||||||
|
if(guiShowPointer != settings[FPSTR(F_GUI_POINTER)].as<bool>()) changed = true;
|
||||||
settings[FPSTR(F_GUI_POINTER)] = guiShowPointer;
|
settings[FPSTR(F_GUI_POINTER)] = guiShowPointer;
|
||||||
|
|
||||||
|
/* Check CalData array has changed */
|
||||||
JsonArray array = settings[FPSTR(F_GUI_CALIBRATION)].to<JsonArray>();
|
JsonArray array = settings[FPSTR(F_GUI_CALIBRATION)].to<JsonArray>();
|
||||||
|
uint8_t i = 0;
|
||||||
|
for(JsonVariant v : array) {
|
||||||
|
Log.verbose(F("GUI CONF: %d: %d <=> %d"), i, calData[i], v.as<uint16_t>());
|
||||||
|
if(i < 5) {
|
||||||
|
if(calData[i] != v.as<uint16_t>()) changed = true;
|
||||||
|
} else {
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Build new CalData array */
|
||||||
for(uint8_t i = 0; i < 5; i++) {
|
for(uint8_t i = 0; i < 5; i++) {
|
||||||
array.add(calData[i]);
|
array.add(calData[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
configOutput(settings);
|
if(changed) configOutput(settings);
|
||||||
return true;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set GUI Configuration.
|
/** Set GUI Configuration.
|
||||||
@ -772,7 +813,6 @@ static void guiSendBmpHeader()
|
|||||||
{
|
{
|
||||||
uint8_t buffer[128];
|
uint8_t buffer[128];
|
||||||
memset(buffer, 0, sizeof(buffer));
|
memset(buffer, 0, sizeof(buffer));
|
||||||
int32_t res;
|
|
||||||
|
|
||||||
lv_disp_t * disp = lv_disp_get_default();
|
lv_disp_t * disp = lv_disp_get_default();
|
||||||
buffer[0] = 0x42; // B
|
buffer[0] = 0x42; // B
|
||||||
|
@ -1910,7 +1910,7 @@ bool httpGetConfig(const JsonObject & settings)
|
|||||||
if(strcmp(httpPassword, settings[FPSTR(F_CONFIG_PASS)].as<String>().c_str()) != 0) changed = true;
|
if(strcmp(httpPassword, settings[FPSTR(F_CONFIG_PASS)].as<String>().c_str()) != 0) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_PASS)] = httpPassword;
|
settings[FPSTR(F_CONFIG_PASS)] = httpPassword;
|
||||||
|
|
||||||
configOutput(settings);
|
if(changed) configOutput(settings);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,10 +75,13 @@ void mdnsStop()
|
|||||||
|
|
||||||
bool mdnsGetConfig(const JsonObject & settings)
|
bool mdnsGetConfig(const JsonObject & settings)
|
||||||
{
|
{
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
if(mdnsEnabled != settings[FPSTR(F_CONFIG_ENABLE)].as<bool>()) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_ENABLE)] = mdnsEnabled;
|
settings[FPSTR(F_CONFIG_ENABLE)] = mdnsEnabled;
|
||||||
|
|
||||||
configOutput(settings);
|
if(changed) configOutput(settings);
|
||||||
return true;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set MDNS Configuration.
|
/** Set MDNS Configuration.
|
||||||
|
@ -123,7 +123,7 @@ void IRAM_ATTR mqtt_send_state(const __FlashStringHelper * subtopic, const char
|
|||||||
|
|
||||||
if(mqttIsConnected()) {
|
if(mqttIsConnected()) {
|
||||||
char topic[64];
|
char topic[64];
|
||||||
snprintf_P(topic, sizeof(topic), PSTR("%sstate/%S"), mqttNodeTopic, subtopic);
|
snprintf_P(topic, sizeof(topic), PSTR("%sstate/%s"), mqttNodeTopic, subtopic);
|
||||||
mqttClient.publish(topic, payload);
|
mqttClient.publish(topic, payload);
|
||||||
} else {
|
} else {
|
||||||
return mqtt_log_no_connection();
|
return mqtt_log_no_connection();
|
||||||
@ -466,7 +466,7 @@ String mqttGetNodename()
|
|||||||
|
|
||||||
void mqttStop()
|
void mqttStop()
|
||||||
{
|
{
|
||||||
if(mqttClient.connected()) {
|
if(mqttEnabled && mqttClient.connected()) {
|
||||||
char topicBuffer[128];
|
char topicBuffer[128];
|
||||||
|
|
||||||
snprintf_P(topicBuffer, sizeof(topicBuffer), PSTR("%sstatus"), mqttNodeTopic);
|
snprintf_P(topicBuffer, sizeof(topicBuffer), PSTR("%sstatus"), mqttNodeTopic);
|
||||||
@ -482,15 +482,28 @@ void mqttStop()
|
|||||||
|
|
||||||
bool mqttGetConfig(const JsonObject & settings)
|
bool mqttGetConfig(const JsonObject & settings)
|
||||||
{
|
{
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
if(strcmp(mqttNodeName, settings[FPSTR(F_CONFIG_NAME)].as<String>().c_str()) != 0) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_NAME)] = mqttNodeName;
|
settings[FPSTR(F_CONFIG_NAME)] = mqttNodeName;
|
||||||
|
|
||||||
|
if(strcmp(mqttGroupName, settings[FPSTR(F_CONFIG_GROUP)].as<String>().c_str()) != 0) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_GROUP)] = mqttGroupName;
|
settings[FPSTR(F_CONFIG_GROUP)] = mqttGroupName;
|
||||||
|
|
||||||
|
if(strcmp(mqttServer, settings[FPSTR(F_CONFIG_HOST)].as<String>().c_str()) != 0) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_HOST)] = mqttServer;
|
settings[FPSTR(F_CONFIG_HOST)] = mqttServer;
|
||||||
|
|
||||||
|
if(mqttPort != settings[FPSTR(F_CONFIG_PORT)].as<uint16_t>()) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_PORT)] = mqttPort;
|
settings[FPSTR(F_CONFIG_PORT)] = mqttPort;
|
||||||
|
|
||||||
|
if(strcmp(mqttUser, settings[FPSTR(F_CONFIG_USER)].as<String>().c_str()) != 0) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_USER)] = mqttUser;
|
settings[FPSTR(F_CONFIG_USER)] = mqttUser;
|
||||||
|
|
||||||
|
if(strcmp(mqttPassword, settings[FPSTR(F_CONFIG_PASS)].as<String>().c_str()) != 0) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_PASS)] = mqttPassword;
|
settings[FPSTR(F_CONFIG_PASS)] = mqttPassword;
|
||||||
|
|
||||||
configOutput(settings);
|
if(changed) configOutput(settings);
|
||||||
return true;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set MQTT Configuration.
|
/** Set MQTT Configuration.
|
||||||
@ -517,6 +530,7 @@ bool mqttSetConfig(const JsonObject & settings)
|
|||||||
String mac = wifiGetMacAddress(3, "");
|
String mac = wifiGetMacAddress(3, "");
|
||||||
mac.toLowerCase();
|
mac.toLowerCase();
|
||||||
snprintf_P(mqttNodeName, sizeof(mqttNodeName), PSTR("plate_%s"), mac.c_str());
|
snprintf_P(mqttNodeName, sizeof(mqttNodeName), PSTR("plate_%s"), mac.c_str());
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!settings[FPSTR(F_CONFIG_GROUP)].isNull()) {
|
if(!settings[FPSTR(F_CONFIG_GROUP)].isNull()) {
|
||||||
@ -524,6 +538,11 @@ bool mqttSetConfig(const JsonObject & settings)
|
|||||||
strncpy(mqttGroupName, settings[FPSTR(F_CONFIG_GROUP)], sizeof(mqttGroupName));
|
strncpy(mqttGroupName, settings[FPSTR(F_CONFIG_GROUP)], sizeof(mqttGroupName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strlen(mqttGroupName) == 0) {
|
||||||
|
strcpy_P(mqttGroupName, PSTR("plates"));
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(!settings[FPSTR(F_CONFIG_HOST)].isNull()) {
|
if(!settings[FPSTR(F_CONFIG_HOST)].isNull()) {
|
||||||
changed |= strcmp(mqttServer, settings[FPSTR(F_CONFIG_HOST)]) != 0;
|
changed |= strcmp(mqttServer, settings[FPSTR(F_CONFIG_HOST)]) != 0;
|
||||||
strncpy(mqttServer, settings[FPSTR(F_CONFIG_HOST)], sizeof(mqttServer));
|
strncpy(mqttServer, settings[FPSTR(F_CONFIG_HOST)], sizeof(mqttServer));
|
||||||
|
@ -26,8 +26,9 @@ extern char httpUser[32];
|
|||||||
extern char httpPassword[32];
|
extern char httpPassword[32];
|
||||||
|
|
||||||
uint8_t telnetLoginState = TELNET_UNAUTHENTICATED;
|
uint8_t telnetLoginState = TELNET_UNAUTHENTICATED;
|
||||||
static WiFiServer * telnetServer; //= new WiFiServer(23);
|
|
||||||
WiFiClient telnetClient;
|
WiFiClient telnetClient;
|
||||||
|
static WiFiServer * telnetServer;
|
||||||
|
uint16_t telnetPort = 23;
|
||||||
bool telnetInCommandMode = false;
|
bool telnetInCommandMode = false;
|
||||||
uint8_t telnetEnabled = true; // Enable telnet debug output
|
uint8_t telnetEnabled = true; // Enable telnet debug output
|
||||||
uint8_t telnetLoginAttempt = 0; // Initial attempt
|
uint8_t telnetLoginAttempt = 0; // Initial attempt
|
||||||
@ -173,17 +174,17 @@ void telnetSetup()
|
|||||||
// telnetSetConfig(settings);
|
// telnetSetConfig(settings);
|
||||||
|
|
||||||
if(telnetEnabled) { // Setup telnet server for remote debug output
|
if(telnetEnabled) { // Setup telnet server for remote debug output
|
||||||
if(!telnetServer) telnetServer = new WiFiServer(23);
|
if(!telnetServer) telnetServer = new WiFiServer(telnetPort);
|
||||||
if(telnetServer) {
|
if(telnetServer) {
|
||||||
telnetServer->setNoDelay(true);
|
telnetServer->setNoDelay(true);
|
||||||
telnetServer->begin();
|
telnetServer->begin();
|
||||||
|
|
||||||
// if(!telnetClient) telnetClient = new WiFiClient;
|
// if(!telnetClient) telnetClient = new WiFiClient;
|
||||||
if(!telnetClient) {
|
// if(!telnetClient) {
|
||||||
Log.error(F("Failed to start telnet client"));
|
// Log.error(F("Failed to start telnet client"));
|
||||||
} else {
|
//} else {
|
||||||
telnetClient.setNoDelay(true);
|
telnetClient.setNoDelay(true);
|
||||||
}
|
//}
|
||||||
|
|
||||||
Log.notice(F("Debug telnet console started"));
|
Log.notice(F("Debug telnet console started"));
|
||||||
} else {
|
} else {
|
||||||
@ -213,10 +214,16 @@ void IRAM_ATTR telnetLoop()
|
|||||||
|
|
||||||
bool telnetGetConfig(const JsonObject & settings)
|
bool telnetGetConfig(const JsonObject & settings)
|
||||||
{
|
{
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
if(telnetEnabled != settings[FPSTR(F_CONFIG_ENABLE)].as<bool>()) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_ENABLE)] = telnetEnabled;
|
settings[FPSTR(F_CONFIG_ENABLE)] = telnetEnabled;
|
||||||
|
|
||||||
configOutput(settings);
|
if(telnetPort != settings[FPSTR(F_CONFIG_PORT)].as<uint16_t>()) changed = true;
|
||||||
return true;
|
settings[FPSTR(F_CONFIG_PORT)] = telnetPort;
|
||||||
|
|
||||||
|
if(changed) configOutput(settings);
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set TELNET Configuration.
|
/** Set TELNET Configuration.
|
||||||
@ -232,6 +239,9 @@ bool telnetSetConfig(const JsonObject & settings)
|
|||||||
configOutput(settings);
|
configOutput(settings);
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
|
changed |= configSet(telnetEnabled, settings[FPSTR(F_CONFIG_ENABLE)], PSTR("telnetEnabled"));
|
||||||
|
changed |= configSet(telnetPort, settings[FPSTR(F_CONFIG_PORT)], PSTR("telnetPort"));
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ bool wifiGetConfig(const JsonObject & settings)
|
|||||||
if(strcmp(wifiPassword, settings[FPSTR(F_CONFIG_PASS)].as<String>().c_str()) != 0) changed = true;
|
if(strcmp(wifiPassword, settings[FPSTR(F_CONFIG_PASS)].as<String>().c_str()) != 0) changed = true;
|
||||||
settings[FPSTR(F_CONFIG_PASS)] = wifiPassword;
|
settings[FPSTR(F_CONFIG_PASS)] = wifiPassword;
|
||||||
|
|
||||||
configOutput(settings);
|
if(changed) configOutput(settings);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user