Changed output of commands GPIO and GPIOs swapped

This commit is contained in:
Theo Arends 2025-03-25 16:53:26 +01:00
parent 2da631e442
commit 714ad233e0
10 changed files with 89 additions and 72 deletions

View File

@ -1623,6 +1623,7 @@ All notable changes to this project will be documented in this file.
- Serial Bridge default internal serial rx buffer size from 64 to 256 (#17120) - Serial Bridge default internal serial rx buffer size from 64 to 256 (#17120)
- Accept filename extensions to GUI file upload input fields (#16875) - Accept filename extensions to GUI file upload input fields (#16875)
- AC PWM dimmer lineair power distribution (#17177) - AC PWM dimmer lineair power distribution (#17177)
- Output of commands `GPIO` and `GPIOs` swapped
### Fixed ### Fixed
- ModbusBridge baudrates over 76500 baud (#17106) - ModbusBridge baudrates over 76500 baud (#17106)

View File

@ -135,6 +135,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
### Changed ### Changed
- ESP32 Platform from 2025.02.30 to 2025.03.30, Framework (Arduino Core) from v3.1.1.250203 to v3.1.3.250302 and IDF from v5.3.2.250120 to 5.3.2.250228 [#23088](https://github.com/arendst/Tasmota/issues/23088) - ESP32 Platform from 2025.02.30 to 2025.03.30, Framework (Arduino Core) from v3.1.1.250203 to v3.1.3.250302 and IDF from v5.3.2.250120 to 5.3.2.250228 [#23088](https://github.com/arendst/Tasmota/issues/23088)
- Output of commands `GPIO` and `GPIOs` swapped
- RCSwitch `RCSWITCH_SEPARATION_LIMIT` from 4100 to 3600 - RCSwitch `RCSWITCH_SEPARATION_LIMIT` from 4100 to 3600
- GPIOViewer from v1.6.1 to v1.6.2 (No functional change) - GPIOViewer from v1.6.1 to v1.6.2 (No functional change)
- ESP8266 enable FTP for >= 4MB variants [#23120](https://github.com/arendst/Tasmota/issues/23120) - ESP8266 enable FTP for >= 4MB variants [#23120](https://github.com/arendst/Tasmota/issues/23120)

View File

@ -858,18 +858,21 @@
// Log message prefix // Log message prefix
#define D_LOG_APPLICATION "APP: " // Application #define D_LOG_APPLICATION "APP: " // Application
#define D_LOG_BRIDGE "BRG: " // Bridge #define D_LOG_BRIDGE "BRG: " // Bridge
#define D_LOG_BERRY "BRY: " // Berry scripting language
#define D_LOG_CONFIG "CFG: " // Settings #define D_LOG_CONFIG "CFG: " // Settings
#define D_LOG_COMMAND "CMD: " // Command #define D_LOG_COMMAND "CMD: " // Command
#define D_LOG_DEBUG "DBG: " // Debug #define D_LOG_DEBUG "DBG: " // Debug
#define D_LOG_DHT "DHT: " // DHT sensor #define D_LOG_DHT "DHT: " // DHT sensor
#define D_LOG_DOMOTICZ "DOM: " // Domoticz #define D_LOG_DOMOTICZ "DOM: " // Domoticz
#define D_LOG_DSB "DSB: " // DS18xB20 sensor #define D_LOG_DSB "DSB: " // DS18xB20 sensor
#define D_LOG_ETH "ETH: " // Ethernet
#define D_LOG_HTTP "HTP: " // HTTP webserver #define D_LOG_HTTP "HTP: " // HTTP webserver
#define D_LOG_HRE "HRE: " #define D_LOG_HRE "HRE: " // Badger HR-E Water Meter
#define D_LOG_I2C "I2C: " // I2C #define D_LOG_I2C "I2C: " // I2C
#define D_LOG_IRR "IRR: " // Infra Red Received #define D_LOG_IRR "IRR: " // Infra Red Received
#define D_LOG_KNX "KNX: " #define D_LOG_KNX "KNX: " // KNX server
#define D_LOG_LOG "LOG: " // Logging #define D_LOG_LOG "LOG: " // Logging
#define D_LOG_LVGL "LVG: " // LVGL graphics engine
#define D_LOG_MODULE "MOD: " // Module #define D_LOG_MODULE "MOD: " // Module
#define D_LOG_MDNS "mDN: " // mDNS #define D_LOG_MDNS "mDN: " // mDNS
#define D_LOG_MQTT "MQT: " // MQTT #define D_LOG_MQTT "MQT: " // MQTT
@ -877,18 +880,17 @@
#define D_LOG_RESULT "RSL: " // Result #define D_LOG_RESULT "RSL: " // Result
#define D_LOG_RFR "RFR: " // RF Received #define D_LOG_RFR "RFR: " // RF Received
#define D_LOG_SERIAL "SER: " // Serial #define D_LOG_SERIAL "SER: " // Serial
#define D_LOG_SENSEAIR "SNA: " // Senseair driver
#define D_LOG_SENSOR "SNS: " // Sensor driver
#define D_LOG_SHT1 "SHT: " // SHT1x sensor #define D_LOG_SHT1 "SHT: " // SHT1x sensor
#define D_LOG_TCP "TCP: " // TCP bridge
#define D_LOG_TELNET "TEL: " // Telnet server
#define D_LOG_THERMOSTAT "THE: " // Thermostat driver
#define D_LOG_UFS "UFS: " // File system
#define D_LOG_UPLOAD "UPL: " // Upload #define D_LOG_UPLOAD "UPL: " // Upload
#define D_LOG_UPNP "UPP: " // UPnP #define D_LOG_UPNP "UPP: " // UPnP
#define D_LOG_WIFI "WIF: " // Wifi #define D_LOG_WIFI "WIF: " // Wifi
#define D_LOG_ETH "ETH: " // Ethernet
#define D_LOG_ZIGBEE "ZIG: " // Zigbee #define D_LOG_ZIGBEE "ZIG: " // Zigbee
#define D_LOG_TCP "TCP: " // TCP bridge
#define D_LOG_BERRY "BRY: " // Berry scripting language
#define D_LOG_LVGL "LVG: " // LVGL graphics engine
#define D_LOG_THERMOSTAT "THE: " // Thermostat driver
#define D_LOG_SENSOR "SNS: " // Sensor driver
#define D_LOG_SENSEAIR "SNA: " // Senseair driver
/********************************************************************************************/ /********************************************************************************************/

View File

@ -486,7 +486,7 @@
#define USE_KNX_WEB_MENU // Enable KNX WEB MENU (+8.3k code, +144 mem) #define USE_KNX_WEB_MENU // Enable KNX WEB MENU (+8.3k code, +144 mem)
// -- Telnet -------------------------------------- // -- Telnet --------------------------------------
//#define USE_TELNET // Add support for telnet (+1k9 code) //#define USE_TELNET // Add support for telnet (+2k code)
// #define TELNET_BUF_SIZE 256 // [TelnetBuffer] Size of input buffer (default 256) // #define TELNET_BUF_SIZE 256 // [TelnetBuffer] Size of input buffer (default 256)
// #define TELNET_START 1 // [Telnet] Start telnet on network connection (default 0 - No start) // #define TELNET_START 1 // [Telnet] Start telnet on network connection (default 0 - No start)
// #define TELNET_PORT 23 // [Telnet] Telnet port (default 23) // #define TELNET_PORT 23 // [Telnet] Telnet port (default 23)

View File

@ -1823,8 +1823,11 @@ void CmndModules(void)
ResponseJsonEndEnd(); ResponseJsonEndEnd();
} }
void CmndGpio(void) void CmndGpio(void) {
{ // Gpio - Show all GPIOs available in module configuration
// Gpio 1 - Show all GPIOs in use in module configuration
// Gpio 255 - Show all GPIOs available in template configuration
// Gpio2 224 - Set GPIO2 as Relay1
if (XdrvMailbox.index < nitems(Settings->my_gp.io)) { if (XdrvMailbox.index < nitems(Settings->my_gp.io)) {
myio template_gp; myio template_gp;
TemplateGpios(&template_gp); TemplateGpios(&template_gp);
@ -1852,12 +1855,6 @@ void CmndGpio(void)
bool jsflg2 = false; bool jsflg2 = false;
for (uint32_t i = 0; i < nitems(Settings->my_gp.io); i++) { for (uint32_t i = 0; i < nitems(Settings->my_gp.io); i++) {
if (ValidGPIO(i, template_gp.io[i]) || ((255 == XdrvMailbox.payload) && !FlashPin(i))) { if (ValidGPIO(i, template_gp.io[i]) || ((255 == XdrvMailbox.payload) && !FlashPin(i))) {
if (!jsflg) {
Response_P(PSTR("{"));
} else {
ResponseAppend_P(PSTR(","));
}
jsflg = true;
uint32_t sensor_type = Settings->my_gp.io[i]; uint32_t sensor_type = Settings->my_gp.io[i];
if (!ValidGPIO(i, template_gp.io[i])) { if (!ValidGPIO(i, template_gp.io[i])) {
sensor_type = template_gp.io[i]; sensor_type = template_gp.io[i];
@ -1865,6 +1862,9 @@ void CmndGpio(void)
sensor_type = GPIO_NONE; sensor_type = GPIO_NONE;
} }
} }
if ((1 == XdrvMailbox.payload) && (GPIO_NONE == sensor_type)) {
continue;
}
char sindex[4] = { 0 }; char sindex[4] = { 0 };
uint32_t sensor_name_idx = BGPIO(sensor_type); uint32_t sensor_name_idx = BGPIO(sensor_type);
uint32_t nice_list_search = sensor_type & 0xFFE0; uint32_t nice_list_search = sensor_type & 0xFFE0;
@ -1880,8 +1880,14 @@ void CmndGpio(void)
sensor_name_idx = sensor_name_idx - GPIO_FIX_START -1; sensor_name_idx = sensor_name_idx - GPIO_FIX_START -1;
sensor_names = kSensorNamesFixed; sensor_names = kSensorNamesFixed;
} }
if (!jsflg) {
Response_P(PSTR("{"));
} else {
ResponseAppend_P(PSTR(","));
}
jsflg = true;
char stemp1[TOPSZ]; char stemp1[TOPSZ];
ResponseAppend_P(PSTR("\"" D_CMND_GPIO "%d\":{\"%d\":\"%s%s\"}"), i, sensor_type, GetTextIndexed(stemp1, sizeof(stemp1), sensor_name_idx, sensor_names), sindex); ResponseAppend_P(PSTR("\"" D_CMND_GPIO "%d\":{\"%s%s\":%d}"), i, GetTextIndexed(stemp1, sizeof(stemp1), sensor_name_idx, sensor_names), sindex, sensor_type);
jsflg2 = true; jsflg2 = true;
} }
} }
@ -1935,7 +1941,7 @@ void ShowGpios(const uint16_t *NiceList, uint32_t size, uint32_t offset, uint32_
} }
jsflg = true; jsflg = true;
char stemp1[TOPSZ]; char stemp1[TOPSZ];
if ((ResponseAppend_P(PSTR("\"%d\":\"%s\""), ridx, GetTextIndexed(stemp1, sizeof(stemp1), midx, kSensorNames)) > (MAX_LOGSZ - TOPSZ)) || (i == size -1)) { if ((ResponseAppend_P(PSTR("\"%s\":%d"), GetTextIndexed(stemp1, sizeof(stemp1), midx, kSensorNames), ridx) > (MAX_LOGSZ - TOPSZ)) || (i == size -1)) {
ResponseJsonEndEnd(); ResponseJsonEndEnd();
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, XdrvMailbox.command); MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, XdrvMailbox.command);
jsflg = false; jsflg = false;

View File

@ -125,3 +125,11 @@ String NetworkUniqueId(void) {
unique_id.replace(":", ""); // Full 12 chars MAC address as ID unique_id.replace(":", ""); // Full 12 chars MAC address as ID
return unique_id; return unique_id;
} }
void AddLogServerActive(const char *server) {
AddLog(LOG_LEVEL_INFO, PSTR("%s server active on %s%s with IP address %s"),
server,
NetworkHostname(),
(Mdns.begun) ? PSTR(".local") : "",
IPGetListeningAddressStr().c_str());
}

View File

@ -677,8 +677,7 @@ void StartWebserver(int type) {
Webserver->begin(); // Web server start Webserver->begin(); // Web server start
} }
if (Web.state != type) { if (Web.state != type) {
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"), AddLogServerActive(PSTR(D_LOG_HTTP "Web"));
NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", IPGetListeningAddressStr().c_str());
TasmotaGlobal.rules_flag.http_init = 1; TasmotaGlobal.rules_flag.http_init = 1;
Web.state = type; Web.state = type;
} }

View File

@ -10823,7 +10823,7 @@ void ScriptServeFile82(void) {
if (ufsp->exists(cp)) { if (ufsp->exists(cp)) {
#endif #endif
if (glob_script_mem.download82_busy == true) { if (glob_script_mem.download82_busy == true) {
AddLog(LOG_LEVEL_INFO, PSTR("UFS: 82 Download is busy")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "82 Download is busy"));
return; return;
} }
glob_script_mem.download82_busy = true; glob_script_mem.download82_busy = true;
@ -10927,7 +10927,7 @@ int32_t SendFile(char *fname) {
#ifdef ESP32 #ifdef ESP32
#ifdef USE_DLTASK #ifdef USE_DLTASK
if (glob_script_mem.script_download_busy == true) { if (glob_script_mem.script_download_busy == true) {
AddLog(LOG_LEVEL_INFO, PSTR("UFS: Download is busy")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "Download is busy"));
return -1; return -1;
} }
glob_script_mem.script_download_busy = true; glob_script_mem.script_download_busy = true;

View File

@ -154,7 +154,7 @@ void UfsInit(void) {
UfsData.run_file_pos = -1; UfsData.run_file_pos = -1;
UfsInitOnce(); UfsInitOnce();
if (ufs_type) { if (ufs_type) {
AddLog(LOG_LEVEL_INFO, PSTR("UFS: FlashFS mounted with %d kB free"), UfsInfo(1, 0)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "FlashFS mounted with %d kB free"), UfsInfo(1, 0));
} }
} }
@ -217,10 +217,10 @@ void UfsCheckSDCardInit(void) {
// make sd card the global filesystem // make sd card the global filesystem
#ifdef ESP8266 #ifdef ESP8266
// on esp8266 sdcard info takes several seconds !!!, so we ommit it here // on esp8266 sdcard info takes several seconds !!!, so we ommit it here
AddLog(LOG_LEVEL_INFO, PSTR("UFS: SDCard mounted")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "SDCard mounted"));
#endif // ESP8266 #endif // ESP8266
#ifdef ESP32 #ifdef ESP32
AddLog(LOG_LEVEL_INFO, PSTR("UFS: SDCard mounted (SPI mode) with %d kB free"), UfsInfo(1, 0)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "SDCard mounted (SPI mode) with %d kB free"), UfsInfo(1, 0));
#endif // ESP32 #endif // ESP32
} }
} }
@ -249,7 +249,7 @@ void UfsCheckSDCardInit(void) {
dfsp = ufsp; dfsp = ufsp;
if (ffsp) {ufs_dir = 1;} if (ffsp) {ufs_dir = 1;}
// make sd card the global filesystem // make sd card the global filesystem
AddLog(LOG_LEVEL_INFO, PSTR("UFS: SDCard mounted (SDIO %i-bit) with %d kB free"), bit_4_mode ? 4 : 1, UfsInfo(1, 0)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "SDCard mounted (SDIO %i-bit) with %d kB free"), bit_4_mode ? 4 : 1, UfsInfo(1, 0));
} }
} }
#endif #endif
@ -1049,7 +1049,7 @@ public:
//log_v("StaticRequestHandler::handle: request=%s _uri=%s\r\n", requestUri.c_str(), _uri.c_str()); //log_v("StaticRequestHandler::handle: request=%s _uri=%s\r\n", requestUri.c_str(), _uri.c_str());
#ifdef SERVING_DEBUG #ifdef SERVING_DEBUG
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: ::handle: request=%s _uri=%s"), requestUri.c_str(), _uri.c_str()); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "::handle: request=%s _uri=%s"), requestUri.c_str(), _uri.c_str());
#endif #endif
String path(_path); String path(_path);
@ -1063,7 +1063,7 @@ public:
path += requestUri.substring(_baseUriLength); path += requestUri.substring(_baseUriLength);
} }
#ifdef SERVING_DEBUG #ifdef SERVING_DEBUG
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: ::handle: path=%s, isFile=%d"), path.c_str(), _isFile); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "::handle: path=%s, isFile=%d"), path.c_str(), _isFile);
#endif #endif
String contentType = getContentType(path); String contentType = getContentType(path);
@ -1077,15 +1077,15 @@ public:
File f = _fs.open(path, "r"); File f = _fs.open(path, "r");
if (!f || !f.available()){ if (!f || !f.available()){
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: ::handler missing file?")); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "::handler missing file?"));
return false; return false;
} }
#ifdef SERVING_DEBUG #ifdef SERVING_DEBUG
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: ::handler file open %d"), f.available()); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "::handler file open %d"), f.available());
#endif #endif
if (_requireAuth && !WebAuthenticate()) { if (_requireAuth && !WebAuthenticate()) {
#ifdef SERVING_DEBUG #ifdef SERVING_DEBUG
AddLog(LOG_LEVEL_ERROR, PSTR("UFS: serv of %s denied"), requestUri.c_str()); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_UFS "serv of %s denied"), requestUri.c_str());
#endif #endif
server.requestAuthentication(); server.requestAuthentication();
return true; return true;
@ -1095,7 +1095,7 @@ public:
server.sendHeader("Cache-Control", _cache_header); server.sendHeader("Cache-Control", _cache_header);
#ifdef SERVING_DEBUG #ifdef SERVING_DEBUG
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: ::handler sending")); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "::handler sending"));
#endif #endif
uint8_t buff[512]; uint8_t buff[512];
uint32_t bread; uint32_t bread;
@ -1110,18 +1110,18 @@ public:
bread = f.read(buff, sizeof(buff)); bread = f.read(buff, sizeof(buff));
cnt += bread; cnt += bread;
#ifdef SERVING_DEBUG #ifdef SERVING_DEBUG
//AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: ::handler sending %d/%d"), cnt, flen); //AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "::handler sending %d/%d"), cnt, flen);
#endif #endif
uint32_t bw = download_Client.write((const char*)buff, bread); uint32_t bw = download_Client.write((const char*)buff, bread);
if (!bw) { break; } if (!bw) { break; }
yield(); yield();
} }
#ifdef SERVING_DEBUG #ifdef SERVING_DEBUG
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: ::handler sent %d/%d"), cnt, flen); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "::handler sent %d/%d"), cnt, flen);
#endif #endif
if (cnt != flen){ if (cnt != flen){
AddLog(LOG_LEVEL_ERROR, PSTR("UFS: ::handler incomplete file send: sent %d/%d"), cnt, flen); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_UFS "::handler incomplete file send: sent %d/%d"), cnt, flen);
} }
// It does seem that on lesser ESP32, this causes a problem? A lockup... // It does seem that on lesser ESP32, this causes a problem? A lockup...
@ -1131,7 +1131,7 @@ public:
download_Client.stop(); download_Client.stop();
#ifdef SERVING_DEBUG #ifdef SERVING_DEBUG
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: ::handler done")); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "::handler done"));
#endif #endif
return true; return true;
} }
@ -1524,21 +1524,21 @@ void UfsListDir(char *path, uint8_t depth) {
uint8_t UfsDownloadFile(char *file) { uint8_t UfsDownloadFile(char *file) {
File download_file; File download_file;
AddLog(LOG_LEVEL_INFO, PSTR("UFS: File '%s' download"), file); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "File '%s' download"), file);
if (!dfsp->exists(file)) { if (!dfsp->exists(file)) {
AddLog(LOG_LEVEL_INFO, PSTR("UFS: File '%s' not found"), file); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "File '%s' not found"), file);
return 0; return 0;
} }
download_file = dfsp->open(file, UFS_FILE_READ); download_file = dfsp->open(file, UFS_FILE_READ);
if (!download_file) { if (!download_file) {
AddLog(LOG_LEVEL_INFO, PSTR("UFS: Could not open file '%s'"), file); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "Could not open file '%s'"), file);
return 0; return 0;
} }
if (download_file.isDirectory()) { if (download_file.isDirectory()) {
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: File '%s' to download is directory"), file); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "File '%s' to download is directory"), file);
download_file.close(); download_file.close();
return 1; return 1;
} }
@ -1588,7 +1588,7 @@ uint8_t UfsDownloadFile(char *file) {
download_file.close(); download_file.close();
if (UfsData.download_busy == true) { if (UfsData.download_busy == true) {
AddLog(LOG_LEVEL_INFO, PSTR("UFS: Download is busy")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "Download is busy"));
return 0; return 0;
} }
@ -1597,7 +1597,7 @@ uint8_t UfsDownloadFile(char *file) {
strcpy(path,file); strcpy(path,file);
BaseType_t ret = xTaskCreatePinnedToCore(download_task, "DT", 6000, (void*)path, 3, nullptr, 1); BaseType_t ret = xTaskCreatePinnedToCore(download_task, "DT", 6000, (void*)path, 3, nullptr, 1);
if (ret != pdPASS) if (ret != pdPASS)
AddLog(LOG_LEVEL_INFO, PSTR("UFS: Download task failed with %d"), ret); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "Download task failed with %d"), ret);
yield(); yield();
#endif // ESP32_DOWNLOAD_TASK #endif // ESP32_DOWNLOAD_TASK
@ -1614,12 +1614,12 @@ void download_task(void *path) {
WiFiClient download_Client; WiFiClient download_Client;
char *file = (char*) path; char *file = (char*) path;
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: ESP32 File '%s' to download"), file); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "ESP32 File '%s' to download"), file);
download_file = dfsp->open(file, UFS_FILE_READ); download_file = dfsp->open(file, UFS_FILE_READ);
uint32_t flen = download_file.size(); uint32_t flen = download_file.size();
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: len %d to download"), flen); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "len %d to download"), flen);
download_Client = Webserver->client(); download_Client = Webserver->client();
Webserver->setContentLength(flen); Webserver->setContentLength(flen);
@ -1647,7 +1647,7 @@ void download_task(void *path) {
UfsData.download_busy = false; UfsData.download_busy = false;
vTaskDelete( NULL ); vTaskDelete( NULL );
free(path); free(path);
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: esp32 sent file")); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "esp32 sent file"));
} }
#endif // ESP32_DOWNLOAD_TASK #endif // ESP32_DOWNLOAD_TASK
@ -1682,7 +1682,7 @@ void UfsUploadFileClose(void) {
void UfsEditor(void) { void UfsEditor(void) {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor GET")); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "UfsEditor GET"));
char fname_input[UFS_FILENAME_SIZE]; char fname_input[UFS_FILENAME_SIZE];
if (Webserver->hasArg(F("file"))) { if (Webserver->hasArg(F("file"))) {
@ -1693,7 +1693,7 @@ void UfsEditor(void) {
char fname[UFS_FILENAME_SIZE]; char fname[UFS_FILENAME_SIZE];
UfsFilename(fname, fname_input); // Trim spaces and add slash UfsFilename(fname, fname_input); // Trim spaces and add slash
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file=%s, ffs_type=%d, TfsFileExist=%d"), fname, ffs_type, dfsp->exists(fname)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "UfsEditor: file=%s, ffs_type=%d, TfsFileExist=%d"), fname, ffs_type, dfsp->exists(fname));
WSContentStart_P(PSTR(D_EDIT_FILE)); WSContentStart_P(PSTR(D_EDIT_FILE));
WSContentSendStyle(); WSContentSendStyle();
@ -1703,15 +1703,15 @@ void UfsEditor(void) {
if (ffs_type && dfsp->exists(fname)) { if (ffs_type && dfsp->exists(fname)) {
File fp = dfsp->open(fname, "r"); File fp = dfsp->open(fname, "r");
if (!fp) { if (!fp) {
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file open failed")); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "UfsEditor: file open failed"));
WSContentSend_P(D_NEW_FILE); WSContentSend_P(D_NEW_FILE);
} else { } else {
uint8_t *buf = (uint8_t*)malloc(FILE_BUFFER_SIZE+1); uint8_t *buf = (uint8_t*)malloc(FILE_BUFFER_SIZE+1);
size_t filelen = fp.size(); size_t filelen = fp.size();
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file len=%d"), filelen); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "UfsEditor: file len=%d"), filelen);
while (filelen > 0) { while (filelen > 0) {
size_t l = fp.read(buf, FILE_BUFFER_SIZE); size_t l = fp.read(buf, FILE_BUFFER_SIZE);
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UFS: UfsEditor: read=%d"), l); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UFS "UfsEditor: read=%d"), l);
if (l < 0) { break; } if (l < 0) { break; }
buf[l] = '\0'; buf[l] = '\0';
WSContentSend_P(PSTR("%s"), HtmlEscape((char*)buf).c_str()); WSContentSend_P(PSTR("%s"), HtmlEscape((char*)buf).c_str());
@ -1719,7 +1719,7 @@ void UfsEditor(void) {
} }
fp.close(); fp.close();
free(buf); free(buf);
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: read done")); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "UfsEditor: read done"));
} }
} else { } else {
WSContentSend_P(D_NEW_FILE); WSContentSend_P(D_NEW_FILE);
@ -1732,12 +1732,12 @@ void UfsEditor(void) {
} }
void UfsEditorUpload(void) { void UfsEditorUpload(void) {
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file upload")); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "UfsEditor: file upload"));
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
if (!Webserver->hasArg("name")) { if (!Webserver->hasArg("name")) {
AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: file upload - no filename")); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_UFS "UfsEditor: file upload - no filename"));
WSSend(400, CT_PLAIN, F("400: Bad request - no filename")); WSSend(400, CT_PLAIN, F("400: Bad request - no filename"));
return; return;
} }
@ -1746,10 +1746,10 @@ void UfsEditorUpload(void) {
WebGetArg(PSTR("name"), fname_input, sizeof(fname_input)); WebGetArg(PSTR("name"), fname_input, sizeof(fname_input));
char fname[UFS_FILENAME_SIZE]; char fname[UFS_FILENAME_SIZE];
UfsFilename(fname, fname_input); // Trim spaces and add slash UfsFilename(fname, fname_input); // Trim spaces and add slash
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: file '%s'"), fname); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "UfsEditor: file '%s'"), fname);
if (!Webserver->hasArg("content")) { if (!Webserver->hasArg("content")) {
AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: file upload - no content")); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_UFS "UfsEditor: file upload - no content"));
WSSend(400, CT_PLAIN, F("400: Bad request - no content")); WSSend(400, CT_PLAIN, F("400: Bad request - no content"));
return; return;
} }
@ -1757,7 +1757,7 @@ void UfsEditorUpload(void) {
if (!dfsp) { if (!dfsp) {
Web.upload_error = 1; Web.upload_error = 1;
AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: 507: no storage available")); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_UFS "UfsEditor: 507: no storage available"));
WSSend(507, CT_PLAIN, F("507: no storage available")); WSSend(507, CT_PLAIN, F("507: no storage available"));
return; return;
} }
@ -1782,7 +1782,7 @@ void UfsEditorUpload(void) {
File fp = dfsp->open(fname, "w"); File fp = dfsp->open(fname, "w");
if (!fp) { if (!fp) {
Web.upload_error = 1; Web.upload_error = 1;
AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: 400: invalid file name '%s'"), fname); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_UFS "UfsEditor: 400: invalid file name '%s'"), fname);
WSSend(400, CT_PLAIN, F("400: bad request - invalid filename")); WSSend(400, CT_PLAIN, F("400: bad request - invalid filename"));
return; return;
} }
@ -1793,7 +1793,7 @@ void UfsEditorUpload(void) {
} }
if (!fp.print(content)) { if (!fp.print(content)) {
AddLog(LOG_LEVEL_ERROR, PSTR("UFS: UfsEditor: write error on '%s'"), fname); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_UFS "UfsEditor: write error on '%s'"), fname);
} }
fp.close(); fp.close();
@ -1826,7 +1826,7 @@ void FTP_Server(uint32_t mode) {
} else { } else {
ftpSrv->begin(USER_FTP,PW_FTP, ffsp); ftpSrv->begin(USER_FTP,PW_FTP, ffsp);
} }
AddLog(LOG_LEVEL_INFO, PSTR("UFS: FTP Server started in mode: '%d'"), mode); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UFS "FTP Server started in mode: '%d'"), mode);
} else { } else {
if (ftpSrv) { if (ftpSrv) {
delete ftpSrv; delete ftpSrv;

View File

@ -129,11 +129,11 @@ void TelnetLoop(void) {
if ((Telnet.server) && (Telnet.server->hasClient())) { if ((Telnet.server) && (Telnet.server->hasClient())) {
WiFiClient new_client = Telnet.server->available(); WiFiClient new_client = Telnet.server->available();
AddLog(LOG_LEVEL_INFO, PSTR("TLN: Connection from %s"), new_client.remoteIP().toString().c_str()); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TELNET "Connection from %s"), new_client.remoteIP().toString().c_str());
if (Telnet.ip_filter_enabled) { // Check for IP filtering if it's enabled if (Telnet.ip_filter_enabled) { // Check for IP filtering if it's enabled
if (Telnet.ip_filter != new_client.remoteIP()) { if (Telnet.ip_filter != new_client.remoteIP()) {
AddLog(LOG_LEVEL_INFO, PSTR("TLN: Rejected due to filtering")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TELNET "Rejected due to filtering"));
new_client.stop(); new_client.stop();
} }
} }
@ -143,7 +143,7 @@ void TelnetLoop(void) {
} }
Telnet.client = new_client; Telnet.client = new_client;
if (Telnet.client) { if (Telnet.client) {
Telnet.client.printf("Tasmota %s %s (%s) %s\r\n", TasmotaGlobal.hostname, TasmotaGlobal.version, GetBuildDateAndTime().c_str(), GetDeviceHardware().c_str()); Telnet.client.printf("Tasmota %s %s (%s) %s\r\n", NetworkHostname(), TasmotaGlobal.version, GetBuildDateAndTime().c_str(), GetDeviceHardware().c_str());
Telnet.prompt = 3; Telnet.prompt = 3;
#ifdef ESP32 #ifdef ESP32
uint32_t index = 1; uint32_t index = 1;
@ -164,7 +164,7 @@ void TelnetLoop(void) {
#ifdef ESP32 #ifdef ESP32
if (0 == Telnet.prompt) { if (0 == Telnet.prompt) {
TelnetWriteColor(Telnet.color[0]); TelnetWriteColor(Telnet.color[0]);
Telnet.client.printf("%s:# ", TasmotaGlobal.hostname); Telnet.client.printf("%s:# ", NetworkHostname());
TelnetWriteColor(0); TelnetWriteColor(0);
Telnet.prompt = 3; // Print linefeed for non-requested data Telnet.prompt = 3; // Print linefeed for non-requested data
while (Telnet.client.available()) { Telnet.client.read(); } // Flush input while (Telnet.client.available()) { Telnet.client.read(); } // Flush input
@ -182,7 +182,7 @@ void TelnetLoop(void) {
if (any_line) { if (any_line) {
if ((0 == Telnet.log_index) || (Telnet.prompt != 2)) { if ((0 == Telnet.log_index) || (Telnet.prompt != 2)) {
TelnetWriteColor(Telnet.color[0]); TelnetWriteColor(Telnet.color[0]);
Telnet.client.printf("%s:# ", TasmotaGlobal.hostname); Telnet.client.printf("%s:# ", NetworkHostname());
TelnetWriteColor(0); TelnetWriteColor(0);
Telnet.prompt = 3; // Print linefeed for non-requested data Telnet.prompt = 3; // Print linefeed for non-requested data
while (Telnet.client.available()) { Telnet.client.read(); } // Flush input while (Telnet.client.available()) { Telnet.client.read(); } // Flush input
@ -207,14 +207,14 @@ void TelnetLoop(void) {
Telnet.client.write("\r"); // Move cursor to begin of line (needed for non-buffered input) Telnet.client.write("\r"); // Move cursor to begin of line (needed for non-buffered input)
Telnet.prompt = 1; // Do not print linefeed for requested data and use response color Telnet.prompt = 1; // Do not print linefeed for requested data and use response color
if (Telnet.in_byte_counter >= Telnet.buffer_size) { if (Telnet.in_byte_counter >= Telnet.buffer_size) {
AddLog(LOG_LEVEL_INFO, PSTR("TLN: buffer overrun")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TELNET "Buffer overrun"));
} else { } else {
char command[CMDSZ]; char command[CMDSZ];
if (GetCommandCode(command, sizeof(command), Telnet.buffer, kTelnetExits) >= 0) { if (GetCommandCode(command, sizeof(command), Telnet.buffer, kTelnetExits) >= 0) {
AddLog(LOG_LEVEL_INFO, PSTR("TLN: Connection closed")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TELNET "Connection closed"));
Telnet.client.stop(); Telnet.client.stop();
} else { } else {
AddLog(LOG_LEVEL_INFO, PSTR("TLN: %s"), Telnet.buffer); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TELNET "%s"), Telnet.buffer);
ExecuteCommand(Telnet.buffer, SRC_TELNET); ExecuteCommand(Telnet.buffer, SRC_TELNET);
} }
} }
@ -254,13 +254,13 @@ void TelnetStart(void) {
if (Telnet.buffer) { if (Telnet.buffer) {
if (1 == Telnet.port) { Telnet.port = TELNET_PORT; } if (1 == Telnet.port) { Telnet.port = TELNET_PORT; }
Telnet.server = new WiFiServer(Telnet.port); Telnet.server = new WiFiServer(Telnet.port);
Telnet.server->begin(); // Start TCP server Telnet.server->begin(); // Start Telnet server
Telnet.server->setNoDelay(true); Telnet.server->setNoDelay(true);
AddLog(LOG_LEVEL_INFO, PSTR("TLN: Started")); AddLogServerActive(PSTR(D_LOG_TELNET "Telnet"));
return; return;
} }
} }
AddLog(LOG_LEVEL_INFO, PSTR("TLN: Stopped")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TELNET "Stopped"));
} }
void TelnetInit(void) { void TelnetInit(void) {