mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 13:16:32 +00:00
Changed output of commands GPIO
and GPIOs
swapped
This commit is contained in:
parent
2da631e442
commit
714ad233e0
@ -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)
|
||||
- Accept filename extensions to GUI file upload input fields (#16875)
|
||||
- AC PWM dimmer lineair power distribution (#17177)
|
||||
- Output of commands `GPIO` and `GPIOs` swapped
|
||||
|
||||
### Fixed
|
||||
- ModbusBridge baudrates over 76500 baud (#17106)
|
||||
|
@ -135,6 +135,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
||||
|
||||
### 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)
|
||||
- Output of commands `GPIO` and `GPIOs` swapped
|
||||
- RCSwitch `RCSWITCH_SEPARATION_LIMIT` from 4100 to 3600
|
||||
- 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)
|
||||
|
@ -858,18 +858,21 @@
|
||||
// Log message prefix
|
||||
#define D_LOG_APPLICATION "APP: " // Application
|
||||
#define D_LOG_BRIDGE "BRG: " // Bridge
|
||||
#define D_LOG_BERRY "BRY: " // Berry scripting language
|
||||
#define D_LOG_CONFIG "CFG: " // Settings
|
||||
#define D_LOG_COMMAND "CMD: " // Command
|
||||
#define D_LOG_DEBUG "DBG: " // Debug
|
||||
#define D_LOG_DHT "DHT: " // DHT sensor
|
||||
#define D_LOG_DOMOTICZ "DOM: " // Domoticz
|
||||
#define D_LOG_DSB "DSB: " // DS18xB20 sensor
|
||||
#define D_LOG_ETH "ETH: " // Ethernet
|
||||
#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_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_LVGL "LVG: " // LVGL graphics engine
|
||||
#define D_LOG_MODULE "MOD: " // Module
|
||||
#define D_LOG_MDNS "mDN: " // mDNS
|
||||
#define D_LOG_MQTT "MQT: " // MQTT
|
||||
@ -877,18 +880,17 @@
|
||||
#define D_LOG_RESULT "RSL: " // Result
|
||||
#define D_LOG_RFR "RFR: " // RF Received
|
||||
#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_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_UPNP "UPP: " // UPnP
|
||||
#define D_LOG_WIFI "WIF: " // Wifi
|
||||
#define D_LOG_ETH "ETH: " // Ethernet
|
||||
#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
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
|
@ -486,7 +486,7 @@
|
||||
#define USE_KNX_WEB_MENU // Enable KNX WEB MENU (+8.3k code, +144 mem)
|
||||
|
||||
// -- 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_START 1 // [Telnet] Start telnet on network connection (default 0 - No start)
|
||||
// #define TELNET_PORT 23 // [Telnet] Telnet port (default 23)
|
||||
|
@ -1823,8 +1823,11 @@ void CmndModules(void)
|
||||
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)) {
|
||||
myio template_gp;
|
||||
TemplateGpios(&template_gp);
|
||||
@ -1852,12 +1855,6 @@ void CmndGpio(void)
|
||||
bool jsflg2 = false;
|
||||
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 (!jsflg) {
|
||||
Response_P(PSTR("{"));
|
||||
} else {
|
||||
ResponseAppend_P(PSTR(","));
|
||||
}
|
||||
jsflg = true;
|
||||
uint32_t sensor_type = Settings->my_gp.io[i];
|
||||
if (!ValidGPIO(i, template_gp.io[i])) {
|
||||
sensor_type = template_gp.io[i];
|
||||
@ -1865,6 +1862,9 @@ void CmndGpio(void)
|
||||
sensor_type = GPIO_NONE;
|
||||
}
|
||||
}
|
||||
if ((1 == XdrvMailbox.payload) && (GPIO_NONE == sensor_type)) {
|
||||
continue;
|
||||
}
|
||||
char sindex[4] = { 0 };
|
||||
uint32_t sensor_name_idx = BGPIO(sensor_type);
|
||||
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_names = kSensorNamesFixed;
|
||||
}
|
||||
if (!jsflg) {
|
||||
Response_P(PSTR("{"));
|
||||
} else {
|
||||
ResponseAppend_P(PSTR(","));
|
||||
}
|
||||
jsflg = true;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -1935,7 +1941,7 @@ void ShowGpios(const uint16_t *NiceList, uint32_t size, uint32_t offset, uint32_
|
||||
}
|
||||
jsflg = true;
|
||||
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();
|
||||
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, XdrvMailbox.command);
|
||||
jsflg = false;
|
||||
|
@ -125,3 +125,11 @@ String NetworkUniqueId(void) {
|
||||
unique_id.replace(":", ""); // Full 12 chars MAC address as 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());
|
||||
}
|
@ -677,8 +677,7 @@ void StartWebserver(int type) {
|
||||
Webserver->begin(); // Web server start
|
||||
}
|
||||
if (Web.state != type) {
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"),
|
||||
NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", IPGetListeningAddressStr().c_str());
|
||||
AddLogServerActive(PSTR(D_LOG_HTTP "Web"));
|
||||
TasmotaGlobal.rules_flag.http_init = 1;
|
||||
Web.state = type;
|
||||
}
|
||||
|
@ -10823,7 +10823,7 @@ void ScriptServeFile82(void) {
|
||||
if (ufsp->exists(cp)) {
|
||||
#endif
|
||||
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;
|
||||
}
|
||||
glob_script_mem.download82_busy = true;
|
||||
@ -10927,7 +10927,7 @@ int32_t SendFile(char *fname) {
|
||||
#ifdef ESP32
|
||||
#ifdef USE_DLTASK
|
||||
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;
|
||||
}
|
||||
glob_script_mem.script_download_busy = true;
|
||||
|
@ -154,7 +154,7 @@ void UfsInit(void) {
|
||||
UfsData.run_file_pos = -1;
|
||||
UfsInitOnce();
|
||||
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
|
||||
#ifdef ESP8266
|
||||
// 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
|
||||
#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
|
||||
}
|
||||
}
|
||||
@ -249,7 +249,7 @@ void UfsCheckSDCardInit(void) {
|
||||
dfsp = ufsp;
|
||||
if (ffsp) {ufs_dir = 1;}
|
||||
// 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
|
||||
@ -1049,7 +1049,7 @@ public:
|
||||
|
||||
//log_v("StaticRequestHandler::handle: request=%s _uri=%s\r\n", requestUri.c_str(), _uri.c_str());
|
||||
#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
|
||||
String path(_path);
|
||||
|
||||
@ -1063,7 +1063,7 @@ public:
|
||||
path += requestUri.substring(_baseUriLength);
|
||||
}
|
||||
#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
|
||||
String contentType = getContentType(path);
|
||||
|
||||
@ -1077,15 +1077,15 @@ public:
|
||||
|
||||
File f = _fs.open(path, "r");
|
||||
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;
|
||||
}
|
||||
#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
|
||||
if (_requireAuth && !WebAuthenticate()) {
|
||||
#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
|
||||
server.requestAuthentication();
|
||||
return true;
|
||||
@ -1095,7 +1095,7 @@ public:
|
||||
server.sendHeader("Cache-Control", _cache_header);
|
||||
|
||||
#ifdef SERVING_DEBUG
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: ::handler sending"));
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "::handler sending"));
|
||||
#endif
|
||||
uint8_t buff[512];
|
||||
uint32_t bread;
|
||||
@ -1110,18 +1110,18 @@ public:
|
||||
bread = f.read(buff, sizeof(buff));
|
||||
cnt += bread;
|
||||
#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
|
||||
uint32_t bw = download_Client.write((const char*)buff, bread);
|
||||
if (!bw) { break; }
|
||||
yield();
|
||||
}
|
||||
#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
|
||||
|
||||
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...
|
||||
@ -1131,7 +1131,7 @@ public:
|
||||
download_Client.stop();
|
||||
|
||||
#ifdef SERVING_DEBUG
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: ::handler done"));
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "::handler done"));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
@ -1524,21 +1524,21 @@ void UfsListDir(char *path, uint8_t depth) {
|
||||
uint8_t UfsDownloadFile(char *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)) {
|
||||
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;
|
||||
}
|
||||
|
||||
download_file = dfsp->open(file, UFS_FILE_READ);
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
return 1;
|
||||
}
|
||||
@ -1588,7 +1588,7 @@ uint8_t UfsDownloadFile(char *file) {
|
||||
download_file.close();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1597,7 +1597,7 @@ uint8_t UfsDownloadFile(char *file) {
|
||||
strcpy(path,file);
|
||||
BaseType_t ret = xTaskCreatePinnedToCore(download_task, "DT", 6000, (void*)path, 3, nullptr, 1);
|
||||
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();
|
||||
#endif // ESP32_DOWNLOAD_TASK
|
||||
|
||||
@ -1614,12 +1614,12 @@ void download_task(void *path) {
|
||||
WiFiClient download_Client;
|
||||
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);
|
||||
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();
|
||||
Webserver->setContentLength(flen);
|
||||
@ -1647,7 +1647,7 @@ void download_task(void *path) {
|
||||
UfsData.download_busy = false;
|
||||
vTaskDelete( NULL );
|
||||
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
|
||||
|
||||
@ -1682,7 +1682,7 @@ void UfsUploadFileClose(void) {
|
||||
void UfsEditor(void) {
|
||||
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];
|
||||
if (Webserver->hasArg(F("file"))) {
|
||||
@ -1693,7 +1693,7 @@ void UfsEditor(void) {
|
||||
char fname[UFS_FILENAME_SIZE];
|
||||
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));
|
||||
WSContentSendStyle();
|
||||
@ -1703,15 +1703,15 @@ void UfsEditor(void) {
|
||||
if (ffs_type && dfsp->exists(fname)) {
|
||||
File fp = dfsp->open(fname, "r");
|
||||
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);
|
||||
} else {
|
||||
uint8_t *buf = (uint8_t*)malloc(FILE_BUFFER_SIZE+1);
|
||||
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) {
|
||||
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; }
|
||||
buf[l] = '\0';
|
||||
WSContentSend_P(PSTR("%s"), HtmlEscape((char*)buf).c_str());
|
||||
@ -1719,7 +1719,7 @@ void UfsEditor(void) {
|
||||
}
|
||||
fp.close();
|
||||
free(buf);
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("UFS: UfsEditor: read done"));
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UFS "UfsEditor: read done"));
|
||||
}
|
||||
} else {
|
||||
WSContentSend_P(D_NEW_FILE);
|
||||
@ -1732,12 +1732,12 @@ void UfsEditor(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 (!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"));
|
||||
return;
|
||||
}
|
||||
@ -1746,10 +1746,10 @@ void UfsEditorUpload(void) {
|
||||
WebGetArg(PSTR("name"), fname_input, sizeof(fname_input));
|
||||
char fname[UFS_FILENAME_SIZE];
|
||||
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")) {
|
||||
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"));
|
||||
return;
|
||||
}
|
||||
@ -1757,7 +1757,7 @@ void UfsEditorUpload(void) {
|
||||
|
||||
if (!dfsp) {
|
||||
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"));
|
||||
return;
|
||||
}
|
||||
@ -1782,7 +1782,7 @@ void UfsEditorUpload(void) {
|
||||
File fp = dfsp->open(fname, "w");
|
||||
if (!fp) {
|
||||
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"));
|
||||
return;
|
||||
}
|
||||
@ -1793,7 +1793,7 @@ void UfsEditorUpload(void) {
|
||||
}
|
||||
|
||||
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();
|
||||
@ -1826,7 +1826,7 @@ void FTP_Server(uint32_t mode) {
|
||||
} else {
|
||||
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 {
|
||||
if (ftpSrv) {
|
||||
delete ftpSrv;
|
||||
|
@ -129,11 +129,11 @@ void TelnetLoop(void) {
|
||||
if ((Telnet.server) && (Telnet.server->hasClient())) {
|
||||
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 != 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();
|
||||
}
|
||||
}
|
||||
@ -143,7 +143,7 @@ void TelnetLoop(void) {
|
||||
}
|
||||
Telnet.client = new_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;
|
||||
#ifdef ESP32
|
||||
uint32_t index = 1;
|
||||
@ -164,7 +164,7 @@ void TelnetLoop(void) {
|
||||
#ifdef ESP32
|
||||
if (0 == Telnet.prompt) {
|
||||
TelnetWriteColor(Telnet.color[0]);
|
||||
Telnet.client.printf("%s:# ", TasmotaGlobal.hostname);
|
||||
Telnet.client.printf("%s:# ", NetworkHostname());
|
||||
TelnetWriteColor(0);
|
||||
Telnet.prompt = 3; // Print linefeed for non-requested data
|
||||
while (Telnet.client.available()) { Telnet.client.read(); } // Flush input
|
||||
@ -182,7 +182,7 @@ void TelnetLoop(void) {
|
||||
if (any_line) {
|
||||
if ((0 == Telnet.log_index) || (Telnet.prompt != 2)) {
|
||||
TelnetWriteColor(Telnet.color[0]);
|
||||
Telnet.client.printf("%s:# ", TasmotaGlobal.hostname);
|
||||
Telnet.client.printf("%s:# ", NetworkHostname());
|
||||
TelnetWriteColor(0);
|
||||
Telnet.prompt = 3; // Print linefeed for non-requested data
|
||||
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.prompt = 1; // Do not print linefeed for requested data and use response color
|
||||
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 {
|
||||
char command[CMDSZ];
|
||||
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();
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
@ -254,13 +254,13 @@ void TelnetStart(void) {
|
||||
if (Telnet.buffer) {
|
||||
if (1 == Telnet.port) { Telnet.port = TELNET_PORT; }
|
||||
Telnet.server = new WiFiServer(Telnet.port);
|
||||
Telnet.server->begin(); // Start TCP server
|
||||
Telnet.server->begin(); // Start Telnet server
|
||||
Telnet.server->setNoDelay(true);
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("TLN: Started"));
|
||||
AddLogServerActive(PSTR(D_LOG_TELNET "Telnet"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("TLN: Stopped"));
|
||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TELNET "Stopped"));
|
||||
}
|
||||
|
||||
void TelnetInit(void) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user