Refactor AddLog usage

This commit is contained in:
Theo Arends 2021-01-23 16:26:23 +01:00
parent 5b5220100d
commit efaed8046d
66 changed files with 676 additions and 676 deletions

View File

@ -247,7 +247,7 @@ void SettingsBufferFree(void) {
bool SettingsBufferAlloc(void) { bool SettingsBufferAlloc(void) {
SettingsBufferFree(); SettingsBufferFree();
if (!(settings_buffer = (uint8_t *)malloc(sizeof(Settings)))) { if (!(settings_buffer = (uint8_t *)malloc(sizeof(Settings)))) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_UPLOAD_ERR_2)); // Not enough (memory) space AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_UPLOAD_ERR_2)); // Not enough (memory) space
return false; return false;
} }
return true; return true;
@ -322,7 +322,7 @@ void UpdateQuickPowerCycle(bool update) {
} else { } else {
qpc_buffer[0] = 0; qpc_buffer[0] = 0;
ESP.flashWrite(qpc_location + (counter * 4), (uint32*)&qpc_buffer, 4); ESP.flashWrite(qpc_location + (counter * 4), (uint32*)&qpc_buffer, 4);
AddLog_P(LOG_LEVEL_INFO, PSTR("QPC: Count %d"), counter); AddLog(LOG_LEVEL_INFO, PSTR("QPC: Count %d"), counter);
} }
} }
else if ((qpc_buffer[0] != QPC_SIGNATURE) || (0 == qpc_buffer[1])) { else if ((qpc_buffer[0] != QPC_SIGNATURE) || (0 == qpc_buffer[1])) {
@ -330,7 +330,7 @@ void UpdateQuickPowerCycle(bool update) {
// Assume flash is default all ones and setting a bit to zero does not need an erase // Assume flash is default all ones and setting a bit to zero does not need an erase
if (ESP.flashEraseSector(qpc_sector)) { if (ESP.flashEraseSector(qpc_sector)) {
ESP.flashWrite(qpc_location, (uint32*)&qpc_buffer, 4); ESP.flashWrite(qpc_location, (uint32*)&qpc_buffer, 4);
AddLog_P(LOG_LEVEL_INFO, PSTR("QPC: Reset")); AddLog(LOG_LEVEL_INFO, PSTR("QPC: Reset"));
} }
} }
#endif // ESP8266 #endif // ESP8266
@ -347,13 +347,13 @@ void UpdateQuickPowerCycle(bool update) {
} else { } else {
pc_register = 0xFFA55AF0 | counter; pc_register = 0xFFA55AF0 | counter;
QPCWrite(&pc_register, sizeof(pc_register)); QPCWrite(&pc_register, sizeof(pc_register));
AddLog_P(LOG_LEVEL_INFO, PSTR("QPC: Count %d"), counter); AddLog(LOG_LEVEL_INFO, PSTR("QPC: Count %d"), counter);
} }
} }
else if (pc_register != QPC_SIGNATURE) { else if (pc_register != QPC_SIGNATURE) {
pc_register = QPC_SIGNATURE; pc_register = QPC_SIGNATURE;
QPCWrite(&pc_register, sizeof(pc_register)); QPCWrite(&pc_register, sizeof(pc_register));
AddLog_P(LOG_LEVEL_INFO, PSTR("QPC: Reset")); AddLog(LOG_LEVEL_INFO, PSTR("QPC: Reset"));
} }
#endif // ESP32 #endif // ESP32
@ -414,12 +414,12 @@ bool SettingsUpdateText(uint32_t index, const char* replace_me) {
uint32_t current_len = end_pos - start_pos; uint32_t current_len = end_pos - start_pos;
int diff = replace_len - current_len; int diff = replace_len - current_len;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TST: start %d, end %d, len %d, current %d, replace %d, diff %d"), // AddLog(LOG_LEVEL_DEBUG, PSTR("TST: start %d, end %d, len %d, current %d, replace %d, diff %d"),
// start_pos, end_pos, char_len, current_len, replace_len, diff); // start_pos, end_pos, char_len, current_len, replace_len, diff);
int too_long = (char_len + diff) - settings_text_size; int too_long = (char_len + diff) - settings_text_size;
if (too_long > 0) { if (too_long > 0) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_CONFIG "Text overflow by %d char(s)"), too_long); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_CONFIG "Text overflow by %d char(s)"), too_long);
return false; // Replace text too long return false; // Replace text too long
} }
@ -441,9 +441,9 @@ bool SettingsUpdateText(uint32_t index, const char* replace_me) {
} }
#ifdef DEBUG_FUNC_SETTINGSUPDATETEXT #ifdef DEBUG_FUNC_SETTINGSUPDATETEXT
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "CR %d/%d, Busy %d, Id %02d = \"%s\""), GetSettingsTextLen(), settings_text_size, settings_text_busy_count, index_save, replace); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "CR %d/%d, Busy %d, Id %02d = \"%s\""), GetSettingsTextLen(), settings_text_size, settings_text_busy_count, index_save, replace);
#else #else
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "CR %d/%d, Busy %d"), GetSettingsTextLen(), settings_text_size, settings_text_busy_count); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "CR %d/%d, Busy %d"), GetSettingsTextLen(), settings_text_size, settings_text_busy_count);
#endif #endif
return true; return true;
@ -529,11 +529,11 @@ void SettingsSave(uint8_t rotate) {
delay(1); delay(1);
} }
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG D_SAVED_TO_FLASH_AT " %X, " D_COUNT " %d, " D_BYTES " %d"), settings_location, Settings.save_flag, sizeof(Settings)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG D_SAVED_TO_FLASH_AT " %X, " D_COUNT " %d, " D_BYTES " %d"), settings_location, Settings.save_flag, sizeof(Settings));
#endif // ESP8266 #endif // ESP8266
#ifdef ESP32 #ifdef ESP32
SettingsWrite(&Settings, sizeof(Settings)); SettingsWrite(&Settings, sizeof(Settings));
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "Saved, " D_COUNT " %d, " D_BYTES " %d"), Settings.save_flag, sizeof(Settings)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "Saved, " D_COUNT " %d, " D_BYTES " %d"), Settings.save_flag, sizeof(Settings));
#endif // ESP32 #endif // ESP32
settings_crc32 = Settings.cfg_crc32; settings_crc32 = Settings.cfg_crc32;
@ -578,19 +578,19 @@ void SettingsLoad(void) {
#ifdef USE_UFILESYS #ifdef USE_UFILESYS
if (1 == settings_location) { if (1 == settings_location) {
TfsLoadFile(TASM_FILE_SETTINGS, (uint8_t*)&Settings, sizeof(Settings)); TfsLoadFile(TASM_FILE_SETTINGS, (uint8_t*)&Settings, sizeof(Settings));
AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded from File, " D_COUNT " %lu"), Settings.save_flag); AddLog(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded from File, " D_COUNT " %lu"), Settings.save_flag);
} else } else
#endif // USE_UFILESYS #endif // USE_UFILESYS
{ {
ESP.flashRead(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(Settings)); ESP.flashRead(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(Settings));
AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %lu"), settings_location, Settings.save_flag); AddLog(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %lu"), settings_location, Settings.save_flag);
} }
} }
#endif // ESP8266 #endif // ESP8266
#ifdef ESP32 #ifdef ESP32
uint32_t source = SettingsRead(&Settings, sizeof(Settings)); uint32_t source = SettingsRead(&Settings, sizeof(Settings));
if (source) { settings_location = 1; } if (source) { settings_location = 1; }
AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded from %s, " D_COUNT " %lu"), (source)?"File":"Nvm", Settings.save_flag); AddLog(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded from %s, " D_COUNT " %lu"), (source)?"File":"Nvm", Settings.save_flag);
#endif // ESP32 #endif // ESP32
#ifndef FIRMWARE_MINIMAL #ifndef FIRMWARE_MINIMAL
@ -598,7 +598,7 @@ void SettingsLoad(void) {
#ifdef USE_UFILESYS #ifdef USE_UFILESYS
if (TfsLoadFile(TASM_FILE_SETTINGS_LKG, (uint8_t*)&Settings, sizeof(Settings)) && (Settings.cfg_crc32 == GetSettingsCrc32())) { if (TfsLoadFile(TASM_FILE_SETTINGS_LKG, (uint8_t*)&Settings, sizeof(Settings)) && (Settings.cfg_crc32 == GetSettingsCrc32())) {
settings_location = 1; settings_location = 1;
AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded from LKG File, " D_COUNT " %lu"), Settings.save_flag); AddLog(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded from LKG File, " D_COUNT " %lu"), Settings.save_flag);
} else } else
#endif // USE_UFILESYS #endif // USE_UFILESYS
{ {
@ -679,7 +679,7 @@ void SettingsSdkErase(void) {
/********************************************************************************************/ /********************************************************************************************/
void SettingsDefault(void) { void SettingsDefault(void) {
AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_USE_DEFAULTS)); AddLog(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_USE_DEFAULTS));
SettingsDefaultSet1(); SettingsDefaultSet1();
SettingsDefaultSet2(); SettingsDefaultSet2();
SettingsSave(2); SettingsSave(2);

View File

@ -49,10 +49,10 @@ void OsWatchTicker(void)
#ifdef DEBUG_THEO #ifdef DEBUG_THEO
int32_t rssi = WiFi.RSSI(); int32_t rssi = WiFi.RSSI();
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_OSWATCH " FreeRam %d, rssi %d %% (%d dBm), last_run %d"), ESP_getFreeHeap(), WifiGetRssiAsQuality(rssi), rssi, last_run); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_OSWATCH " FreeRam %d, rssi %d %% (%d dBm), last_run %d"), ESP_getFreeHeap(), WifiGetRssiAsQuality(rssi), rssi, last_run);
#endif // DEBUG_THEO #endif // DEBUG_THEO
if (last_run >= (OSWATCH_RESET_TIME * 1000)) { if (last_run >= (OSWATCH_RESET_TIME * 1000)) {
// AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_OSWATCH " " D_BLOCKED_LOOP ". " D_RESTARTING)); // Save iram space // AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_OSWATCH " " D_BLOCKED_LOOP ". " D_RESTARTING)); // Save iram space
RtcSettings.oswatch_blocked_loop = 1; RtcSettings.oswatch_blocked_loop = 1;
RtcSettingsSave(); RtcSettingsSave();
@ -1042,7 +1042,7 @@ uint32_t GetSerialBaudrate(void) {
void SetSerialBegin(void) { void SetSerialBegin(void) {
TasmotaGlobal.baudrate = Settings.baudrate * 300; TasmotaGlobal.baudrate = Settings.baudrate * 300;
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_SERIAL "Set to %s %d bit/s"), GetSerialConfig().c_str(), TasmotaGlobal.baudrate); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_SERIAL "Set to %s %d bit/s"), GetSerialConfig().c_str(), TasmotaGlobal.baudrate);
Serial.flush(); Serial.flush();
#ifdef ESP8266 #ifdef ESP8266
Serial.begin(TasmotaGlobal.baudrate, (SerialConfig)pgm_read_byte(kTasmotaSerialConfig + Settings.serial_config)); Serial.begin(TasmotaGlobal.baudrate, (SerialConfig)pgm_read_byte(kTasmotaSerialConfig + Settings.serial_config));
@ -1085,7 +1085,7 @@ void SetSerial(uint32_t baudrate, uint32_t serial_config) {
void ClaimSerial(void) { void ClaimSerial(void) {
TasmotaGlobal.serial_local = true; TasmotaGlobal.serial_local = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("SNS: Hardware Serial")); AddLog(LOG_LEVEL_INFO, PSTR("SNS: Hardware Serial"));
SetSeriallog(LOG_LEVEL_NONE); SetSeriallog(LOG_LEVEL_NONE);
TasmotaGlobal.baudrate = GetSerialBaudrate(); TasmotaGlobal.baudrate = GetSerialBaudrate();
Settings.baudrate = TasmotaGlobal.baudrate / 300; Settings.baudrate = TasmotaGlobal.baudrate / 300;
@ -1132,7 +1132,7 @@ void ShowSource(uint32_t source)
{ {
if ((source > 0) && (source < SRC_MAX)) { if ((source > 0) && (source < SRC_MAX)) {
char stemp1[20]; char stemp1[20];
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SRC: %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource)); AddLog(LOG_LEVEL_DEBUG, PSTR("SRC: %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource));
} }
} }
@ -1321,7 +1321,7 @@ void TemplateConvert(uint8_t template8[], uint16_t template16[]) {
} }
template16[(sizeof(mytmplt) / 2) -2] = Adc0Convert(template8[sizeof(mytmplt8285) -1]); template16[(sizeof(mytmplt) / 2) -2] = Adc0Convert(template8[sizeof(mytmplt8285) -1]);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("FNC: TemplateConvert")); // AddLog(LOG_LEVEL_DEBUG, PSTR("FNC: TemplateConvert"));
// AddLogBuffer(LOG_LEVEL_DEBUG, template8, sizeof(mytmplt8285)); // AddLogBuffer(LOG_LEVEL_DEBUG, template8, sizeof(mytmplt8285));
// AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)template16, sizeof(mytmplt) / 2, 2); // AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)template16, sizeof(mytmplt) / 2, 2);
} }
@ -1337,7 +1337,7 @@ void ConvertGpios(void) {
Settings.my_gp.io[(sizeof(myio) / 2) -1] = Adc0Convert(Settings.ex_my_adc0); Settings.my_gp.io[(sizeof(myio) / 2) -1] = Adc0Convert(Settings.ex_my_adc0);
Settings.gpio16_converted = 0xF5A0; Settings.gpio16_converted = 0xF5A0;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("FNC: ConvertGpios")); // AddLog(LOG_LEVEL_DEBUG, PSTR("FNC: ConvertGpios"));
// AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t *)&Settings.ex_my_gp8.io, sizeof(myio8)); // AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t *)&Settings.ex_my_gp8.io, sizeof(myio8));
// AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t *)&Settings.my_gp.io, sizeof(myio) / 2, 2); // AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t *)&Settings.my_gp.io, sizeof(myio) / 2, 2);
} }
@ -1488,7 +1488,7 @@ String ModuleName(void)
void GetInternalTemplate(void* ptr, uint32_t module, uint32_t option) { void GetInternalTemplate(void* ptr, uint32_t module, uint32_t option) {
uint8_t module_template = pgm_read_byte(kModuleTemplateList + module); uint8_t module_template = pgm_read_byte(kModuleTemplateList + module);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Template %d, Option %d"), module_template, option); // AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Template %d, Option %d"), module_template, option);
// template8 = GPIO 0,1,2,3,4,5,9,10,12,13,14,15,16,Adc // template8 = GPIO 0,1,2,3,4,5,9,10,12,13,14,15,16,Adc
uint8_t template8[sizeof(mytmplt8285)] = { GPIO_NONE }; uint8_t template8[sizeof(mytmplt8285)] = { GPIO_NONE };
@ -1520,7 +1520,7 @@ void GetInternalTemplate(void* ptr, uint32_t module, uint32_t option) {
} }
memcpy(ptr, &template16[index], size); memcpy(ptr, &template16[index], size);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("FNC: GetInternalTemplate option %d"), option); // AddLog(LOG_LEVEL_DEBUG, PSTR("FNC: GetInternalTemplate option %d"), option);
// AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t *)ptr, size / 2, 2); // AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t *)ptr, size / 2, 2);
} }
#endif // ESP8266 #endif // ESP8266
@ -1674,7 +1674,7 @@ bool JsonTemplate(char* dataBuf)
} }
if (old_template) { if (old_template) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TPL: Converting template ...")); AddLog(LOG_LEVEL_DEBUG, PSTR("TPL: Converting template ..."));
val = root[PSTR(D_JSON_FLAG)]; val = root[PSTR(D_JSON_FLAG)];
if (val) { if (val) {
@ -1708,7 +1708,7 @@ bool JsonTemplate(char* dataBuf)
Settings.user_template_base = base -1; // Default WEMOS Settings.user_template_base = base -1; // Default WEMOS
} }
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TPL: Converted")); // AddLog(LOG_LEVEL_DEBUG, PSTR("TPL: Converted"));
// AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)&Settings.user_template, sizeof(Settings.user_template) / 2, 2); // AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)&Settings.user_template, sizeof(Settings.user_template) / 2, 2);
return true; return true;
@ -1716,7 +1716,7 @@ bool JsonTemplate(char* dataBuf)
void TemplateJson(void) void TemplateJson(void)
{ {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TPL: Show")); // AddLog(LOG_LEVEL_DEBUG, PSTR("TPL: Show"));
// AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)&Settings.user_template, sizeof(Settings.user_template) / 2, 2); // AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)&Settings.user_template, sizeof(Settings.user_template) / 2, 2);
Response_P(PSTR("{\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), SettingsText(SET_TEMPLATE_NAME)); Response_P(PSTR("{\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), SettingsText(SET_TEMPLATE_NAME));
@ -1989,7 +1989,7 @@ void I2cResetActive(uint32_t addr, uint32_t count = 1)
i2c_active[addr / 32] &= ~(1 << (addr % 32)); i2c_active[addr / 32] &= ~(1 << (addr % 32));
addr++; addr++;
} }
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("I2C: Active %08X,%08X,%08X,%08X"), i2c_active[0], i2c_active[1], i2c_active[2], i2c_active[3]); // AddLog(LOG_LEVEL_DEBUG, PSTR("I2C: Active %08X,%08X,%08X,%08X"), i2c_active[0], i2c_active[1], i2c_active[2], i2c_active[3]);
} }
void I2cSetActive(uint32_t addr, uint32_t count = 1) void I2cSetActive(uint32_t addr, uint32_t count = 1)
@ -2000,13 +2000,13 @@ void I2cSetActive(uint32_t addr, uint32_t count = 1)
i2c_active[addr / 32] |= (1 << (addr % 32)); i2c_active[addr / 32] |= (1 << (addr % 32));
addr++; addr++;
} }
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("I2C: Active %08X,%08X,%08X,%08X"), i2c_active[0], i2c_active[1], i2c_active[2], i2c_active[3]); // AddLog(LOG_LEVEL_DEBUG, PSTR("I2C: Active %08X,%08X,%08X,%08X"), i2c_active[0], i2c_active[1], i2c_active[2], i2c_active[3]);
} }
void I2cSetActiveFound(uint32_t addr, const char *types) void I2cSetActiveFound(uint32_t addr, const char *types)
{ {
I2cSetActive(addr); I2cSetActive(addr);
AddLog_P(LOG_LEVEL_INFO, S_LOG_I2C_FOUND_AT, types, addr); AddLog(LOG_LEVEL_INFO, S_LOG_I2C_FOUND_AT, types, addr);
} }
bool I2cActive(uint32_t addr) bool I2cActive(uint32_t addr)
@ -2033,7 +2033,7 @@ bool I2cSetDevice(uint32_t addr)
* Syslog * Syslog
* *
* Example: * Example:
* AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_LOG "Any value %d"), value); * AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_LOG "Any value %d"), value);
* *
\*********************************************************************************************/ \*********************************************************************************************/
@ -2074,7 +2074,7 @@ void SyslogAsync(bool refresh) {
if (!PortUdp.beginPacket(syslog_host_addr, Settings.syslog_port)) { if (!PortUdp.beginPacket(syslog_host_addr, Settings.syslog_port)) {
TasmotaGlobal.syslog_level = 0; TasmotaGlobal.syslog_level = 0;
TasmotaGlobal.syslog_timer = SYSLOG_TIMER; TasmotaGlobal.syslog_timer = SYSLOG_TIMER;
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_HOST_NOT_FOUND ". " D_RETRY_IN " %d " D_UNIT_SECOND), SYSLOG_TIMER); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_HOST_NOT_FOUND ". " D_RETRY_IN " %d " D_UNIT_SECOND), SYSLOG_TIMER);
return; return;
} }
char log_data[len +72]; // Hostname + Id + log data char log_data[len +72]; // Hostname + Id + log data
@ -2263,7 +2263,7 @@ void AddLogSerial(uint32_t loglevel)
void AddLogMissed(const char *sensor, uint32_t misses) void AddLogMissed(const char *sensor, uint32_t misses)
{ {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SNS: %s missed %d"), sensor, SENSOR_MAX_MISS - misses); AddLog(LOG_LEVEL_DEBUG, PSTR("SNS: %s missed %d"), sensor, SENSOR_MAX_MISS - misses);
} }
void AddLogBufferSize(uint32_t loglevel, uint8_t *buffer, uint32_t count, uint32_t size) { void AddLogBufferSize(uint32_t loglevel, uint8_t *buffer, uint32_t count, uint32_t size) {
@ -2286,15 +2286,15 @@ void AddLogSpi(bool hardware, uint32_t clk, uint32_t mosi, uint32_t miso) {
uint32_t enabled = (hardware) ? TasmotaGlobal.spi_enabled : TasmotaGlobal.soft_spi_enabled; uint32_t enabled = (hardware) ? TasmotaGlobal.spi_enabled : TasmotaGlobal.soft_spi_enabled;
switch(enabled) { switch(enabled) {
case SPI_MOSI: case SPI_MOSI:
AddLog_P(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK) and GPIO%02d(MOSI)"), AddLog(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK) and GPIO%02d(MOSI)"),
(hardware) ? PSTR("Hardware") : PSTR("Software"), clk, mosi); (hardware) ? PSTR("Hardware") : PSTR("Software"), clk, mosi);
break; break;
case SPI_MISO: case SPI_MISO:
AddLog_P(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK) and GPIO%02d(MISO)"), AddLog(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK) and GPIO%02d(MISO)"),
(hardware) ? PSTR("Hardware") : PSTR("Software"), clk, miso); (hardware) ? PSTR("Hardware") : PSTR("Software"), clk, miso);
break; break;
case SPI_MOSI_MISO: case SPI_MOSI_MISO:
AddLog_P(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK), GPIO%02d(MOSI) and GPIO%02d(MISO)"), AddLog(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK), GPIO%02d(MOSI) and GPIO%02d(MISO)"),
(hardware) ? PSTR("Hardware") : PSTR("Software"), clk, mosi, miso); (hardware) ? PSTR("Hardware") : PSTR("Software"), clk, mosi, miso);
break; break;
} }

View File

@ -146,7 +146,7 @@ void ButtonHandler(void) {
if (!button_index && ((SONOFF_DUAL == TasmotaGlobal.module_type) || (CH4 == TasmotaGlobal.module_type))) { if (!button_index && ((SONOFF_DUAL == TasmotaGlobal.module_type) || (CH4 == TasmotaGlobal.module_type))) {
button_present = 1; button_present = 1;
if (Button.dual_code) { if (Button.dual_code) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON " " D_CODE " %04X"), Button.dual_code); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON " " D_CODE " %04X"), Button.dual_code);
button = PRESSED; button = PRESSED;
if (0xF500 == Button.dual_code) { // Button hold if (0xF500 == Button.dual_code) { // Button hold
Button.hold_timer[button_index] = (loops_per_second * Settings.param[P_HOLD_TIME] / 10) -1; // SetOption32 (40) Button.hold_timer[button_index] = (loops_per_second * Settings.param[P_HOLD_TIME] / 10) -1; // SetOption32 (40)
@ -176,7 +176,7 @@ void ButtonHandler(void) {
Button.touch_hits[button_index] = 0; Button.touch_hits[button_index] = 0;
} }
if (bitRead(TOUCH_BUTTON.calibration, button_index+1)) { if (bitRead(TOUCH_BUTTON.calibration, button_index+1)) {
AddLog_P(LOG_LEVEL_INFO, PSTR("PLOT: %u, %u, %u,"), button_index+1, _value, Button.touch_hits[button_index]); // Button number (1..4), value, continuous hits under threshold AddLog(LOG_LEVEL_INFO, PSTR("PLOT: %u, %u, %u,"), button_index+1, _value, Button.touch_hits[button_index]); // Button number (1..4), value, continuous hits under threshold
} }
} else } else
#endif // ESP32 #endif // ESP32
@ -206,12 +206,12 @@ void ButtonHandler(void) {
bool button_pressed = false; bool button_pressed = false;
if ((PRESSED == button) && (NOT_PRESSED == Button.last_state[button_index])) { if ((PRESSED == button) && (NOT_PRESSED == Button.last_state[button_index])) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_10), button_index +1); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_10), button_index +1);
Button.hold_timer[button_index] = loops_per_second; Button.hold_timer[button_index] = loops_per_second;
button_pressed = true; button_pressed = true;
} }
if ((NOT_PRESSED == button) && (PRESSED == Button.last_state[button_index])) { if ((NOT_PRESSED == button) && (PRESSED == Button.last_state[button_index])) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_01), button_index +1); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_01), button_index +1);
if (!Button.hold_timer[button_index]) { button_pressed = true; } // Do not allow within 1 second if (!Button.hold_timer[button_index]) { button_pressed = true; } // Do not allow within 1 second
} }
if (button_pressed) { if (button_pressed) {
@ -230,7 +230,7 @@ void ButtonHandler(void) {
if (Settings.flag.button_single) { // SetOption13 (0) - Allow only single button press for immediate action, if (Settings.flag.button_single) { // SetOption13 (0) - Allow only single button press for immediate action,
if (!Settings.flag3.mqtt_buttons) { // SetOption73 (0) - Decouple button from relay and send just mqtt topic if (!Settings.flag3.mqtt_buttons) { // SetOption73 (0) - Decouple button from relay and send just mqtt topic
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_IMMEDIATE), button_index +1); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_IMMEDIATE), button_index +1);
if (!SendKey(KEY_BUTTON, button_index +1, POWER_TOGGLE)) { // Execute Toggle command via MQTT if ButtonTopic is set if (!SendKey(KEY_BUTTON, button_index +1, POWER_TOGGLE)) { // Execute Toggle command via MQTT if ButtonTopic is set
ExecuteCommandPower(button_index +1, POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally ExecuteCommandPower(button_index +1, POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally
} }
@ -239,7 +239,7 @@ void ButtonHandler(void) {
} }
} else { } else {
Button.press_counter[button_index] = (Button.window_timer[button_index]) ? Button.press_counter[button_index] +1 : 1; Button.press_counter[button_index] = (Button.window_timer[button_index]) ? Button.press_counter[button_index] +1 : 1;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_MULTI_PRESS " %d"), button_index +1, Button.press_counter[button_index]); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_MULTI_PRESS " %d"), button_index +1, Button.press_counter[button_index]);
Button.window_timer[button_index] = loops_per_second / 2; // 0.5 second multi press window Button.window_timer[button_index] = loops_per_second / 2; // 0.5 second multi press window
} }
TasmotaGlobal.blinks = 201; TasmotaGlobal.blinks = 201;
@ -327,7 +327,7 @@ void ButtonHandler(void) {
#endif // ESP8266 #endif // ESP8266
if ((Button.press_counter[button_index] > 1) && valid_relay && (Button.press_counter[button_index] <= MAX_RELAY_BUTTON1)) { if ((Button.press_counter[button_index] > 1) && valid_relay && (Button.press_counter[button_index] <= MAX_RELAY_BUTTON1)) {
ExecuteCommandPower(button_index + Button.press_counter[button_index], POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally ExecuteCommandPower(button_index + Button.press_counter[button_index], POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Relay%d found on GPIO%d"), Button.press_counter[button_index], Pin(GPIO_REL1, Button.press_counter[button_index]-1)); // AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Relay%d found on GPIO%d"), Button.press_counter[button_index], Pin(GPIO_REL1, Button.press_counter[button_index]-1));
} }
} }
} }

View File

@ -227,7 +227,7 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len)
type[i] = '\0'; type[i] = '\0';
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CMD: " D_GROUP " %d, " D_INDEX " %d, " D_COMMAND " \"%s\", " D_DATA " \"%s\""), grpflg, index, type, dataBuf); AddLog(LOG_LEVEL_DEBUG, PSTR("CMD: " D_GROUP " %d, " D_INDEX " %d, " D_COMMAND " \"%s\", " D_DATA " \"%s\""), grpflg, index, type, dataBuf);
if (type != nullptr) { if (type != nullptr) {
Response_P(PSTR("{\"" D_JSON_COMMAND "\":\"" D_JSON_ERROR "\"}")); Response_P(PSTR("{\"" D_JSON_COMMAND "\":\"" D_JSON_ERROR "\"}"));
@ -744,7 +744,7 @@ void CmndRestart(void)
CmndBlockedLoop(); CmndBlockedLoop();
break; break;
case 99: case 99:
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
EspRestart(); EspRestart();
break; break;
default: default:
@ -2117,7 +2117,7 @@ void CmndTouchCal(void)
} }
Response_P(PSTR("{\"" D_CMND_TOUCH_CAL "\": %u"), TOUCH_BUTTON.calibration); Response_P(PSTR("{\"" D_CMND_TOUCH_CAL "\": %u"), TOUCH_BUTTON.calibration);
ResponseJsonEnd(); ResponseJsonEnd();
AddLog_P(LOG_LEVEL_INFO, PSTR("Button Touchvalue Hits,")); AddLog(LOG_LEVEL_INFO, PSTR("Button Touchvalue Hits,"));
} }
void CmndTouchThres(void) void CmndTouchThres(void)

View File

@ -129,7 +129,7 @@ void DeviceGroupsInit(void)
// Initialize the device information for each device group. // Initialize the device information for each device group.
device_groups = (struct device_group *)calloc(device_group_count, sizeof(struct device_group)); device_groups = (struct device_group *)calloc(device_group_count, sizeof(struct device_group));
if (!device_groups) { if (!device_groups) {
AddLog_P(LOG_LEVEL_ERROR, PSTR("DGR: Error allocating %u-element array"), device_group_count); AddLog(LOG_LEVEL_ERROR, PSTR("DGR: Error allocating %u-element array"), device_group_count);
return; return;
} }
@ -169,7 +169,7 @@ void DeviceGroupsStart()
// Subscribe to device groups multicasts. // Subscribe to device groups multicasts.
if (!device_groups_udp.beginMulticast(WiFi.localIP(), IPAddress(DEVICE_GROUPS_ADDRESS), DEVICE_GROUPS_PORT)) { if (!device_groups_udp.beginMulticast(WiFi.localIP(), IPAddress(DEVICE_GROUPS_ADDRESS), DEVICE_GROUPS_PORT)) {
AddLog_P(LOG_LEVEL_ERROR, PSTR("DGR: Error subscribing")); AddLog(LOG_LEVEL_ERROR, PSTR("DGR: Error subscribing"));
return; return;
} }
device_groups_up = true; device_groups_up = true;
@ -185,7 +185,7 @@ void DeviceGroupsStart()
device_group->initial_status_requests_remaining = 10; device_group->initial_status_requests_remaining = 10;
device_group->next_ack_check_time = next_check_time; device_group->next_ack_check_time = next_check_time;
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: (Re)discovering members")); AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: (Re)discovering members"));
} }
} }
@ -318,7 +318,7 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de
case DGR_ITEM_LIGHT_CHANNELS: case DGR_ITEM_LIGHT_CHANNELS:
break; break;
default: default:
AddLog_P(LOG_LEVEL_ERROR, PSTR("DGR: *** Invalid item=%u"), item); AddLog(LOG_LEVEL_ERROR, PSTR("DGR: *** Invalid item=%u"), item);
} }
#endif // DEVICE_GROUPS_DEBUG #endif // DEVICE_GROUPS_DEBUG
@ -439,12 +439,12 @@ write_log:
} }
delay(10); delay(10);
} }
if (attempt > 5) AddLog_P(LOG_LEVEL_ERROR, PSTR("DGR: Error sending message")); if (attempt > 5) AddLog(LOG_LEVEL_ERROR, PSTR("DGR: Error sending message"));
} }
goto cleanup; goto cleanup;
badmsg: badmsg:
AddLog_P(LOG_LEVEL_ERROR, PSTR("%s ** incorrect length"), log_buffer); AddLog(LOG_LEVEL_ERROR, PSTR("%s ** incorrect length"), log_buffer);
cleanup: cleanup:
if (received) { if (received) {
@ -476,7 +476,7 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes
// Load the message header, sequence and flags. // Load the message header, sequence and flags.
#ifdef DEVICE_GROUPS_DEBUG #ifdef DEVICE_GROUPS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Building %s %spacket"), device_group->group_name, (message_type == DGR_MSGTYP_FULL_STATUS ? PSTR("full status ") : PSTR(""))); AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Building %s %spacket"), device_group->group_name, (message_type == DGR_MSGTYP_FULL_STATUS ? PSTR("full status ") : PSTR("")));
#endif // DEVICE_GROUPS_DEBUG #endif // DEVICE_GROUPS_DEBUG
uint16_t original_sequence = device_group->outgoing_sequence; uint16_t original_sequence = device_group->outgoing_sequence;
uint16_t flags = 0; uint16_t flags = 0;
@ -652,7 +652,7 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes
previous_message_ptr += value; previous_message_ptr += value;
} }
#ifdef DEVICE_GROUPS_DEBUG #ifdef DEVICE_GROUPS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: %u items carried over"), kept_item_count); AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: %u items carried over"), kept_item_count);
#endif // DEVICE_GROUPS_DEBUG #endif // DEVICE_GROUPS_DEBUG
} }
@ -770,12 +770,12 @@ void ProcessDeviceGroupMessage(uint8_t * message, int message_length)
if (!device_group_member) { if (!device_group_member) {
device_group_member = (struct device_group_member *)calloc(1, sizeof(struct device_group_member)); device_group_member = (struct device_group_member *)calloc(1, sizeof(struct device_group_member));
if (device_group_member == nullptr) { if (device_group_member == nullptr) {
AddLog_P(LOG_LEVEL_ERROR, PSTR("DGR: Error allocating member block")); AddLog(LOG_LEVEL_ERROR, PSTR("DGR: Error allocating member block"));
return; return;
} }
device_group_member->ip_address = remote_ip; device_group_member->ip_address = remote_ip;
*flink = device_group_member; *flink = device_group_member;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Member %s added"), remote_ip.toString().c_str()); AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Member %s added"), remote_ip.toString().c_str());
break; break;
} }
else if (device_group_member->ip_address == remote_ip) { else if (device_group_member->ip_address == remote_ip) {
@ -822,7 +822,7 @@ void DeviceGroupsLoop(void)
// If it's time to check on things, iterate through the device groups. // If it's time to check on things, iterate through the device groups.
if ((long)(now - next_check_time) >= 0) { if ((long)(now - next_check_time) >= 0) {
#ifdef DEVICE_GROUPS_DEBUG #ifdef DEVICE_GROUPS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next_check_time, now); AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next_check_time, now);
#endif // DEVICE_GROUPS_DEBUG #endif // DEVICE_GROUPS_DEBUG
next_check_time = now + DGR_ANNOUNCEMENT_INTERVAL * 2; next_check_time = now + DGR_ANNOUNCEMENT_INTERVAL * 2;
@ -839,7 +839,7 @@ AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next
if (device_group->initial_status_requests_remaining) { if (device_group->initial_status_requests_remaining) {
if (--device_group->initial_status_requests_remaining) { if (--device_group->initial_status_requests_remaining) {
#ifdef DEVICE_GROUPS_DEBUG #ifdef DEVICE_GROUPS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Sending initial status request for group %s"), device_group->group_name); AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Sending initial status request for group %s"), device_group->group_name);
#endif // DEVICE_GROUPS_DEBUG #endif // DEVICE_GROUPS_DEBUG
SendReceiveDeviceGroupMessage(device_group, nullptr, device_group->message, device_group->message_length, false); SendReceiveDeviceGroupMessage(device_group, nullptr, device_group->message, device_group->message_length, false);
device_group->message[device_group->message_header_length + 2] = DGR_FLAG_STATUS_REQUEST; // The reset flag is on only for the first packet - turn it off now device_group->message[device_group->message_header_length + 2] = DGR_FLAG_STATUS_REQUEST; // The reset flag is on only for the first packet - turn it off now
@ -857,7 +857,7 @@ AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next
// If we're done initializing, iterate through the group memebers, ... // If we're done initializing, iterate through the group memebers, ...
else { else {
#ifdef DEVICE_GROUPS_DEBUG #ifdef DEVICE_GROUPS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Checking for ack's")); AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Checking for ack's"));
#endif // DEVICE_GROUPS_DEBUG #endif // DEVICE_GROUPS_DEBUG
bool acked = true; bool acked = true;
struct device_group_member ** flink = &device_group->device_group_members; struct device_group_member ** flink = &device_group->device_group_members;
@ -872,7 +872,7 @@ AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next
if ((long)(now - device_group->member_timeout_time) >= 0) { if ((long)(now - device_group->member_timeout_time) >= 0) {
*flink = device_group_member->flink; *flink = device_group_member->flink;
free(device_group_member); free(device_group_member);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Member %s removed"), device_group_member->ip_address.toString().c_str()); AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Member %s removed"), device_group_member->ip_address.toString().c_str());
continue; continue;
} }
@ -910,7 +910,7 @@ AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next
// announcement interval plus a random number of milliseconds so that even if all the devices // announcement interval plus a random number of milliseconds so that even if all the devices
// booted at the same time, they don't all multicast their announcements at the same time. // booted at the same time, they don't all multicast their announcements at the same time.
#ifdef DEVICE_GROUPS_DEBUG #ifdef DEVICE_GROUPS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: next_announcement_time=%u, now=%u"), device_group->next_announcement_time, now); AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: next_announcement_time=%u, now=%u"), device_group->next_announcement_time, now);
#endif // DEVICE_GROUPS_DEBUG #endif // DEVICE_GROUPS_DEBUG
if ((long)(now - device_group->next_announcement_time) >= 0) { if ((long)(now - device_group->next_announcement_time) >= 0) {
SendReceiveDeviceGroupMessage(device_group, nullptr, device_group->message, BeginDeviceGroupMessage(device_group, DGR_FLAG_ANNOUNCEMENT, true) - device_group->message, false); SendReceiveDeviceGroupMessage(device_group, nullptr, device_group->message, BeginDeviceGroupMessage(device_group, DGR_FLAG_ANNOUNCEMENT, true) - device_group->message, false);

View File

@ -150,13 +150,13 @@ void SettingsErase(uint8_t type) {
r1 = NvmErase("qpc"); r1 = NvmErase("qpc");
r2 = NvmErase("main"); r2 = NvmErase("main");
r3 = TfsDeleteFile(TASM_FILE_SETTINGS); r3 = TfsDeleteFile(TASM_FILE_SETTINGS);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " Tasmota data (%d,%d,%d)"), r1, r2, r3); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " Tasmota data (%d,%d,%d)"), r1, r2, r3);
break; break;
case 1: // Reset 3 = SDK parameter area case 1: // Reset 3 = SDK parameter area
case 4: // WIFI_FORCE_RF_CAL_ERASE = SDK parameter area case 4: // WIFI_FORCE_RF_CAL_ERASE = SDK parameter area
r1 = esp_phy_erase_cal_data_in_nvs(); r1 = esp_phy_erase_cal_data_in_nvs();
// r1 = NvmErase("cal_data"); // r1 = NvmErase("cal_data");
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " PHY data (%d)"), r1); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " PHY data (%d)"), r1);
break; break;
case 3: // QPC Reached = QPC, Tasmota and SDK parameter area (0x0F3xxx - 0x0FFFFF) case 3: // QPC Reached = QPC, Tasmota and SDK parameter area (0x0F3xxx - 0x0FFFFF)
// nvs_flash_erase(); // Erase RTC, PHY, sta.mac, ap.sndchan, ap.mac, Tasmota etc. // nvs_flash_erase(); // Erase RTC, PHY, sta.mac, ap.sndchan, ap.mac, Tasmota etc.
@ -164,9 +164,9 @@ void SettingsErase(uint8_t type) {
r2 = NvmErase("main"); r2 = NvmErase("main");
// r3 = esp_phy_erase_cal_data_in_nvs(); // r3 = esp_phy_erase_cal_data_in_nvs();
// r3 = NvmErase("cal_data"); // r3 = NvmErase("cal_data");
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " Tasmota (%d,%d) and PHY data (%d)"), r1, r2, r3); // AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " Tasmota (%d,%d) and PHY data (%d)"), r1, r2, r3);
r3 = TfsDeleteFile(TASM_FILE_SETTINGS); r3 = TfsDeleteFile(TASM_FILE_SETTINGS);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " Tasmota data (%d,%d,%d)"), r1, r2, r3); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " Tasmota data (%d,%d,%d)"), r1, r2, r3);
break; break;
} }
} }
@ -196,7 +196,7 @@ void QPCWrite(const void *pSettings, unsigned nSettingsLen) {
void NvsInfo(void) { void NvsInfo(void) {
nvs_stats_t nvs_stats; nvs_stats_t nvs_stats;
nvs_get_stats(NULL, &nvs_stats); nvs_get_stats(NULL, &nvs_stats);
AddLog_P(LOG_LEVEL_INFO, PSTR("NVS: Used %d/%d entries, NameSpaces %d"), AddLog(LOG_LEVEL_INFO, PSTR("NVS: Used %d/%d entries, NameSpaces %d"),
nvs_stats.used_entries, nvs_stats.total_entries, nvs_stats.namespace_count); nvs_stats.used_entries, nvs_stats.total_entries, nvs_stats.namespace_count);
} }
@ -240,7 +240,7 @@ uint8_t* EspFlashMmap(uint32_t address) {
int32_t err = spi_flash_mmap(address, 5 * SPI_FLASH_MMU_PAGE_SIZE, SPI_FLASH_MMAP_DATA, (const void **)&data, &handle); int32_t err = spi_flash_mmap(address, 5 * SPI_FLASH_MMU_PAGE_SIZE, SPI_FLASH_MMAP_DATA, (const void **)&data, &handle);
/* /*
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Spi_flash_map %d"), err); AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Spi_flash_map %d"), err);
spi_flash_mmap_dump(); spi_flash_mmap_dump();
*/ */
@ -258,7 +258,7 @@ int32_t EspPartitionMmap(uint32_t action) {
if (!partition) { return 0; } if (!partition) { return 0; }
err = esp_partition_mmap(partition, 0, 4 * SPI_FLASH_MMU_PAGE_SIZE, SPI_FLASH_MMAP_DATA, (const void **)&TasmotaGlobal_mmap_data, &handle); err = esp_partition_mmap(partition, 0, 4 * SPI_FLASH_MMU_PAGE_SIZE, SPI_FLASH_MMAP_DATA, (const void **)&TasmotaGlobal_mmap_data, &handle);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Partition start 0x%08X, Partition end 0x%08X, Mmap data 0x%08X"), partition->address, partition->size, TasmotaGlobal_mmap_data); AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Partition start 0x%08X, Partition end 0x%08X, Mmap data 0x%08X"), partition->address, partition->size, TasmotaGlobal_mmap_data);
} else { } else {
spi_flash_munmap(handle); spi_flash_munmap(handle);
@ -407,7 +407,7 @@ uint8_t* FlashDirectAccess(void) {
uint32_t address = FlashWriteStartSector() * SPI_FLASH_SEC_SIZE; uint32_t address = FlashWriteStartSector() * SPI_FLASH_SEC_SIZE;
uint8_t* data = EspFlashMmap(address); uint8_t* data = EspFlashMmap(address);
/* /*
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Flash start address 0x%08X, Mmap address 0x%08X"), address, data); AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Flash start address 0x%08X, Mmap address 0x%08X"), address, data);
uint8_t buf[32]; uint8_t buf[32];
memcpy(buf, data, sizeof(buf)); memcpy(buf, data, sizeof(buf));

View File

@ -95,7 +95,7 @@ bool EsptoolEraseSector(uint32_t sector)
void EsptoolErase(uint32_t start_sector, uint32_t end_sector) void EsptoolErase(uint32_t start_sector, uint32_t end_sector)
{ {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " from 0x%08X to 0x%08X"), start_sector * SPI_FLASH_SEC_SIZE, (end_sector * SPI_FLASH_SEC_SIZE) -1); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " from 0x%08X to 0x%08X"), start_sector * SPI_FLASH_SEC_SIZE, (end_sector * SPI_FLASH_SEC_SIZE) -1);
int next_erase_sector = start_sector; int next_erase_sector = start_sector;
int remaining_erase_sector = end_sector - start_sector; int remaining_erase_sector = end_sector - start_sector;

View File

@ -136,7 +136,7 @@ double TaylorLog(double x)
dtostrfd(log1, 8, log1s); dtostrfd(log1, 8, log1s);
char log2s[33]; char log2s[33];
dtostrfd(totalValue, 8, log2s); dtostrfd(totalValue, 8, log2s);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("input %s, log %s, taylor %s"), logxs, log1s, log2s); AddLog(LOG_LEVEL_DEBUG, PSTR("input %s, log %s, taylor %s"), logxs, log1s, log2s);
*/ */
return totalValue; return totalValue;
} }

View File

@ -32,13 +32,13 @@ void StartMdns(void) {
if (Settings.flag3.mdns_enabled) { // SetOption55 - Control mDNS service if (Settings.flag3.mdns_enabled) { // SetOption55 - Control mDNS service
if (!Mdns.begun) { if (!Mdns.begun) {
// if (mdns_delayed_start) { // if (mdns_delayed_start) {
// AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_ATTEMPTING_CONNECTION)); // AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_ATTEMPTING_CONNECTION));
// mdns_delayed_start--; // mdns_delayed_start--;
// } else { // } else {
// mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START]; // mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START];
MDNS.end(); // close existing or MDNS.begin will fail MDNS.end(); // close existing or MDNS.begin will fail
Mdns.begun = (uint8_t)MDNS.begin(TasmotaGlobal.hostname); Mdns.begun = (uint8_t)MDNS.begin(TasmotaGlobal.hostname);
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS "%s"), (Mdns.begun) ? PSTR(D_INITIALIZED) : PSTR(D_FAILED)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS "%s"), (Mdns.begun) ? PSTR(D_INITIALIZED) : PSTR(D_FAILED));
// } // }
} }
} }
@ -51,7 +51,7 @@ void MqttDiscoverServer(void)
int n = MDNS.queryService("mqtt", "tcp"); // Search for mqtt service int n = MDNS.queryService("mqtt", "tcp"); // Search for mqtt service
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_QUERY_DONE " %d"), n); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_QUERY_DONE " %d"), n);
if (n > 0) { if (n > 0) {
uint32_t i = 0; // If the hostname isn't set, use the first record found. uint32_t i = 0; // If the hostname isn't set, use the first record found.
@ -65,7 +65,7 @@ void MqttDiscoverServer(void)
SettingsUpdateText(SET_MQTT_HOST, MDNS.hostname(i).c_str()); SettingsUpdateText(SET_MQTT_HOST, MDNS.hostname(i).c_str());
Settings.mqtt_port = MDNS.port(i); Settings.mqtt_port = MDNS.port(i);
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_MQTT_SERVICE_FOUND " %s," D_PORT " %d"), SettingsText(SET_MQTT_HOST), Settings.mqtt_port); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_MQTT_SERVICE_FOUND " %s," D_PORT " %d"), SettingsText(SET_MQTT_HOST), Settings.mqtt_port);
} }
} }
#endif // MQTT_HOST_DISCOVERY #endif // MQTT_HOST_DISCOVERY
@ -84,7 +84,7 @@ void MdnsUpdate(void) {
if (2 == Mdns.begun) { if (2 == Mdns.begun) {
MDNS.update(); // this is basically passpacket like a webserver MDNS.update(); // this is basically passpacket like a webserver
// being called in main loop so no logging // being called in main loop so no logging
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_MDNS "MDNS.update")); // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_MDNS "MDNS.update"));
} }
} }
#endif // ESP8266 #endif // ESP8266

View File

@ -209,7 +209,7 @@ void RotaryHandler(void) {
bool button_pressed = (Button.hold_timer[index]); // Button is pressed: set color temperature bool button_pressed = (Button.hold_timer[index]); // Button is pressed: set color temperature
if (button_pressed) { Encoder[index].changed = true; } if (button_pressed) { Encoder[index].changed = true; }
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("ROT: Button1 %d, Position %d"), button_pressed, rotary_position); // AddLog(LOG_LEVEL_DEBUG, PSTR("ROT: Button1 %d, Position %d"), button_pressed, rotary_position);
#ifdef USE_LIGHT #ifdef USE_LIGHT
if (!Settings.flag4.rotary_uses_rules) { // SetOption98 - Use rules instead of light control if (!Settings.flag4.rotary_uses_rules) { // SetOption98 - Use rules instead of light control

View File

@ -396,7 +396,7 @@ void RtcSecond(void)
Rtc.standard_time = RuleToTime(Settings.tflag[0], RtcTime.year); Rtc.standard_time = RuleToTime(Settings.tflag[0], RtcTime.year);
// Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9 // Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9
AddLog_P(LOG_LEVEL_DEBUG, PSTR("RTC: " D_UTC_TIME " %s, " D_DST_TIME " %s, " D_STD_TIME " %s"), AddLog(LOG_LEVEL_DEBUG, PSTR("RTC: " D_UTC_TIME " %s, " D_DST_TIME " %s, " D_STD_TIME " %s"),
GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str()); GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str());
if (Rtc.local_time < START_VALID_TIME) { // 2016-01-01 if (Rtc.local_time < START_VALID_TIME) { // 2016-01-01
@ -411,7 +411,7 @@ void RtcSecond(void)
if ((Rtc.utc_time > (2 * 60 * 60)) && (last_sync < Rtc.utc_time - (2 * 60 * 60))) { // Every two hours a warning if ((Rtc.utc_time > (2 * 60 * 60)) && (last_sync < Rtc.utc_time - (2 * 60 * 60))) { // Every two hours a warning
// Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9 // Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9
AddLog_P(LOG_LEVEL_DEBUG, PSTR("RTC: Not synced")); AddLog(LOG_LEVEL_DEBUG, PSTR("RTC: Not synced"));
last_sync = Rtc.utc_time; last_sync = Rtc.utc_time;
} }
@ -476,7 +476,7 @@ void RtcSecond(void)
void RtcSync(void) { void RtcSync(void) {
Rtc.time_synced = true; Rtc.time_synced = true;
RtcSecond(); RtcSecond();
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("RTC: Synced")); // AddLog(LOG_LEVEL_DEBUG, PSTR("RTC: Synced"));
} }
void RtcSetTime(uint32_t epoch) { void RtcSetTime(uint32_t epoch) {

View File

@ -815,7 +815,7 @@ void PerformEverySecond(void)
if (!(DeepSleepEnabled() && !Settings.flag3.bootcount_update)) { if (!(DeepSleepEnabled() && !Settings.flag3.bootcount_update)) {
#endif #endif
Settings.bootcount++; // Moved to here to stop flash writes during start-up Settings.bootcount++; // Moved to here to stop flash writes during start-up
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount);
#ifdef USE_DEEPSLEEP #ifdef USE_DEEPSLEEP
} }
#endif #endif
@ -832,7 +832,7 @@ void PerformEverySecond(void)
TasmotaGlobal.seriallog_timer--; TasmotaGlobal.seriallog_timer--;
if (!TasmotaGlobal.seriallog_timer) { if (!TasmotaGlobal.seriallog_timer) {
if (TasmotaGlobal.seriallog_level) { if (TasmotaGlobal.seriallog_level) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SERIAL_LOGGING_DISABLED)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SERIAL_LOGGING_DISABLED));
} }
TasmotaGlobal.seriallog_level = 0; TasmotaGlobal.seriallog_level = 0;
} }
@ -843,7 +843,7 @@ void PerformEverySecond(void)
if (!TasmotaGlobal.syslog_timer) { if (!TasmotaGlobal.syslog_timer) {
TasmotaGlobal.syslog_level = Settings.syslog_level; TasmotaGlobal.syslog_level = Settings.syslog_level;
if (Settings.syslog_level) { if (Settings.syslog_level) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_LOGGING_REENABLED)); // Might trigger disable again (on purpose) AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_LOGGING_REENABLED)); // Might trigger disable again (on purpose)
} }
} }
} }
@ -1059,7 +1059,7 @@ void Every250mSeconds(void)
char *ech = strchr(bch, '.'); // Find file type in filename (none, .ino.bin, .ino.bin.gz, .bin, .bin.gz or .gz) char *ech = strchr(bch, '.'); // Find file type in filename (none, .ino.bin, .ino.bin.gz, .bin, .bin.gz or .gz)
if (ech == nullptr) { ech = TasmotaGlobal.mqtt_data + strlen(TasmotaGlobal.mqtt_data); } // Point to '/0' at end of mqtt_data becoming an empty string if (ech == nullptr) { ech = TasmotaGlobal.mqtt_data + strlen(TasmotaGlobal.mqtt_data); } // Point to '/0' at end of mqtt_data becoming an empty string
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("OTA: File type [%s]"), ech); //AddLog(LOG_LEVEL_DEBUG, PSTR("OTA: File type [%s]"), ech);
char ota_url_type[strlen(ech) +1]; char ota_url_type[strlen(ech) +1];
strncpy(ota_url_type, ech, sizeof(ota_url_type)); // Either empty, .ino.bin, .ino.bin.gz, .bin, .bin.gz or .gz strncpy(ota_url_type, ech, sizeof(ota_url_type)); // Either empty, .ino.bin, .ino.bin.gz, .bin, .bin.gz or .gz
@ -1070,7 +1070,7 @@ void Every250mSeconds(void)
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s-" D_JSON_MINIMAL "%s"), TasmotaGlobal.mqtt_data, ota_url_type); // Minimal filename must be filename-minimal snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s-" D_JSON_MINIMAL "%s"), TasmotaGlobal.mqtt_data, ota_url_type); // Minimal filename must be filename-minimal
} }
#endif // FIRMWARE_MINIMAL #endif // FIRMWARE_MINIMAL
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "%s"), TasmotaGlobal.mqtt_data); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "%s"), TasmotaGlobal.mqtt_data);
WiFiClient OTAclient; WiFiClient OTAclient;
ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(OTAclient, TasmotaGlobal.mqtt_data)); ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(OTAclient, TasmotaGlobal.mqtt_data));
if (!ota_result) { if (!ota_result) {
@ -1189,7 +1189,7 @@ void Every250mSeconds(void)
} }
TasmotaGlobal.restart_flag--; TasmotaGlobal.restart_flag--;
if (TasmotaGlobal.restart_flag <= 0) { if (TasmotaGlobal.restart_flag <= 0) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "%s"), (TasmotaGlobal.restart_halt) ? PSTR("Halted") : PSTR(D_RESTARTING)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "%s"), (TasmotaGlobal.restart_halt) ? PSTR("Halted") : PSTR(D_RESTARTING));
EspRestart(); EspRestart();
} }
} }
@ -1300,7 +1300,7 @@ void ArduinoOTAInit(void)
if (Settings.flag.mqtt_enabled) { if (Settings.flag.mqtt_enabled) {
MqttDisconnect(); // SetOption3 - Enable MQTT MqttDisconnect(); // SetOption3 - Enable MQTT
} }
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_UPLOAD_STARTED)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_UPLOAD_STARTED));
arduino_ota_triggered = true; arduino_ota_triggered = true;
arduino_ota_progress_dot_count = 0; arduino_ota_progress_dot_count = 0;
delay(100); // Allow time for message xfer delay(100); // Allow time for message xfer
@ -1331,19 +1331,19 @@ void ArduinoOTAInit(void)
default: default:
snprintf_P(error_str, sizeof(error_str), PSTR(D_UPLOAD_ERROR_CODE " %d"), error); snprintf_P(error_str, sizeof(error_str), PSTR(D_UPLOAD_ERROR_CODE " %d"), error);
} }
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA %s. " D_RESTARTING), error_str); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA %s. " D_RESTARTING), error_str);
EspRestart(); EspRestart();
}); });
ArduinoOTA.onEnd([]() ArduinoOTA.onEnd([]()
{ {
if ((LOG_LEVEL_DEBUG <= TasmotaGlobal.seriallog_level)) { Serial.println(); } if ((LOG_LEVEL_DEBUG <= TasmotaGlobal.seriallog_level)) { Serial.println(); }
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_SUCCESSFUL ". " D_RESTARTING)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_SUCCESSFUL ". " D_RESTARTING));
EspRestart(); EspRestart();
}); });
ArduinoOTA.begin(); ArduinoOTA.begin();
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_ENABLED " " D_PORT " 8266")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_ENABLED " " D_PORT " 8266"));
} }
void ArduinoOtaLoop(void) void ArduinoOtaLoop(void)
@ -1451,7 +1451,7 @@ void SerialInput(void)
TasmotaGlobal.serial_in_buffer[TasmotaGlobal.serial_in_byte_counter] = 0; // Serial data completed TasmotaGlobal.serial_in_buffer[TasmotaGlobal.serial_in_byte_counter] = 0; // Serial data completed
TasmotaGlobal.seriallog_level = (Settings.seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings.seriallog_level; TasmotaGlobal.seriallog_level = (Settings.seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings.seriallog_level;
if (serial_buffer_overrun) { if (serial_buffer_overrun) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "Serial buffer overrun")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "Serial buffer overrun"));
} else { } else {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), TasmotaGlobal.serial_in_buffer); AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), TasmotaGlobal.serial_in_buffer);
ExecuteCommand(TasmotaGlobal.serial_in_buffer, SRC_SERIAL); ExecuteCommand(TasmotaGlobal.serial_in_buffer, SRC_SERIAL);
@ -1519,7 +1519,7 @@ void GpioInit(void)
} }
SetModuleType(); SetModuleType();
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Used GPIOs %d"), GPIO_SENSOR_END); // AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Used GPIOs %d"), GPIO_SENSOR_END);
#ifdef ESP8266 #ifdef ESP8266
ConvertGpios(); ConvertGpios();
@ -1685,7 +1685,7 @@ void GpioInit(void)
for (uint32_t i = 0; i < ARRAY_SIZE(TasmotaGlobal.my_module.io); i++) { for (uint32_t i = 0; i < ARRAY_SIZE(TasmotaGlobal.my_module.io); i++) {
uint32_t mpin = ValidPin(i, TasmotaGlobal.my_module.io[i]); uint32_t mpin = ValidPin(i, TasmotaGlobal.my_module.io[i]);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("INI: gpio pin %d, mpin %d"), i, mpin); // AddLog(LOG_LEVEL_DEBUG, PSTR("INI: gpio pin %d, mpin %d"), i, mpin);
if (AGPIO(GPIO_OUTPUT_HI) == mpin) { if (AGPIO(GPIO_OUTPUT_HI) == mpin) {
pinMode(i, OUTPUT); pinMode(i, OUTPUT);
digitalWrite(i, 1); digitalWrite(i, 1);

View File

@ -71,7 +71,7 @@ bool UdpDisconnect(void)
// stop all // stop all
WiFiUDP::stopAll(); WiFiUDP::stopAll();
#endif // !USE_DEVICE_GROUPS #endif // !USE_DEVICE_GROUPS
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_MULTICAST_DISABLED)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_MULTICAST_DISABLED));
udp_connected = false; udp_connected = false;
} }
return udp_connected; return udp_connected;
@ -87,18 +87,18 @@ bool UdpConnect(void)
ip_addr_t addr = IPADDR4_INIT(INADDR_ANY); ip_addr_t addr = IPADDR4_INIT(INADDR_ANY);
if (UdpCtx.listen(&addr, 1900)) { // port 1900 if (UdpCtx.listen(&addr, 1900)) { // port 1900
// OK // OK
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_REJOINED)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_REJOINED));
udp_connected = true; udp_connected = true;
} }
#endif // ESP8266 #endif // ESP8266
#ifdef ESP32 #ifdef ESP32
if (PortUdp.beginMulticast(WiFi.localIP(), IPAddress(239,255,255,250), 1900)) { if (PortUdp.beginMulticast(WiFi.localIP(), IPAddress(239,255,255,250), 1900)) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_REJOINED)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_REJOINED));
udp_connected = true; udp_connected = true;
#endif // ESP32 #endif // ESP32
} }
if (!udp_connected) { // if connection failed if (!udp_connected) { // if connection failed
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_JOIN_FAILED)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_JOIN_FAILED));
} }
} }
return udp_connected; return udp_connected;
@ -120,7 +120,7 @@ void PollUdp(void)
packet->buf[packet->len] = 0; // add NULL at the end of the packet packet->buf[packet->len] = 0; // add NULL at the end of the packet
char * packet_buffer = (char*) &packet->buf; char * packet_buffer = (char*) &packet->buf;
int32_t len = packet->len; int32_t len = packet->len;
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d)"), len); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d)"), len);
#endif // ESP8266 #endif // ESP8266
#ifdef ESP32 #ifdef ESP32
while (uint32_t pack_len = PortUdp.parsePacket()) { while (uint32_t pack_len = PortUdp.parsePacket()) {
@ -129,7 +129,7 @@ void PollUdp(void)
int32_t len = PortUdp.read(packet_buffer, UDP_BUFFER_SIZE -1); int32_t len = PortUdp.read(packet_buffer, UDP_BUFFER_SIZE -1);
packet_buffer[len] = 0; packet_buffer[len] = 0;
PortUdp.flush(); PortUdp.flush();
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d/%d)"), len, pack_len); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d/%d)"), len, pack_len);
#endif // ESP32 #endif // ESP32
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), packet_buffer); // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), packet_buffer);
@ -175,7 +175,7 @@ void PollUdp(void)
#ifdef USE_EMULATION_HUE #ifdef USE_EMULATION_HUE
if (!udp_proccessed && (EMUL_HUE == Settings.flag2.emulation)) { if (!udp_proccessed && (EMUL_HUE == Settings.flag2.emulation)) {
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: HUE")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: HUE"));
if ((strstr_P(packet_buffer, PSTR(":device:basic:1")) != nullptr) || if ((strstr_P(packet_buffer, PSTR(":device:basic:1")) != nullptr) ||
(strstr_P(packet_buffer, UPNP_ROOTDEVICE) != nullptr) || (strstr_P(packet_buffer, UPNP_ROOTDEVICE) != nullptr) ||
(strstr_P(packet_buffer, SSDPSEARCH_ALL) != nullptr) || (strstr_P(packet_buffer, SSDPSEARCH_ALL) != nullptr) ||

View File

@ -102,11 +102,11 @@ void WifiConfig(uint8_t type)
TasmotaGlobal.restart_flag = 2; TasmotaGlobal.restart_flag = 2;
} }
else if (WIFI_SERIAL == Wifi.config_type) { else if (WIFI_SERIAL == Wifi.config_type) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_6_SERIAL " " D_ACTIVE_FOR_3_MINUTES)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_6_SERIAL " " D_ACTIVE_FOR_3_MINUTES));
} }
#ifdef USE_WEBSERVER #ifdef USE_WEBSERVER
else if (WIFI_MANAGER == Wifi.config_type || WIFI_MANAGER_RESET_ONLY == Wifi.config_type) { else if (WIFI_MANAGER == Wifi.config_type || WIFI_MANAGER_RESET_ONLY == Wifi.config_type) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_2_WIFIMANAGER " " D_ACTIVE_FOR_3_MINUTES)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_2_WIFIMANAGER " " D_ACTIVE_FOR_3_MINUTES));
WifiManagerBegin(WIFI_MANAGER_RESET_ONLY == Wifi.config_type); WifiManagerBegin(WIFI_MANAGER_RESET_ONLY == Wifi.config_type);
} }
#endif // USE_WEBSERVER #endif // USE_WEBSERVER
@ -125,7 +125,7 @@ void WifiSetMode(WiFiMode_t wifi_mode)
uint32_t retry = 2; uint32_t retry = 2;
while (!WiFi.mode(wifi_mode) && retry--) { while (!WiFi.mode(wifi_mode) && retry--) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI "Retry set Mode...")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI "Retry set Mode..."));
delay(100); delay(100);
} }
@ -217,7 +217,7 @@ void WifiBegin(uint8_t flag, uint8_t channel)
} else { } else {
WiFi.begin(SettingsText(SET_STASSID1 + Settings.sta_active), SettingsText(SET_STAPWD1 + Settings.sta_active)); WiFi.begin(SettingsText(SET_STASSID1 + Settings.sta_active), SettingsText(SET_STAPWD1 + Settings.sta_active));
} }
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s%s " D_IN_MODE " 11%c " D_AS " %s..."), AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s%s " D_IN_MODE " 11%c " D_AS " %s..."),
Settings.sta_active +1, SettingsText(SET_STASSID1 + Settings.sta_active), stemp, pgm_read_byte(&kWifiPhyMode[WiFi.getPhyMode() & 0x3]), TasmotaGlobal.hostname); Settings.sta_active +1, SettingsText(SET_STASSID1 + Settings.sta_active), stemp, pgm_read_byte(&kWifiPhyMode[WiFi.getPhyMode() & 0x3]), TasmotaGlobal.hostname);
#if LWIP_IPV6 #if LWIP_IPV6
@ -225,11 +225,11 @@ void WifiBegin(uint8_t flag, uint8_t channel)
uint16_t cfgcnt = 0; uint16_t cfgcnt = 0;
for (auto addr : addrList) { for (auto addr : addrList) {
if ((configured = !addr.isLocal() && addr.isV6()) || cfgcnt==30) { if ((configured = !addr.isLocal() && addr.isV6()) || cfgcnt==30) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI "Got IPv6 global address %s"), addr.toString().c_str()); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI "Got IPv6 global address %s"), addr.toString().c_str());
break; // IPv6 is mandatory but stop after 15 seconds break; // IPv6 is mandatory but stop after 15 seconds
} }
delay(500); // Loop until real IPv6 address is aquired or too many tries failed delay(500); // Loop until real IPv6 address is aquired or too many tries failed
cfgcnt++; cfgcnt++;
} }
} }
#endif // LWIP_IPV6=1 #endif // LWIP_IPV6=1
@ -260,7 +260,7 @@ void WifiBeginAfterScan(void)
if (WiFi.scanComplete() != WIFI_SCAN_RUNNING) { if (WiFi.scanComplete() != WIFI_SCAN_RUNNING) {
WiFi.scanNetworks(true); // Start wifi scan async WiFi.scanNetworks(true); // Start wifi scan async
Wifi.scan_state++; Wifi.scan_state++;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Network (re)scan started...")); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Network (re)scan started..."));
return; return;
} }
} }
@ -308,7 +308,7 @@ void WifiBeginAfterScan(void)
} }
} }
char hex_char[18]; char hex_char[18];
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Network %d, AP%c, SSId %s, Channel %d, BSSId %s, RSSI %d, Encryption %d"), AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Network %d, AP%c, SSId %s, Channel %d, BSSId %s, RSSI %d, Encryption %d"),
i, i,
(known) ? (j) ? '2' : '1' : '-', (known) ? (j) ? '2' : '1' : '-',
ssid_scan.c_str(), ssid_scan.c_str(),
@ -373,11 +373,11 @@ String WifiGetIPv6(void)
// Check to see if we have any routable IP address // Check to see if we have any routable IP address
inline bool WifiCheck_hasIP(IPAddress const & ip_address) inline bool WifiCheck_hasIP(IPAddress const & ip_address)
{ {
#ifdef LWIP2_IPV6 #ifdef LWIP2_IPV6
return !a.isLocal(); return !a.isLocal();
#else #else
return static_cast<uint32_t>(ip_address) != 0; return static_cast<uint32_t>(ip_address) != 0;
#endif #endif
} }
void WifiCheckIp(void) void WifiCheckIp(void)
@ -387,8 +387,8 @@ void WifiCheckIp(void)
Wifi.counter = WIFI_CHECK_SEC; Wifi.counter = WIFI_CHECK_SEC;
Wifi.retry = Wifi.retry_init; Wifi.retry = Wifi.retry_init;
if (Wifi.status != WL_CONNECTED) { if (Wifi.status != WL_CONNECTED) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTED)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTED));
// AddLog_P(LOG_LEVEL_INFO, PSTR("Wifi: Set IP addresses")); // AddLog(LOG_LEVEL_INFO, PSTR("Wifi: Set IP addresses"));
Settings.ipv4_address[1] = (uint32_t)WiFi.gatewayIP(); Settings.ipv4_address[1] = (uint32_t)WiFi.gatewayIP();
Settings.ipv4_address[2] = (uint32_t)WiFi.subnetMask(); Settings.ipv4_address[2] = (uint32_t)WiFi.subnetMask();
Settings.ipv4_address[3] = (uint32_t)WiFi.dnsIP(); Settings.ipv4_address[3] = (uint32_t)WiFi.dnsIP();
@ -405,12 +405,12 @@ void WifiCheckIp(void)
Wifi.status = WiFi.status(); Wifi.status = WiFi.status();
switch (Wifi.status) { switch (Wifi.status) {
case WL_CONNECTED: case WL_CONNECTED:
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_NO_IP_ADDRESS)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_NO_IP_ADDRESS));
Wifi.status = 0; Wifi.status = 0;
Wifi.retry = Wifi.retry_init; Wifi.retry = Wifi.retry_init;
break; break;
case WL_NO_SSID_AVAIL: case WL_NO_SSID_AVAIL:
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_AP_NOT_REACHED)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_AP_NOT_REACHED));
Settings.wifi_channel = 0; // Disable stored AP Settings.wifi_channel = 0; // Disable stored AP
if (WIFI_WAIT == Settings.sta_config) { if (WIFI_WAIT == Settings.sta_config) {
Wifi.retry = Wifi.retry_init; Wifi.retry = Wifi.retry_init;
@ -424,7 +424,7 @@ void WifiCheckIp(void)
} }
break; break;
case WL_CONNECT_FAILED: case WL_CONNECT_FAILED:
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_WRONG_PASSWORD)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_WRONG_PASSWORD));
Settings.wifi_channel = 0; // Disable stored AP Settings.wifi_channel = 0; // Disable stored AP
if (Wifi.retry > (Wifi.retry_init / 2)) { if (Wifi.retry > (Wifi.retry_init / 2)) {
Wifi.retry = Wifi.retry_init / 2; Wifi.retry = Wifi.retry_init / 2;
@ -435,7 +435,7 @@ void WifiCheckIp(void)
break; break;
default: // WL_IDLE_STATUS and WL_DISCONNECTED default: // WL_IDLE_STATUS and WL_DISCONNECTED
if (!Wifi.retry || ((Wifi.retry_init / 2) == Wifi.retry)) { if (!Wifi.retry || ((Wifi.retry_init / 2) == Wifi.retry)) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_AP_TIMEOUT)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_AP_TIMEOUT));
Settings.wifi_channel = 0; // Disable stored AP Settings.wifi_channel = 0; // Disable stored AP
} else { } else {
if (!strlen(SettingsText(SET_STASSID1)) && !strlen(SettingsText(SET_STASSID2))) { if (!strlen(SettingsText(SET_STASSID1)) && !strlen(SettingsText(SET_STASSID2))) {
@ -443,7 +443,7 @@ void WifiCheckIp(void)
wifi_config_tool = WIFI_MANAGER; // Skip empty SSIDs and start Wifi config tool wifi_config_tool = WIFI_MANAGER; // Skip empty SSIDs and start Wifi config tool
Wifi.retry = 0; Wifi.retry = 0;
} else { } else {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_ATTEMPTING_CONNECTION)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_ATTEMPTING_CONNECTION));
} }
} }
} }
@ -491,7 +491,7 @@ void WifiCheck(uint8_t param)
SettingsUpdateText(SET_STAPWD1, WiFi.psk().c_str()); SettingsUpdateText(SET_STAPWD1, WiFi.psk().c_str());
} }
Settings.sta_active = 0; Settings.sta_active = 0;
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_2_WIFIMANAGER D_CMND_SSID "1 %s"), SettingsText(SET_STASSID1)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_2_WIFIMANAGER D_CMND_SSID "1 %s"), SettingsText(SET_STASSID1));
} }
} }
if (!Wifi.config_counter) { if (!Wifi.config_counter) {
@ -502,7 +502,7 @@ void WifiCheck(uint8_t param)
if (Wifi.scan_state) { WifiBeginAfterScan(); } if (Wifi.scan_state) { WifiBeginAfterScan(); }
if (Wifi.counter <= 0) { if (Wifi.counter <= 0) {
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_WIFI D_CHECKING_CONNECTION)); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_WIFI D_CHECKING_CONNECTION));
Wifi.counter = WIFI_CHECK_SEC; Wifi.counter = WIFI_CHECK_SEC;
WifiCheckIp(); WifiCheckIp();
} }
@ -584,7 +584,7 @@ void WifiConnect(void)
#ifdef WIFI_RF_PRE_INIT #ifdef WIFI_RF_PRE_INIT
if (rf_pre_init_flag) { if (rf_pre_init_flag) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Pre-init done")); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Pre-init done"));
} }
#endif // WIFI_RF_PRE_INIT #endif // WIFI_RF_PRE_INIT
} }
@ -656,7 +656,7 @@ extern "C" {
} }
void stationKeepAliveNow(void) { void stationKeepAliveNow(void) {
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_WIFI "Sending Gratuitous ARP")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_WIFI "Sending Gratuitous ARP"));
for (netif* interface = netif_list; interface != nullptr; interface = interface->next) for (netif* interface = netif_list; interface != nullptr; interface = interface->next)
if ( if (
(interface->flags & NETIF_FLAG_LINK_UP) (interface->flags & NETIF_FLAG_LINK_UP)
@ -744,11 +744,11 @@ uint32_t WifiGetNtp(void) {
ntp_server_id++; ntp_server_id++;
} }
if (!resolved_ip) { if (!resolved_ip) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("NTP: No server found")); // AddLog(LOG_LEVEL_DEBUG, PSTR("NTP: No server found"));
return 0; return 0;
} }
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("NTP: Name %s, IP %s"), ntp_server, time_server_ip.toString().c_str()); // AddLog(LOG_LEVEL_DEBUG, PSTR("NTP: Name %s, IP %s"), ntp_server, time_server_ip.toString().c_str());
WiFiUDP udp; WiFiUDP udp;
@ -798,7 +798,7 @@ uint32_t WifiGetNtp(void) {
if ((packet_buffer[0] & 0b11000000) == 0b11000000) { if ((packet_buffer[0] & 0b11000000) == 0b11000000) {
// Leap-Indicator: unknown (clock unsynchronized) // Leap-Indicator: unknown (clock unsynchronized)
// See: https://github.com/letscontrolit/ESPEasy/issues/2886#issuecomment-586656384 // See: https://github.com/letscontrolit/ESPEasy/issues/2886#issuecomment-586656384
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NTP: IP %s unsynched"), time_server_ip.toString().c_str()); AddLog(LOG_LEVEL_DEBUG, PSTR("NTP: IP %s unsynched"), time_server_ip.toString().c_str());
ntp_server_id++; // Next server next time ntp_server_id++; // Next server next time
return 0; return 0;
} }
@ -818,7 +818,7 @@ uint32_t WifiGetNtp(void) {
delay(10); delay(10);
} }
// Timeout. // Timeout.
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NTP: No reply")); AddLog(LOG_LEVEL_DEBUG, PSTR("NTP: No reply"));
udp.stop(); udp.stop();
ntp_server_id++; // Next server next time ntp_server_id++; // Next server next time
return 0; return 0;

View File

@ -312,7 +312,7 @@ void setup(void) {
Settings.module = Settings.fallback_module; // Reset module to fallback module Settings.module = Settings.fallback_module; // Reset module to fallback module
// Settings.last_module = Settings.fallback_module; // Settings.last_module = Settings.fallback_module;
} }
AddLog_P(LOG_LEVEL_INFO, PSTR("FRC: " D_LOG_SOME_SETTINGS_RESET " (%d)"), RtcReboot.fast_reboot_count); AddLog(LOG_LEVEL_INFO, PSTR("FRC: " D_LOG_SOME_SETTINGS_RESET " (%d)"), RtcReboot.fast_reboot_count);
} }
} }
@ -339,10 +339,10 @@ void setup(void) {
SetPowerOnState(); SetPowerOnState();
AddLog_P(LOG_LEVEL_INFO, PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_CORE_RELEASE "(%s)"), AddLog(LOG_LEVEL_INFO, PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_CORE_RELEASE "(%s)"),
PSTR(PROJECT), SettingsText(SET_DEVICENAME), TasmotaGlobal.version, TasmotaGlobal.image_name, GetBuildDateAndTime().c_str()); PSTR(PROJECT), SettingsText(SET_DEVICENAME), TasmotaGlobal.version, TasmotaGlobal.image_name, GetBuildDateAndTime().c_str());
#ifdef FIRMWARE_MINIMAL #ifdef FIRMWARE_MINIMAL
AddLog_P(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION)); AddLog(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION));
#endif // FIRMWARE_MINIMAL #endif // FIRMWARE_MINIMAL
RtcInit(); RtcInit();

View File

@ -392,7 +392,7 @@ void ShowWebSource(uint32_t source)
{ {
if ((source > 0) && (source < SRC_MAX)) { if ((source > 0) && (source < SRC_MAX)) {
char stemp1[20]; char stemp1[20];
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SRC: %s from %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource), Webserver->client().remoteIP().toString().c_str()); AddLog(LOG_LEVEL_DEBUG, PSTR("SRC: %s from %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource), Webserver->client().remoteIP().toString().c_str());
} }
} }
@ -475,14 +475,14 @@ void StartWebserver(int type, IPAddress ipweb)
#if LWIP_IPV6 #if LWIP_IPV6
String ipv6_addr = WifiGetIPv6(); String ipv6_addr = WifiGetIPv6();
if (ipv6_addr!="") { if (ipv6_addr!="") {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s and IPv6 global address %s "), AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s and IPv6 global address %s "),
NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str(), ipv6_addr.c_str()); NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str(), ipv6_addr.c_str());
} else { } else {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"), AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"),
NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str()); NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str());
} }
#else #else
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"), AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"),
NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str()); NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str());
#endif // LWIP_IPV6 = 1 #endif // LWIP_IPV6 = 1
TasmotaGlobal.rules_flag.http_init = 1; TasmotaGlobal.rules_flag.http_init = 1;
@ -495,7 +495,7 @@ void StopWebserver(void)
if (Web.state) { if (Web.state) {
Webserver->close(); Webserver->close();
Web.state = HTTP_OFF; Web.state = HTTP_OFF;
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_STOPPED)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_STOPPED));
} }
} }
@ -505,11 +505,11 @@ void WifiManagerBegin(bool reset_only)
if (!TasmotaGlobal.global_state.wifi_down) { if (!TasmotaGlobal.global_state.wifi_down) {
// WiFi.mode(WIFI_AP_STA); // WiFi.mode(WIFI_AP_STA);
WifiSetMode(WIFI_AP_STA); WifiSetMode(WIFI_AP_STA);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WIFIMANAGER_SET_ACCESSPOINT_AND_STATION)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WIFIMANAGER_SET_ACCESSPOINT_AND_STATION));
} else { } else {
// WiFi.mode(WIFI_AP); // WiFi.mode(WIFI_AP);
WifiSetMode(WIFI_AP); WifiSetMode(WIFI_AP);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WIFIMANAGER_SET_ACCESSPOINT)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WIFIMANAGER_SET_ACCESSPOINT));
} }
StopWebserver(); StopWebserver();
@ -624,7 +624,7 @@ void _WSContentSendBuffer(void)
return; return;
} }
else if (len == sizeof(TasmotaGlobal.mqtt_data)) { else if (len == sizeof(TasmotaGlobal.mqtt_data)) {
AddLog_P(LOG_LEVEL_INFO, PSTR("HTP: Content too large")); AddLog(LOG_LEVEL_INFO, PSTR("HTP: Content too large"));
} }
else if (len < CHUNKED_BUFFER_SIZE) { // Append chunk buffer with small content else if (len < CHUNKED_BUFFER_SIZE) { // Append chunk buffer with small content
Web.chunk_buffer += TasmotaGlobal.mqtt_data; Web.chunk_buffer += TasmotaGlobal.mqtt_data;
@ -819,7 +819,7 @@ void WebRestart(uint32_t type)
// type 0 = restart // type 0 = restart
// type 1 = restart after config change // type 1 = restart after config change
// type 2 = restart after config change with possible ip address change too // type 2 = restart after config change with possible ip address change too
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESTART)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESTART));
bool reset_only = (HTTP_MANAGER_RESET_ONLY == Web.state); bool reset_only = (HTTP_MANAGER_RESET_ONLY == Web.state);
@ -905,7 +905,7 @@ void HandleRoot(void)
return; return;
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_MAIN_MENU)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_MAIN_MENU));
char stemp[33]; char stemp[33];
@ -1284,7 +1284,7 @@ void HandleConfiguration(void)
{ {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURATION)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURATION));
WSContentStart_P(PSTR(D_CONFIGURATION)); WSContentStart_P(PSTR(D_CONFIGURATION));
WSContentSendStyle(); WSContentSendStyle();
@ -1403,7 +1403,7 @@ void HandleTemplateConfiguration(void)
return; return;
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_TEMPLATE)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_TEMPLATE));
WSContentStart_P(PSTR(D_CONFIGURE_TEMPLATE)); WSContentStart_P(PSTR(D_CONFIGURE_TEMPLATE));
WSContentSend_P(HTTP_SCRIPT_MODULE_TEMPLATE); WSContentSend_P(HTTP_SCRIPT_MODULE_TEMPLATE);
@ -1512,7 +1512,7 @@ void HandleModuleConfiguration(void)
return; return;
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_MODULE)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_MODULE));
char stemp[30]; // Sensor name char stemp[30]; // Sensor name
uint32_t midx; uint32_t midx;
@ -1592,7 +1592,7 @@ void ModuleSaveSettings(void)
} }
} }
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MODULE "%s " D_CMND_MODULE "%s"), ModuleName().c_str(), gpios.c_str()); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MODULE "%s " D_CMND_MODULE "%s"), ModuleName().c_str(), gpios.c_str());
} }
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
@ -1623,7 +1623,7 @@ void HandleWifiConfiguration(void)
{ {
if (!HttpCheckPriviledgedAccess(!WifiIsInManagerMode())) { return; } if (!HttpCheckPriviledgedAccess(!WifiIsInManagerMode())) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_WIFI)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_WIFI));
if (Webserver->hasArg(F("save")) && HTTP_MANAGER_RESET_ONLY != Web.state) { if (Webserver->hasArg(F("save")) && HTTP_MANAGER_RESET_ONLY != Web.state) {
WifiSaveSettings(); WifiSaveSettings();
@ -1645,10 +1645,10 @@ void HandleWifiConfiguration(void)
UdpDisconnect(); UdpDisconnect();
#endif // USE_EMULATION #endif // USE_EMULATION
int n = WiFi.scanNetworks(); int n = WiFi.scanNetworks();
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_SCAN_DONE)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_SCAN_DONE));
if (0 == n) { if (0 == n) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_NO_NETWORKS_FOUND)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_NO_NETWORKS_FOUND));
WSContentSend_P(PSTR(D_NO_NETWORKS_FOUND)); WSContentSend_P(PSTR(D_NO_NETWORKS_FOUND));
WSContentSend_P(PSTR(". " D_REFRESH_TO_SCAN_AGAIN ".")); WSContentSend_P(PSTR(". " D_REFRESH_TO_SCAN_AGAIN "."));
} else { } else {
@ -1802,7 +1802,7 @@ void HandleLoggingConfiguration(void)
{ {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_LOGGING)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_LOGGING));
if (Webserver->hasArg("save")) { if (Webserver->hasArg("save")) {
LoggingSaveSettings(); LoggingSaveSettings();
@ -1867,7 +1867,7 @@ void HandleOtherConfiguration(void)
{ {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_OTHER)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_OTHER));
if (Webserver->hasArg(F("save"))) { if (Webserver->hasArg(F("save"))) {
OtherSaveSettings(); OtherSaveSettings();
@ -1970,7 +1970,7 @@ void HandleBackupConfiguration(void)
{ {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_BACKUP_CONFIGURATION)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_BACKUP_CONFIGURATION));
if (!SettingsBufferAlloc()) { return; } if (!SettingsBufferAlloc()) { return; }
@ -2012,7 +2012,7 @@ void HandleResetConfiguration(void)
{ {
if (!HttpCheckPriviledgedAccess(!WifiIsInManagerMode())) { return; } if (!HttpCheckPriviledgedAccess(!WifiIsInManagerMode())) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESET_CONFIGURATION)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESET_CONFIGURATION));
WSContentStart_P(PSTR(D_RESET_CONFIGURATION), !WifiIsInManagerMode()); WSContentStart_P(PSTR(D_RESET_CONFIGURATION), !WifiIsInManagerMode());
WSContentSendStyle(); WSContentSendStyle();
@ -2030,7 +2030,7 @@ void HandleRestoreConfiguration(void)
{ {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESTORE_CONFIGURATION)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESTORE_CONFIGURATION));
WSContentStart_P(PSTR(D_RESTORE_CONFIGURATION)); WSContentStart_P(PSTR(D_RESTORE_CONFIGURATION));
WSContentSendStyle(); WSContentSendStyle();
@ -2052,7 +2052,7 @@ void HandleInformation(void)
{ {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_INFORMATION)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_INFORMATION));
char stopic[TOPSZ]; char stopic[TOPSZ];
@ -2242,7 +2242,7 @@ uint32_t BUploadWriteBuffer(uint8_t *buf, size_t size) {
void HandleUpgradeFirmware(void) { void HandleUpgradeFirmware(void) {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_FIRMWARE_UPGRADE)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_FIRMWARE_UPGRADE));
WSContentStart_P(PSTR(D_FIRMWARE_UPGRADE)); WSContentStart_P(PSTR(D_FIRMWARE_UPGRADE));
WSContentSendStyle(); WSContentSendStyle();
@ -2259,7 +2259,7 @@ void HandleUpgradeFirmwareStart(void) {
char command[TOPSZ + 10]; // OtaUrl char command[TOPSZ + 10]; // OtaUrl
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPGRADE_STARTED)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPGRADE_STARTED));
WifiConfigCounter(); WifiConfigCounter();
char otaurl[TOPSZ]; char otaurl[TOPSZ];
@ -2294,7 +2294,7 @@ void HandleUploadDone(void) {
} }
#endif // USE_ZIGBEE_EZSP #endif // USE_ZIGBEE_EZSP
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPLOAD_DONE)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPLOAD_DONE));
WifiConfigCounter(); WifiConfigCounter();
UploadServices(1); UploadServices(1);
@ -2339,7 +2339,7 @@ void UploadServices(uint32_t start_service) {
Web.upload_services_stopped = !start_service; Web.upload_services_stopped = !start_service;
if (start_service) { if (start_service) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("UPL: Services enabled")); // AddLog(LOG_LEVEL_DEBUG, PSTR("UPL: Services enabled"));
/* /*
MqttRetryCounter(0); MqttRetryCounter(0);
@ -2355,7 +2355,7 @@ void UploadServices(uint32_t start_service) {
#endif // USE_EMULATION #endif // USE_EMULATION
} else { } else {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("UPL: Services disabled")); // AddLog(LOG_LEVEL_DEBUG, PSTR("UPL: Services disabled"));
#ifdef USE_BLE_ESP32 #ifdef USE_BLE_ESP32
ExtStopBLE(); ExtStopBLE();
@ -2390,7 +2390,7 @@ void HandleUploadLoop(void) {
if (UPL_TASMOTA == Web.upload_file_type) { Update.end(); } if (UPL_TASMOTA == Web.upload_file_type) { Update.end(); }
UploadServices(1); UploadServices(1);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Upload error %d"), Web.upload_error); // AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Upload error %d"), Web.upload_error);
upload_error_signalled = true; upload_error_signalled = true;
} }
@ -2413,7 +2413,7 @@ void HandleUploadLoop(void) {
} }
SettingsSave(1); // Free flash for upload SettingsSave(1); // Free flash for upload
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_FILE " %s"), upload.filename.c_str()); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_FILE " %s"), upload.filename.c_str());
if (UPL_SETTINGS == Web.upload_file_type) { if (UPL_SETTINGS == Web.upload_file_type) {
if (!SettingsBufferAlloc()) { if (!SettingsBufferAlloc()) {
@ -2492,7 +2492,7 @@ void HandleUploadLoop(void) {
return; return;
} }
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "File type %d"), Web.upload_file_type); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "File type %d"), Web.upload_file_type);
} // First block received } // First block received
if (UPL_SETTINGS == Web.upload_file_type) { if (UPL_SETTINGS == Web.upload_file_type) {
@ -2514,7 +2514,7 @@ void HandleUploadLoop(void) {
#ifdef USE_WEB_FW_UPGRADE #ifdef USE_WEB_FW_UPGRADE
else if (BUpload.active) { else if (BUpload.active) {
// Write a block // Write a block
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Size %d"), upload.currentSize); // AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Size %d"), upload.currentSize);
// AddLogBuffer(LOG_LEVEL_DEBUG, upload.buf, 32); // AddLogBuffer(LOG_LEVEL_DEBUG, upload.buf, 32);
Web.upload_error = BUploadWriteBuffer(upload.buf, upload.currentSize); Web.upload_error = BUploadWriteBuffer(upload.buf, upload.currentSize);
if (Web.upload_error != 0) { return; } if (Web.upload_error != 0) { return; }
@ -2525,7 +2525,7 @@ void HandleUploadLoop(void) {
return; return;
} }
if (upload.totalSize && !(upload.totalSize % 102400)) { if (upload.totalSize && !(upload.totalSize % 102400)) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Progress %d kB"), upload.totalSize / 1024); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Progress %d kB"), upload.totalSize / 1024);
} }
} }
@ -2582,12 +2582,12 @@ void HandleUploadLoop(void) {
// Done writing the data to SPI flash // Done writing the data to SPI flash
BUpload.active = false; BUpload.active = false;
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Transfer %u bytes"), upload.totalSize); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Transfer %u bytes"), upload.totalSize);
uint8_t* data = FlashDirectAccess(); uint8_t* data = FlashDirectAccess();
// uint32_t* values = (uint32_t*)(data); // Only 4-byte access allowed // uint32_t* values = (uint32_t*)(data); // Only 4-byte access allowed
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Head 0x%08X"), values[0]); // AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Head 0x%08X"), values[0]);
uint32_t error = 0; uint32_t error = 0;
#ifdef USE_RF_FLASH #ifdef USE_RF_FLASH
@ -2616,7 +2616,7 @@ void HandleUploadLoop(void) {
} }
#endif // USE_ZIGBEE_EZSP #endif // USE_ZIGBEE_EZSP
if (error != 0) { if (error != 0) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Transfer error %d"), error); // AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Transfer error %d"), error);
Web.upload_error = error + (100 * Web.upload_file_type); // Add offset to discriminate transfer errors Web.upload_error = error + (100 * Web.upload_file_type); // Add offset to discriminate transfer errors
return; return;
} }
@ -2626,7 +2626,7 @@ void HandleUploadLoop(void) {
Web.upload_error = 6; // Upload failed. Enable logging 3 Web.upload_error = 6; // Upload failed. Enable logging 3
return; return;
} }
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_SUCCESSFUL " %u bytes"), upload.totalSize); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_SUCCESSFUL " %u bytes"), upload.totalSize);
} }
// ***** Step4: Abort upload file // ***** Step4: Abort upload file
@ -2658,7 +2658,7 @@ void HandleHttpCommand(void)
{ {
if (!HttpCheckPriviledgedAccess(false)) { return; } if (!HttpCheckPriviledgedAccess(false)) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_COMMAND)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_COMMAND));
if (!WebAuthenticate()) { if (!WebAuthenticate()) {
// Prefer authorization via HTTP header (Basic auth), if it fails, use legacy method via GET parameters // Prefer authorization via HTTP header (Basic auth), if it fails, use legacy method via GET parameters
@ -2717,7 +2717,7 @@ void HandleConsole(void)
return; return;
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONSOLE)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONSOLE));
WSContentStart_P(PSTR(D_CONSOLE)); WSContentStart_P(PSTR(D_CONSOLE));
WSContentSend_P(HTTP_SCRIPT_CONSOL, Settings.web_refresh); WSContentSend_P(HTTP_SCRIPT_CONSOL, Settings.web_refresh);
@ -2764,7 +2764,7 @@ void HandleConsoleRefresh(void)
void HandleNotFound(void) void HandleNotFound(void)
{ {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Not found (%s)"), Webserver->uri().c_str()); // AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Not found (%s)"), Webserver->uri().c_str());
if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the error page. if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the error page.
@ -2791,7 +2791,7 @@ bool CaptivePortal(void)
{ {
// Possible hostHeader: connectivitycheck.gstatic.com or 192.168.4.1 // Possible hostHeader: connectivitycheck.gstatic.com or 192.168.4.1
if ((WifiIsInManagerMode()) && !ValidIpAddress(Webserver->hostHeader().c_str())) { if ((WifiIsInManagerMode()) && !ValidIpAddress(Webserver->hostHeader().c_str())) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_REDIRECTED)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_REDIRECTED));
Webserver->sendHeader(F("Location"), String(F("http://")) + Webserver->client().localIP().toString(), true); Webserver->sendHeader(F("Location"), String(F("http://")) + Webserver->client().localIP().toString(), true);
WSSend(302, CT_PLAIN, ""); // Empty content inhibits Content-length header so we have to close the socket ourselves. WSSend(302, CT_PLAIN, ""); // Empty content inhibits Content-length header so we have to close the socket ourselves.

View File

@ -273,12 +273,12 @@ void MqttRetryCounter(uint8_t value) {
} }
void MqttSubscribe(const char *topic) { void MqttSubscribe(const char *topic) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_SUBSCRIBE_TO " %s"), topic); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_SUBSCRIBE_TO " %s"), topic);
MqttSubscribeLib(topic); MqttSubscribeLib(topic);
} }
void MqttUnsubscribe(const char *topic) { void MqttUnsubscribe(const char *topic) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_UNSUBSCRIBE_FROM " %s"), topic); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_UNSUBSCRIBE_FROM " %s"), topic);
MqttUnsubscribeLib(topic); MqttUnsubscribeLib(topic);
} }
@ -381,7 +381,7 @@ void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic, bool retain
free(mqtt_save); free(mqtt_save);
bool result = MqttClient.publish(romram, TasmotaGlobal.mqtt_data, false); bool result = MqttClient.publish(romram, TasmotaGlobal.mqtt_data, false);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Updated shadow: %s"), romram); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Updated shadow: %s"), romram);
yield(); // #3313 yield(); // #3313
} }
#endif // USE_MQTT_AWS_IOT #endif // USE_MQTT_AWS_IOT
@ -475,7 +475,7 @@ void MqttDisconnected(int state) {
MqttClient.disconnect(); MqttClient.disconnect();
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CONNECT_FAILED_TO " %s:%d, rc %d. " D_RETRY_IN " %d " D_UNIT_SECOND), SettingsText(SET_MQTT_HOST), Settings.mqtt_port, state, Mqtt.retry_counter); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CONNECT_FAILED_TO " %s:%d, rc %d. " D_RETRY_IN " %d " D_UNIT_SECOND), SettingsText(SET_MQTT_HOST), Settings.mqtt_port, state, Mqtt.retry_counter);
TasmotaGlobal.rules_flag.mqtt_disconnected = 1; TasmotaGlobal.rules_flag.mqtt_disconnected = 1;
} }
@ -483,7 +483,7 @@ void MqttConnected(void) {
char stopic[TOPSZ]; char stopic[TOPSZ];
if (Mqtt.allowed) { if (Mqtt.allowed) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CONNECTED)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CONNECTED));
Mqtt.connected = true; Mqtt.connected = true;
Mqtt.retry_counter = 0; Mqtt.retry_counter = 0;
Mqtt.retry_counter_delay = 1; Mqtt.retry_counter_delay = 1;
@ -604,7 +604,7 @@ void MqttReconnect(void) {
#endif #endif
#endif #endif
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_ATTEMPTING_CONNECTION)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_ATTEMPTING_CONNECTION));
char *mqtt_user = nullptr; char *mqtt_user = nullptr;
char *mqtt_pwd = nullptr; char *mqtt_pwd = nullptr;
@ -680,21 +680,21 @@ void MqttReconnect(void) {
#ifdef USE_MQTT_TLS #ifdef USE_MQTT_TLS
if (Mqtt.mqtt_tls) { if (Mqtt.mqtt_tls) {
#ifdef ESP8266 #ifdef ESP8266
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "TLS connected in %d ms, max ThunkStack used %d"), AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "TLS connected in %d ms, max ThunkStack used %d"),
millis() - mqtt_connect_time, tlsClient->getMaxThunkStackUse()); millis() - mqtt_connect_time, tlsClient->getMaxThunkStackUse());
#elif defined(ESP32) #elif defined(ESP32)
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "TLS connected in %d ms, stack low mark %d"), AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "TLS connected in %d ms, stack low mark %d"),
millis() - mqtt_connect_time, uxTaskGetStackHighWaterMark(nullptr)); millis() - mqtt_connect_time, uxTaskGetStackHighWaterMark(nullptr));
#endif #endif
if (!tlsClient->getMFLNStatus()) { if (!tlsClient->getMFLNStatus()) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "MFLN not supported by TLS server")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "MFLN not supported by TLS server"));
} }
#ifndef USE_MQTT_TLS_CA_CERT // don't bother with fingerprints if using CA validation #ifndef USE_MQTT_TLS_CA_CERT // don't bother with fingerprints if using CA validation
const uint8_t *recv_fingerprint = tlsClient->getRecvPubKeyFingerprint(); const uint8_t *recv_fingerprint = tlsClient->getRecvPubKeyFingerprint();
// create a printable version of the fingerprint received // create a printable version of the fingerprint received
char buf_fingerprint[64]; char buf_fingerprint[64];
ToHex_P(recv_fingerprint, 20, buf_fingerprint, sizeof(buf_fingerprint), ' '); ToHex_P(recv_fingerprint, 20, buf_fingerprint, sizeof(buf_fingerprint), ' ');
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Server fingerprint: %s"), buf_fingerprint); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Server fingerprint: %s"), buf_fingerprint);
bool learned = false; bool learned = false;
@ -713,7 +713,7 @@ void MqttReconnect(void) {
} }
if (learned) { if (learned) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "Fingerprint learned: %s"), buf_fingerprint); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "Fingerprint learned: %s"), buf_fingerprint);
SettingsSaveAll(); // save settings SettingsSaveAll(); // save settings
} }
@ -724,7 +724,7 @@ void MqttReconnect(void) {
} else { } else {
#ifdef USE_MQTT_TLS #ifdef USE_MQTT_TLS
if (Mqtt.mqtt_tls) { if (Mqtt.mqtt_tls) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "TLS connection error: %d"), tlsClient->getLastError()); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "TLS connection error: %d"), tlsClient->getLastError());
} }
#endif #endif
MqttDisconnected(MqttClient.state()); // status codes are documented here http://pubsubclient.knolleary.net/api.html#state MqttDisconnected(MqttClient.state()); // status codes are documented here http://pubsubclient.knolleary.net/api.html#state
@ -1128,7 +1128,7 @@ void CmndTlsKey(void) {
// first copy SPI buffer into ram // first copy SPI buffer into ram
uint8_t *spi_buffer = (uint8_t*) malloc(tls_spi_len); uint8_t *spi_buffer = (uint8_t*) malloc(tls_spi_len);
if (!spi_buffer) { if (!spi_buffer) {
AddLog_P(LOG_LEVEL_ERROR, ALLOCATE_ERROR); AddLog(LOG_LEVEL_ERROR, ALLOCATE_ERROR);
return; return;
} }
memcpy_P(spi_buffer, tls_spi_start, tls_spi_len); memcpy_P(spi_buffer, tls_spi_start, tls_spi_len);
@ -1142,7 +1142,7 @@ void CmndTlsKey(void) {
if (bin_len > 0) { if (bin_len > 0) {
bin_buf = (uint8_t*) malloc(bin_len + 4); bin_buf = (uint8_t*) malloc(bin_len + 4);
if (!bin_buf) { if (!bin_buf) {
AddLog_P(LOG_LEVEL_ERROR, ALLOCATE_ERROR); AddLog(LOG_LEVEL_ERROR, ALLOCATE_ERROR);
free(spi_buffer); free(spi_buffer);
return; return;
} }
@ -1163,7 +1163,7 @@ void CmndTlsKey(void) {
if (bin_len > 0) { if (bin_len > 0) {
if (bin_len != 32) { if (bin_len != 32) {
// no private key was previously stored, abort // no private key was previously stored, abort
AddLog_P(LOG_LEVEL_INFO, PSTR("TLSKey: Certificate must be 32 bytes: %d."), bin_len); AddLog(LOG_LEVEL_INFO, PSTR("TLSKey: Certificate must be 32 bytes: %d."), bin_len);
free(spi_buffer); free(spi_buffer);
free(bin_buf); free(bin_buf);
return; return;
@ -1180,14 +1180,14 @@ void CmndTlsKey(void) {
// Try to write Certificate // Try to write Certificate
if (TLS_NAME_SKEY != tls_dir.entry[0].name) { if (TLS_NAME_SKEY != tls_dir.entry[0].name) {
// no private key was previously stored, abort // no private key was previously stored, abort
AddLog_P(LOG_LEVEL_INFO, PSTR("TLSKey: cannot store Cert if no Key previously stored.")); AddLog(LOG_LEVEL_INFO, PSTR("TLSKey: cannot store Cert if no Key previously stored."));
free(spi_buffer); free(spi_buffer);
free(bin_buf); free(bin_buf);
return; return;
} }
if (bin_len <= 256) { if (bin_len <= 256) {
// Certificate lenght too short // Certificate lenght too short
AddLog_P(LOG_LEVEL_INFO, PSTR("TLSKey: Certificate length too short: %d."), bin_len); AddLog(LOG_LEVEL_INFO, PSTR("TLSKey: Certificate length too short: %d."), bin_len);
free(spi_buffer); free(spi_buffer);
free(bin_buf); free(bin_buf);
return; return;
@ -1264,7 +1264,7 @@ void HandleMqttConfiguration(void)
{ {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_MQTT)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_MQTT));
if (Webserver->hasArg(F("save"))) { if (Webserver->hasArg(F("save"))) {
MqttSaveSettings(); MqttSaveSettings();

View File

@ -227,7 +227,7 @@ void EnergyUpdateTotal(float value, bool kwh)
{ {
// char energy_total_chr[FLOATSZ]; // char energy_total_chr[FLOATSZ];
// dtostrfd(value, 4, energy_total_chr); // dtostrfd(value, 4, energy_total_chr);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: Energy Total %s %sWh"), energy_total_chr, (kwh) ? "k" : ""); // AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Energy Total %s %sWh"), energy_total_chr, (kwh) ? "k" : "");
uint32_t multiplier = (kwh) ? 100000 : 100; // kWh or Wh to deca milli Wh uint32_t multiplier = (kwh) ? 100000 : 100; // kWh or Wh to deca milli Wh
@ -244,7 +244,7 @@ void EnergyUpdateTotal(float value, bool kwh)
Settings.energy_kWhtotal = RtcSettings.energy_kWhtotal; Settings.energy_kWhtotal = RtcSettings.energy_kWhtotal;
Energy.total = (float)(RtcSettings.energy_kWhtotal + Energy.kWhtoday_offset + Energy.kWhtoday) / 100000; Energy.total = (float)(RtcSettings.energy_kWhtotal + Energy.kWhtoday_offset + Energy.kWhtoday) / 100000;
Settings.energy_kWhtotal_time = (!Energy.kWhtoday_offset) ? LocalTime() : Midnight(); Settings.energy_kWhtotal_time = (!Energy.kWhtoday_offset) ? LocalTime() : Midnight();
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: Energy Total updated with hardware value")); // AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Energy Total updated with hardware value"));
} }
EnergyUpdateToday(); EnergyUpdateToday();
} }
@ -338,7 +338,7 @@ void EnergyMarginCheck(void)
for (uint32_t phase = 0; phase < Energy.phase_count; phase++) { for (uint32_t phase = 0; phase < Energy.phase_count; phase++) {
uint16_t active_power = (uint16_t)(Energy.active_power[phase]); uint16_t active_power = (uint16_t)(Energy.active_power[phase]);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: APower %d, HPower0 %d, HPower1 %d, HPower2 %d"), active_power, Energy.power_history[phase][0], Energy.power_history[phase][1], Energy.power_history[phase][2]); // AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: APower %d, HPower0 %d, HPower1 %d, HPower2 %d"), active_power, Energy.power_history[phase][0], Energy.power_history[phase][1], Energy.power_history[phase][2]);
if (Settings.energy_power_delta[phase]) { if (Settings.energy_power_delta[phase]) {
power_diff[phase] = active_power - Energy.power_history[phase][0]; power_diff[phase] = active_power - Energy.power_history[phase][0];
@ -509,7 +509,7 @@ void EnergyEverySecond(void)
char temperature[33]; char temperature[33];
dtostrfd(TasmotaGlobal.temperature_celsius, 1, temperature); dtostrfd(TasmotaGlobal.temperature_celsius, 1, temperature);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: GlobTemp %s"), temperature); AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: GlobTemp %s"), temperature);
SetAllPower(POWER_ALL_OFF, SRC_OVERTEMP); SetAllPower(POWER_ALL_OFF, SRC_OVERTEMP);
} }
@ -537,7 +537,7 @@ void EnergyEverySecond(void)
} }
if (!data_valid) { if (!data_valid) {
Energy.start_energy = 0; Energy.start_energy = 0;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: Energy reset by " STR(ENERGY_WATCHDOG) " seconds invalid data")); AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Energy reset by " STR(ENERGY_WATCHDOG) " seconds invalid data"));
XnrgCall(FUNC_ENERGY_RESET); XnrgCall(FUNC_ENERGY_RESET);
} }

View File

@ -324,7 +324,7 @@ class LightStateClass {
public: public:
LightStateClass() { LightStateClass() {
//AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::Constructor RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _bri); //AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::Constructor RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _bri);
} }
void setSubType(uint8_t sub_type) { void setSubType(uint8_t sub_type) {
@ -371,7 +371,7 @@ class LightStateClass {
if (0 == _briCT) { _briCT = maxbri; } if (0 == _briCT) { _briCT = maxbri; }
} }
#ifdef DEBUG_LIGHT #ifdef DEBUG_LIGHT
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setColorMode prev_cm (%d) req_cm (%d) new_cm (%d)", prev_cm, cm, _color_mode); AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setColorMode prev_cm (%d) req_cm (%d) new_cm (%d)", prev_cm, cm, _color_mode);
#endif #endif
return prev_cm; return prev_cm;
} }
@ -484,7 +484,7 @@ class LightStateClass {
setBriRGB(_color_mode & LCM_RGB ? bri : 0); setBriRGB(_color_mode & LCM_RGB ? bri : 0);
setBriCT(_color_mode & LCM_CT ? bri : 0); setBriCT(_color_mode & LCM_CT ? bri : 0);
#ifdef DEBUG_LIGHT #ifdef DEBUG_LIGHT
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setBri RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB); AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setBri RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB);
#endif #endif
} }
@ -530,7 +530,7 @@ class LightStateClass {
addCTMode(); addCTMode();
} }
#ifdef DEBUG_LIGHT #ifdef DEBUG_LIGHT
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setCT RGB raw (%d %d %d) HS (%d %d) briRGB (%d) briCT (%d) CT (%d)", _r, _g, _b, _hue, _sat, _briRGB, _briCT, _ct); AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setCT RGB raw (%d %d %d) HS (%d %d) briRGB (%d) briCT (%d) CT (%d)", _r, _g, _b, _hue, _sat, _briRGB, _briCT, _ct);
#endif #endif
} }
@ -570,7 +570,7 @@ class LightStateClass {
if (_color_mode & LCM_CT) { _briCT = free_range ? max : (sum > 255 ? 255 : sum); } if (_color_mode & LCM_CT) { _briCT = free_range ? max : (sum > 255 ? 255 : sum); }
} }
#ifdef DEBUG_LIGHT #ifdef DEBUG_LIGHT
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setCW CW (%d %d) CT (%d) briCT (%d)", c, w, _ct, _briCT); AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setCW CW (%d %d) CT (%d) briCT (%d)", c, w, _ct, _briCT);
#endif #endif
} }
@ -579,7 +579,7 @@ class LightStateClass {
uint16_t hue; uint16_t hue;
uint8_t sat; uint8_t sat;
#ifdef DEBUG_LIGHT #ifdef DEBUG_LIGHT
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setRGB RGB input (%d %d %d)", r, g, b); AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setRGB RGB input (%d %d %d)", r, g, b);
#endif #endif
uint32_t max = (r > g && r > b) ? r : (g > b) ? g : b; // 0..255 uint32_t max = (r > g && r > b) ? r : (g > b) ? g : b; // 0..255
@ -607,7 +607,7 @@ class LightStateClass {
_hue = hue; _hue = hue;
_sat = sat; _sat = sat;
#ifdef DEBUG_LIGHT #ifdef DEBUG_LIGHT
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setRGB RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB); AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setRGB RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB);
#endif #endif
return max; return max;
} }
@ -622,8 +622,8 @@ class LightStateClass {
_sat = sat; _sat = sat;
addRGBMode(); addRGBMode();
#ifdef DEBUG_LIGHT #ifdef DEBUG_LIGHT
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setHS HS (%d %d) rgb (%d %d %d)", hue, sat, r, g, b); AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setHS HS (%d %d) rgb (%d %d %d)", hue, sat, r, g, b);
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setHS RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB); AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setHS RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB);
#endif #endif
} }
@ -644,10 +644,10 @@ class LightStateClass {
setRGB(channels[0], channels[1], channels[2]); setRGB(channels[0], channels[1], channels[2]);
setCW(channels[3], channels[4], true); // free range for WC and WW setCW(channels[3], channels[4], true); // free range for WC and WW
#ifdef DEBUG_LIGHT #ifdef DEBUG_LIGHT
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels (%d %d %d %d %d)", AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels (%d %d %d %d %d)",
channels[0], channels[1], channels[2], channels[3], channels[4]); channels[0], channels[1], channels[2], channels[3], channels[4]);
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels CT (%d) briRGB (%d) briCT (%d)", _ct, _briRGB, _briCT); AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels CT (%d) briRGB (%d) briCT (%d)", _ct, _briRGB, _briCT);
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels Actuals (%d %d %d %d %d)", AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels Actuals (%d %d %d %d %d)",
_r, _g, _b, _wc, _ww); _r, _g, _b, _wc, _ww);
#endif #endif
} }
@ -704,9 +704,9 @@ public:
void debugLogs() { void debugLogs() {
uint8_t r,g,b,c,w; uint8_t r,g,b,c,w;
_state->getActualRGBCW(&r,&g,&b,&c,&w); _state->getActualRGBCW(&r,&g,&b,&c,&w);
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::debugLogs rgb (%d %d %d) cw (%d %d)", AddLog(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::debugLogs rgb (%d %d %d) cw (%d %d)",
r, g, b, c, w); r, g, b, c, w);
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::debugLogs lightCurrent (%d %d %d %d %d)", AddLog(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::debugLogs lightCurrent (%d %d %d %d %d)",
Light.current_color[0], Light.current_color[1], Light.current_color[2], Light.current_color[0], Light.current_color[1], Light.current_color[2],
Light.current_color[3], Light.current_color[4]); Light.current_color[3], Light.current_color[4]);
} }
@ -714,10 +714,10 @@ public:
void loadSettings() { void loadSettings() {
#ifdef DEBUG_LIGHT #ifdef DEBUG_LIGHT
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::loadSettings Settings.light_color (%d %d %d %d %d - %d)", AddLog(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::loadSettings Settings.light_color (%d %d %d %d %d - %d)",
Settings.light_color[0], Settings.light_color[1], Settings.light_color[2], Settings.light_color[0], Settings.light_color[1], Settings.light_color[2],
Settings.light_color[3], Settings.light_color[4], Settings.light_dimmer); Settings.light_color[3], Settings.light_color[4], Settings.light_dimmer);
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::loadSettings light_type/sub (%d %d)", AddLog(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::loadSettings light_type/sub (%d %d)",
TasmotaGlobal.light_type, Light.subtype); TasmotaGlobal.light_type, Light.subtype);
#endif #endif
if (_pwm_multi_channels) { if (_pwm_multi_channels) {
@ -892,7 +892,7 @@ public:
} }
} }
#ifdef DEBUG_LIGHT #ifdef DEBUG_LIGHT
AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::saveSettings Settings.light_color (%d %d %d %d %d - %d)", AddLog(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::saveSettings Settings.light_color (%d %d %d %d %d - %d)",
Settings.light_color[0], Settings.light_color[1], Settings.light_color[2], Settings.light_color[0], Settings.light_color[1], Settings.light_color[2],
Settings.light_color[3], Settings.light_color[4], Settings.light_dimmer); Settings.light_color[3], Settings.light_color[4], Settings.light_dimmer);
#endif #endif
@ -1074,7 +1074,7 @@ void LightCalcPWMRange(void) {
Light.pwm_min = pwm_min; Light.pwm_min = pwm_min;
Light.pwm_max = pwm_max; Light.pwm_max = pwm_max;
//AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("LightCalcPWMRange %d %d - %d %d"), Settings.dimmer_hw_min, Settings.dimmer_hw_max, Light.pwm_min, Light.pwm_max); //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("LightCalcPWMRange %d %d - %d %d"), Settings.dimmer_hw_min, Settings.dimmer_hw_max, Light.pwm_min, Light.pwm_max);
} }
void LightInit(void) void LightInit(void)
@ -1189,7 +1189,7 @@ void LightUpdateColorMapping(void)
Light.color_remap[4] = tmp[1-param]; Light.color_remap[4] = tmp[1-param];
Light.update = true; Light.update = true;
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("%d colors: %d %d %d %d %d") ,Settings.param[P_RGB_REMAP], Light.color_remap[0],Light.color_remap[1],Light.color_remap[2],Light.color_remap[3],Light.color_remap[4]); //AddLog(LOG_LEVEL_DEBUG, PSTR("%d colors: %d %d %d %d %d") ,Settings.param[P_RGB_REMAP], Light.color_remap[0],Light.color_remap[1],Light.color_remap[2],Light.color_remap[3],Light.color_remap[4]);
} }
uint8_t LightGetDimmer(uint8_t dimmer) { uint8_t LightGetDimmer(uint8_t dimmer) {
@ -1306,7 +1306,7 @@ void LightSetSignal(uint16_t lo, uint16_t hi, uint16_t value)
*/ */
if (Settings.flag.light_signal) { // SetOption18 - Pair light signal with CO2 sensor if (Settings.flag.light_signal) { // SetOption18 - Pair light signal with CO2 sensor
uint16_t signal = changeUIntScale(value, lo, hi, 0, 255); // 0..255 uint16_t signal = changeUIntScale(value, lo, hi, 0, 255); // 0..255
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Light signal %d"), signal); // AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Light signal %d"), signal);
light_controller.changeRGB(signal, 255 - signal, 0, true); // keep bri light_controller.changeRGB(signal, 255 - signal, 0, true); // keep bri
Settings.light_scheme = 0; Settings.light_scheme = 0;
if (0 == light_state.getBri()) { if (0 == light_state.getBri()) {
@ -1423,7 +1423,7 @@ void ResponseLightState(uint8_t append)
void LightPreparePower(power_t channels = 0xFFFFFFFF) { // 1 = only RGB, 2 = only CT, 3 = both RGB and CT void LightPreparePower(power_t channels = 0xFFFFFFFF) { // 1 = only RGB, 2 = only CT, 3 = both RGB and CT
#ifdef DEBUG_LIGHT #ifdef DEBUG_LIGHT
AddLog_P(LOG_LEVEL_DEBUG, "LightPreparePower power=%d Light.power=%d", TasmotaGlobal.power, Light.power); AddLog(LOG_LEVEL_DEBUG, "LightPreparePower power=%d Light.power=%d", TasmotaGlobal.power, Light.power);
#endif #endif
// If multi-channels, then we only switch off channels with a value of zero // If multi-channels, then we only switch off channels with a value of zero
if (Light.pwm_multi_channels) { if (Light.pwm_multi_channels) {
@ -1486,7 +1486,7 @@ void LightPreparePower(power_t channels = 0xFFFFFFFF) { // 1 = only RGB, 2 =
} }
#ifdef DEBUG_LIGHT #ifdef DEBUG_LIGHT
AddLog_P(LOG_LEVEL_DEBUG, "LightPreparePower End power=%d Light.power=%d", TasmotaGlobal.power, Light.power); AddLog(LOG_LEVEL_DEBUG, "LightPreparePower End power=%d Light.power=%d", TasmotaGlobal.power, Light.power);
#endif #endif
Light.power = TasmotaGlobal.power >> (Light.device - 1); // reset next state, works also with unlinked RGB/CT Light.power = TasmotaGlobal.power >> (Light.device - 1); // reset next state, works also with unlinked RGB/CT
ResponseLightState(0); ResponseLightState(0);
@ -1543,7 +1543,7 @@ void LightCycleColor(int8_t direction)
(Light.random > Light.wheel +128) ? 0 : 1; // Increment or Decrement and roll-over (Light.random > Light.wheel +128) ? 0 : 1; // Increment or Decrement and roll-over
Light.random = (Light.random & 0xFE) | my_dir; Light.random = (Light.random & 0xFE) | my_dir;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: random %d"), Light.random); // AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: random %d"), Light.random);
} }
// direction = (Light.random < Light.wheel) ? -1 : 1; // direction = (Light.random < Light.wheel) ? -1 : 1;
direction = (Light.random &0x01) ? 1 : -1; direction = (Light.random &0x01) ? 1 : -1;
@ -1554,7 +1554,7 @@ void LightCycleColor(int8_t direction)
Light.wheel += direction; Light.wheel += direction;
uint16_t hue = changeUIntScale(Light.wheel, 0, 255, 0, 359); // Scale to hue to keep amount of steps low (max 255 instead of 359) uint16_t hue = changeUIntScale(Light.wheel, 0, 255, 0, 359); // Scale to hue to keep amount of steps low (max 255 instead of 359)
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: random %d, wheel %d, hue %d"), Light.random, Light.wheel, hue); // AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: random %d, wheel %d, hue %d"), Light.random, Light.wheel, hue);
if (!Light.pwm_multi_channels) { if (!Light.pwm_multi_channels) {
uint8_t sat; uint8_t sat;

View File

@ -132,7 +132,7 @@ void RgbToHsb(uint8_t ir, uint8_t ig, uint8_t ib, uint16_t *r_hue, uint8_t *r_sa
if (r_hue) *r_hue = hue; if (r_hue) *r_hue = hue;
if (r_sat) *r_sat = sat; if (r_sat) *r_sat = sat;
if (r_bri) *r_bri = bri; if (r_bri) *r_bri = bri;
//AddLog_P(LOG_LEVEL_DEBUG_MORE, "RgbToHsb rgb (%d %d %d) hsb (%d %d %d)", r, g, b, hue, sat, bri); //AddLog(LOG_LEVEL_DEBUG_MORE, "RgbToHsb rgb (%d %d %d) hsb (%d %d %d)", r, g, b, hue, sat, bri);
} }
void HsToRgb(uint16_t hue, uint8_t sat, uint8_t *r_r, uint8_t *r_g, uint8_t *r_b) { void HsToRgb(uint16_t hue, uint8_t sat, uint8_t *r_r, uint8_t *r_g, uint8_t *r_b) {

View File

@ -190,7 +190,7 @@ void IrReceiveCheck(void)
Uint64toHex(results.value, hvalue, 32); // UNKNOWN is always 32 bits hash Uint64toHex(results.value, hvalue, 32); // UNKNOWN is always 32 bits hash
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_IRR "RawLen %d, Overflow %d, Bits %d, Value 0x%s, Decode %d"), AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_IRR "RawLen %d, Overflow %d, Bits %d, Value 0x%s, Decode %d"),
results.rawlen, results.overflow, results.bits, hvalue, results.decode_type); results.rawlen, results.overflow, results.bits, hvalue, results.decode_type);
unsigned long now = millis(); unsigned long now = millis();

View File

@ -219,7 +219,7 @@ bool DomoticzMqttData(void) {
uint32_t idx = domoticz.getUInt(PSTR("idx"), 0); uint32_t idx = domoticz.getUInt(PSTR("idx"), 0);
int16_t nvalue = domoticz.getInt(PSTR("nvalue"), -1); int16_t nvalue = domoticz.getInt(PSTR("nvalue"), -1);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ "idx %d, nvalue %d"), idx, nvalue); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ "idx %d, nvalue %d"), idx, nvalue);
bool found = false; bool found = false;
if ((idx > 0) && (nvalue >= 0) && (nvalue <= 15)) { if ((idx > 0) && (nvalue >= 0) && (nvalue <= 15)) {
@ -544,7 +544,7 @@ const char HTTP_FORM_DOMOTICZ_TIMER[] PROGMEM =
void HandleDomoticzConfiguration(void) { void HandleDomoticzConfiguration(void) {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_DOMOTICZ)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_DOMOTICZ));
if (Webserver->hasArg(F("save"))) { if (Webserver->hasArg(F("save"))) {
DomoticzSaveSettings(); DomoticzSaveSettings();

View File

@ -839,7 +839,7 @@ void HandleTimerConfiguration(void)
{ {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_TIMER)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_TIMER));
if (Webserver->hasArg(F("save"))) { if (Webserver->hasArg(F("save"))) {
TimerSaveSettings(); TimerSaveSettings();

View File

@ -358,7 +358,7 @@ int32_t SetRule(uint32_t idx, const char *content, bool append = false) {
len_uncompressed = strlen(Settings.rules[idx]); len_uncompressed = strlen(Settings.rules[idx]);
len_compressed = compressor.unishox_compress(Settings.rules[idx], len_uncompressed, nullptr /* dry-run */, MAX_RULE_SIZE + 8); len_compressed = compressor.unishox_compress(Settings.rules[idx], len_uncompressed, nullptr /* dry-run */, MAX_RULE_SIZE + 8);
AddLog_P(LOG_LEVEL_INFO, PSTR("RUL: Stored uncompressed, would compress from %d to %d (-%d%%)"), len_uncompressed, len_compressed, 100 - changeUIntScale(len_compressed, 0, len_uncompressed, 0, 100)); AddLog(LOG_LEVEL_INFO, PSTR("RUL: Stored uncompressed, would compress from %d to %d (-%d%%)"), len_uncompressed, len_compressed, 100 - changeUIntScale(len_compressed, 0, len_uncompressed, 0, 100));
} }
#endif // USE_UNISHOX_COMPRESSION #endif // USE_UNISHOX_COMPRESSION
@ -387,7 +387,7 @@ int32_t SetRule(uint32_t idx, const char *content, bool append = false) {
Settings.rules[idx][1] = (len_in + 7) / 8; // store original length in first bytes (4 bytes chuks) Settings.rules[idx][1] = (len_in + 7) / 8; // store original length in first bytes (4 bytes chuks)
memcpy(&Settings.rules[idx][2], buf_out, len_compressed); memcpy(&Settings.rules[idx][2], buf_out, len_compressed);
Settings.rules[idx][len_compressed + 2] = 0; // add NULL termination Settings.rules[idx][len_compressed + 2] = 0; // add NULL termination
AddLog_P(LOG_LEVEL_INFO, PSTR("RUL: Compressed from %d to %d (-%d%%)"), len_in, len_compressed, 100 - changeUIntScale(len_compressed, 0, len_in, 0, 100)); AddLog(LOG_LEVEL_INFO, PSTR("RUL: Compressed from %d to %d (-%d%%)"), len_in, len_compressed, 100 - changeUIntScale(len_compressed, 0, len_in, 0, 100));
// AddLog_P(LOG_LEVEL_INFO, PSTR("RUL: First bytes: %02X%02X%02X%02X"), Settings.rules[idx][0], Settings.rules[idx][1], Settings.rules[idx][2], Settings.rules[idx][3]); // AddLog_P(LOG_LEVEL_INFO, PSTR("RUL: First bytes: %02X%02X%02X%02X"), Settings.rules[idx][0], Settings.rules[idx][1], Settings.rules[idx][2], Settings.rules[idx][3]);
// AddLog_P(LOG_LEVEL_INFO, PSTR("RUL: GetRuleLenStorage = %d"), GetRuleLenStorage(idx)); // AddLog_P(LOG_LEVEL_INFO, PSTR("RUL: GetRuleLenStorage = %d"), GetRuleLenStorage(idx));
} else { } else {
@ -2103,7 +2103,7 @@ void CmndRule(void)
} }
int32_t res = SetRule(index - 1, ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data, append); int32_t res = SetRule(index - 1, ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data, append);
if (res < 0) { if (res < 0) {
AddLog_P(LOG_LEVEL_ERROR, PSTR("RUL: Not enough space")); AddLog(LOG_LEVEL_ERROR, PSTR("RUL: Not enough space"));
} }
} }
Rules.triggers[index -1] = 0; // Reset once flag Rules.triggers[index -1] = 0; // Reset once flag

View File

@ -1025,7 +1025,7 @@ void HAssAnnounceDeviceInfoAndStatusSensor(void)
if (!Settings.flag.hass_discovery) { if (!Settings.flag.hass_discovery) {
TasmotaGlobal.masterlog_level = 0; TasmotaGlobal.masterlog_level = 0;
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_LOG "Home Assistant MQTT Discovery disabled.")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_LOG "Home Assistant MQTT Discovery disabled."));
} }
} }

View File

@ -1289,7 +1289,7 @@ void DisplayInitDriver(void)
} }
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model); // AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model);
if (Settings.display_model) { if (Settings.display_model) {
TasmotaGlobal.devices_present++; TasmotaGlobal.devices_present++;
@ -1312,7 +1312,7 @@ void DisplaySetPower(void)
{ {
disp_power = bitRead(XdrvMailbox.index, disp_device -1); disp_power = bitRead(XdrvMailbox.index, disp_device -1);
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("DSP: Power %d"), disp_power); //AddLog(LOG_LEVEL_DEBUG, PSTR("DSP: Power %d"), disp_power);
if (Settings.display_model) { if (Settings.display_model) {
if (!renderer) { if (!renderer) {
@ -2176,7 +2176,7 @@ uint8_t vbutt=0;
if (!(tbstate[tbut] & 1)) { if (!(tbstate[tbut] & 1)) {
// pressed // pressed
tbstate[tbut] |= 1; tbstate[tbut] |= 1;
//AddLog_P(LOG_LEVEL_INFO, PSTR("tbut: %d pressed"), tbut); //AddLog(LOG_LEVEL_INFO, PSTR("tbut: %d pressed"), tbut);
Touch_MQTT(tbut, "BIB", tbstate[tbut] & 1); Touch_MQTT(tbut, "BIB", tbstate[tbut] & 1);
} }
} }
@ -2186,7 +2186,7 @@ uint8_t vbutt=0;
rotconvert(&pLoc.x, &pLoc.y); rotconvert(&pLoc.x, &pLoc.y);
//AddLog_P(LOG_LEVEL_INFO, PSTR("touch %d - %d"), pLoc.x, pLoc.y); //AddLog(LOG_LEVEL_INFO, PSTR("touch %d - %d"), pLoc.x, pLoc.y);
// now must compare with defined buttons // now must compare with defined buttons
for (uint8_t count=0; count<MAX_TOUCH_BUTTONS; count++) { for (uint8_t count=0; count<MAX_TOUCH_BUTTONS; count++) {
if (buttons[count] && !buttons[count]->vpower.disable) { if (buttons[count] && !buttons[count]->vpower.disable) {
@ -2233,7 +2233,7 @@ uint8_t vbutt=0;
// released // released
tbstate[tbut] &= 0xfe; tbstate[tbut] &= 0xfe;
Touch_MQTT(tbut, "BIB", tbstate[tbut] & 1); Touch_MQTT(tbut, "BIB", tbstate[tbut] & 1);
//AddLog_P(LOG_LEVEL_INFO, PSTR("tbut: %d released"), tbut); //AddLog(LOG_LEVEL_INFO, PSTR("tbut: %d released"), tbut);
} }
} }
#endif #endif

View File

@ -148,7 +148,7 @@ void CmndTuyaSend(void) {
TuyaRequestState(8); TuyaRequestState(8);
} else if (XdrvMailbox.index == 9) { // TuyaSend Topic Toggle } else if (XdrvMailbox.index == 9) { // TuyaSend Topic Toggle
Settings.tuyamcu_topic = !Settings.tuyamcu_topic; Settings.tuyamcu_topic = !Settings.tuyamcu_topic;
AddLog_P(LOG_LEVEL_INFO, PSTR("TYA: TuyaMCU Stat Topic %s"), (Settings.tuyamcu_topic ? PSTR("enabled") : PSTR("disabled"))); AddLog(LOG_LEVEL_INFO, PSTR("TYA: TuyaMCU Stat Topic %s"), (Settings.tuyamcu_topic ? PSTR("enabled") : PSTR("disabled")));
} else { } else {
if (XdrvMailbox.data_len > 0) { if (XdrvMailbox.data_len > 0) {
@ -207,7 +207,7 @@ void CmndTuyaMcu(void) {
TuyaAddMcuFunc(parm[0], parm[1]); TuyaAddMcuFunc(parm[0], parm[1]);
TasmotaGlobal.restart_flag = 2; TasmotaGlobal.restart_flag = 2;
} else { } else {
AddLog_P(LOG_LEVEL_ERROR, PSTR("TYA: TuyaMcu Invalid function id=%d"), parm[0]); AddLog(LOG_LEVEL_ERROR, PSTR("TYA: TuyaMcu Invalid function id=%d"), parm[0]);
} }
} }
@ -626,9 +626,9 @@ void LightSerialDuty(uint16_t duty, char *hex_char, uint8_t TuyaIdx)
} else { } else {
duty = changeUIntScale(duty, 0, 100, 0, Settings.dimmer_hw_max); duty = changeUIntScale(duty, 0, 100, 0, Settings.dimmer_hw_max);
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Send dim skipped value %d for dpid %d"), duty, dpid); // due to 0 or already set AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Send dim skipped value %d for dpid %d"), duty, dpid); // due to 0 or already set
} else { } else {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Cannot set dimmer. Dimmer Id unknown")); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Cannot set dimmer. Dimmer Id unknown"));
} }
} }
@ -638,7 +638,7 @@ void LightSerialDuty(uint16_t duty, char *hex_char, uint8_t TuyaIdx)
TuyaSendEnum(TuyaGetDpId(TUYA_MCU_FUNC_MODESET), 1); TuyaSendEnum(TuyaGetDpId(TUYA_MCU_FUNC_MODESET), 1);
} }
TuyaSendString(dpid, hex_char); TuyaSendString(dpid, hex_char);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: TX RGB hex %s to dpId %d"), hex_char, dpid); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: TX RGB hex %s to dpId %d"), hex_char, dpid);
} }
} }
@ -646,7 +646,7 @@ void TuyaRequestState(uint8_t state_type)
{ {
if (TuyaSerial) { if (TuyaSerial) {
// Get current status of MCU // Get current status of MCU
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Read MCU state")); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Read MCU state"));
Tuya.SuspendTopic = true; Tuya.SuspendTopic = true;
Tuya.ignore_topic_timeout = millis() + 1000; // suppress /STAT topic for 1000ms to limit data Tuya.ignore_topic_timeout = millis() + 1000; // suppress /STAT topic for 1000ms to limit data
switch (state_type) { switch (state_type) {
@ -680,23 +680,23 @@ void TuyaProcessStatePacket(void) {
dpDataLen = Tuya.buffer[dpidStart + 2] << 8 | Tuya.buffer[dpidStart + 3]; dpDataLen = Tuya.buffer[dpidStart + 2] << 8 | Tuya.buffer[dpidStart + 3];
fnId = TuyaGetFuncId(Tuya.buffer[dpidStart]); fnId = TuyaGetFuncId(Tuya.buffer[dpidStart]);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: fnId=%d is set for dpId=%d"), fnId, Tuya.buffer[dpidStart]); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: fnId=%d is set for dpId=%d"), fnId, Tuya.buffer[dpidStart]);
if (Tuya.buffer[dpidStart + 1] == 1) { // Data Type 1 if (Tuya.buffer[dpidStart + 1] == 1) { // Data Type 1
if (fnId >= TUYA_MCU_FUNC_REL1 && fnId <= TUYA_MCU_FUNC_REL8) { if (fnId >= TUYA_MCU_FUNC_REL1 && fnId <= TUYA_MCU_FUNC_REL8) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX Relay-%d --> MCU State: %s Current State:%s"), fnId - TUYA_MCU_FUNC_REL1 + 1, Tuya.buffer[dpidStart + 4]?"On":"Off",bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1)?"On":"Off"); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX Relay-%d --> MCU State: %s Current State:%s"), fnId - TUYA_MCU_FUNC_REL1 + 1, Tuya.buffer[dpidStart + 4]?"On":"Off",bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1)?"On":"Off");
if ((TasmotaGlobal.power || Settings.light_dimmer > 0) && (Tuya.buffer[dpidStart + 4] != bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1))) { if ((TasmotaGlobal.power || Settings.light_dimmer > 0) && (Tuya.buffer[dpidStart + 4] != bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1))) {
if (!Tuya.buffer[dpidStart + 4]) { PowerOff = true; } if (!Tuya.buffer[dpidStart + 4]) { PowerOff = true; }
ExecuteCommandPower(fnId - TUYA_MCU_FUNC_REL1 + 1, Tuya.buffer[dpidStart + 4], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction ExecuteCommandPower(fnId - TUYA_MCU_FUNC_REL1 + 1, Tuya.buffer[dpidStart + 4], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
} }
} else if (fnId >= TUYA_MCU_FUNC_REL1_INV && fnId <= TUYA_MCU_FUNC_REL8_INV) { } else if (fnId >= TUYA_MCU_FUNC_REL1_INV && fnId <= TUYA_MCU_FUNC_REL8_INV) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX Relay-%d-Inverted --> MCU State: %s Current State:%s"), fnId - TUYA_MCU_FUNC_REL1_INV + 1, Tuya.buffer[dpidStart + 4]?"Off":"On",bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1_INV) ^ 1?"Off":"On"); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX Relay-%d-Inverted --> MCU State: %s Current State:%s"), fnId - TUYA_MCU_FUNC_REL1_INV + 1, Tuya.buffer[dpidStart + 4]?"Off":"On",bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1_INV) ^ 1?"Off":"On");
if (Tuya.buffer[dpidStart + 4] != bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1_INV) ^ 1) { if (Tuya.buffer[dpidStart + 4] != bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1_INV) ^ 1) {
ExecuteCommandPower(fnId - TUYA_MCU_FUNC_REL1_INV + 1, Tuya.buffer[dpidStart + 4] ^ 1, SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction ExecuteCommandPower(fnId - TUYA_MCU_FUNC_REL1_INV + 1, Tuya.buffer[dpidStart + 4] ^ 1, SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
if (Tuya.buffer[dpidStart + 4]) { PowerOff = true; } if (Tuya.buffer[dpidStart + 4]) { PowerOff = true; }
} }
} else if (fnId >= TUYA_MCU_FUNC_SWT1 && fnId <= TUYA_MCU_FUNC_SWT4) { } else if (fnId >= TUYA_MCU_FUNC_SWT1 && fnId <= TUYA_MCU_FUNC_SWT4) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX Switch-%d --> MCU State: %d Current State:%d"),fnId - TUYA_MCU_FUNC_SWT1 + 1,Tuya.buffer[dpidStart + 4], SwitchGetVirtual(fnId - TUYA_MCU_FUNC_SWT1)); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX Switch-%d --> MCU State: %d Current State:%d"),fnId - TUYA_MCU_FUNC_SWT1 + 1,Tuya.buffer[dpidStart + 4], SwitchGetVirtual(fnId - TUYA_MCU_FUNC_SWT1));
if (SwitchGetVirtual(fnId - TUYA_MCU_FUNC_SWT1) != Tuya.buffer[dpidStart + 4]) { if (SwitchGetVirtual(fnId - TUYA_MCU_FUNC_SWT1) != Tuya.buffer[dpidStart + 4]) {
SwitchSetVirtual(fnId - TUYA_MCU_FUNC_SWT1, Tuya.buffer[dpidStart + 4]); SwitchSetVirtual(fnId - TUYA_MCU_FUNC_SWT1, Tuya.buffer[dpidStart + 4]);
@ -747,7 +747,7 @@ void TuyaProcessStatePacket(void) {
Tuya.Levels[dimIndex] = changeUIntScale(packetValue, 0, Settings.dimmer_hw_max, 0, 100); Tuya.Levels[dimIndex] = changeUIntScale(packetValue, 0, Settings.dimmer_hw_max, 0, 100);
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX value %d from dpId %d "), packetValue, Tuya.buffer[dpidStart]); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX value %d from dpId %d "), packetValue, Tuya.buffer[dpidStart]);
if ((fnId == TUYA_MCU_FUNC_DIMMER) || (fnId == TUYA_MCU_FUNC_REPORT1) || if ((fnId == TUYA_MCU_FUNC_DIMMER) || (fnId == TUYA_MCU_FUNC_REPORT1) ||
(fnId == TUYA_MCU_FUNC_DIMMER2) || (fnId == TUYA_MCU_FUNC_REPORT2) || (fnId == TUYA_MCU_FUNC_DIMMER2) || (fnId == TUYA_MCU_FUNC_REPORT2) ||
@ -787,13 +787,13 @@ void TuyaProcessStatePacket(void) {
#ifdef USE_ENERGY_SENSOR #ifdef USE_ENERGY_SENSOR
else if (tuya_energy_enabled && fnId == TUYA_MCU_FUNC_VOLTAGE) { else if (tuya_energy_enabled && fnId == TUYA_MCU_FUNC_VOLTAGE) {
Energy.voltage[0] = (float)packetValue / 10; Energy.voltage[0] = (float)packetValue / 10;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Voltage=%d"), Tuya.buffer[dpidStart], packetValue); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Voltage=%d"), Tuya.buffer[dpidStart], packetValue);
} else if (tuya_energy_enabled && fnId == TUYA_MCU_FUNC_CURRENT) { } else if (tuya_energy_enabled && fnId == TUYA_MCU_FUNC_CURRENT) {
Energy.current[0] = (float)packetValue / 1000; Energy.current[0] = (float)packetValue / 1000;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Current=%d"), Tuya.buffer[dpidStart], packetValue); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Current=%d"), Tuya.buffer[dpidStart], packetValue);
} else if (tuya_energy_enabled && fnId == TUYA_MCU_FUNC_POWER) { } else if (tuya_energy_enabled && fnId == TUYA_MCU_FUNC_POWER) {
Energy.active_power[0] = (float)packetValue / 10; Energy.active_power[0] = (float)packetValue / 10;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Active_Power=%d"), Tuya.buffer[dpidStart], packetValue); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Active_Power=%d"), Tuya.buffer[dpidStart], packetValue);
if (RtcTime.valid) { if (RtcTime.valid) {
if (Tuya.lastPowerCheckTime != 0 && Energy.active_power[0] > 0) { if (Tuya.lastPowerCheckTime != 0 && Energy.active_power[0] > 0) {
@ -882,7 +882,7 @@ void TuyaLowPowerModePacketProcess(void) {
void TuyaHandleProductInfoPacket(void) { void TuyaHandleProductInfoPacket(void) {
uint16_t dataLength = Tuya.buffer[4] << 8 | Tuya.buffer[5]; uint16_t dataLength = Tuya.buffer[4] << 8 | Tuya.buffer[5];
char *data = &Tuya.buffer[6]; char *data = &Tuya.buffer[6];
AddLog_P(LOG_LEVEL_INFO, PSTR("TYA: MCU Product ID: %.*s"), dataLength, data); AddLog(LOG_LEVEL_INFO, PSTR("TYA: MCU Product ID: %.*s"), dataLength, data);
} }
void TuyaSendLowPowerSuccessIfNeeded(void) { void TuyaSendLowPowerSuccessIfNeeded(void) {
@ -903,9 +903,9 @@ void TuyaNormalPowerModePacketProcess(void)
break; break;
case TUYA_CMD_HEARTBEAT: case TUYA_CMD_HEARTBEAT:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Heartbeat")); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Heartbeat"));
if (Tuya.buffer[6] == 0) { if (Tuya.buffer[6] == 0) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Detected MCU restart")); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Detected MCU restart"));
Tuya.wifi_state = -2; Tuya.wifi_state = -2;
} }
break; break;
@ -916,17 +916,17 @@ void TuyaNormalPowerModePacketProcess(void)
case TUYA_CMD_WIFI_RESET: case TUYA_CMD_WIFI_RESET:
case TUYA_CMD_WIFI_SELECT: case TUYA_CMD_WIFI_SELECT:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX WiFi Reset")); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX WiFi Reset"));
TuyaResetWifi(); TuyaResetWifi();
break; break;
case TUYA_CMD_WIFI_STATE: case TUYA_CMD_WIFI_STATE:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX WiFi LED set ACK")); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX WiFi LED set ACK"));
Tuya.wifi_state = TuyaGetTuyaWifiState(); Tuya.wifi_state = TuyaGetTuyaWifiState();
break; break;
case TUYA_CMD_MCU_CONF: case TUYA_CMD_MCU_CONF:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX MCU configuration Mode=%d"), Tuya.buffer[5]); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX MCU configuration Mode=%d"), Tuya.buffer[5]);
if (Tuya.buffer[5] == 2) { // Processing by ESP module mode if (Tuya.buffer[5] == 2) { // Processing by ESP module mode
uint8_t led1_gpio = Tuya.buffer[6]; uint8_t led1_gpio = Tuya.buffer[6];
@ -954,7 +954,7 @@ void TuyaNormalPowerModePacketProcess(void)
break; break;
#endif #endif
default: default:
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX unknown command")); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX unknown command"));
} }
} }
@ -1039,7 +1039,7 @@ void TuyaInit(void)
// Get MCU Configuration // Get MCU Configuration
Tuya.SuspendTopic = true; Tuya.SuspendTopic = true;
Tuya.ignore_topic_timeout = millis() + 1000; // suppress /STAT topic for 1000ms to avoid data overflow Tuya.ignore_topic_timeout = millis() + 1000; // suppress /STAT topic for 1000ms to avoid data overflow
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Request MCU configuration at %d bps"), baudrate); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Request MCU configuration at %d bps"), baudrate);
} }
@ -1175,7 +1175,7 @@ void TuyaSerialInput(void)
bool TuyaButtonPressed(void) bool TuyaButtonPressed(void)
{ {
if (!XdrvMailbox.index && ((PRESSED == XdrvMailbox.payload) && (NOT_PRESSED == Button.last_state[XdrvMailbox.index]))) { if (!XdrvMailbox.index && ((PRESSED == XdrvMailbox.payload) && (NOT_PRESSED == Button.last_state[XdrvMailbox.index]))) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Reset GPIO triggered")); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Reset GPIO triggered"));
TuyaResetWifi(); TuyaResetWifi();
return true; // Reset GPIO served here return true; // Reset GPIO served here
} }
@ -1204,7 +1204,7 @@ uint8_t TuyaGetTuyaWifiState(void) {
void TuyaSetWifiLed(void) void TuyaSetWifiLed(void)
{ {
Tuya.wifi_state = TuyaGetTuyaWifiState(); Tuya.wifi_state = TuyaGetTuyaWifiState();
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Set WiFi LED %d (%d)"), Tuya.wifi_state, WifiState()); AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Set WiFi LED %d (%d)"), Tuya.wifi_state, WifiState());
if (Tuya.low_power_mode) { if (Tuya.low_power_mode) {
TuyaSendCmd(TUYA_LOW_POWER_CMD_WIFI_STATE, &Tuya.wifi_state, 1); TuyaSendCmd(TUYA_LOW_POWER_CMD_WIFI_STATE, &Tuya.wifi_state, 1);

View File

@ -56,7 +56,7 @@ void RfReceiveCheck(void) {
int protocol = mySwitch.getReceivedProtocol(); int protocol = mySwitch.getReceivedProtocol();
int delay = mySwitch.getReceivedDelay(); int delay = mySwitch.getReceivedDelay();
AddLog_P(LOG_LEVEL_DEBUG, PSTR("RFR: Data 0x%lX (%u), Bits %d, Protocol %d, Delay %d"), data, data, bits, protocol, delay); AddLog(LOG_LEVEL_DEBUG, PSTR("RFR: Data 0x%lX (%u), Bits %d, Protocol %d, Delay %d"), data, data, bits, protocol, delay);
uint32_t now = millis(); uint32_t now = millis();
if ((now - rf_lasttime > RF_TIME_AVOID_DUPLICATE) && (data > 0)) { if ((now - rf_lasttime > RF_TIME_AVOID_DUPLICATE) && (data > 0)) {
@ -130,7 +130,7 @@ void CmndRfProtocol(void) {
} }
} }
mySwitch.setReceiveProtocolMask(Settings.rf_protocol_mask); mySwitch.setReceiveProtocolMask(Settings.rf_protocol_mask);
// AddLog_P(LOG_LEVEL_INFO, PSTR("RFR: CmndRfProtocol:: Start responce")); // AddLog(LOG_LEVEL_INFO, PSTR("RFR: CmndRfProtocol:: Start responce"));
Response_P(PSTR("{\"" D_CMND_RFPROTOCOL "\":\"")); Response_P(PSTR("{\"" D_CMND_RFPROTOCOL "\":\""));
bool gotone = false; bool gotone = false;
thisdat = 1; thisdat = 1;

View File

@ -61,11 +61,11 @@ void LightSerial2Duty(uint8_t duty1, uint8_t duty2)
ArmtronixSerial->print("\nDimmer2:"); ArmtronixSerial->print("\nDimmer2:");
ArmtronixSerial->println(duty2); ArmtronixSerial->println(duty2);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ARM: Send Serial Packet Dim Values=%d,%d"), Armtronix.dim_state[0],Armtronix.dim_state[1]); AddLog(LOG_LEVEL_DEBUG, PSTR("ARM: Send Serial Packet Dim Values=%d,%d"), Armtronix.dim_state[0],Armtronix.dim_state[1]);
} else { } else {
Armtronix.ignore_dim = false; Armtronix.ignore_dim = false;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ARM: Send Dim Level skipped due to already set. Value=%d,%d"), Armtronix.dim_state[0],Armtronix.dim_state[1]); AddLog(LOG_LEVEL_DEBUG, PSTR("ARM: Send Dim Level skipped due to already set. Value=%d,%d"), Armtronix.dim_state[0],Armtronix.dim_state[1]);
} }
} }
@ -74,7 +74,7 @@ void ArmtronixRequestState(void)
{ {
if (ArmtronixSerial) { if (ArmtronixSerial) {
// Get current status of MCU // Get current status of MCU
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ARM: Request MCU state")); AddLog(LOG_LEVEL_DEBUG, PSTR("ARM: Request MCU state"));
ArmtronixSerial->println("Status"); ArmtronixSerial->println("Status");
} }
@ -124,7 +124,7 @@ void ArmtronixSerialInput(void)
Armtronix.ignore_dim = true; Armtronix.ignore_dim = true;
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_CHANNEL "%d %d"),i+1, temp); snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_CHANNEL "%d %d"),i+1, temp);
ExecuteCommand(scmnd,SRC_SWITCH); ExecuteCommand(scmnd,SRC_SWITCH);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ARM: Send CMND_CHANNEL=%s"), scmnd ); AddLog(LOG_LEVEL_DEBUG, PSTR("ARM: Send CMND_CHANNEL=%s"), scmnd );
} }
commaIndex = answer.indexOf(',',commaIndex+1); commaIndex = answer.indexOf(',',commaIndex+1);
} }
@ -148,7 +148,7 @@ void ArmtronixSetWifiLed(void)
break; break;
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ARM: Set WiFi LED to state %d (%d)"), wifi_state, WifiState()); AddLog(LOG_LEVEL_DEBUG, PSTR("ARM: Set WiFi LED to state %d (%d)"), wifi_state, WifiState());
char state = '0' + ((wifi_state & 1) > 0); char state = '0' + ((wifi_state & 1) > 0);
ArmtronixSerial->print("Setled:"); ArmtronixSerial->print("Setled:");

View File

@ -223,7 +223,7 @@ void HueRespondToMSearch(void)
snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE)); snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE));
} }
// Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9 // Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_HUE " %s " D_TO " %s:%d"), AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_HUE " %s " D_TO " %s:%d"),
message, udp_remote_ip.toString().c_str(), udp_remote_port); message, udp_remote_ip.toString().c_str(), udp_remote_port);
} }
@ -427,7 +427,7 @@ String GetHueUserId(void)
void HandleUpnpSetupHue(void) void HandleUpnpSetupHue(void)
{ {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_HUE_BRIDGE_SETUP)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_HUE_BRIDGE_SETUP));
String description_xml = Decompress(HUE_DESCRIPTION_XML_COMPRESSED,HUE_DESCRIPTION_XML_SIZE); String description_xml = Decompress(HUE_DESCRIPTION_XML_COMPRESSED,HUE_DESCRIPTION_XML_SIZE);
description_xml.replace(F("{x1"), WiFi.localIP().toString()); description_xml.replace(F("{x1"), WiFi.localIP().toString());
description_xml.replace(F("{x2"), HueUuid()); description_xml.replace(F("{x2"), HueUuid());
@ -437,7 +437,7 @@ void HandleUpnpSetupHue(void)
void HueNotImplemented(String *path) void HueNotImplemented(String *path)
{ {
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API_NOT_IMPLEMENTED " (%s)"), path->c_str()); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API_NOT_IMPLEMENTED " (%s)"), path->c_str());
WSSend(200, CT_JSON, PSTR("{}")); WSSend(200, CT_JSON, PSTR("{}"));
} }
@ -690,7 +690,7 @@ void HueAuthentication(String *path)
snprintf_P(response, sizeof(response), PSTR("[{\"success\":{\"username\":\"%s\"}}]"), GetHueUserId().c_str()); snprintf_P(response, sizeof(response), PSTR("[{\"success\":{\"username\":\"%s\"}}]"), GetHueUserId().c_str());
WSSend(200, CT_JSON, response); WSSend(200, CT_JSON, response);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Authentication Result (%s)"), response); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Authentication Result (%s)"), response);
} }
#ifdef USE_LIGHT #ifdef USE_LIGHT
@ -805,7 +805,7 @@ void HueLightsCommand(uint8_t device, uint32_t device_id, String &response) {
RgbToHsb(rr, gg, bb, &hue, &sat, nullptr); RgbToHsb(rr, gg, bb, &hue, &sat, nullptr);
prev_hue = changeUIntScale(hue, 0, 360, 0, 65535); // calculate back prev_hue prev_hue = changeUIntScale(hue, 0, 360, 0, 65535); // calculate back prev_hue
prev_sat = (sat > 254 ? 254 : sat); prev_sat = (sat > 254 ? 254 : sat);
//AddLog_P(LOG_LEVEL_DEBUG_MORE, "XY RGB (%d %d %d) HS (%d %d)", rr,gg,bb,hue,sat); //AddLog(LOG_LEVEL_DEBUG_MORE, "XY RGB (%d %d %d) HS (%d %d)", rr,gg,bb,hue,sat);
if (resp) { response += ","; } if (resp) { response += ","; }
snprintf_P(buf, buf_size, snprintf_P(buf, buf_size,
msg[HUE_RESP_XY], msg[HUE_RESP_XY],
@ -874,7 +874,7 @@ void HueLightsCommand(uint8_t device, uint32_t device_id, String &response) {
if (change) { if (change) {
#ifdef USE_SHUTTER #ifdef USE_SHUTTER
if (ShutterState(device)) { if (ShutterState(device)) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Settings.shutter_invert: %d"), Settings.shutter_options[device-1] & 1); AddLog(LOG_LEVEL_DEBUG, PSTR("Settings.shutter_invert: %d"), Settings.shutter_options[device-1] & 1);
ShutterSetPosition(device, bri * 100.0f ); ShutterSetPosition(device, bri * 100.0f );
} else } else
#endif #endif
@ -962,7 +962,7 @@ void HueLights(String *path)
} }
else if(path->indexOf(F("/lights/")) >= 0) { // Got /lights/ID else if(path->indexOf(F("/lights/")) >= 0) { // Got /lights/ID
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("/lights path=%s"), path->c_str()); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("/lights path=%s"), path->c_str());
path->remove(0,8); // Remove /lights/ path->remove(0,8); // Remove /lights/
device_id = atoi(path->c_str()); device_id = atoi(path->c_str());
device = DecodeLightId(device_id); device = DecodeLightId(device_id);
@ -996,7 +996,7 @@ void HueLights(String *path)
code = 406; code = 406;
} }
exit: exit:
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Result (%s)"), response.c_str()); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Result (%s)"), response.c_str());
WSSend(code, CT_JSON, response); WSSend(code, CT_JSON, response);
} }
@ -1029,7 +1029,7 @@ void HueGroups(String *path)
response += F("}"); response += F("}");
} }
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " HueGroups Result (%s)"), path->c_str()); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " HueGroups Result (%s)"), path->c_str());
WSSend(200, CT_JSON, response); WSSend(200, CT_JSON, response);
} }
@ -1051,10 +1051,10 @@ void HandleHueApi(String *path)
path->remove(0, 4); // remove /api path->remove(0, 4); // remove /api
uint16_t apilen = path->length(); uint16_t apilen = path->length();
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API " (%s) from %s"), path->c_str(), Webserver->client().remoteIP().toString().c_str()); // HTP: Hue API (//lights/1/state) from 192.168.1.20 AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API " (%s) from %s"), path->c_str(), Webserver->client().remoteIP().toString().c_str()); // HTP: Hue API (//lights/1/state) from 192.168.1.20
for (args = 0; args < Webserver->args(); args++) { for (args = 0; args < Webserver->args(); args++) {
String json = Webserver->arg(args); String json = Webserver->arg(args);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_POST_ARGS " (%s)"), json.c_str()); // HTP: Hue POST args ({"on":false}) AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_POST_ARGS " (%s)"), json.c_str()); // HTP: Hue POST args ({"on":false})
} }
UnishoxStrings msg(HUE_API); UnishoxStrings msg(HUE_API);

View File

@ -74,7 +74,7 @@ void WemoRespondToMSearch(int echo_type)
snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE)); snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE));
} }
// Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9 // Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_WEMO " " D_JSON_TYPE " %d, %s " D_TO " %s:%d"), AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_WEMO " " D_JSON_TYPE " %d, %s " D_TO " %s:%d"),
echo_type, message, udp_remote_ip.toString().c_str(), udp_remote_port); echo_type, message, udp_remote_ip.toString().c_str(), udp_remote_port);
} }
@ -265,7 +265,7 @@ const char WEMO_SETUP_XML[] PROGMEM =
/********************************************************************************************/ /********************************************************************************************/
void LogUpnpWithClient(const char *msg) { void LogUpnpWithClient(const char *msg) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "%s from %s"), msg, Webserver->client().remoteIP().toString().c_str()); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "%s from %s"), msg, Webserver->client().remoteIP().toString().c_str());
} }
void HandleUpnpEvent(void) void HandleUpnpEvent(void)
@ -275,7 +275,7 @@ void HandleUpnpEvent(void)
char event[500]; char event[500];
strlcpy(event, Webserver->arg(0).c_str(), sizeof(event)); strlcpy(event, Webserver->arg(0).c_str(), sizeof(event));
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), event); // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), event);
//differentiate get and set state //differentiate get and set state
char state = 'G'; char state = 'G';

View File

@ -256,7 +256,7 @@ public:
_deviceId = deviceId; _deviceId = deviceId;
_webServer = webServer; _webServer = webServer;
#ifdef USE_EMULATION_WEMO_DEBUG #ifdef USE_EMULATION_WEMO_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: Device #%d listening on port %d"), _deviceId, _localPort); AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Device #%d listening on port %d"), _deviceId, _localPort);
#endif #endif
} }
@ -264,7 +264,7 @@ public:
_deviceId = deviceId; _deviceId = deviceId;
_localPort = localPort; _localPort = localPort;
#ifdef USE_EMULATION_WEMO_DEBUG #ifdef USE_EMULATION_WEMO_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: Device #%d listening on port %d"), _deviceId, _localPort); AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Device #%d listening on port %d"), _deviceId, _localPort);
#endif #endif
_webServer = new ESP8266WebServer(_localPort); _webServer = new ESP8266WebServer(_localPort);
@ -278,7 +278,7 @@ public:
} }
void WemoRespondToMSearch(int echo_type) { void WemoRespondToMSearch(int echo_type) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: WemoRespondToMSearch device #%d: %d"), _deviceId, echo_type); // AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: WemoRespondToMSearch device #%d: %d"), _deviceId, echo_type);
char message[TOPSZ]; char message[TOPSZ];
@ -294,14 +294,14 @@ public:
PortUdp.write(response); PortUdp.write(response);
PortUdp.endPacket(); PortUdp.endPacket();
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: Sending packet device %d: %s"), _deviceId, response); // AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Sending packet device %d: %s"), _deviceId, response);
snprintf_P(message, sizeof(message), PSTR(D_RESPONSE_SENT)); snprintf_P(message, sizeof(message), PSTR(D_RESPONSE_SENT));
} else { } else {
snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE)); snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE));
} }
// Do not use AddLog_P here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9 // Do not use AddLog_P here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9
AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: WeMo Type %d, %s to %s:%d"), AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: WeMo Type %d, %s to %s:%d"),
echo_type, message, udp_remote_ip.toString().c_str(), udp_remote_port); echo_type, message, udp_remote_ip.toString().c_str(), udp_remote_port);
} }
@ -319,7 +319,7 @@ private:
} }
void LogUpnpWithClient(const char *msg) { void LogUpnpWithClient(const char *msg) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "%s from %s"), msg, _webServer->client().remoteIP().toString().c_str()); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "%s from %s"), msg, _webServer->client().remoteIP().toString().c_str());
} }
void HandleUpnpEvent() { void HandleUpnpEvent() {
@ -329,8 +329,8 @@ private:
strlcpy(event, _webServer->arg(0).c_str(), sizeof(event)); strlcpy(event, _webServer->arg(0).c_str(), sizeof(event));
#ifdef USE_EMULATION_WEMO_DEBUG #ifdef USE_EMULATION_WEMO_DEBUG
//AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), event); //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), event);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: HandleUpnpEvent for deviceId %d: %s"), _deviceId, event); AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: HandleUpnpEvent for deviceId %d: %s"), _deviceId, event);
#endif #endif
//differentiate get and set state //differentiate get and set state
@ -362,7 +362,7 @@ private:
void HandleUpnpService(void) { void HandleUpnpService(void) {
#ifdef USE_EMULATION_WEMO_DEBUG #ifdef USE_EMULATION_WEMO_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: HandleUpnpService")); AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: HandleUpnpService"));
#endif #endif
LogUpnpWithClient(PSTR(D_WEMO_EVENT_SERVICE)); LogUpnpWithClient(PSTR(D_WEMO_EVENT_SERVICE));
@ -375,7 +375,7 @@ private:
void HandleUpnpMetaService(void) { void HandleUpnpMetaService(void) {
#ifdef USE_EMULATION_WEMO_DEBUG #ifdef USE_EMULATION_WEMO_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: HandleUpnpMetaService")); AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: HandleUpnpMetaService"));
#endif #endif
LogUpnpWithClient(PSTR(D_WEMO_META_SERVICE)); LogUpnpWithClient(PSTR(D_WEMO_META_SERVICE));
@ -399,14 +399,14 @@ private:
setup_xml.replace("{x3", WemoSerialnumber()); setup_xml.replace("{x3", WemoSerialnumber());
InternalWSSend(200, CT_XML, setup_xml); InternalWSSend(200, CT_XML, setup_xml);
#ifdef USE_EMULATION_WEMO_DEBUG #ifdef USE_EMULATION_WEMO_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: Sending device #%d: %s"), _deviceId, setup_xml.c_str()); AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Sending device #%d: %s"), _deviceId, setup_xml.c_str());
#endif #endif
} }
public: public:
void RegisterHandlers(void) { void RegisterHandlers(void) {
#ifdef USE_EMULATION_WEMO_DEBUG #ifdef USE_EMULATION_WEMO_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: Register device #%d"), _deviceId); AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Register device #%d"), _deviceId);
#endif #endif
_webServer->on(F("/upnp/control/basicevent1"), [&]() { HandleUpnpEvent(); }); _webServer->on(F("/upnp/control/basicevent1"), [&]() { HandleUpnpEvent(); });
_webServer->on(F("/eventservice.xml"), [&]() { HandleUpnpService(); }); _webServer->on(F("/eventservice.xml"), [&]() { HandleUpnpService(); });
@ -441,7 +441,7 @@ bool Xdrv21(uint8_t function)
break; break;
case FUNC_WEB_ADD_HANDLER: case FUNC_WEB_ADD_HANDLER:
#ifdef USE_EMULATION_WEMO_DEBUG #ifdef USE_EMULATION_WEMO_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: Adding handlers for %d devices"), TasmotaGlobal.devices_present); AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Adding handlers for %d devices"), TasmotaGlobal.devices_present);
#endif #endif
// For the first device use the current webserver, for the others.. create a new one listening on a different PortUdp // For the first device use the current webserver, for the others.. create a new one listening on a different PortUdp
wemoDevice[numOfWemoSwitch] = new WemoSwitch(1, Webserver); wemoDevice[numOfWemoSwitch] = new WemoSwitch(1, Webserver);

View File

@ -637,7 +637,7 @@ Z_Data & Z_Data_Set::getByType(Z_Data_Type type, uint8_t ep) {
// Byte 3: Power // Byte 3: Power
Z_Data & Z_Data_Set::createFromBuffer(const SBuffer & buf, uint32_t start, uint32_t len) { Z_Data & Z_Data_Set::createFromBuffer(const SBuffer & buf, uint32_t start, uint32_t len) {
if (len < sizeof(Z_Data)) { if (len < sizeof(Z_Data)) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Invalid len (<4) %d"), len); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Invalid len (<4) %d"), len);
return *(Z_Data*)nullptr; return *(Z_Data*)nullptr;
} }
@ -651,7 +651,7 @@ Z_Data & Z_Data_Set::createFromBuffer(const SBuffer & buf, uint32_t start, uint3
memcpy(&elt, buf.buf(start), len); memcpy(&elt, buf.buf(start), len);
} else { } else {
memcpy(&elt, buf.buf(start), sizeof(Z_Data)); memcpy(&elt, buf.buf(start), sizeof(Z_Data));
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "buffer len overflow %d > %d"), len, expected_len); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "buffer len overflow %d > %d"), len, expected_len);
} }
return elt; return elt;
} }

View File

@ -170,7 +170,7 @@ void ZigbeeHueDimmer(uint16_t shortaddr, uint8_t dimmer) {
// CT // CT
void ZigbeeHueCT(uint16_t shortaddr, uint16_t ct) { void ZigbeeHueCT(uint16_t shortaddr, uint16_t ct) {
if (ct > 0xFEFF) { ct = 0xFEFF; } if (ct > 0xFEFF) { ct = 0xFEFF; }
AddLog_P(LOG_LEVEL_INFO, PSTR("ZigbeeHueCT 0x%04X - %d"), shortaddr, ct); AddLog(LOG_LEVEL_INFO, PSTR("ZigbeeHueCT 0x%04X - %d"), shortaddr, ct);
char param[12]; char param[12];
snprintf_P(param, sizeof(param), PSTR("%02X%02X0A00"), ct & 0xFF, ct >> 8); snprintf_P(param, sizeof(param), PSTR("%02X%02X0A00"), ct & 0xFF, ct >> 8);
uint8_t colormode = 2; // "ct" uint8_t colormode = 2; // "ct"

View File

@ -301,7 +301,7 @@ void loadZigbeeDevices(bool dump_only = false) {
// first copy SPI buffer into ram // first copy SPI buffer into ram
uint8_t *spi_buffer = (uint8_t*) malloc(z_spi_len); uint8_t *spi_buffer = (uint8_t*) malloc(z_spi_len);
if (!spi_buffer) { if (!spi_buffer) {
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer")); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer"));
return; return;
} }
#ifdef USE_UFILESYS #ifdef USE_UFILESYS
@ -311,8 +311,8 @@ void loadZigbeeDevices(bool dump_only = false) {
#endif // ESP32 #endif // ESP32
Z_Flashentry flashdata; Z_Flashentry flashdata;
memcpy_P(&flashdata, z_dev_start, sizeof(Z_Flashentry)); memcpy_P(&flashdata, z_dev_start, sizeof(Z_Flashentry));
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Memory %d"), ESP_getFreeHeap()); // AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Memory %d"), ESP_getFreeHeap());
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Zigbee signature in Flash: %08X - %d"), flashdata.name, flashdata.len); // AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Zigbee signature in Flash: %08X - %d"), flashdata.name, flashdata.len);
// Check the signature // Check the signature
if ( ((flashdata.name == ZIGB_NAME1) || (flashdata.name == ZIGB_NAME2)) if ( ((flashdata.name == ZIGB_NAME1) || (flashdata.name == ZIGB_NAME2))
@ -322,7 +322,7 @@ void loadZigbeeDevices(bool dump_only = false) {
// parse what seems to be a valid entry // parse what seems to be a valid entry
SBuffer buf(buf_len); SBuffer buf(buf_len);
buf.addBuffer(z_dev_start + sizeof(Z_Flashentry), buf_len); buf.addBuffer(z_dev_start + sizeof(Z_Flashentry), buf_len);
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee device information in %s (%d bytes)"), PSTR("Flash"), buf_len); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee device information in %s (%d bytes)"), PSTR("Flash"), buf_len);
if (dump_only) { if (dump_only) {
size_t buf_len = buf.len(); size_t buf_len = buf.len();
@ -336,7 +336,7 @@ void loadZigbeeDevices(bool dump_only = false) {
zigbee_devices.clean(); // don't write back to Flash what we just loaded zigbee_devices.clean(); // don't write back to Flash what we just loaded
} }
} else { } else {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No Zigbee device information in %s"), PSTR("Flash")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No Zigbee device information in %s"), PSTR("Flash"));
} }
#ifdef ESP32 #ifdef ESP32
free(spi_buffer); free(spi_buffer);
@ -354,14 +354,14 @@ void saveZigbeeDevices(void) {
SBuffer buf = hibernateDevices(); SBuffer buf = hibernateDevices();
size_t buf_len = buf.len(); size_t buf_len = buf.len();
if (buf_len > 2040) { if (buf_len > 2040) {
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Buffer too big to fit in Flash (%d bytes)"), buf_len); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Buffer too big to fit in Flash (%d bytes)"), buf_len);
return; return;
} }
// first copy SPI buffer into ram // first copy SPI buffer into ram
uint8_t *spi_buffer = (uint8_t*) malloc(z_spi_len); uint8_t *spi_buffer = (uint8_t*) malloc(z_spi_len);
if (!spi_buffer) { if (!spi_buffer) {
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer")); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer"));
return; return;
} }
// copy the flash into RAM to make local change, and write back the whole buffer // copy the flash into RAM to make local change, and write back the whole buffer
@ -386,13 +386,13 @@ void saveZigbeeDevices(void) {
if (ESP.flashEraseSector(z_spi_start_sector)) { if (ESP.flashEraseSector(z_spi_start_sector)) {
ESP.flashWrite(z_spi_start_sector * SPI_FLASH_SEC_SIZE, (uint32_t*) spi_buffer, SPI_FLASH_SEC_SIZE); ESP.flashWrite(z_spi_start_sector * SPI_FLASH_SEC_SIZE, (uint32_t*) spi_buffer, SPI_FLASH_SEC_SIZE);
} }
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data store in Flash (0x%08X - %d bytes)"), z_dev_start, buf_len); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data store in Flash (0x%08X - %d bytes)"), z_dev_start, buf_len);
#endif // ESP8266 #endif // ESP8266
#ifdef ESP32 #ifdef ESP32
#ifdef USE_UFILESYS #ifdef USE_UFILESYS
TfsSaveFile(TASM_FILE_ZIGBEE, spi_buffer, z_spi_len); TfsSaveFile(TASM_FILE_ZIGBEE, spi_buffer, z_spi_len);
#endif #endif
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data saved in %s (%d bytes)"), PSTR("Flash"), buf_len); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data saved in %s (%d bytes)"), PSTR("Flash"), buf_len);
#endif // ESP32 #endif // ESP32
free(spi_buffer); free(spi_buffer);
} }
@ -407,7 +407,7 @@ void eraseZigbeeDevices(void) {
// first copy SPI buffer into ram // first copy SPI buffer into ram
uint8_t *spi_buffer = (uint8_t*) malloc(z_spi_len); uint8_t *spi_buffer = (uint8_t*) malloc(z_spi_len);
if (!spi_buffer) { if (!spi_buffer) {
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer")); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer"));
return; return;
} }
// copy the flash into RAM to make local change, and write back the whole buffer // copy the flash into RAM to make local change, and write back the whole buffer
@ -422,13 +422,13 @@ void eraseZigbeeDevices(void) {
} }
free(spi_buffer); free(spi_buffer);
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased in %s"), PSTR("Flash")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased in %s"), PSTR("Flash"));
#endif // ESP8266 #endif // ESP8266
#ifdef ESP32 #ifdef ESP32
#ifdef USE_UFILESYS #ifdef USE_UFILESYS
TfsInitFile(TASM_FILE_ZIGBEE, z_block_len, 0xFF); TfsInitFile(TASM_FILE_ZIGBEE, z_block_len, 0xFF);
#endif #endif
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased (%d bytes)"), z_block_len); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased (%d bytes)"), z_block_len);
#endif // ESP32 #endif // ESP32
} }

View File

@ -41,7 +41,7 @@
int32_t hydrateDeviceWideData(class Z_Device & device, const SBuffer & buf, size_t start, size_t len) { int32_t hydrateDeviceWideData(class Z_Device & device, const SBuffer & buf, size_t start, size_t len) {
size_t segment_len = buf.get8(start); size_t segment_len = buf.get8(start);
if ((segment_len < 6) || (segment_len > len)) { if ((segment_len < 6) || (segment_len > len)) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "invalid device wide data length=%d"), segment_len); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "invalid device wide data length=%d"), segment_len);
return -1; return -1;
} }
device.last_seen = buf.get32(start+1); device.last_seen = buf.get32(start+1);
@ -77,13 +77,13 @@ bool hydrateDeviceData(class Z_Device & device, const SBuffer & buf, size_t star
int32_t hydrateSingleDevice(const class SBuffer & buf, size_t start, size_t len) { int32_t hydrateSingleDevice(const class SBuffer & buf, size_t start, size_t len) {
uint8_t segment_len = buf.get8(start); uint8_t segment_len = buf.get8(start);
if ((segment_len < 4) || (start + segment_len > len)) { if ((segment_len < 4) || (start + segment_len > len)) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "invalid segment_len=%d"), segment_len); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "invalid segment_len=%d"), segment_len);
return -1; return -1;
} }
// read shortaddr // read shortaddr
uint16_t shortaddr = buf.get16(start + 1); uint16_t shortaddr = buf.get16(start + 1);
if (shortaddr >= 0xFFF0) { if (shortaddr >= 0xFFF0) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "invalid shortaddr=0x%04X"), shortaddr); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "invalid shortaddr=0x%04X"), shortaddr);
return -1; return -1;
} }
#ifdef Z_EEPROM_DEBUG #ifdef Z_EEPROM_DEBUG
@ -118,9 +118,9 @@ bool hydrateDevicesDataFromEEPROM(void) {
if (!zigbee.eeprom_ready) { return false; } if (!zigbee.eeprom_ready) { return false; }
int32_t file_length = ZFS::getLength(ZIGB_DATA2); int32_t file_length = ZFS::getLength(ZIGB_DATA2);
if (file_length > 0) { if (file_length > 0) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee device data in EEPROM (%d bytes)"), file_length); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee device data in EEPROM (%d bytes)"), file_length);
} else { } else {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No Zigbee device data in EEPROM")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No Zigbee device data in EEPROM"));
return false; return false;
} }
@ -222,7 +222,7 @@ void hibernateAllData(void) {
} }
int32_t ret = write_data.close(); int32_t ret = write_data.close();
#ifdef Z_EEPROM_DEBUG #ifdef Z_EEPROM_DEBUG
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "ZbData - %d bytes written to EEPROM"), ret); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "ZbData - %d bytes written to EEPROM"), ret);
#endif #endif
#endif // USE_ZIGBEE_EZSP #endif // USE_ZIGBEE_EZSP
} }
@ -270,10 +270,10 @@ bool hibernateDevicesInEEPROM(void) {
int32_t ret = write_data.close(); int32_t ret = write_data.close();
if (ret < 0) { if (ret < 0) {
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Error writing Devices to EEPROM")); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Error writing Devices to EEPROM"));
return false; return false;
} else { } else {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data saved in %s (%d bytes)"), PSTR("EEPROM"), ret); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data saved in %s (%d bytes)"), PSTR("EEPROM"), ret);
} }
return true; return true;
} }
@ -288,10 +288,10 @@ bool loadZigbeeDevicesFromEEPROM(void) {
ZFS::readBytes(ZIGB_NAME2, &num_devices, sizeof(num_devices), 0, sizeof(num_devices)); ZFS::readBytes(ZIGB_NAME2, &num_devices, sizeof(num_devices), 0, sizeof(num_devices));
if ((file_len < 10) || (num_devices == 0x00) || (num_devices == 0xFF)) { // No data if ((file_len < 10) || (num_devices == 0x00) || (num_devices == 0xFF)) { // No data
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No Zigbee device information in %s"), PSTR("EEPROM")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No Zigbee device information in %s"), PSTR("EEPROM"));
return false; return false;
} }
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee device information in %s (%d bytes)"), PSTR("EEPROM"), file_len); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee device information in %s (%d bytes)"), PSTR("EEPROM"), file_len);
uint32_t k = 1; // byte index in global buffer uint32_t k = 1; // byte index in global buffer
for (uint32_t i = 0; (i < num_devices) && (k < file_len); i++) { for (uint32_t i = 0; (i < num_devices) && (k < file_len); i++) {
@ -301,7 +301,7 @@ bool loadZigbeeDevicesFromEEPROM(void) {
buf.setLen(dev_record_len); buf.setLen(dev_record_len);
ret = ZFS::readBytes(ZIGB_NAME2, buf.getBuffer(), dev_record_len, k, dev_record_len); ret = ZFS::readBytes(ZIGB_NAME2, buf.getBuffer(), dev_record_len, k, dev_record_len);
if (ret != dev_record_len) { if (ret != dev_record_len) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "File too short when reading EEPROM")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "File too short when reading EEPROM"));
return false; return false;
} }
@ -318,7 +318,7 @@ bool loadZigbeeDevicesFromEEPROM(void) {
void ZFS_Erase(void) { void ZFS_Erase(void) {
if (zigbee.eeprom_present) { if (zigbee.eeprom_present) {
ZFS::erase(); ZFS::erase();
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased in %s"), PSTR("EEPROM")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased in %s"), PSTR("EEPROM"));
} }
} }

View File

@ -1656,7 +1656,7 @@ void ZCLFrame::parseClusterSpecificCommand(Z_attribute_list& attr_list) {
Z_Device & device = zigbee_devices.getShortAddr(_srcaddr); Z_Device & device = zigbee_devices.getShortAddr(_srcaddr);
if ((device.debounce_endpoint != 0) && (device.debounce_endpoint == _srcendpoint) && (device.debounce_transact == _transact_seq)) { if ((device.debounce_endpoint != 0) && (device.debounce_endpoint == _srcendpoint) && (device.debounce_transact == _transact_seq)) {
// this is a duplicate, drop the packet // this is a duplicate, drop the packet
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Discarding duplicate command from 0x%04X, endpoint %d"), _srcaddr, _srcendpoint); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Discarding duplicate command from 0x%04X, endpoint %d"), _srcaddr, _srcendpoint);
} else { } else {
// reset the duplicate marker, parse the packet normally, and set a timer to reset the marker later (which will discard any existing timer for the same device/endpoint) // reset the duplicate marker, parse the packet normally, and set a timer to reset the marker later (which will discard any existing timer for the same device/endpoint)
device.debounce_endpoint = _srcendpoint; device.debounce_endpoint = _srcendpoint;

View File

@ -932,12 +932,12 @@ void ZigbeeGotoLabel(uint8_t label) {
} }
// no label found, abort // no label found, abort
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Goto label not found, label=%d pc=%d"), label, zigbee.pc); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Goto label not found, label=%d pc=%d"), label, zigbee.pc);
if (ZIGBEE_LABEL_ABORT != label) { if (ZIGBEE_LABEL_ABORT != label) {
// if not already looking for ZIGBEE_LABEL_ABORT, goto ZIGBEE_LABEL_ABORT // if not already looking for ZIGBEE_LABEL_ABORT, goto ZIGBEE_LABEL_ABORT
ZigbeeGotoLabel(ZIGBEE_LABEL_ABORT); ZigbeeGotoLabel(ZIGBEE_LABEL_ABORT);
} else { } else {
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Label Abort (%d) not present, aborting Zigbee"), ZIGBEE_LABEL_ABORT); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Label Abort (%d) not present, aborting Zigbee"), ZIGBEE_LABEL_ABORT);
zigbee.state_machine = false; zigbee.state_machine = false;
zigbee.active = false; zigbee.active = false;
} }
@ -955,7 +955,7 @@ void ZigbeeStateMachine_Run(void) {
// checking if timeout expired // checking if timeout expired
if ((zigbee.next_timeout) && (now > zigbee.next_timeout)) { // if next_timeout == 0 then wait forever if ((zigbee.next_timeout) && (now > zigbee.next_timeout)) { // if next_timeout == 0 then wait forever
if (!zigbee.state_no_timeout) { if (!zigbee.state_no_timeout) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "timeout, goto label %d"), zigbee.on_timeout_goto); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "timeout, goto label %d"), zigbee.on_timeout_goto);
ZigbeeGotoLabel(zigbee.on_timeout_goto); ZigbeeGotoLabel(zigbee.on_timeout_goto);
} else { } else {
zigbee.state_waiting = false; // simply stop waiting zigbee.state_waiting = false; // simply stop waiting
@ -971,7 +971,7 @@ void ZigbeeStateMachine_Run(void) {
zigbee.state_no_timeout = false; // reset the no_timeout for next instruction zigbee.state_no_timeout = false; // reset the no_timeout for next instruction
if (zigbee.pc > ARRAY_SIZE(zb_prog)) { if (zigbee.pc > ARRAY_SIZE(zb_prog)) {
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Invalid pc: %d, aborting"), zigbee.pc); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Invalid pc: %d, aborting"), zigbee.pc);
zigbee.pc = -1; zigbee.pc = -1;
} }
if (zigbee.pc < 0) { if (zigbee.pc < 0) {
@ -1020,7 +1020,7 @@ void ZigbeeStateMachine_Run(void) {
case ZGB_INSTR_STOP: case ZGB_INSTR_STOP:
zigbee.state_machine = false; zigbee.state_machine = false;
if (cur_d8) { if (cur_d8) {
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Stopping (%d)"), cur_d8); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Stopping (%d)"), cur_d8);
} }
break; break;
case ZGB_INSTR_CALL: case ZGB_INSTR_CALL:

View File

@ -195,7 +195,7 @@ int32_t EZ_MessageSent(int32_t res, const class SBuffer &buf) {
uint16_t group_addr = buf.get16(13); uint16_t group_addr = buf.get16(13);
if ((EMBER_OUTGOING_MULTICAST == message_type) && (0xFFFD == dst_addr)) { if ((EMBER_OUTGOING_MULTICAST == message_type) && (0xFFFD == dst_addr)) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Sniffing group 0x%04X"), group_addr); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Sniffing group 0x%04X"), group_addr);
} }
return -1; // ignore return -1; // ignore
} }
@ -229,7 +229,7 @@ void Z_Send_State_or_Map(uint16_t shortaddr, uint8_t index, uint16_t zdo_cmd) {
// This callback is registered to send ZbMap(s) to each device one at a time // This callback is registered to send ZbMap(s) to each device one at a time
void Z_Map(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint, uint32_t value) { void Z_Map(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint, uint32_t value) {
if (BAD_SHORTADDR != shortaddr) { if (BAD_SHORTADDR != shortaddr) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "sending `ZbMap 0x%04X`"), shortaddr); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "sending `ZbMap 0x%04X`"), shortaddr);
#ifdef USE_ZIGBEE_ZNP #ifdef USE_ZIGBEE_ZNP
Z_Send_State_or_Map(shortaddr, value, ZDO_MGMT_LQI_REQ); Z_Send_State_or_Map(shortaddr, value, ZDO_MGMT_LQI_REQ);
#endif // USE_ZIGBEE_ZNP #endif // USE_ZIGBEE_ZNP
@ -237,7 +237,7 @@ void Z_Map(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t end
Z_Send_State_or_Map(shortaddr, value, ZDO_Mgmt_Lqi_req); Z_Send_State_or_Map(shortaddr, value, ZDO_Mgmt_Lqi_req);
#endif // USE_ZIGBEE_EZSP #endif // USE_ZIGBEE_EZSP
} else { } else {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "ZbMap done")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "ZbMap done"));
zigbee.mapping_in_progress = false; zigbee.mapping_in_progress = false;
zigbee.mapping_ready = true; zigbee.mapping_ready = true;
} }
@ -1393,7 +1393,7 @@ void Z_WriteCIEAddress(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster,
buf.add8(ZEUI64); buf.add8(ZEUI64);
buf.add64(localIEEEAddr); buf.add64(localIEEEAddr);
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Writing CIE address")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Writing CIE address"));
ZigbeeZCLSend_Raw(ZigbeeZCLSendMessage({ ZigbeeZCLSend_Raw(ZigbeeZCLSendMessage({
shortaddr, shortaddr,
0x0000, /* group */ 0x0000, /* group */
@ -1417,7 +1417,7 @@ void Z_SendCIEZoneEnrollResponse(uint16_t shortaddr, uint16_t groupaddr, uint16_
uint8_t transacid = zigbee_devices.getNextSeqNumber(shortaddr); uint8_t transacid = zigbee_devices.getNextSeqNumber(shortaddr);
uint8_t EnrollRSP[2] = { 0x00 /* Sucess */, Z_B0(value) /* ZoneID */ }; uint8_t EnrollRSP[2] = { 0x00 /* Sucess */, Z_B0(value) /* ZoneID */ };
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Sending Enroll Zone %d"), Z_B0(value)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Sending Enroll Zone %d"), Z_B0(value));
ZigbeeZCLSend_Raw(ZigbeeZCLSendMessage({ ZigbeeZCLSend_Raw(ZigbeeZCLSendMessage({
shortaddr, shortaddr,
0x0000, /* group */ 0x0000, /* group */
@ -1549,7 +1549,7 @@ void Z_AutoConfigReportingForCluster(uint16_t shortaddr, uint16_t groupaddr, uin
// encode value // encode value
int32_t res = encodeSingleAttribute(buf, report_change, "", attr_type); int32_t res = encodeSingleAttribute(buf, report_change, "", attr_type);
if (res < 0) { if (res < 0) {
AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "internal error, unsupported attribute type")); AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "internal error, unsupported attribute type"));
} else { } else {
Z_attribute attr; Z_attribute attr;
attr.setKeyName(PSTR("ReportableChange"), true); // true because in PMEM attr.setKeyName(PSTR("ReportableChange"), true); // true because in PMEM
@ -1676,7 +1676,7 @@ void Z_IncomingMessage(class ZCLFrame &zcl_received) {
// discard the message if it was sent by us (broadcast or group loopback) // discard the message if it was sent by us (broadcast or group loopback)
if (srcaddr == localShortAddr) { if (srcaddr == localShortAddr) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "loopback message, ignoring")); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "loopback message, ignoring"));
return; // abort the rest of message management return; // abort the rest of message management
} }

View File

@ -101,14 +101,14 @@ void ZigbeeInputLoop(void) {
// in this case the first bit (lsb) is missed and Tasmota receives 0xFF instead of 0xFE // in this case the first bit (lsb) is missed and Tasmota receives 0xFF instead of 0xFE
// We forgive this mistake, and next bytes are automatically resynchronized // We forgive this mistake, and next bytes are automatically resynchronized
if (ZIGBEE_SOF_ALT == zigbee_in_byte) { if (ZIGBEE_SOF_ALT == zigbee_in_byte) {
AddLog_P(LOG_LEVEL_INFO, PSTR("ZbInput forgiven first byte %02X (only for statistics)"), zigbee_in_byte); AddLog(LOG_LEVEL_INFO, PSTR("ZbInput forgiven first byte %02X (only for statistics)"), zigbee_in_byte);
zigbee_in_byte = ZIGBEE_SOF; zigbee_in_byte = ZIGBEE_SOF;
} }
} }
if ((0 == zigbee_buffer->len()) && (ZIGBEE_SOF != zigbee_in_byte)) { if ((0 == zigbee_buffer->len()) && (ZIGBEE_SOF != zigbee_in_byte)) {
// waiting for SOF (Start Of Frame) byte, discard anything else // waiting for SOF (Start Of Frame) byte, discard anything else
AddLog_P(LOG_LEVEL_INFO, PSTR("ZbInput discarding byte %02X"), zigbee_in_byte); AddLog(LOG_LEVEL_INFO, PSTR("ZbInput discarding byte %02X"), zigbee_in_byte);
continue; // discard continue; // discard
} }

View File

@ -84,7 +84,7 @@ char ZigbeeUploadFlashRead(void) {
// static bool padding = true; // static bool padding = true;
// if (padding) { // if (padding) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Start padding from %d"), ZbUpload.byte_counter); // AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Start padding from %d"), ZbUpload.byte_counter);
// padding = false; // padding = false;
// } // }
@ -151,7 +151,7 @@ char XModemWaitACK(void)
in_char = ZigbeeSerial->read(); in_char = ZigbeeSerial->read();
// if (in_char != XM_ACK) { // if (in_char != XM_ACK) {
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd3 0x%02X"), in_char); // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd3 0x%02X"), in_char);
// } // }
if (XM_CAN == in_char) { return XM_CAN; } if (XM_CAN == in_char) { return XM_CAN; }
@ -266,7 +266,7 @@ bool ZigbeeUploadBootloaderPrompt(void) {
if (buf_len) { if (buf_len) {
char hex_char[256]; char hex_char[256];
ToHex_P(serial_buffer, buf_len, hex_char, 256); ToHex_P(serial_buffer, buf_len, hex_char, 256);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd %s"), hex_char); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd %s"), hex_char);
} }
return ((4 == ZbUpload.byte_counter) && (millis() > XModem.flush_delay)); return ((4 == ZbUpload.byte_counter) && (millis() > XModem.flush_delay));
@ -279,7 +279,7 @@ bool ZigbeeUploadXmodem(void) {
} }
#ifdef ZIGBEE_BOOTLOADER_SOFTWARE_RESET_FIRST #ifdef ZIGBEE_BOOTLOADER_SOFTWARE_RESET_FIRST
case ZBU_INIT: { // *** Init ESF32 bootloader case ZBU_INIT: { // *** Init ESF32 bootloader
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Init bootloader")); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Init bootloader"));
ZbUpload.ota_step = ZBU_SOFTWARE_RESET; ZbUpload.ota_step = ZBU_SOFTWARE_RESET;
return false; // Keep Zigbee serial active return false; // Keep Zigbee serial active
} }
@ -294,7 +294,7 @@ bool ZigbeeUploadXmodem(void) {
} }
case ZBU_SOFTWARE_SEND: { case ZBU_SOFTWARE_SEND: {
if (millis() > XModem.timeout) { if (millis() > XModem.timeout) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader software reset send timeout")); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader software reset send timeout"));
ZbUpload.ota_step = ZBU_HARDWARE_RESET; ZbUpload.ota_step = ZBU_HARDWARE_RESET;
return true; return true;
} }
@ -319,17 +319,17 @@ bool ZigbeeUploadXmodem(void) {
case ZBU_PROMPT: { // *** Wait for prompt and select option upload ebl case ZBU_PROMPT: { // *** Wait for prompt and select option upload ebl
if (millis() > XModem.timeout) { if (millis() > XModem.timeout) {
if (ZBU_SOFTWARE_RESET == ZbUpload.bootloader) { if (ZBU_SOFTWARE_RESET == ZbUpload.bootloader) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader software reset timeout")); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader software reset timeout"));
ZbUpload.ota_step = ZBU_HARDWARE_RESET; ZbUpload.ota_step = ZBU_HARDWARE_RESET;
} else { } else {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader hardware reset timeout")); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader hardware reset timeout"));
ZbUpload.ota_step = ZBU_ERROR; ZbUpload.ota_step = ZBU_ERROR;
} }
return true; return true;
} }
#else // No ZIGBEE_BOOTLOADER_SOFTWARE_RESET_FIRST #else // No ZIGBEE_BOOTLOADER_SOFTWARE_RESET_FIRST
case ZBU_INIT: { // *** Init ESF32 bootloader case ZBU_INIT: { // *** Init ESF32 bootloader
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Init bootloader")); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Init bootloader"));
ZigbeeUploadSetBootloader(0); // Reboot MCU EFR32 which returns below text ZigbeeUploadSetBootloader(0); // Reboot MCU EFR32 which returns below text
XModem.timeout = millis() + (30 * 1000); // Allow 30 seconds to receive EBL prompt XModem.timeout = millis() + (30 * 1000); // Allow 30 seconds to receive EBL prompt
XModem.delay = millis() + (2 * XMODEM_FLUSH_DELAY); XModem.delay = millis() + (2 * XMODEM_FLUSH_DELAY);
@ -339,7 +339,7 @@ bool ZigbeeUploadXmodem(void) {
} }
case ZBU_PROMPT: { // *** Wait for prompt and select option upload ebl case ZBU_PROMPT: { // *** Wait for prompt and select option upload ebl
if (millis() > XModem.timeout) { if (millis() > XModem.timeout) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader timeout")); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader timeout"));
ZbUpload.ota_step = ZBU_ERROR; ZbUpload.ota_step = ZBU_ERROR;
return true; return true;
} }
@ -360,7 +360,7 @@ bool ZigbeeUploadXmodem(void) {
// 3. ebl info[cr][lf] // 3. ebl info[cr][lf]
// BL > // BL >
if (ZigbeeUploadBootloaderPrompt()) { if (ZigbeeUploadBootloaderPrompt()) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Init sync")); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Init sync"));
ZigbeeSerial->flush(); ZigbeeSerial->flush();
ZigbeeSerial->write('1'); // upload ebl ZigbeeSerial->write('1'); // upload ebl
if (TasmotaGlobal.sleep > 0) { if (TasmotaGlobal.sleep > 0) {
@ -374,7 +374,7 @@ bool ZigbeeUploadXmodem(void) {
} }
case ZBU_SYNC: { // *** Handle file upload using XModem - sync case ZBU_SYNC: { // *** Handle file upload using XModem - sync
if (millis() > XModem.timeout) { if (millis() > XModem.timeout) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: SYNC timeout")); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: SYNC timeout"));
ZbUpload.ota_step = ZBU_ERROR; ZbUpload.ota_step = ZBU_ERROR;
return true; return true;
} }
@ -385,7 +385,7 @@ bool ZigbeeUploadXmodem(void) {
// C // C
char xmodem_sync = ZigbeeSerial->read(); char xmodem_sync = ZigbeeSerial->read();
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd2 0x%02X"), xmodem_sync); // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd2 0x%02X"), xmodem_sync);
if (('C' == xmodem_sync) || (XM_NAK == xmodem_sync)) { if (('C' == xmodem_sync) || (XM_NAK == xmodem_sync)) {
// Determine which checksum algorithm to use // Determine which checksum algorithm to use
@ -393,7 +393,7 @@ bool ZigbeeUploadXmodem(void) {
XModem.packet_no = 1; XModem.packet_no = 1;
ZbUpload.byte_counter = 0; ZbUpload.byte_counter = 0;
ZbUpload.ota_step = ZBU_UPLOAD; ZbUpload.ota_step = ZBU_UPLOAD;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Init packet send")); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Init packet send"));
} }
} }
break; break;
@ -401,10 +401,10 @@ bool ZigbeeUploadXmodem(void) {
case ZBU_UPLOAD: { // *** Handle file upload using XModem - upload case ZBU_UPLOAD: { // *** Handle file upload using XModem - upload
if (ZigbeeUploadAvailable()) { if (ZigbeeUploadAvailable()) {
if (ZbUpload.byte_counter && !(ZbUpload.byte_counter % 10240)) { // Show progress every 10kB if (ZbUpload.byte_counter && !(ZbUpload.byte_counter % 10240)) { // Show progress every 10kB
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Progress %d kB"), ZbUpload.byte_counter / 1024); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Progress %d kB"), ZbUpload.byte_counter / 1024);
} }
if (!XModemSendPacket(XModem.packet_no)) { if (!XModemSendPacket(XModem.packet_no)) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Packet %d send failed"), XModem.packet_no); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Packet %d send failed"), XModem.packet_no);
ZbUpload.ota_step = ZBU_ERROR; ZbUpload.ota_step = ZBU_ERROR;
return true; return true;
} }
@ -416,7 +416,7 @@ bool ZigbeeUploadXmodem(void) {
ZigbeeSerial->write(XM_EOT); ZigbeeSerial->write(XM_EOT);
XModem.timeout = millis() + (30 * 1000); // Allow 30 seconds to receive EOT ACK XModem.timeout = millis() + (30 * 1000); // Allow 30 seconds to receive EOT ACK
ZbUpload.ota_step = ZBU_EOT; ZbUpload.ota_step = ZBU_EOT;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Transferred %d bytes"), ZbUpload.ota_size); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Transferred %d bytes"), ZbUpload.ota_size);
} }
break; break;
} }
@ -427,19 +427,19 @@ bool ZigbeeUploadXmodem(void) {
// its XModem state machine waits a sufficient amount of time to allow this checksum process // its XModem state machine waits a sufficient amount of time to allow this checksum process
// to occur without timing out on the response just before the EOT is sent. // to occur without timing out on the response just before the EOT is sent.
if (millis() > XModem.timeout) { if (millis() > XModem.timeout) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: EOT ACK timeout")); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: EOT ACK timeout"));
ZbUpload.ota_step = ZBU_ERROR; ZbUpload.ota_step = ZBU_ERROR;
return true; return true;
} }
if (ZigbeeSerial->available()) { if (ZigbeeSerial->available()) {
char xmodem_ack = XModemWaitACK(); char xmodem_ack = XModemWaitACK();
if (XM_CAN == xmodem_ack) { if (XM_CAN == xmodem_ack) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Transfer invalid")); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Transfer invalid"));
ZbUpload.ota_step = ZBU_ERROR; ZbUpload.ota_step = ZBU_ERROR;
return true; return true;
} }
else if (XM_ACK == xmodem_ack) { else if (XM_ACK == xmodem_ack) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: " D_SUCCESSFUL)); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: " D_SUCCESSFUL));
XModem.timeout = millis() + (30 * 1000); // Allow 30 seconds to receive EBL prompt XModem.timeout = millis() + (30 * 1000); // Allow 30 seconds to receive EBL prompt
ZbUpload.byte_counter = 0; ZbUpload.byte_counter = 0;
ZbUpload.ota_step = ZBU_COMPLETE; ZbUpload.ota_step = ZBU_COMPLETE;
@ -449,7 +449,7 @@ bool ZigbeeUploadXmodem(void) {
} }
case ZBU_COMPLETE: { // *** Wait for Serial upload complete EBL prompt case ZBU_COMPLETE: { // *** Wait for Serial upload complete EBL prompt
if (millis() > XModem.timeout) { if (millis() > XModem.timeout) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader timeout")); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader timeout"));
ZbUpload.ota_step = ZBU_ERROR; ZbUpload.ota_step = ZBU_ERROR;
return true; return true;
} else { } else {
@ -467,14 +467,14 @@ bool ZigbeeUploadXmodem(void) {
if (ZigbeeUploadBootloaderPrompt()) { if (ZigbeeUploadBootloaderPrompt()) {
ZbUpload.state = ZBU_COMPLETE; ZbUpload.state = ZBU_COMPLETE;
ZbUpload.ota_step = ZBU_DONE; ZbUpload.ota_step = ZBU_DONE;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: " D_RESTARTING)); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: " D_RESTARTING));
} }
} }
break; break;
} }
case ZBU_ERROR: case ZBU_ERROR:
ZbUpload.state = ZBU_ERROR; ZbUpload.state = ZBU_ERROR;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: " D_FAILED)); AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: " D_FAILED));
case ZBU_DONE: { // *** Clean up and restart to disable bootloader and use new firmware case ZBU_DONE: { // *** Clean up and restart to disable bootloader and use new firmware
ZigbeeUploadSetBootloader(1); // Disable bootloader and reset MCU - should happen at restart ZigbeeUploadSetBootloader(1); // Disable bootloader and reset MCU - should happen at restart
if (1 == TasmotaGlobal.sleep) { if (1 == TasmotaGlobal.sleep) {
@ -547,7 +547,7 @@ void HandleZigbeeXfer(void) {
return; return;
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPLOAD_TRANSFER)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPLOAD_TRANSFER));
WSContentStart_P(PSTR(D_INFORMATION)); WSContentStart_P(PSTR(D_INFORMATION));
WSContentSend_P(HTTP_SCRIPT_XFER_STATE); WSContentSend_P(HTTP_SCRIPT_XFER_STATE);

View File

@ -67,7 +67,7 @@ void ZigbeeInit(void)
// Check if settings in Flash are set // Check if settings in Flash are set
if (PinUsed(GPIO_ZIGBEE_RX) && PinUsed(GPIO_ZIGBEE_TX)) { if (PinUsed(GPIO_ZIGBEE_RX) && PinUsed(GPIO_ZIGBEE_TX)) {
if (0 == Settings.zb_channel) { if (0 == Settings.zb_channel) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_RANDOMIZING_ZBCONFIG)); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_RANDOMIZING_ZBCONFIG));
uint64_t mac64 = 0; // stuff mac address into 64 bits uint64_t mac64 = 0; // stuff mac address into 64 bits
WiFi.macAddress((uint8_t*) &mac64); WiFi.macAddress((uint8_t*) &mac64);
uint32_t esp_id = ESP_getChipId(); uint32_t esp_id = ESP_getChipId();
@ -103,7 +103,7 @@ void ZigbeeInit(void)
Wire.beginTransmission(USE_ZIGBEE_ZBBRIDGE_EEPROM); Wire.beginTransmission(USE_ZIGBEE_ZBBRIDGE_EEPROM);
uint8_t error = Wire.endTransmission(); uint8_t error = Wire.endTransmission();
if (0 == error) { if (0 == error) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_EEPROM_FOUND_AT_ADDRESS " 0x%02X"), USE_ZIGBEE_ZBBRIDGE_EEPROM); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_EEPROM_FOUND_AT_ADDRESS " 0x%02X"), USE_ZIGBEE_ZBBRIDGE_EEPROM);
zigbee.eeprom_present = true; zigbee.eeprom_present = true;
} }
#endif #endif

View File

@ -97,7 +97,7 @@ void BuzzerBeep(uint32_t count, uint32_t on, uint32_t off, uint32_t tune, uint32
Buzzer.freq_mode = 0; Buzzer.freq_mode = 0;
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BUZ: %d(%d),%d,%d,0x%08X(0x%08X),%d"), count, Buzzer.count, on, off, tune, Buzzer.tune, Buzzer.freq_mode); AddLog(LOG_LEVEL_DEBUG, PSTR("BUZ: %d(%d),%d,%d,0x%08X(0x%08X),%d"), count, Buzzer.count, on, off, tune, Buzzer.tune, Buzzer.freq_mode);
Buzzer.enable = (Buzzer.count > 0); Buzzer.enable = (Buzzer.count > 0);
if (Buzzer.enable) { if (Buzzer.enable) {

View File

@ -98,7 +98,7 @@ void AriluxRfHandler(void)
uint16_t stored_hostcode = Settings.rf_code[1][6] << 8 | Settings.rf_code[1][7]; uint16_t stored_hostcode = Settings.rf_code[1][6] << 8 | Settings.rf_code[1][7];
// DEBUG_DRIVER_LOG(PSTR(D_LOG_RFR D_HOST D_CODE " 0x%04X, " D_RECEIVED " 0x%06X"), stored_hostcode, Arilux.rf_received_value); // DEBUG_DRIVER_LOG(PSTR(D_LOG_RFR D_HOST D_CODE " 0x%04X, " D_RECEIVED " 0x%06X"), stored_hostcode, Arilux.rf_received_value);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_RFR D_HOST D_CODE " 0x%04X, " D_RECEIVED " 0x%06X"), stored_hostcode, Arilux.rf_received_value); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_RFR D_HOST D_CODE " 0x%04X, " D_RECEIVED " 0x%06X"), stored_hostcode, Arilux.rf_received_value);
if (hostcode == stored_hostcode) { if (hostcode == stored_hostcode) {
char command[33]; char command[33];

View File

@ -144,7 +144,7 @@ void ShutterRtc50mS(void)
case SHT_COUNTER: case SHT_COUNTER:
if (Shutter[i].accelerator) { if (Shutter[i].accelerator) {
//AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Accelerator i=%d -> %d"),i, Shutter[i].accelerator); //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Accelerator i=%d -> %d"),i, Shutter[i].accelerator);
ShutterUpdateVelocity(i); ShutterUpdateVelocity(i);
analogWriteFreq(Shutter[i].pwm_velocity); analogWriteFreq(Shutter[i].pwm_velocity);
analogWrite(Pin(GPIO_PWM1, i), 50); analogWrite(Pin(GPIO_PWM1, i), 50);
@ -164,7 +164,7 @@ int32_t ShutterPercentToRealPosition(int16_t percent, uint32_t index)
// check against DIV 0 // check against DIV 0
for (uint32_t j = 0; j < 5; j++) { for (uint32_t j = 0; j < 5; j++) {
if (0 == Settings.shuttercoeff[j][index]) { if (0 == Settings.shuttercoeff[j][index]) {
AddLog_P(LOG_LEVEL_ERROR, PSTR("SHT: RESET/INIT CALIBRATION MATRIX DIV 0")); AddLog(LOG_LEVEL_ERROR, PSTR("SHT: RESET/INIT CALIBRATION MATRIX DIV 0"));
for (uint32_t k = 0; k < 5; k++) { for (uint32_t k = 0; k < 5; k++) {
Settings.shuttercoeff[k][index] = SHT_DIV_ROUND(calibrate_pos[k+1] * 1000, calibrate_pos[5]); Settings.shuttercoeff[k][index] = SHT_DIV_ROUND(calibrate_pos[k+1] * 1000, calibrate_pos[5]);
} }
@ -251,7 +251,7 @@ void ShutterInit(void)
if (Settings.shutter_mode == SHT_UNDEF) { if (Settings.shutter_mode == SHT_UNDEF) {
bool relay_in_interlock = false; bool relay_in_interlock = false;
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Mode undef.. calculate...")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Mode undef.. calculate..."));
for (uint32_t j = 0; j < MAX_INTERLOCKS * Settings.flag.interlock; j++) { // CMND_INTERLOCK - Enable/disable interlock for (uint32_t j = 0; j < MAX_INTERLOCKS * Settings.flag.interlock; j++) { // CMND_INTERLOCK - Enable/disable interlock
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Interlock state i=%d %d, flag %d, Shuttermask %d, MaskedIL %d"),i, Settings.interlock[i], Settings.flag.interlock,ShutterGlobal.RelayShutterMask, Settings.interlock[i]&ShutterGlobal.RelayShutterMask); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Interlock state i=%d %d, flag %d, Shuttermask %d, MaskedIL %d"),i, Settings.interlock[i], Settings.flag.interlock,ShutterGlobal.RelayShutterMask, Settings.interlock[i]&ShutterGlobal.RelayShutterMask);
@ -400,7 +400,7 @@ void ShutterDecellerateForStop(uint8_t i)
int16_t missing_steps; int16_t missing_steps;
Shutter[i].accelerator = -(ShutterGlobal.open_velocity_max / (Shutter[i].motordelay>4 ? (Shutter[i].motordelay*11)/10 : 4) ); Shutter[i].accelerator = -(ShutterGlobal.open_velocity_max / (Shutter[i].motordelay>4 ? (Shutter[i].motordelay*11)/10 : 4) );
while (Shutter[i].pwm_velocity > -2*Shutter[i].accelerator ) { while (Shutter[i].pwm_velocity > -2*Shutter[i].accelerator ) {
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Velocity %ld, Delta %d"), Shutter[i].pwm_velocity, Shutter[i].accelerator ); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Velocity %ld, Delta %d"), Shutter[i].pwm_velocity, Shutter[i].accelerator );
//Shutter[i].pwm_velocity = tmax(Shutter[i].pwm_velocity-Shutter[i].accelerator , 0); //Shutter[i].pwm_velocity = tmax(Shutter[i].pwm_velocity-Shutter[i].accelerator , 0);
// Control will be done in RTC Ticker. // Control will be done in RTC Ticker.
delay(50); delay(50);
@ -408,7 +408,7 @@ void ShutterDecellerateForStop(uint8_t i)
if (ShutterGlobal.position_mode == SHT_COUNTER){ if (ShutterGlobal.position_mode == SHT_COUNTER){
missing_steps = ((Shutter[i].target_position-Shutter[i].start_position)*Shutter[i].direction*ShutterGlobal.open_velocity_max/RESOLUTION/STEPS_PER_SECOND) - RtcSettings.pulse_counter[i]; missing_steps = ((Shutter[i].target_position-Shutter[i].start_position)*Shutter[i].direction*ShutterGlobal.open_velocity_max/RESOLUTION/STEPS_PER_SECOND) - RtcSettings.pulse_counter[i];
//prepare for stop PWM //prepare for stop PWM
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Remain steps %d, Counter %d, Freq %d"), missing_steps, RtcSettings.pulse_counter[i] ,Shutter[i].pwm_velocity); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Remain steps %d, Counter %d, Freq %d"), missing_steps, RtcSettings.pulse_counter[i] ,Shutter[i].pwm_velocity);
Shutter[i].accelerator = 0; Shutter[i].accelerator = 0;
Shutter[i].pwm_velocity = Shutter[i].pwm_velocity > 250 ? 250 : Shutter[i].pwm_velocity; Shutter[i].pwm_velocity = Shutter[i].pwm_velocity > 250 ? 250 : Shutter[i].pwm_velocity;
analogWriteFreq(Shutter[i].pwm_velocity); analogWriteFreq(Shutter[i].pwm_velocity);
@ -419,7 +419,7 @@ void ShutterDecellerateForStop(uint8_t i)
} }
analogWrite(Pin(GPIO_PWM1, i), 0); // removed with 8.3 because of reset caused by watchog analogWrite(Pin(GPIO_PWM1, i), 0); // removed with 8.3 because of reset caused by watchog
Shutter[i].real_position = ShutterCalculatePosition(i); Shutter[i].real_position = ShutterCalculatePosition(i);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Real %d, Pulsecount %d, Start %d"), Shutter[i].real_position,RtcSettings.pulse_counter[i], Shutter[i].start_position); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Real %d, Pulsecount %d, Start %d"), Shutter[i].real_position,RtcSettings.pulse_counter[i], Shutter[i].start_position);
} }
Shutter[i].direction = 0; Shutter[i].direction = 0;
@ -429,7 +429,7 @@ void ShutterDecellerateForStop(uint8_t i)
} }
void ShutterPowerOff(uint8_t i) { void ShutterPowerOff(uint8_t i) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Stop Shutter %d. Switchmode %d"), i,Shutter[i].switch_mode); AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Stop Shutter %d. Switchmode %d"), i,Shutter[i].switch_mode);
ShutterDecellerateForStop(i); ShutterDecellerateForStop(i);
switch (Shutter[i].switch_mode) { switch (Shutter[i].switch_mode) {
case SHT_SWITCH: case SHT_SWITCH:
@ -520,14 +520,14 @@ void ShutterAllowPreStartProcedure(uint8_t i)
{ {
#ifdef USE_RULES #ifdef USE_RULES
uint32_t uptime_Local=0; uint32_t uptime_Local=0;
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start. var%d <99>=<%s>, max10s?"),i+i, rules_vars[i]); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start. var%d <99>=<%s>, max10s?"),i+i, rules_vars[i]);
TasmotaGlobal.rules_flag.shutter_moving = 1; TasmotaGlobal.rules_flag.shutter_moving = 1;
XdrvRulesProcess(); XdrvRulesProcess();
uptime_Local = TasmotaGlobal.uptime; uptime_Local = TasmotaGlobal.uptime;
while (uptime_Local+10 > TasmotaGlobal.uptime && (String)rules_vars[i] == "99") { while (uptime_Local+10 > TasmotaGlobal.uptime && (String)rules_vars[i] == "99") {
loop(); loop();
} }
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start. Done")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start. Done"));
#endif // USE_RULES #endif // USE_RULES
} }
@ -657,7 +657,7 @@ void ShutterRelayChanged(void)
switch (powerstate_local) { switch (powerstate_local) {
case 1: case 1:
ShutterStartInit(i, Shutter[i].lastdirection*-1 , Shutter[i].lastdirection == 1 ? 0 : Shutter[i].open_max); ShutterStartInit(i, Shutter[i].lastdirection*-1 , Shutter[i].lastdirection == 1 ? 0 : Shutter[i].open_max);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d Garage. NewTarget %d"), i, Shutter[i].target_position); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d Garage. NewTarget %d"), i, Shutter[i].target_position);
break; break;
default: default:
Shutter[i].target_position = Shutter[i].real_position; Shutter[i].target_position = Shutter[i].real_position;
@ -665,7 +665,7 @@ void ShutterRelayChanged(void)
} // switch (ShutterGlobal.position_mode) } // switch (ShutterGlobal.position_mode)
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d, Target %ld, Powerstatelocal %d"), i+1, Shutter[i].target_position, powerstate_local); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d, Target %ld, Powerstatelocal %d"), i+1, Shutter[i].target_position, powerstate_local);
} // if (manual_relays_changed) } // if (manual_relays_changed)
} // for (uint32_t i = 0; i < TasmotaGlobal.shutters_present; i++) } // for (uint32_t i = 0; i < TasmotaGlobal.shutters_present; i++)
} }
@ -760,12 +760,12 @@ void ShutterButtonHandler(void)
Settings.shutter_button[i], shutter_index, Button.press_counter[i] , min_shutterbutton_press_counter, i); Settings.shutter_button[i], shutter_index, Button.press_counter[i] , min_shutterbutton_press_counter, i);
if ((button_index != i) && (Settings.shutter_button[i] & (1<<31)) && ((Settings.shutter_button[i] & 0x03) == shutter_index) && (i != button_index) && (Button.press_counter[i] < min_shutterbutton_press_counter)) { if ((button_index != i) && (Settings.shutter_button[i] & (1<<31)) && ((Settings.shutter_button[i] & 0x03) == shutter_index) && (i != button_index) && (Button.press_counter[i] < min_shutterbutton_press_counter)) {
min_shutterbutton_press_counter = Button.press_counter[i]; min_shutterbutton_press_counter = Button.press_counter[i];
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: minShutterButtonPressCounter %d"), min_shutterbutton_press_counter); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: minShutterButtonPressCounter %d"), min_shutterbutton_press_counter);
} }
} }
if (min_shutterbutton_press_counter == Button.press_counter[button_index]) { if (min_shutterbutton_press_counter == Button.press_counter[button_index]) {
// simultaneous shutter button press detected // simultaneous shutter button press detected
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Simultanous press detected")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Simultanous press detected"));
press_index = Button.press_counter[button_index]; press_index = Button.press_counter[button_index];
for (uint32_t i = 0; i < MAX_KEYS; i++) for (uint32_t i = 0; i < MAX_KEYS; i++)
if ((Settings.shutter_button[i] & (1<<31)) && ((Settings.shutter_button[i] & 0x03) != shutter_index)) if ((Settings.shutter_button[i] & (1<<31)) && ((Settings.shutter_button[i] & 0x03) != shutter_index))
@ -871,7 +871,7 @@ void ShutterSetPosition(uint32_t device, uint32_t position)
void ShutterToggle(bool dir) void ShutterToggle(bool dir)
{ {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Payload toggle: %d, i %d, dir %d"), XdrvMailbox.payload, XdrvMailbox.index, dir); AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Payload toggle: %d, i %d, dir %d"), XdrvMailbox.payload, XdrvMailbox.index, dir);
if ((1 == XdrvMailbox.index) && (XdrvMailbox.payload != -99)) { if ((1 == XdrvMailbox.index) && (XdrvMailbox.payload != -99)) {
XdrvMailbox.index = XdrvMailbox.payload; XdrvMailbox.index = XdrvMailbox.payload;
} }
@ -895,7 +895,7 @@ void ShutterToggle(bool dir)
void CmndShutterOpen(void) void CmndShutterOpen(void)
{ {
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Payload open: %d, i %d"), XdrvMailbox.payload, XdrvMailbox.index); //AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Payload open: %d, i %d"), XdrvMailbox.payload, XdrvMailbox.index);
if ((1 == XdrvMailbox.index) && (XdrvMailbox.payload != -99)) { if ((1 == XdrvMailbox.index) && (XdrvMailbox.payload != -99)) {
XdrvMailbox.index = XdrvMailbox.payload; XdrvMailbox.index = XdrvMailbox.payload;
} }
@ -918,7 +918,7 @@ void CmndShutterStopOpen(void)
void CmndShutterClose(void) void CmndShutterClose(void)
{ {
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Payload close: %d, i %d"), XdrvMailbox.payload, XdrvMailbox.index); //AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Payload close: %d, i %d"), XdrvMailbox.payload, XdrvMailbox.index);
if ((1 == XdrvMailbox.index) && (XdrvMailbox.payload != -99)) { if ((1 == XdrvMailbox.index) && (XdrvMailbox.payload != -99)) {
XdrvMailbox.index = XdrvMailbox.payload; XdrvMailbox.index = XdrvMailbox.payload;
} }
@ -984,7 +984,7 @@ void CmndShutterStop(void)
uint32_t i = XdrvMailbox.index -1; uint32_t i = XdrvMailbox.index -1;
if (Shutter[i].direction != 0) { if (Shutter[i].direction != 0) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Stop moving %d: dir: %d"), XdrvMailbox.index, Shutter[i].direction); AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Stop moving %d: dir: %d"), XdrvMailbox.index, Shutter[i].direction);
Shutter[i].target_position = Shutter[i].real_position; Shutter[i].target_position = Shutter[i].real_position;
} }
if (XdrvMailbox.command) if (XdrvMailbox.command)
@ -1016,7 +1016,7 @@ void CmndShutterPosition(void)
if (!(Settings.shutter_options[XdrvMailbox.index-1] & 2)) { if (!(Settings.shutter_options[XdrvMailbox.index-1] & 2)) {
uint32_t index = XdrvMailbox.index-1; uint32_t index = XdrvMailbox.index-1;
//limit the payload //limit the payload
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Pos. in: payload %s (%d), payload %d, idx %d, src %d"), XdrvMailbox.data , XdrvMailbox.data_len, XdrvMailbox.payload , XdrvMailbox.index, TasmotaGlobal.last_source ); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Pos. in: payload %s (%d), payload %d, idx %d, src %d"), XdrvMailbox.data , XdrvMailbox.data_len, XdrvMailbox.payload , XdrvMailbox.index, TasmotaGlobal.last_source );
// value 0 with data_len > 0 can mean Open // value 0 with data_len > 0 can mean Open
// special handling fo UP,DOWN,TOGGLE,STOP command comming with payload -99 // special handling fo UP,DOWN,TOGGLE,STOP command comming with payload -99
@ -1053,7 +1053,7 @@ void CmndShutterPosition(void)
Shutter[index].target_position = ShutterPercentToRealPosition(target_pos_percent, index); Shutter[index].target_position = ShutterPercentToRealPosition(target_pos_percent, index);
//Shutter[i].accelerator[index] = ShutterGlobal.open_velocity_max / ((Shutter[i].motordelay[index] > 0) ? Shutter[i].motordelay[index] : 1); //Shutter[i].accelerator[index] = ShutterGlobal.open_velocity_max / ((Shutter[i].motordelay[index] > 0) ? Shutter[i].motordelay[index] : 1);
//Shutter[i].target_position[index] = XdrvMailbox.payload < 5 ? Settings.shuttercoeff[2][index] * XdrvMailbox.payload : Settings.shuttercoeff[1][index] * XdrvMailbox.payload + Settings.shuttercoeff[0,index]; //Shutter[i].target_position[index] = XdrvMailbox.payload < 5 ? Settings.shuttercoeff[2][index] * XdrvMailbox.payload : Settings.shuttercoeff[1][index] * XdrvMailbox.payload + Settings.shuttercoeff[0,index];
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: lastsource %d:, real %d, target %d, payload %d"), TasmotaGlobal.last_source, Shutter[index].real_position ,Shutter[index].target_position,target_pos_percent); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: lastsource %d:, real %d, target %d, payload %d"), TasmotaGlobal.last_source, Shutter[index].real_position ,Shutter[index].target_position,target_pos_percent);
} }
if ( (target_pos_percent >= 0) && (target_pos_percent <= 100) && abs(Shutter[index].target_position - Shutter[index].real_position ) / Shutter[index].close_velocity > 2) { if ( (target_pos_percent >= 0) && (target_pos_percent <= 100) && abs(Shutter[index].target_position - Shutter[index].real_position ) / Shutter[index].close_velocity > 2) {
if (Settings.shutter_options[index] & 4) { if (Settings.shutter_options[index] & 4) {
@ -1090,7 +1090,7 @@ void CmndShutterPosition(void)
case SHT_TIME_GARAGE: case SHT_TIME_GARAGE:
if (!ShutterGlobal.skip_relay_change) { if (!ShutterGlobal.skip_relay_change) {
if (new_shutterdirection == Shutter[index].lastdirection) { if (new_shutterdirection == Shutter[index].lastdirection) {
AddLog_P(LOG_LEVEL_INFO, PSTR("SHT: Garage not move in this direction: %d"), Shutter[index].switch_mode == SHT_PULSE); AddLog(LOG_LEVEL_INFO, PSTR("SHT: Garage not move in this direction: %d"), Shutter[index].switch_mode == SHT_PULSE);
for (uint8_t k=0 ; k <= (uint8_t)(Shutter[index].switch_mode == SHT_PULSE) ; k++) { for (uint8_t k=0 ; k <= (uint8_t)(Shutter[index].switch_mode == SHT_PULSE) ; k++) {
ExecuteCommandPowerShutter(Settings.shutter_startrelay[index], 1, SRC_SHUTTER); ExecuteCommandPowerShutter(Settings.shutter_startrelay[index], 1, SRC_SHUTTER);
delay(500); delay(500);
@ -1400,7 +1400,7 @@ void CmndShutterPwmRange(void)
} }
Settings.shutter_pwmrange[i][XdrvMailbox.index -1] = field; Settings.shutter_pwmrange[i][XdrvMailbox.index -1] = field;
} }
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Init1. pwmmin %d, pwmmax %d"), XdrvMailbox.index , Settings.shutter_pwmrange[0][XdrvMailbox.index -1], Settings.shutter_pwmrange[1][XdrvMailbox.index -1]); AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Init1. pwmmin %d, pwmmax %d"), XdrvMailbox.index , Settings.shutter_pwmrange[0][XdrvMailbox.index -1], Settings.shutter_pwmrange[1][XdrvMailbox.index -1]);
ShutterInit(); ShutterInit();
ResponseCmndIdxChar(XdrvMailbox.data); ResponseCmndIdxChar(XdrvMailbox.data);
} else { } else {
@ -1433,7 +1433,7 @@ void CmndShutterCalibration(void)
Settings.shutter_set50percent[XdrvMailbox.index -1] = 50; Settings.shutter_set50percent[XdrvMailbox.index -1] = 50;
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
Settings.shuttercoeff[i][XdrvMailbox.index -1] = SHT_DIV_ROUND((uint32_t)messwerte[i] * 1000, messwerte[4]); Settings.shuttercoeff[i][XdrvMailbox.index -1] = SHT_DIV_ROUND((uint32_t)messwerte[i] * 1000, messwerte[4]);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Shuttercoeff %d, i %d, Value %d, MeasuredValue %d"), i,XdrvMailbox.index -1,Settings.shuttercoeff[i][XdrvMailbox.index -1], messwerte[i]); AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shuttercoeff %d, i %d, Value %d, MeasuredValue %d"), i,XdrvMailbox.index -1,Settings.shuttercoeff[i][XdrvMailbox.index -1], messwerte[i]);
} }
ShutterInit(); ShutterInit();
ResponseCmndIdxChar(XdrvMailbox.data); ResponseCmndIdxChar(XdrvMailbox.data);
@ -1514,7 +1514,7 @@ bool Xdrv27(uint8_t function)
char stemp1[10]; char stemp1[10];
// extract the number of the relay that was switched and save for later in Update Position. // extract the number of the relay that was switched and save for later in Update Position.
ShutterGlobal.RelayCurrentMask = XdrvMailbox.index ^ ShutterGlobal.RelayOldMask; ShutterGlobal.RelayCurrentMask = XdrvMailbox.index ^ ShutterGlobal.RelayOldMask;
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Switched relay %d by %s"), ShutterGlobal.RelayCurrentMask,GetTextIndexed(stemp1, sizeof(stemp1), TasmotaGlobal.last_source, kCommandSource)); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Switched relay %d by %s"), ShutterGlobal.RelayCurrentMask,GetTextIndexed(stemp1, sizeof(stemp1), TasmotaGlobal.last_source, kCommandSource));
ShutterRelayChanged(); ShutterRelayChanged();
ShutterGlobal.RelayOldMask = XdrvMailbox.index; ShutterGlobal.RelayOldMask = XdrvMailbox.index;
break; break;
@ -1527,10 +1527,10 @@ bool Xdrv27(uint8_t function)
} }
ShutterGlobal.RelayCurrentMask >>= 1; ShutterGlobal.RelayCurrentMask >>= 1;
} }
//AddLog_P(LOG_LEVEL_ERROR, PSTR("SHT: Skip relay change %d"), i+1); //AddLog(LOG_LEVEL_ERROR, PSTR("SHT: Skip relay change %d"), i+1);
result = true; result = true;
ShutterGlobal.skip_relay_change = 0; ShutterGlobal.skip_relay_change = 0;
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Skipping switch off relay %d"), i); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Skipping switch off relay %d"), i);
ExecuteCommandPowerShutter(i+1, 0, SRC_SHUTTER); ExecuteCommandPowerShutter(i+1, 0, SRC_SHUTTER);
} }
break; break;

View File

@ -48,14 +48,14 @@ void Pcf8574SwitchRelay(void)
for (uint32_t i = 0; i < TasmotaGlobal.devices_present; i++) { for (uint32_t i = 0; i < TasmotaGlobal.devices_present; i++) {
uint8_t relay_state = bitRead(XdrvMailbox.index, i); uint8_t relay_state = bitRead(XdrvMailbox.index, i);
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("PCF: Pcf8574.max_devices %d requested pin %d"), Pcf8574.max_devices,Pcf8574.pin[i]); //AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Pcf8574.max_devices %d requested pin %d"), Pcf8574.max_devices,Pcf8574.pin[i]);
if (Pcf8574.max_devices > 0 && Pcf8574.pin[i] < 99) { if (Pcf8574.max_devices > 0 && Pcf8574.pin[i] < 99) {
uint8_t board = Pcf8574.pin[i]>>3; uint8_t board = Pcf8574.pin[i]>>3;
uint8_t oldpinmask = Pcf8574.pin_mask[board]; uint8_t oldpinmask = Pcf8574.pin_mask[board];
uint8_t _val = bitRead(TasmotaGlobal.rel_inverted, i) ? !relay_state : relay_state; uint8_t _val = bitRead(TasmotaGlobal.rel_inverted, i) ? !relay_state : relay_state;
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("PCF: Pcf8574SwitchRelay %d on pin %d"), i,state); //AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Pcf8574SwitchRelay %d on pin %d"), i,state);
if (_val) { if (_val) {
Pcf8574.pin_mask[board] |= _val << (Pcf8574.pin[i]&0x7); Pcf8574.pin_mask[board] |= _val << (Pcf8574.pin[i]&0x7);
@ -79,7 +79,7 @@ void Pcf8574Init(void)
#ifdef USE_MCP230xx_ADDR #ifdef USE_MCP230xx_ADDR
if (USE_MCP230xx_ADDR == pcf8574_address) { if (USE_MCP230xx_ADDR == pcf8574_address) {
AddLog_P(LOG_LEVEL_INFO, PSTR("PCF: Address 0x%02x reserved for MCP320xx skipped"), pcf8574_address); AddLog(LOG_LEVEL_INFO, PSTR("PCF: Address 0x%02x reserved for MCP320xx skipped"), pcf8574_address);
pcf8574_address++; pcf8574_address++;
if ((PCF8574_ADDR1 +7) == pcf8574_address) { // Support I2C addresses 0x20 to 0x26 and 0x39 to 0x3F if ((PCF8574_ADDR1 +7) == pcf8574_address) { // Support I2C addresses 0x20 to 0x26 and 0x39 to 0x3F
pcf8574_address = PCF8574_ADDR2 +1; pcf8574_address = PCF8574_ADDR2 +1;
@ -87,7 +87,7 @@ void Pcf8574Init(void)
} }
#endif #endif
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("PCF: Probing addr: 0x%x for PCF8574"), pcf8574_address); // AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Probing addr: 0x%x for PCF8574"), pcf8574_address);
if (I2cSetDevice(pcf8574_address)) { if (I2cSetDevice(pcf8574_address)) {
Pcf8574.type = true; Pcf8574.type = true;
@ -115,7 +115,7 @@ void Pcf8574Init(void)
Pcf8574.max_connected_ports = 0; // reset no of devices to avoid duplicate ports on duplicate init. Pcf8574.max_connected_ports = 0; // reset no of devices to avoid duplicate ports on duplicate init.
for (uint32_t idx = 0; idx < Pcf8574.max_devices; idx++) { // suport up to 8 boards PCF8574 for (uint32_t idx = 0; idx < Pcf8574.max_devices; idx++) { // suport up to 8 boards PCF8574
AddLog_P(LOG_LEVEL_DEBUG, PSTR("PCF: Device %d config 0x%02x"), idx +1, Settings.pcf8574_config[idx]); AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Device %d config 0x%02x"), idx +1, Settings.pcf8574_config[idx]);
for (uint32_t i = 0; i < 8; i++) { for (uint32_t i = 0; i < 8; i++) {
uint8_t _result = Settings.pcf8574_config[idx] >> i &1; uint8_t _result = Settings.pcf8574_config[idx] >> i &1;
@ -128,7 +128,7 @@ void Pcf8574Init(void)
} }
} }
} }
AddLog_P(LOG_LEVEL_INFO, PSTR("PCF: Total devices %d, PCF8574 output ports %d"), Pcf8574.max_devices, Pcf8574.max_connected_ports); AddLog(LOG_LEVEL_INFO, PSTR("PCF: Total devices %d, PCF8574 output ports %d"), Pcf8574.max_devices, Pcf8574.max_connected_ports);
} }
} }
@ -158,7 +158,7 @@ void HandlePcf8574(void)
{ {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_PCF8574)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_PCF8574));
if (Webserver->hasArg("save")) { if (Webserver->hasArg("save")) {
Pcf8574SaveSettings(); Pcf8574SaveSettings();
@ -193,7 +193,7 @@ void Pcf8574SaveSettings(void)
char stemp[7]; char stemp[7];
char tmp[100]; char tmp[100];
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("PCF: Start working on Save arguements: inverted:%d")), Webserver->hasArg("b1"); //AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Start working on Save arguements: inverted:%d")), Webserver->hasArg("b1");
Settings.flag3.pcf8574_ports_inverted = Webserver->hasArg("b1"); // SetOption81 - Invert all ports on PCF8574 devices Settings.flag3.pcf8574_ports_inverted = Webserver->hasArg("b1"); // SetOption81 - Invert all ports on PCF8574 devices
for (byte idx = 0; idx < Pcf8574.max_devices; idx++) { for (byte idx = 0; idx < Pcf8574.max_devices; idx++) {
@ -219,7 +219,7 @@ void Pcf8574SaveSettings(void)
} }
} }
//Settings.pcf8574_config[0] = (!strlen(webServer->arg("i2cs0").c_str())) ? 0 : atoi(webServer->arg("i2cs0").c_str()); //Settings.pcf8574_config[0] = (!strlen(webServer->arg("i2cs0").c_str())) ? 0 : atoi(webServer->arg("i2cs0").c_str());
//AddLog_P(LOG_LEVEL_INFO, PSTR("PCF: I2C Board: %d, Config: %2x")), idx, Settings.pcf8574_config[idx]; //AddLog(LOG_LEVEL_INFO, PSTR("PCF: I2C Board: %d, Config: %2x")), idx, Settings.pcf8574_config[idx];
} }
} }

View File

@ -68,7 +68,7 @@ void DeepSleepReInit(void)
if ((RtcSettings.ultradeepsleep > DEEPSLEEP_MAX_CYCLE) && (RtcSettings.ultradeepsleep < 1700000000)) { if ((RtcSettings.ultradeepsleep > DEEPSLEEP_MAX_CYCLE) && (RtcSettings.ultradeepsleep < 1700000000)) {
// Go back to sleep after 60 minutes if requested deepsleep has not been reached // Go back to sleep after 60 minutes if requested deepsleep has not been reached
RtcSettings.ultradeepsleep = RtcSettings.ultradeepsleep - DEEPSLEEP_MAX_CYCLE; RtcSettings.ultradeepsleep = RtcSettings.ultradeepsleep - DEEPSLEEP_MAX_CYCLE;
AddLog_P(LOG_LEVEL_ERROR, PSTR("DSL: Remain DeepSleep %d"), RtcSettings.ultradeepsleep); AddLog(LOG_LEVEL_ERROR, PSTR("DSL: Remain DeepSleep %d"), RtcSettings.ultradeepsleep);
RtcSettingsSave(); RtcSettingsSave();
RtcRebootReset(); RtcRebootReset();
#ifdef ESP8266 #ifdef ESP8266
@ -96,7 +96,7 @@ void DeepSleepPrepare(void)
(RtcSettings.deepsleep_slip < 9000) || (RtcSettings.deepsleep_slip < 9000) ||
(RtcSettings.deepsleep_slip > 11000) || (RtcSettings.deepsleep_slip > 11000) ||
(RtcSettings.nextwakeup > (UtcTime() + Settings.deepsleep))) { (RtcSettings.nextwakeup > (UtcTime() + Settings.deepsleep))) {
AddLog_P(LOG_LEVEL_ERROR, PSTR("DSL: Reset wrong settings wakeup: %ld, slip %ld"), RtcSettings.nextwakeup, RtcSettings.deepsleep_slip ); AddLog(LOG_LEVEL_ERROR, PSTR("DSL: Reset wrong settings wakeup: %ld, slip %ld"), RtcSettings.nextwakeup, RtcSettings.deepsleep_slip );
RtcSettings.nextwakeup = 0; RtcSettings.nextwakeup = 0;
RtcSettings.deepsleep_slip = 10000; RtcSettings.deepsleep_slip = 10000;
} }
@ -137,7 +137,7 @@ void DeepSleepPrepare(void)
void DeepSleepStart(void) void DeepSleepStart(void)
{ {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Sleeping")); // Won't show in GUI AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Sleeping")); // Won't show in GUI
WifiShutdown(); WifiShutdown();
RtcSettings.ultradeepsleep = RtcSettings.nextwakeup - UtcTime(); RtcSettings.ultradeepsleep = RtcSettings.nextwakeup - UtcTime();

View File

@ -124,7 +124,7 @@ void ExsSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0)
char rc; char rc;
#ifdef EXS_DEBUG #ifdef EXS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: Tx Packet:")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: Tx Packet:"));
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)data, len); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)data, len);
#endif #endif
@ -145,7 +145,7 @@ void ExsSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0)
{ {
// timeout // timeout
#ifdef EXS_DEBUG #ifdef EXS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ESX: serial send timeout")); AddLog(LOG_LEVEL_DEBUG, PSTR("ESX: serial send timeout"));
#endif #endif
continue; continue;
} }
@ -215,9 +215,9 @@ void ExsSetBri(uint8_t device, uint8_t bri)
void ExsSyncState(uint8_t device) void ExsSyncState(uint8_t device)
{ {
#ifdef EXS_DEBUG #ifdef EXS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("EXS: Channel %d Power Want %d, Is %d"), AddLog(LOG_LEVEL_DEBUG, PSTR("EXS: Channel %d Power Want %d, Is %d"),
device, bitRead(Exs.power, device), Exs.dimmer.channel[device].dimm); device, bitRead(Exs.power, device), Exs.dimmer.channel[device].dimm);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("EXS: Set Channel %d Brightness Want %d, Is %d"), AddLog(LOG_LEVEL_DEBUG, PSTR("EXS: Set Channel %d Brightness Want %d, Is %d"),
device, Exs.dimm[device], Exs.dimmer.channel[device].bright_tbl); device, Exs.dimm[device], Exs.dimmer.channel[device].bright_tbl);
#endif #endif
@ -236,7 +236,7 @@ void ExsSyncState(uint8_t device)
bool ExsSyncState() bool ExsSyncState()
{ {
#ifdef EXS_DEBUG #ifdef EXS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("EXS: Serial %p, Cmd %d"), ExsSerial, Exs.cmd_status); AddLog(LOG_LEVEL_DEBUG, PSTR("EXS: Serial %p, Cmd %d"), ExsSerial, Exs.cmd_status);
#endif #endif
if (!ExsSerial || Exs.cmd_status != 0) if (!ExsSerial || Exs.cmd_status != 0)
@ -363,7 +363,7 @@ bool ExsModuleSelected(void)
bool ExsSetChannels(void) bool ExsSetChannels(void)
{ {
#ifdef EXS_DEBUG #ifdef EXS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: SetChannels:")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: SetChannels:"));
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)XdrvMailbox.data, XdrvMailbox.data_len); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)XdrvMailbox.data, XdrvMailbox.data_len);
#endif #endif
@ -374,7 +374,7 @@ bool ExsSetChannels(void)
bool ExsSetPower(void) bool ExsSetPower(void)
{ {
AddLog_P(LOG_LEVEL_INFO, PSTR("EXS: Set Power, Device %d, Power 0x%02x"), AddLog(LOG_LEVEL_INFO, PSTR("EXS: Set Power, Device %d, Power 0x%02x"),
TasmotaGlobal.active_device, XdrvMailbox.index); TasmotaGlobal.active_device, XdrvMailbox.index);
Exs.power = XdrvMailbox.index; Exs.power = XdrvMailbox.index;
@ -386,7 +386,7 @@ void EsxMcuStart(void)
int retries = 3; int retries = 3;
#ifdef EXS_DEBUG #ifdef EXS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("EXS: Request MCU configuration, PIN %d to Low"), Pin(GPIO_EXS_ENABLE)); AddLog(LOG_LEVEL_DEBUG, PSTR("EXS: Request MCU configuration, PIN %d to Low"), Pin(GPIO_EXS_ENABLE));
#endif #endif
pinMode(Pin(GPIO_EXS_ENABLE), OUTPUT); pinMode(Pin(GPIO_EXS_ENABLE), OUTPUT);
@ -404,7 +404,7 @@ void EsxMcuStart(void)
void ExsInit(void) void ExsInit(void)
{ {
#ifdef EXS_DEBUG #ifdef EXS_DEBUG
AddLog_P(LOG_LEVEL_INFO, PSTR("EXS: Starting Tx %d Rx %d"), Pin(GPIO_TXD), Pin(GPIO_RXD)); AddLog(LOG_LEVEL_INFO, PSTR("EXS: Starting Tx %d Rx %d"), Pin(GPIO_TXD), Pin(GPIO_RXD));
#endif #endif
Exs.buffer = (uint8_t *)malloc(EXS_BUFFER_SIZE); Exs.buffer = (uint8_t *)malloc(EXS_BUFFER_SIZE);
@ -432,7 +432,7 @@ void ExsSerialInput(void)
yield(); yield();
uint8_t serial_in_byte = ExsSerial->read(); uint8_t serial_in_byte = ExsSerial->read();
AddLog_P(LOG_LEVEL_INFO, PSTR("EXS: Serial In Byte 0x%02x"), serial_in_byte); AddLog(LOG_LEVEL_INFO, PSTR("EXS: Serial In Byte 0x%02x"), serial_in_byte);
if (Exs.cmd_status == 0 && if (Exs.cmd_status == 0 &&
serial_in_byte == 0x7B) serial_in_byte == 0x7B)
@ -456,7 +456,7 @@ void ExsSerialInput(void)
Exs.cmd_status = 0; Exs.cmd_status = 0;
#ifdef EXS_DEBUG #ifdef EXS_DEBUG
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: CRC: 0x%02x, RX Packet:"), crc); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: CRC: 0x%02x, RX Packet:"), crc);
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)Exs.buffer, Exs.byte_counter); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)Exs.buffer, Exs.byte_counter);
#endif #endif

View File

@ -238,14 +238,14 @@ uint8_t TasmotaClient_receiveData(char* buffer, int size) {
} }
if (255 == index) { index = 0; } if (255 == index) { index = 0; }
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TCL: ReceiveData")); // AddLog(LOG_LEVEL_DEBUG, PSTR("TCL: ReceiveData"));
// AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t*)buffer, index); // AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t*)buffer, index);
return index; return index;
} }
uint8_t TasmotaClient_sendBytes(uint8_t* bytes, int count) { uint8_t TasmotaClient_sendBytes(uint8_t* bytes, int count) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TCL: SendBytes")); // AddLog(LOG_LEVEL_DEBUG, PSTR("TCL: SendBytes"));
// AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t*)&bytes, count); // AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t*)&bytes, count);
TasmotaClient_Serial->write(bytes, count); TasmotaClient_Serial->write(bytes, count);
@ -298,7 +298,7 @@ uint32_t TasmotaClient_Flash(uint8_t* data, size_t size) {
} }
if (timeout > 50) { return 1; } // Error: Bootloader could not be found if (timeout > 50) { return 1; } // Error: Bootloader could not be found
AddLog_P(LOG_LEVEL_INFO, PSTR("TCL: Found bootloader")); AddLog(LOG_LEVEL_INFO, PSTR("TCL: Found bootloader"));
uint8_t ProgParams[] = {0x86, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00}; uint8_t ProgParams[] = {0x86, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00};
if (!TasmotaClient_execParam(CMND_STK_SET_DEVICE, ProgParams, sizeof(ProgParams))) { if (!TasmotaClient_execParam(CMND_STK_SET_DEVICE, ProgParams, sizeof(ProgParams))) {
@ -368,7 +368,7 @@ uint32_t TasmotaClient_Flash(uint8_t* data, size_t size) {
} }
else if (0x0A != flash_buffer[ca]) { else if (0x0A != flash_buffer[ca]) {
if (!isalnum(flash_buffer[ca])) { if (!isalnum(flash_buffer[ca])) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Size %d, Processed %d"), size, processed); // AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Size %d, Processed %d"), size, processed);
error = 7; // Error: Invalid data error = 7; // Error: Invalid data
break; break;
} }
@ -408,7 +408,7 @@ void TasmotaClient_Init(void) {
pinMode(Pin(GPIO_TASMOTACLIENT_RST), OUTPUT); pinMode(Pin(GPIO_TASMOTACLIENT_RST), OUTPUT);
TClient.SerialEnabled = true; TClient.SerialEnabled = true;
TasmotaClient_Reset(); TasmotaClient_Reset();
AddLog_P(LOG_LEVEL_INFO, PSTR("TCL: Enabled")); AddLog(LOG_LEVEL_INFO, PSTR("TCL: Enabled"));
} }
} }
} }
@ -421,10 +421,10 @@ void TasmotaClient_Init(void) {
memcpy(&TClientSettings, &buffer, sizeof(TClientSettings)); memcpy(&TClientSettings, &buffer, sizeof(TClientSettings));
if (TASMOTA_CLIENT_LIB_VERSION == TClientSettings.features_version) { if (TASMOTA_CLIENT_LIB_VERSION == TClientSettings.features_version) {
TClient.type = true; TClient.type = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("TCL: Version %u"), TClientSettings.features_version); AddLog(LOG_LEVEL_INFO, PSTR("TCL: Version %u"), TClientSettings.features_version);
} else { } else {
if ((!TClient.unsupported) && (TClientSettings.features_version > 0)) { if ((!TClient.unsupported) && (TClientSettings.features_version > 0)) {
AddLog_P(LOG_LEVEL_INFO, PSTR("TCL: Version %u not supported!"), TClientSettings.features_version); AddLog(LOG_LEVEL_INFO, PSTR("TCL: Version %u not supported!"), TClientSettings.features_version);
TClient.unsupported = true; TClient.unsupported = true;
} }
} }
@ -456,7 +456,7 @@ void TasmotaClient_sendCmnd(uint8_t cmnd, uint8_t param) {
memcpy(&buffer[1], &TClientCommand, sizeof(TClientCommand)); memcpy(&buffer[1], &TClientCommand, sizeof(TClientCommand));
buffer[sizeof(TClientCommand)+1] = CMND_END; buffer[sizeof(TClientCommand)+1] = CMND_END;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TCL: SendCmnd")); // AddLog(LOG_LEVEL_DEBUG, PSTR("TCL: SendCmnd"));
// AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t*)&buffer, sizeof(buffer)); // AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t*)&buffer, sizeof(buffer));
for (uint32_t ca = 0; ca < sizeof(buffer); ca++) { for (uint32_t ca = 0; ca < sizeof(buffer); ca++) {

View File

@ -67,10 +67,10 @@ void NRF24Detect(void) {
if (PinUsed(GPIO_NRF24_CS) && PinUsed(GPIO_NRF24_DC) && TasmotaGlobal.spi_enabled) { if (PinUsed(GPIO_NRF24_CS) && PinUsed(GPIO_NRF24_DC) && TasmotaGlobal.spi_enabled) {
if (NRF24initRadio()) { if (NRF24initRadio()) {
NRF24.chipType = 32; // SPACE NRF24.chipType = 32; // SPACE
AddLog_P(LOG_LEVEL_INFO, PSTR("NRF: Model 24L01 initialized")); AddLog(LOG_LEVEL_INFO, PSTR("NRF: Model 24L01 initialized"));
if (NRF24radio.isPVariant()) { if (NRF24radio.isPVariant()) {
NRF24.chipType = 43; // + NRF24.chipType = 43; // +
AddLog_P(LOG_LEVEL_INFO, PSTR("NRF: Model 24L01+ detected")); AddLog(LOG_LEVEL_INFO, PSTR("NRF: Model 24L01+ detected"));
} }
} }
} }

View File

@ -97,7 +97,7 @@ void GenerateDeviceCryptKey()
jaroliftDevice.device_key_msb = k.decrypt(jaroliftDevice.serial | 0x60000000L); jaroliftDevice.device_key_msb = k.decrypt(jaroliftDevice.serial | 0x60000000L);
jaroliftDevice.device_key_lsb = k.decrypt(jaroliftDevice.serial | 0x20000000L); jaroliftDevice.device_key_lsb = k.decrypt(jaroliftDevice.serial | 0x20000000L);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("generated device keys: %08x %08x"), jaroliftDevice.device_key_msb, jaroliftDevice.device_key_lsb); AddLog(LOG_LEVEL_DEBUG, PSTR("generated device keys: %08x %08x"), jaroliftDevice.device_key_msb, jaroliftDevice.device_key_lsb);
} }
void CmdSendButton(void) void CmdSendButton(void)
@ -114,7 +114,7 @@ void CmdSendButton(void)
DEBUG_DRIVER_LOG(LOG_LEVEL_DEBUG_MORE, PSTR("lsb: %08x"), jaroliftDevice.device_key_lsb); DEBUG_DRIVER_LOG(LOG_LEVEL_DEBUG_MORE, PSTR("lsb: %08x"), jaroliftDevice.device_key_lsb);
DEBUG_DRIVER_LOG(LOG_LEVEL_DEBUG_MORE, PSTR("serial: %08x"), jaroliftDevice.serial); DEBUG_DRIVER_LOG(LOG_LEVEL_DEBUG_MORE, PSTR("serial: %08x"), jaroliftDevice.serial);
DEBUG_DRIVER_LOG(LOG_LEVEL_DEBUG_MORE, PSTR("disc: %08x"), jaroliftDevice.disc); DEBUG_DRIVER_LOG(LOG_LEVEL_DEBUG_MORE, PSTR("disc: %08x"), jaroliftDevice.disc);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("KLQ: count: %08x"), jaroliftDevice.count); AddLog(LOG_LEVEL_DEBUG, PSTR("KLQ: count: %08x"), jaroliftDevice.count);
CreateKeeloqPacket(); CreateKeeloqPacket();
jaroliftDevice.count++; jaroliftDevice.count++;
@ -236,8 +236,8 @@ void CreateKeeloqPacket()
jaroliftDevice.enc = k.encrypt(result); jaroliftDevice.enc = k.encrypt(result);
jaroliftDevice.pack |= jaroliftDevice.enc; jaroliftDevice.pack |= jaroliftDevice.enc;
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("pack high: %08x"), jaroliftDevice.pack>>32); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("pack high: %08x"), jaroliftDevice.pack>>32);
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("pack low: %08x"), jaroliftDevice.pack); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("pack low: %08x"), jaroliftDevice.pack);
} }
void KeeloqInit() void KeeloqInit()
@ -248,7 +248,7 @@ void KeeloqInit()
DEBUG_DRIVER_LOG(LOG_LEVEL_DEBUG_MORE, PSTR("cc1101.init()")); DEBUG_DRIVER_LOG(LOG_LEVEL_DEBUG_MORE, PSTR("cc1101.init()"));
delay(100); delay(100);
cc1101.init(); cc1101.init();
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("CC1101 done.")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("CC1101 done."));
cc1101.setSyncWord(SYNC_WORD, false); cc1101.setSyncWord(SYNC_WORD, false);
cc1101.setCarrierFreq(CFREQ_433); cc1101.setCarrierFreq(CFREQ_433);
cc1101.disableAddressCheck(); cc1101.disableAddressCheck();
@ -272,7 +272,7 @@ bool Xdrv36(uint8_t function)
switch (function) { switch (function) {
case FUNC_COMMAND: case FUNC_COMMAND:
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("calling command")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("calling command"));
result = DecodeCommand(kJaroliftCommands, jaroliftCommand); result = DecodeCommand(kJaroliftCommands, jaroliftCommand);
break; break;
case FUNC_INIT: case FUNC_INIT:

View File

@ -50,7 +50,7 @@ void SonoffD1Received(void)
if (action != SnfD1.power) { if (action != SnfD1.power) {
SnfD1.power = action; SnfD1.power = action;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SD1: Remote power (%d, %d)"), SnfD1.power, SnfD1.dimmer); // AddLog(LOG_LEVEL_DEBUG, PSTR("SD1: Remote power (%d, %d)"), SnfD1.power, SnfD1.dimmer);
ExecuteCommandPower(1, action, SRC_SWITCH); ExecuteCommandPower(1, action, SRC_SWITCH);
} }
@ -59,7 +59,7 @@ void SonoffD1Received(void)
if (dimmer != SnfD1.dimmer) { if (dimmer != SnfD1.dimmer) {
SnfD1.dimmer = dimmer; SnfD1.dimmer = dimmer;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SD1: Remote dimmer (%d, %d)"), SnfD1.power, SnfD1.dimmer); // AddLog(LOG_LEVEL_DEBUG, PSTR("SD1: Remote dimmer (%d, %d)"), SnfD1.power, SnfD1.dimmer);
char scmnd[20]; char scmnd[20];
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), SnfD1.dimmer); snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), SnfD1.dimmer);
@ -137,7 +137,7 @@ bool SonoffD1SendPower(void)
if (action != SnfD1.power) { if (action != SnfD1.power) {
SnfD1.power = action; SnfD1.power = action;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SD1: Tasmota power (%d, %d)"), SnfD1.power, SnfD1.dimmer); // AddLog(LOG_LEVEL_DEBUG, PSTR("SD1: Tasmota power (%d, %d)"), SnfD1.power, SnfD1.dimmer);
SonoffD1Send(); SonoffD1Send();
} }
@ -152,7 +152,7 @@ bool SonoffD1SendDimmer(void)
if (dimmer != SnfD1.dimmer) { if (dimmer != SnfD1.dimmer) {
SnfD1.dimmer = dimmer; SnfD1.dimmer = dimmer;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SD1: Tasmota dimmer (%d, %d)"), SnfD1.power, SnfD1.dimmer); // AddLog(LOG_LEVEL_DEBUG, PSTR("SD1: Tasmota dimmer (%d, %d)"), SnfD1.power, SnfD1.dimmer);
SonoffD1Send(); SonoffD1Send();
} }

View File

@ -1272,58 +1272,58 @@ void ThermostatVirtualSwitchCtrState(uint8_t ctr_output)
void ThermostatDebug(uint8_t ctr_output) void ThermostatDebug(uint8_t ctr_output)
{ {
char result_chr[FLOATSZ]; char result_chr[FLOATSZ];
AddLog_P(LOG_LEVEL_DEBUG, PSTR("")); AddLog(LOG_LEVEL_DEBUG, PSTR(""));
AddLog_P(LOG_LEVEL_DEBUG, PSTR("------ Thermostat Start ------")); AddLog(LOG_LEVEL_DEBUG, PSTR("------ Thermostat Start ------"));
dtostrfd(Thermostat[ctr_output].status.counter_seconds, 0, result_chr); dtostrfd(Thermostat[ctr_output].status.counter_seconds, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.counter_seconds: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.counter_seconds: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].status.thermostat_mode, 0, result_chr); dtostrfd(Thermostat[ctr_output].status.thermostat_mode, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.thermostat_mode: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.thermostat_mode: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].diag.state_emergency, 0, result_chr); dtostrfd(Thermostat[ctr_output].diag.state_emergency, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].diag.state_emergency: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].diag.state_emergency: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].diag.output_inconsist_ctr, 0, result_chr); dtostrfd(Thermostat[ctr_output].diag.output_inconsist_ctr, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].diag.output_inconsist_ctr: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].diag.output_inconsist_ctr: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].status.controller_mode, 0, result_chr); dtostrfd(Thermostat[ctr_output].status.controller_mode, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.controller_mode: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.controller_mode: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].status.command_output, 0, result_chr); dtostrfd(Thermostat[ctr_output].status.command_output, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.command_output: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.command_output: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].status.status_output, 0, result_chr); dtostrfd(Thermostat[ctr_output].status.status_output, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.status_output: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.status_output: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].status.status_input, 0, result_chr); dtostrfd(Thermostat[ctr_output].status.status_input, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.status_input: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.status_input: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].status.phase_hybrid_ctr, 0, result_chr); dtostrfd(Thermostat[ctr_output].status.phase_hybrid_ctr, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.phase_hybrid_ctr: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.phase_hybrid_ctr: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].status.sensor_alive, 0, result_chr); dtostrfd(Thermostat[ctr_output].status.sensor_alive, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.sensor_alive: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.sensor_alive: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].status.status_cycle_active, 0, result_chr); dtostrfd(Thermostat[ctr_output].status.status_cycle_active, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.status_cycle_active: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.status_cycle_active: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].temp_pi_error, 0, result_chr); dtostrfd(Thermostat[ctr_output].temp_pi_error, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_pi_error: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_pi_error: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].temp_pi_accum_error, 0, result_chr); dtostrfd(Thermostat[ctr_output].temp_pi_accum_error, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_pi_accum_error: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_pi_accum_error: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].time_proportional_pi, 0, result_chr); dtostrfd(Thermostat[ctr_output].time_proportional_pi, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_proportional_pi: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_proportional_pi: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].time_integral_pi, 0, result_chr); dtostrfd(Thermostat[ctr_output].time_integral_pi, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_integral_pi: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_integral_pi: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].time_total_pi, 0, result_chr); dtostrfd(Thermostat[ctr_output].time_total_pi, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_total_pi: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_total_pi: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].temp_measured_gradient, 0, result_chr); dtostrfd(Thermostat[ctr_output].temp_measured_gradient, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_measured_gradient: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_measured_gradient: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].time_rampup_deadtime, 0, result_chr); dtostrfd(Thermostat[ctr_output].time_rampup_deadtime, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_rampup_deadtime: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_rampup_deadtime: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].temp_rampup_meas_gradient, 0, result_chr); dtostrfd(Thermostat[ctr_output].temp_rampup_meas_gradient, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_rampup_meas_gradient: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_rampup_meas_gradient: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].time_ctr_changepoint, 0, result_chr); dtostrfd(Thermostat[ctr_output].time_ctr_changepoint, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_ctr_changepoint: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_ctr_changepoint: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].temp_rampup_output_off, 0, result_chr); dtostrfd(Thermostat[ctr_output].temp_rampup_output_off, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_rampup_output_off: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_rampup_output_off: %s"), result_chr);
dtostrfd(Thermostat[ctr_output].time_ctr_checkpoint, 0, result_chr); dtostrfd(Thermostat[ctr_output].time_ctr_checkpoint, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_ctr_checkpoint: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_ctr_checkpoint: %s"), result_chr);
dtostrfd(TasmotaGlobal.uptime, 0, result_chr); dtostrfd(TasmotaGlobal.uptime, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("uptime: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("uptime: %s"), result_chr);
dtostrfd(TasmotaGlobal.power, 0, result_chr); dtostrfd(TasmotaGlobal.power, 0, result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("power: %s"), result_chr); AddLog(LOG_LEVEL_DEBUG, PSTR("power: %s"), result_chr);
AddLog_P(LOG_LEVEL_DEBUG, PSTR("------ Thermostat End ------")); AddLog(LOG_LEVEL_DEBUG, PSTR("------ Thermostat End ------"));
AddLog_P(LOG_LEVEL_DEBUG, PSTR("")); AddLog(LOG_LEVEL_DEBUG, PSTR(""));
} }
#endif // DEBUG_THERMOSTAT #endif // DEBUG_THERMOSTAT

View File

@ -99,7 +99,7 @@ bool TelegramInit(void) {
Telegram.next_update_id = 0; // Code of last read Message Telegram.next_update_id = 0; // Code of last read Message
Telegram.message[0].text = ""; Telegram.message[0].text = "";
AddLog_P(LOG_LEVEL_INFO, PSTR("TGM: Started")); AddLog(LOG_LEVEL_INFO, PSTR("TGM: Started"));
} }
init_done = true; init_done = true;
} }
@ -115,7 +115,7 @@ String TelegramConnectToTelegram(String command) {
uint32_t tls_connect_time = millis(); uint32_t tls_connect_time = millis();
if (telegramClient->connect("api.telegram.org", 443)) { if (telegramClient->connect("api.telegram.org", 443)) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TGM: Connected in %d ms, max ThunkStack used %d"), millis() - tls_connect_time, telegramClient->getMaxThunkStackUse()); // AddLog(LOG_LEVEL_DEBUG, PSTR("TGM: Connected in %d ms, max ThunkStack used %d"), millis() - tls_connect_time, telegramClient->getMaxThunkStackUse());
telegramClient->println("GET /"+command); telegramClient->println("GET /"+command);
@ -144,7 +144,7 @@ String TelegramConnectToTelegram(String command) {
} }
void TelegramGetUpdates(uint32_t offset) { void TelegramGetUpdates(uint32_t offset) {
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: getUpdates")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: getUpdates"));
if (!TelegramInit()) { return; } if (!TelegramInit()) { return; }
@ -241,15 +241,15 @@ void TelegramGetUpdates(uint32_t offset) {
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Parsed update_id %d, chat_id %d, text \"%s\""), Telegram.message[i].update_id, Telegram.message[i].chat_id, Telegram.message[i].text.c_str()); AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Parsed update_id %d, chat_id %d, text \"%s\""), Telegram.message[i].update_id, Telegram.message[i].chat_id, Telegram.message[i].text.c_str());
} }
} else { } else {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TGM: No new messages")); // AddLog(LOG_LEVEL_DEBUG, PSTR("TGM: No new messages"));
} }
} else { } else {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TGM: Failed to update")); // AddLog(LOG_LEVEL_DEBUG, PSTR("TGM: Failed to update"));
} }
} }
bool TelegramSendMessage(int32_t chat_id, String text) { bool TelegramSendMessage(int32_t chat_id, String text) {
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: sendMessage")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: sendMessage"));
if (!TelegramInit()) { return false; } if (!TelegramInit()) { return false; }
@ -262,7 +262,7 @@ bool TelegramSendMessage(int32_t chat_id, String text) {
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Response %s"), response.c_str()); // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Response %s"), response.c_str());
if (response.startsWith("{\"ok\":true")) { if (response.startsWith("{\"ok\":true")) {
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TGM: Message sent")); // AddLog(LOG_LEVEL_DEBUG, PSTR("TGM: Message sent"));
sent = true; sent = true;
} }
} }
@ -272,7 +272,7 @@ bool TelegramSendMessage(int32_t chat_id, String text) {
/* /*
void TelegramSendGetMe(void) { void TelegramSendGetMe(void) {
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: getMe")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: getMe"));
if (!TelegramInit()) { return; } if (!TelegramInit()) { return; }

View File

@ -127,7 +127,7 @@ void TCPLoop(void)
void TCPInit(void) { void TCPInit(void) {
if (PinUsed(GPIO_TCP_RX) && PinUsed(GPIO_TCP_TX)) { if (PinUsed(GPIO_TCP_RX) && PinUsed(GPIO_TCP_TX)) {
tcp_buf = (uint8_t*) malloc(TCP_BRIDGE_BUF_SIZE); tcp_buf = (uint8_t*) malloc(TCP_BRIDGE_BUF_SIZE);
if (!tcp_buf) { AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_TCP "could not allocate buffer")); return; } if (!tcp_buf) { AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_TCP "could not allocate buffer")); return; }
if (!Settings.tcp_baudrate) { Settings.tcp_baudrate = 115200 / 1200; } if (!Settings.tcp_baudrate) { Settings.tcp_baudrate = 115200 / 1200; }
TCPSerial = new TasmotaSerial(Pin(GPIO_TCP_RX), Pin(GPIO_TCP_TX), TasmotaGlobal.seriallog_level ? 1 : 2, 0, TCP_BRIDGE_BUF_SIZE); // set a receive buffer of 256 bytes TCPSerial = new TasmotaSerial(Pin(GPIO_TCP_RX), Pin(GPIO_TCP_TX), TasmotaGlobal.seriallog_level ? 1 : 2, 0, TCP_BRIDGE_BUF_SIZE); // set a receive buffer of 256 bytes
@ -151,7 +151,7 @@ void CmndTCPStart(void) {
int32_t tcp_port = XdrvMailbox.payload; int32_t tcp_port = XdrvMailbox.payload;
if (server_tcp) { if (server_tcp) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_TCP "Stopping TCP server")); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TCP "Stopping TCP server"));
server_tcp->stop(); server_tcp->stop();
delete server_tcp; delete server_tcp;
server_tcp = nullptr; server_tcp = nullptr;
@ -162,7 +162,7 @@ void CmndTCPStart(void) {
} }
} }
if (tcp_port > 0) { if (tcp_port > 0) {
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_TCP "Starting TCP server on port %d"), tcp_port); AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TCP "Starting TCP server on port %d"), tcp_port);
server_tcp = new WiFiServer(tcp_port); server_tcp = new WiFiServer(tcp_port);
server_tcp->begin(); // start TCP server server_tcp->begin(); // start TCP server
server_tcp->setNoDelay(true); server_tcp->setNoDelay(true);

View File

@ -379,7 +379,7 @@ uint32_t i2s_record(char *path, uint32_t secs) {
if (data_offset >= mic_size-DATA_SIZE) break; if (data_offset >= mic_size-DATA_SIZE) break;
delay(0); delay(0);
} }
//AddLog_P(LOG_LEVEL_INFO, PSTR("rectime: %d ms"), millis()-stime); //AddLog(LOG_LEVEL_INFO, PSTR("rectime: %d ms"), millis()-stime);
SpeakerMic(MODE_SPK); SpeakerMic(MODE_SPK);
// save to path // save to path
SaveWav(path, mic_buff, mic_size); SaveWav(path, mic_buff, mic_size);
@ -457,7 +457,7 @@ void MDCallback(void *cbData, const char *type, bool isUnicode, const char *str)
if (strstr_P(type, PSTR("Title"))) { if (strstr_P(type, PSTR("Title"))) {
strncpy(wr_title, str, sizeof(wr_title)); strncpy(wr_title, str, sizeof(wr_title));
wr_title[sizeof(wr_title)-1] = 0; wr_title[sizeof(wr_title)-1] = 0;
//AddLog_P(LOG_LEVEL_INFO,PSTR("WR-Title: %s"),wr_title); //AddLog(LOG_LEVEL_INFO,PSTR("WR-Title: %s"),wr_title);
} else { } else {
// Who knows what to do? Not me! // Who knows what to do? Not me!
} }

View File

@ -413,7 +413,7 @@ void MLX90640HandleWebGuiResponse(void){
WebGetArg("ul", tmp, sizeof(tmp)); // update line WebGetArg("ul", tmp, sizeof(tmp)); // update line
if (strlen(tmp)) { if (strlen(tmp)) {
uint8_t _line = atoi(tmp); uint8_t _line = atoi(tmp);
// AddLog_P(LOG_LEVEL_DEBUG, "MLX90640: send line %u", _line); // AddLog(LOG_LEVEL_DEBUG, "MLX90640: send line %u", _line);
float _buf[65]; float _buf[65];
if(_line==0){_buf[0]=1000+MLX90640.Ta;} //ambient temperature modulation hack if(_line==0){_buf[0]=1000+MLX90640.Ta;} //ambient temperature modulation hack
else{_buf[0]=(float)_line;} else{_buf[0]=(float)_line;}
@ -431,9 +431,9 @@ void MLX90640HandleWebGuiResponse(void){
uint32_t _poiNum = (_poi-(_poi%10000))/10000; uint32_t _poiNum = (_poi-(_poi%10000))/10000;
MLX90640.pois[_poiNum*2] = (_poi%10000)/100; MLX90640.pois[_poiNum*2] = (_poi%10000)/100;
MLX90640.pois[(_poiNum*2)+1] = _poi%100; MLX90640.pois[(_poiNum*2)+1] = _poi%100;
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("RAW: %u, POI-%u: x: %u, y: %u"),_poi,_poiNum,MLX90640.pois[_poiNum],MLX90640.pois[_poiNum+1]); // AddLog(LOG_LEVEL_DEBUG, PSTR("RAW: %u, POI-%u: x: %u, y: %u"),_poi,_poiNum,MLX90640.pois[_poiNum],MLX90640.pois[_poiNum+1]);
for(int i = 0;i<MLX90640_POI_NUM;i++){ for(int i = 0;i<MLX90640_POI_NUM;i++){
AddLog_P(LOG_LEVEL_DEBUG, PSTR("POI-%u: x: %u, y: %u"),i+1,MLX90640.pois[i*2],MLX90640.pois[(i*2)+1]); AddLog(LOG_LEVEL_DEBUG, PSTR("POI-%u: x: %u, y: %u"),i+1,MLX90640.pois[i*2],MLX90640.pois[(i*2)+1]);
} }
return; return;
} }
@ -468,7 +468,7 @@ bool MLX90640Cmd(void){
MLX90640.pois[_idx+1] = _coord%100; MLX90640.pois[_idx+1] = _coord%100;
if(MLX90640.pois[_idx+1]>23) MLX90640.pois[_idx+1]=23; if(MLX90640.pois[_idx+1]>23) MLX90640.pois[_idx+1]=23;
} }
AddLog_P(LOG_LEVEL_INFO, PSTR("POI-%u = x:%u,y:%u"),XdrvMailbox.index,MLX90640.pois[_idx],MLX90640.pois[_idx+1]); AddLog(LOG_LEVEL_INFO, PSTR("POI-%u = x:%u,y:%u"),XdrvMailbox.index,MLX90640.pois[_idx],MLX90640.pois[_idx+1]);
Response_P(S_JSON_MLX90640_COMMAND_NVALUE, command, XdrvMailbox.payload); Response_P(S_JSON_MLX90640_COMMAND_NVALUE, command, XdrvMailbox.payload);
break; break;
default: default:
@ -494,10 +494,10 @@ void MLX90640init()
if(!MLX90640.dumpedEE){ if(!MLX90640.dumpedEE){
status = MLX90640_DumpEE(MLX90640_ADDRESS, MLX90640.Frame); status = MLX90640_DumpEE(MLX90640_ADDRESS, MLX90640.Frame);
if (status != 0){ if (status != 0){
AddLog_P(LOG_LEVEL_INFO, PSTR("Failed to load system parameters")); AddLog(LOG_LEVEL_INFO, PSTR("Failed to load system parameters"));
} }
else { else {
AddLog_P(LOG_LEVEL_INFO, PSTR("MLX90640: started")); AddLog(LOG_LEVEL_INFO, PSTR("MLX90640: started"));
MLX90640.type = true; MLX90640.type = true;
} }
MLX90640.params = new paramsMLX90640; MLX90640.params = new paramsMLX90640;
@ -514,11 +514,11 @@ void MLX90640every100msec(){
if(!MLX90640.extractedParams){ if(!MLX90640.extractedParams){
static uint32_t _chunk = 0; static uint32_t _chunk = 0;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: will read chunk: %u"), _chunk); AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: will read chunk: %u"), _chunk);
_time = millis(); _time = millis();
status = MLX90640_ExtractParameters(MLX90640.Frame, MLX90640.params, _chunk); status = MLX90640_ExtractParameters(MLX90640.Frame, MLX90640.params, _chunk);
if (status == 0){ if (status == 0){
AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: parameter received after: %u msec, status: %u"), TimePassedSince(_time), status); AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: parameter received after: %u msec, status: %u"), TimePassedSince(_time), status);
} }
if (_chunk == 5) MLX90640.extractedParams = true; if (_chunk == 5) MLX90640.extractedParams = true;
_chunk++; _chunk++;
@ -529,12 +529,12 @@ void MLX90640every100msec(){
case 0: case 0:
if(MLX90640_SynchFrame(MLX90640_ADDRESS)!=0){ if(MLX90640_SynchFrame(MLX90640_ADDRESS)!=0){
_job=-1; _job=-1;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: frame not ready")); AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: frame not ready"));
break; break;
} }
// _time = millis(); // _time = millis();
status = MLX90640_GetFrameData(MLX90640_ADDRESS, MLX90640.Frame); status = MLX90640_GetFrameData(MLX90640_ADDRESS, MLX90640.Frame);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: got frame 0 in %u msecs, status: %i"), TimePassedSince(_time), status); // AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: got frame 0 in %u msecs, status: %i"), TimePassedSince(_time), status);
break; break;
case 1: case 1:
MLX90640.Ta = MLX90640_GetTa(MLX90640.Frame, MLX90640.params); MLX90640.Ta = MLX90640_GetTa(MLX90640.Frame, MLX90640.params);
@ -542,7 +542,7 @@ void MLX90640every100msec(){
case 2: case 2:
// _time = millis(); // _time = millis();
MLX90640_CalculateTo(MLX90640.Frame, MLX90640.params, 0.95f, MLX90640.Ta - 8, MLX90640.To, 0); MLX90640_CalculateTo(MLX90640.Frame, MLX90640.params, 0.95f, MLX90640.Ta - 8, MLX90640.To, 0);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: calculated temperatures in %u msecs"), TimePassedSince(_time)); // AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: calculated temperatures in %u msecs"), TimePassedSince(_time));
break; break;
case 5: case 5:
if(MLX90640_SynchFrame(MLX90640_ADDRESS)!=0){ if(MLX90640_SynchFrame(MLX90640_ADDRESS)!=0){
@ -551,12 +551,12 @@ void MLX90640every100msec(){
} }
// _time = millis(); // _time = millis();
status = MLX90640_GetFrameData(MLX90640_ADDRESS, MLX90640.Frame); status = MLX90640_GetFrameData(MLX90640_ADDRESS, MLX90640.Frame);
// // AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: got frame 1 in %u msecs, status: %i"), TimePassedSince(_time), status); // // AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: got frame 1 in %u msecs, status: %i"), TimePassedSince(_time), status);
break; break;
case 7: case 7:
// _time = millis(); // _time = millis();
MLX90640_CalculateTo(MLX90640.Frame, MLX90640.params, 0.95f, MLX90640.Ta - 8, MLX90640.To, 1); MLX90640_CalculateTo(MLX90640.Frame, MLX90640.params, 0.95f, MLX90640.Ta - 8, MLX90640.To, 1);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: calculated temperatures in %u msecs"), TimePassedSince(_time)); // AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: calculated temperatures in %u msecs"), TimePassedSince(_time));
break; break;
default: default:
break; break;
@ -580,8 +580,8 @@ void MLX90640Show(uint8_t json)
char obj_tstr[FLOATSZ]; char obj_tstr[FLOATSZ];
dtostrfd(MLX90640.To[MLX90640.pois[i*2]+(MLX90640.pois[(i*2)+1]*32)], Settings.flag2.temperature_resolution, obj_tstr); dtostrfd(MLX90640.To[MLX90640.pois[i*2]+(MLX90640.pois[(i*2)+1]*32)], Settings.flag2.temperature_resolution, obj_tstr);
ResponseAppend_P(PSTR(",%s"),obj_tstr); ResponseAppend_P(PSTR(",%s"),obj_tstr);
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("Array pos: %u"),MLX90640.pois[i*2]+(MLX90640.pois[(i*2)+1]*32)); // AddLog(LOG_LEVEL_DEBUG, PSTR("Array pos: %u"),MLX90640.pois[i*2]+(MLX90640.pois[(i*2)+1]*32));
AddLog_P(LOG_LEVEL_DEBUG, PSTR("POI-%u: x: %u, y: %u"),i+1,MLX90640.pois[i*2],MLX90640.pois[(i*2)+1]); AddLog(LOG_LEVEL_DEBUG, PSTR("POI-%u: x: %u, y: %u"),i+1,MLX90640.pois[i*2],MLX90640.pois[(i*2)+1]);
} }
ResponseAppend_P(PSTR("]}")); ResponseAppend_P(PSTR("]}"));
} }

View File

@ -845,7 +845,7 @@ static void
miel_hvac_input_connected(struct miel_hvac_softc *sc, miel_hvac_input_connected(struct miel_hvac_softc *sc,
const void *buf, size_t len) const void *buf, size_t len)
{ {
AddLog_P(LOG_LEVEL_INFO, AddLog(LOG_LEVEL_INFO,
PSTR(MIEL_HVAC_LOGNAME ": connected to Mitsubishi Electric HVAC")); PSTR(MIEL_HVAC_LOGNAME ": connected to Mitsubishi Electric HVAC"));
sc->sc_connected = 1; sc->sc_connected = 1;
} }
@ -973,7 +973,7 @@ miel_hvac_input_data(struct miel_hvac_softc *sc,
miel_hvac_log_bytes(sc, "data", buf, len); miel_hvac_log_bytes(sc, "data", buf, len);
if (len < sizeof(*d)) { if (len < sizeof(*d)) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME AddLog(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME
": short data response (%zu < %zu)"), len, sizeof(*d)); ": short data response (%zu < %zu)"), len, sizeof(*d));
return; return;
} }
@ -1021,7 +1021,7 @@ miel_hvac_pre_init(void)
sc = (struct miel_hvac_softc *)malloc(sizeof(*sc)); sc = (struct miel_hvac_softc *)malloc(sizeof(*sc));
if (sc == NULL) { if (sc == NULL) {
AddLog_P(LOG_LEVEL_ERROR, AddLog(LOG_LEVEL_ERROR,
PSTR(MIEL_HVAC_LOGNAME ": unable to allocate state")); PSTR(MIEL_HVAC_LOGNAME ": unable to allocate state"));
return; return;
} }
@ -1033,7 +1033,7 @@ miel_hvac_pre_init(void)
Pin(GPIO_MIEL_HVAC_TX), 2); Pin(GPIO_MIEL_HVAC_TX), 2);
if (!sc->sc_serial->begin(baudrate, 2)) { if (!sc->sc_serial->begin(baudrate, 2)) {
AddLog_P(LOG_LEVEL_ERROR, AddLog(LOG_LEVEL_ERROR,
PSTR(MIEL_HVAC_LOGNAME ": unable to begin serial " PSTR(MIEL_HVAC_LOGNAME ": unable to begin serial "
"(baudrate %d)"), baudrate); "(baudrate %d)"), baudrate);
goto del; goto del;

View File

@ -111,7 +111,7 @@ struct SHD
void ShdResetToDFUMode() void ShdResetToDFUMode()
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Request co-processor reset in dfu mode")); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Request co-processor reset in dfu mode"));
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
pinMode(Pin(GPIO_SHELLY_DIMMER_RST_INV), OUTPUT); pinMode(Pin(GPIO_SHELLY_DIMMER_RST_INV), OUTPUT);
@ -133,7 +133,7 @@ void ShdResetToDFUMode()
bool ShdUpdateFirmware(uint8_t* data, uint32_t size) bool ShdUpdateFirmware(uint8_t* data, uint32_t size)
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Update firmware")); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Update firmware"));
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
bool ret = true; bool ret = true;
@ -148,7 +148,7 @@ bool ShdUpdateFirmware(uint8_t* data, uint32_t size)
stm32_err_t s_err; stm32_err_t s_err;
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "STM32 erase memory")); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "STM32 erase memory"));
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
stm32_erase_memory(stm, 0, STM32_MASS_ERASE); stm32_erase_memory(stm, 0, STM32_MASS_ERASE);
@ -190,7 +190,7 @@ bool ShdPresent(void) {
uint32_t ShdFlash(uint8_t* data, size_t size) { uint32_t ShdFlash(uint8_t* data, size_t size) {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Updating firmware v%u.%u with %u bytes"), Shd.dimmer.version_major, Shd.dimmer.version_minor, size); AddLog(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Updating firmware v%u.%u with %u bytes"), Shd.dimmer.version_major, Shd.dimmer.version_minor, size);
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
Serial.end(); Serial.end();
@ -244,7 +244,7 @@ int check_byte()
if (chksm != chksm_calc) if (chksm != chksm_calc)
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Checksum: %x calculated: %x"), chksm, chksm_calc); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Checksum: %x calculated: %x"), chksm, chksm_calc);
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
return 0; return 0;
} }
@ -267,7 +267,7 @@ bool ShdSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0)
int retries = 3; int retries = 3;
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Tx Packet:")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Tx Packet:"));
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t*)data, len); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t*)data, len);
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
@ -287,7 +287,7 @@ bool ShdSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0)
} }
// timeout // timeout
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Serial send timeout")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Serial send timeout"));
} }
return false; return false;
} }
@ -426,9 +426,9 @@ void ShdSendCalibration(uint16_t brightness, uint16_t func, uint16_t fade_rate)
bool ShdSyncState() bool ShdSyncState()
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Serial %p"), ShdSerial); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Serial %p"), ShdSerial);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set Brightness Want %d, Is %d"), Shd.req_brightness, Shd.dimmer.brightness); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set Brightness Want %d, Is %d"), Shd.req_brightness, Shd.dimmer.brightness);
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set Fade Want %d, Is %d"), Settings.light_speed, Shd.dimmer.fade_rate); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set Fade Want %d, Is %d"), Settings.light_speed, Shd.dimmer.fade_rate);
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
if (!ShdSerial) if (!ShdSerial)
@ -456,7 +456,7 @@ bool ShdSyncState()
void ShdDebugState() void ShdDebugState()
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "MCU v%d.%d, Brightness:%d(%d%%), Power:%d, Fade:%d"), AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "MCU v%d.%d, Brightness:%d(%d%%), Power:%d, Fade:%d"),
Shd.dimmer.version_major, Shd.dimmer.version_minor, Shd.dimmer.version_major, Shd.dimmer.version_minor,
Shd.dimmer.brightness, Shd.dimmer.brightness,
changeUIntScale(Shd.dimmer.brightness, 0, 1000, 0, 100), changeUIntScale(Shd.dimmer.brightness, 0, 1000, 0, 100),
@ -538,7 +538,7 @@ bool ShdPacketProcess(void)
{ {
float kWhused = (float)Energy.active_power[0] * (Rtc.utc_time - Shd.last_power_check) / 36; float kWhused = (float)Energy.active_power[0] * (Rtc.utc_time - Shd.last_power_check) / 36;
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Adding %i mWh to todays usage from %lu to %lu"), (int)(kWhused * 10), Shd.last_power_check, Rtc.utc_time); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Adding %i mWh to todays usage from %lu to %lu"), (int)(kWhused * 10), Shd.last_power_check, Rtc.utc_time);
#endif // USE_ENERGY_SENSOR #endif // USE_ENERGY_SENSOR
Energy.kWhtoday += kWhused; Energy.kWhtoday += kWhused;
EnergyUpdateToday(); EnergyUpdateToday();
@ -547,7 +547,7 @@ bool ShdPacketProcess(void)
#endif // USE_ENERGY_SENSOR #endif // USE_ENERGY_SENSOR
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "ShdPacketProcess: Brightness:%d Power:%lu Voltage:%lu Current:%lu Fade:%d"), brightness, wattage_raw, voltage_raw, current_raw, fade_rate); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "ShdPacketProcess: Brightness:%d Power:%lu Voltage:%lu Current:%lu Fade:%d"), brightness, wattage_raw, voltage_raw, current_raw, fade_rate);
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
Shd.dimmer.brightness = brightness; Shd.dimmer.brightness = brightness;
Shd.dimmer.power = wattage_raw; Shd.dimmer.power = wattage_raw;
@ -557,7 +557,7 @@ bool ShdPacketProcess(void)
case SHD_VERSION_CMD: case SHD_VERSION_CMD:
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "ShdPacketProcess: Version: %u.%u"), Shd.buffer[pos + 1], Shd.buffer[pos]); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "ShdPacketProcess: Version: %u.%u"), Shd.buffer[pos + 1], Shd.buffer[pos]);
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
Shd.dimmer.version_minor = Shd.buffer[pos]; Shd.dimmer.version_minor = Shd.buffer[pos];
Shd.dimmer.version_major = Shd.buffer[pos + 1]; Shd.dimmer.version_major = Shd.buffer[pos + 1];
@ -581,7 +581,7 @@ bool ShdPacketProcess(void)
void ShdResetToAppMode() void ShdResetToAppMode()
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Request co-processor reset in app mode")); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Request co-processor reset in app mode"));
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
pinMode(Pin(GPIO_SHELLY_DIMMER_RST_INV), OUTPUT); pinMode(Pin(GPIO_SHELLY_DIMMER_RST_INV), OUTPUT);
@ -603,7 +603,7 @@ void ShdResetToAppMode()
void ShdPoll(void) void ShdPoll(void)
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Poll")); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Poll"));
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
if (!ShdSerial) if (!ShdSerial)
@ -616,7 +616,7 @@ void ShdPoll(void)
bool ShdSendVersion(void) bool ShdSendVersion(void)
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Sending version command")); AddLog(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Sending version command"));
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
return ShdSendCmd(SHD_VERSION_CMD, 0, 0); return ShdSendCmd(SHD_VERSION_CMD, 0, 0);
} }
@ -632,7 +632,7 @@ void ShdGetSettings(void)
if (strstr(SettingsText(SET_SHD_PARAM), ",") != nullptr) if (strstr(SettingsText(SET_SHD_PARAM), ",") != nullptr)
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Loading params: %s"), SettingsText(SET_SHD_PARAM)); AddLog(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Loading params: %s"), SettingsText(SET_SHD_PARAM));
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
// Shd.req_brightness = atoi(subStr(parameters, SettingsText(SET_SHD_PARAM), ",", 1)); // Shd.req_brightness = atoi(subStr(parameters, SettingsText(SET_SHD_PARAM), ",", 1));
Shd.leading_edge = atoi(subStr(parameters, SettingsText(SET_SHD_PARAM), ",", 2)); Shd.leading_edge = atoi(subStr(parameters, SettingsText(SET_SHD_PARAM), ",", 2));
@ -653,7 +653,7 @@ void ShdSaveSettings(void)
void ShdInit(void) void ShdInit(void)
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Shelly Dimmer Driver Starting Tx %d Rx %d"), Pin(GPIO_TXD), Pin(GPIO_RXD)); AddLog(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Shelly Dimmer Driver Starting Tx %d Rx %d"), Pin(GPIO_TXD), Pin(GPIO_RXD));
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
Shd.buffer = (uint8_t *)malloc(SHD_BUFFER_SIZE); Shd.buffer = (uint8_t *)malloc(SHD_BUFFER_SIZE);
@ -669,7 +669,7 @@ void ShdInit(void)
ShdResetToAppMode(); ShdResetToAppMode();
bool got_version = ShdSendVersion(); bool got_version = ShdSendVersion();
AddLog_P(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Shelly Dimmer Co-processor Version v%u.%u"), Shd.dimmer.version_major, Shd.dimmer.version_minor); AddLog(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Shelly Dimmer Co-processor Version v%u.%u"), Shd.dimmer.version_major, Shd.dimmer.version_minor);
ShdGetSettings(); ShdGetSettings();
ShdSaveSettings(); ShdSaveSettings();
@ -694,7 +694,7 @@ bool ShdSerialInput(void)
// finished // finished
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
Shd.byte_counter++; Shd.byte_counter++;
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Rx Packet:")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Rx Packet:"));
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, Shd.buffer, Shd.byte_counter); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, Shd.buffer, Shd.byte_counter);
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
Shd.byte_counter = 0; Shd.byte_counter = 0;
@ -707,7 +707,7 @@ bool ShdSerialInput(void)
{ {
// wrong data // wrong data
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Byte %i of received data frame is invalid. Rx Packet:"), Shd.byte_counter); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Byte %i of received data frame is invalid. Rx Packet:"), Shd.byte_counter);
Shd.byte_counter++; Shd.byte_counter++;
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, Shd.buffer, Shd.byte_counter); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, Shd.buffer, Shd.byte_counter);
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
@ -739,7 +739,7 @@ bool ShdModuleSelected(void) {
bool ShdSetChannels(void) bool ShdSetChannels(void)
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "SetChannels:")); AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "SetChannels:"));
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)XdrvMailbox.data, XdrvMailbox.data_len); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)XdrvMailbox.data, XdrvMailbox.data_len);
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
@ -757,7 +757,7 @@ bool ShdSetChannels(void)
bool ShdSetPower(void) bool ShdSetPower(void)
{ {
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Set Power, Power 0x%02x"), XdrvMailbox.index); AddLog(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Set Power, Power 0x%02x"), XdrvMailbox.index);
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
Shd.req_on = (bool)XdrvMailbox.index; Shd.req_on = (bool)XdrvMailbox.index;
@ -784,9 +784,9 @@ void CmndShdLeadingEdge(void)
Settings.shd_leading_edge = XdrvMailbox.payload; Settings.shd_leading_edge = XdrvMailbox.payload;
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
if (Shd.leading_edge == 1) if (Shd.leading_edge == 1)
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set to trailing edge")); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set to trailing edge"));
else else
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set to leading edge")); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set to leading edge"));
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
ShdSendSettings(); ShdSendSettings();
} }
@ -801,7 +801,7 @@ void CmndShdWarmupBrightness(void)
Shd.warmup_brightness = XdrvMailbox.payload * 10; Shd.warmup_brightness = XdrvMailbox.payload * 10;
Settings.shd_warmup_brightness = XdrvMailbox.payload; Settings.shd_warmup_brightness = XdrvMailbox.payload;
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set warmup brightness to %d%%"), XdrvMailbox.payload); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set warmup brightness to %d%%"), XdrvMailbox.payload);
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
ShdSendSettings(); ShdSendSettings();
} }
@ -816,7 +816,7 @@ void CmndShdWarmupTime(void)
Shd.warmup_time = XdrvMailbox.payload; Shd.warmup_time = XdrvMailbox.payload;
Settings.shd_warmup_time = XdrvMailbox.payload; Settings.shd_warmup_time = XdrvMailbox.payload;
#ifdef SHELLY_DIMMER_DEBUG #ifdef SHELLY_DIMMER_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set warmup time to %dms"), XdrvMailbox.payload); AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set warmup time to %dms"), XdrvMailbox.payload);
#endif // SHELLY_DIMMER_DEBUG #endif // SHELLY_DIMMER_DEBUG
ShdSendSettings(); ShdSendSettings();
} }

View File

@ -533,7 +533,7 @@ void CCLProgrammerInit(void)
bool CCLoaderinit() bool CCLoaderinit()
{ {
CCLProgrammerInit(); CCLProgrammerInit();
AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: programmer init")); AddLog(LOG_LEVEL_INFO,PSTR("CCL: programmer init"));
CCL.init = true; CCL.init = true;
return true; return true;
} }
@ -564,17 +564,17 @@ void CCLoaderLoop() {
switch(step) { switch(step) {
case 0: case 0:
CCLdebug_init(); CCLdebug_init();
AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: debug init")); AddLog(LOG_LEVEL_INFO,PSTR("CCL: debug init"));
step++; step++;
break; break;
case 1: case 1:
CCLread_chip_id(); CCLread_chip_id();
if((CCL.chip.ID!=0)) { if((CCL.chip.ID!=0)) {
AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: found chip with ID: %x, Rev: %x -> %s"), CCL.chip.ID, CCL.chip.rev, CCLChipName(CCL.chip.ID).c_str()); AddLog(LOG_LEVEL_INFO,PSTR("CCL: found chip with ID: %x, Rev: %x -> %s"), CCL.chip.ID, CCL.chip.rev, CCLChipName(CCL.chip.ID).c_str());
step++; step++;
} }
else { else {
AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: no chip found")); AddLog(LOG_LEVEL_INFO,PSTR("CCL: no chip found"));
return; return;
} }
break; break;
@ -587,7 +587,7 @@ bool CLLFlashFirmware(uint8_t* data, uint32_t size)
bool ret = true; bool ret = true;
unsigned char debug_config = 0; unsigned char debug_config = 0;
unsigned char Verify = 0; unsigned char Verify = 0;
AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: .bin file downloaded with size: %u blocks"), size/512); AddLog(LOG_LEVEL_INFO,PSTR("CCL: .bin file downloaded with size: %u blocks"), size/512);
if (CCL.chip.ID!=0) if (CCL.chip.ID!=0)
{ {
CCLRunDUP(); CCLRunDUP();
@ -608,7 +608,7 @@ bool CLLFlashFirmware(uint8_t* data, uint32_t size)
unsigned char rxBuf[512]; unsigned char rxBuf[512];
uint32_t block = 0; uint32_t block = 0;
unsigned int addr = 0x0000; unsigned int addr = 0x0000;
AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: will flash ....")); AddLog(LOG_LEVEL_INFO,PSTR("CCL: will flash ...."));
AddLogBuffer(LOG_LEVEL_DEBUG,data,16); // quick check to compare with a hex editor AddLogBuffer(LOG_LEVEL_DEBUG,data,16); // quick check to compare with a hex editor
while((block*512)<size) while((block*512)<size)
@ -624,7 +624,7 @@ bool CLLFlashFirmware(uint8_t* data, uint32_t size)
{ {
if(read_data[i] !=rxBuf[i]) if(read_data[i] !=rxBuf[i])
{ {
AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: flashing error, erasing flash!!")); AddLog(LOG_LEVEL_INFO,PSTR("CCL: flashing error, erasing flash!!"));
CCLchip_erase(); CCLchip_erase();
return true; return true;
} }
@ -633,7 +633,7 @@ bool CLLFlashFirmware(uint8_t* data, uint32_t size)
addr += (unsigned int)128; addr += (unsigned int)128;
block++; block++;
delay(10); // feed the dog delay(10); // feed the dog
AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: written block %u of %u"), block, size/512); AddLog(LOG_LEVEL_INFO,PSTR("CCL: written block %u of %u"), block, size/512);
} }
CCLRunDUP(); CCLRunDUP();
} }

View File

@ -49,11 +49,11 @@
Timing of an ALL OFF frame in clock cycles T=377µs, triggering on rising edge: Timing of an ALL OFF frame in clock cycles T=377µs, triggering on rising edge:
IDLE-2222444422224444-IDLE IDLE-2222444422224444-IDLE
********************* *********************
* About this driver * * About this driver *
********************* *********************
This driver implements the reverse engineered protocol of the FTC532 touch controller. This driver implements the reverse engineered protocol of the FTC532 touch controller.
The protocol encodes the bitmap of touched keys in variable length pulses comprising a The protocol encodes the bitmap of touched keys in variable length pulses comprising a
fixed length frame. These frames are then sent out continuously from the FTC532 chip. fixed length frame. These frames are then sent out continuously from the FTC532 chip.
@ -67,7 +67,7 @@
'snappiness' of touch reactions. Higher values will accumulate more samples in 50 ms steps 'snappiness' of touch reactions. Higher values will accumulate more samples in 50 ms steps
before actually firing the rules trigger. It will eat a few bytes off your RAM and Flash before actually firing the rules trigger. It will eat a few bytes off your RAM and Flash
budget, too. budget, too.
Usage: Usage:
------ ------
This driver does not actually switch anything. It is a pure "rules" driver that solely emits This driver does not actually switch anything. It is a pure "rules" driver that solely emits
@ -76,7 +76,7 @@
e.g. "00" means "no key touched" while "03" means "keys 1 and 2 touched simultaneously". e.g. "00" means "no key touched" while "03" means "keys 1 and 2 touched simultaneously".
Selecting "FTC532" on a GPIO will awake the driver. This driver can only be selected once. Selecting "FTC532" on a GPIO will awake the driver. This driver can only be selected once.
\*********************************************************************************************/ \*********************************************************************************************/
#define XDRV_47 47 #define XDRV_47 47
@ -180,7 +180,7 @@ void ftc532_update(void) { // Usually called every 50 m
if (++Ftc532.key_cnt >= FTC532_DEBOUNCE) { if (++Ftc532.key_cnt >= FTC532_DEBOUNCE) {
#endif // FTC532_DEBOUNCE > 1 #endif // FTC532_DEBOUNCE > 1
#ifdef DEBUG_FTC532 #ifdef DEBUG_FTC532
AddLog_P(LOG_LEVEL_DEBUG, PSTR("FTC: SAM=%04X KEY=%X OLD=%X INV=%u NOI=%u FRM=%u OK=%u TIME=%lu Pin=%u"), AddLog(LOG_LEVEL_DEBUG, PSTR("FTC: SAM=%04X KEY=%X OLD=%X INV=%u NOI=%u FRM=%u OK=%u TIME=%lu Pin=%u"),
Ftc532.sample, Ftc532.keys, Ftc532.old_keys, Ftc532.e_inv, Ftc532.e_noise, Ftc532.e_frame, Ftc532.sample, Ftc532.keys, Ftc532.old_keys, Ftc532.e_inv, Ftc532.e_noise, Ftc532.e_frame,
Ftc532.valid, Ftc532.rxtime, Pin(GPIO_FTC532)); Ftc532.valid, Ftc532.rxtime, Pin(GPIO_FTC532));
#endif // DEBUG_FTC532 #endif // DEBUG_FTC532
@ -197,7 +197,7 @@ void ftc532_update(void) { // Usually called every 50 m
#ifdef DEBUG_FTC532 #ifdef DEBUG_FTC532
else { else {
++Ftc532.e_inv; ++Ftc532.e_inv;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("FTC: ILL SAM=%04X"), Ftc532.sample); AddLog(LOG_LEVEL_DEBUG, PSTR("FTC: ILL SAM=%04X"), Ftc532.sample);
} }
#endif // DEBUG_FTC532 #endif // DEBUG_FTC532
} }

View File

@ -136,7 +136,7 @@ void TimepropSetPower(int index, float power) {
} }
void TimepropInit(void) { void TimepropInit(void) {
// AddLog_P(LOG_LEVEL_INFO, PSTR("TPR: Timeprop Init")); // AddLog(LOG_LEVEL_INFO, PSTR("TPR: Timeprop Init"));
int cycleTimes[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_CYCLETIMES}; int cycleTimes[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_CYCLETIMES};
int deadTimes[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_DEADTIMES}; int deadTimes[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_DEADTIMES};
int opInverts[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_OPINVERTS}; int opInverts[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_OPINVERTS};

View File

@ -246,7 +246,7 @@ void PIDShowSensor() {
Pid.run_pid_now = true; Pid.run_pid_now = true;
} }
} else { } else {
AddLog_P(LOG_LEVEL_ERROR, PSTR("PID: No local temperature sensor found")); AddLog(LOG_LEVEL_ERROR, PSTR("PID: No local temperature sensor found"));
} }
} }

View File

@ -131,7 +131,7 @@ void UfsInitOnce(void) {
void UfsInit(void) { void UfsInit(void) {
UfsInitOnce(); UfsInitOnce();
if (ufs_type) { if (ufs_type) {
AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: FlashFS mounted with %d kB free"), UfsInfo(1, 0)); AddLog(LOG_LEVEL_INFO, PSTR("UFS: FlashFS mounted with %d kB free"), UfsInfo(1, 0));
} }
} }
@ -165,10 +165,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_P(LOG_LEVEL_INFO, PSTR("UFS: SDCard mounted")); AddLog(LOG_LEVEL_INFO, PSTR("UFS: SDCard mounted"));
#endif // ESP8266 #endif // ESP8266
#ifdef ESP32 #ifdef ESP32
AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: SDCard mounted with %d kB free"), UfsInfo(1, 0)); AddLog(LOG_LEVEL_INFO, PSTR("UFS: SDCard mounted with %d kB free"), UfsInfo(1, 0));
#endif // ESP32 #endif // ESP32
} }
} }
@ -276,7 +276,7 @@ bool TfsFileExists(const char *fname){
bool yes = ffsp->exists(fname); bool yes = ffsp->exists(fname);
if (!yes) { if (!yes) {
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: File not found")); AddLog(LOG_LEVEL_INFO, PSTR("TFS: File not found"));
} }
return yes; return yes;
} }
@ -286,7 +286,7 @@ bool TfsSaveFile(const char *fname, const uint8_t *buf, uint32_t len) {
File file = ffsp->open(fname, "w"); File file = ffsp->open(fname, "w");
if (!file) { if (!file) {
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Save failed")); AddLog(LOG_LEVEL_INFO, PSTR("TFS: Save failed"));
return false; return false;
} }
@ -300,7 +300,7 @@ bool TfsInitFile(const char *fname, uint32_t len, uint8_t init_value) {
File file = ffsp->open(fname, "w"); File file = ffsp->open(fname, "w");
if (!file) { if (!file) {
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Erase failed")); AddLog(LOG_LEVEL_INFO, PSTR("TFS: Erase failed"));
return false; return false;
} }
@ -317,7 +317,7 @@ bool TfsLoadFile(const char *fname, uint8_t *buf, uint32_t len) {
File file = ffsp->open(fname, "r"); File file = ffsp->open(fname, "r");
if (!file) { if (!file) {
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: File not found")); AddLog(LOG_LEVEL_INFO, PSTR("TFS: File not found"));
return false; return false;
} }
@ -330,7 +330,7 @@ bool TfsDeleteFile(const char *fname) {
if (!ffs_type) { return false; } if (!ffs_type) { return false; }
if (!ffsp->remove(fname)) { if (!ffsp->remove(fname)) {
AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Delete failed")); AddLog(LOG_LEVEL_INFO, PSTR("TFS: Delete failed"));
return false; return false;
} }
return true; return true;
@ -446,7 +446,7 @@ const char UFS_FORM_SDC_HREFdel[] PROGMEM =
void UfsDirectory(void) { void UfsDirectory(void) {
if (!HttpCheckPriviledgedAccess()) { return; } if (!HttpCheckPriviledgedAccess()) { return; }
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_MANAGE_FILE_SYSTEM)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_MANAGE_FILE_SYSTEM));
uint8_t depth = 0; uint8_t depth = 0;
@ -597,13 +597,13 @@ uint8_t UfsDownloadFile(char *file) {
File download_file; File download_file;
if (!dfsp->exists(file)) { if (!dfsp->exists(file)) {
AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: File not found")); AddLog(LOG_LEVEL_INFO, PSTR("UFS: File not found"));
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_P(LOG_LEVEL_INFO, PSTR("UFS: Could not open file")); AddLog(LOG_LEVEL_INFO, PSTR("UFS: Could not open file"));
return 0; return 0;
} }
@ -659,7 +659,7 @@ uint8_t UfsDownloadFile(char *file) {
download_file.close(); download_file.close();
if (download_busy == true) { if (download_busy == true) {
AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: Download is busy")); AddLog(LOG_LEVEL_INFO, PSTR("UFS: Download is busy"));
return 0; return 0;
} }

View File

@ -34,7 +34,7 @@
THE PROTOCOL [tm]: THE PROTOCOL [tm]:
================== ==================
see Holtek-Semicon BS814A-2 datasheet for details see Holtek-Semicon BS814A-2 datasheet for details
********************* *********************
* About this driver * * About this driver *
********************* *********************
@ -100,7 +100,7 @@ void bs814_read(void) { // Poll touch keys
uint8_t checksum = 0; uint8_t checksum = 0;
uint8_t bitp; uint8_t bitp;
bool bitval; bool bitval;
// generate clock signal & sample frame // generate clock signal & sample frame
for (bitp = 0; bitp < 2 * BS814_KEYS_MAX; ++bitp) { for (bitp = 0; bitp < 2 * BS814_KEYS_MAX; ++bitp) {
digitalWrite(Pin(GPIO_BS814_CLK), LOW); digitalWrite(Pin(GPIO_BS814_CLK), LOW);
@ -123,8 +123,8 @@ void bs814_read(void) { // Poll touch keys
// validate frame // validate frame
if (BS814_KEYS_MAX - checksum != ((frame >> 4) & 0x7)) { // checksum error if (BS814_KEYS_MAX - checksum != ((frame >> 4) & 0x7)) { // checksum error
#ifdef DEBUG_BS814_DRIVER #ifdef DEBUG_BS814_DRIVER
++Bs814.e_cksum; ++Bs814.e_cksum;
AddLog_P(LOG_LEVEL_DEBUG, PSTR("CKS=%02X CFR=%02X"), checksum, (frame >> 4) & 0x7); AddLog(LOG_LEVEL_DEBUG, PSTR("CKS=%02X CFR=%02X"), checksum, (frame >> 4) & 0x7);
#endif // DEBUG_BS814_DRIVER #endif // DEBUG_BS814_DRIVER
return; return;
} }
@ -144,7 +144,7 @@ void bs814_update(void) { // Usually called every 50 ms
bs814_read(); bs814_read();
if ((Bs814.keys & 0xF) != (Bs814.keys >> 4)) { if ((Bs814.keys & 0xF) != (Bs814.keys >> 4)) {
#ifdef DEBUG_BS814_DRIVER #ifdef DEBUG_BS814_DRIVER
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BS814: KEY=%0X OLD=%0X LVL=%u CKS=%u STP=%u OK=%u CLK=%u DAT=%u"), AddLog(LOG_LEVEL_DEBUG, PSTR("BS814: KEY=%0X OLD=%0X LVL=%u CKS=%u STP=%u OK=%u CLK=%u DAT=%u"),
Bs814.keys & 0xF, Bs814.keys >> 4, Bs814.e_level, Bs814.e_cksum, Bs814.e_stp, Bs814.keys & 0xF, Bs814.keys >> 4, Bs814.e_level, Bs814.e_cksum, Bs814.e_stp,
Bs814.valid, Pin(GPIO_BS814_CLK), Pin(GPIO_BS814_DAT)); Bs814.valid, Pin(GPIO_BS814_CLK), Pin(GPIO_BS814_DAT));
#endif // DEBUG_BS814_DRIVER #endif // DEBUG_BS814_DRIVER

View File

@ -599,7 +599,7 @@ int addSeenDevice(const uint8_t *mac, uint8_t addrtype, const char *name, int8_t
int total = seenDevices.size(); int total = seenDevices.size();
if (total < MAX_BLE_DEVICES_LOGGED){ if (total < MAX_BLE_DEVICES_LOGGED){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: New seendev slot %d"), total); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: New seendev slot %d"), total);
#endif #endif
BLE_ESP32::BLE_simple_device_t* dev = new BLE_ESP32::BLE_simple_device_t; BLE_ESP32::BLE_simple_device_t* dev = new BLE_ESP32::BLE_simple_device_t;
freeDevices.push_back(dev); freeDevices.push_back(dev);
@ -667,10 +667,10 @@ int deleteSeenDevices(int ageS = 0){
dump(addr, 20, dev->mac, 6); dump(addr, 20, dev->mac, 6);
const char *alias = getAlias(dev->mac); const char *alias = getAlias(dev->mac);
if (!filter){ if (!filter){
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Delete device %s(%s) by age lastseen %u + maxage %u < now %u."), AddLog(LOG_LEVEL_INFO,PSTR("BLE: Delete device %s(%s) by age lastseen %u + maxage %u < now %u."),
addr, alias, lastseenS, ageS, nowS); addr, alias, lastseenS, ageS, nowS);
} else { } else {
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Delete device %s(%s) by addrtype filter %d > %d."), AddLog(LOG_LEVEL_INFO,PSTR("BLE: Delete device %s(%s) by addrtype filter %d > %d."),
addr, alias, dev->addrtype, BLEAddressFilter); addr, alias, dev->addrtype, BLEAddressFilter);
} }
#endif #endif
@ -682,7 +682,7 @@ int deleteSeenDevices(int ageS = 0){
} }
if (res){ if (res){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Deleted %d devices"), res); AddLog(LOG_LEVEL_INFO,PSTR("BLE: Deleted %d devices"), res);
#endif #endif
} }
return res; return res;
@ -820,7 +820,7 @@ int getSeenDevicesToJson(char *dest, int maxlen){
} }
// deliberate test of SafeAddLog_P from main thread... // deliberate test of SafeAddLog_P from main thread...
//AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: getSeen %d"), seenDevices.size()); //AddLog(LOG_LEVEL_INFO,PSTR("BLE: getSeen %d"), seenDevices.size());
int len; int len;
@ -1184,17 +1184,17 @@ void postAdvertismentDetails(){
class BLESensorCallback : public NimBLEClientCallbacks { class BLESensorCallback : public NimBLEClientCallbacks {
void onConnect(NimBLEClient* pClient) { void onConnect(NimBLEClient* pClient) {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: onConnect %s"), ((std::string)pClient->getPeerAddress()).c_str()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: onConnect %s"), ((std::string)pClient->getPeerAddress()).c_str());
#endif #endif
} }
void onDisconnect(NimBLEClient* pClient) { void onDisconnect(NimBLEClient* pClient) {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: onDisconnect %s"), ((std::string)pClient->getPeerAddress()).c_str()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: onDisconnect %s"), ((std::string)pClient->getPeerAddress()).c_str());
#endif #endif
} }
bool onConnParamsUpdateRequest(NimBLEClient* pClient, const ble_gap_upd_params* params) { bool onConnParamsUpdateRequest(NimBLEClient* pClient, const ble_gap_upd_params* params) {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: onConnParamsUpdateRequest %s"), ((std::string)pClient->getPeerAddress()).c_str()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: onConnParamsUpdateRequest %s"), ((std::string)pClient->getPeerAddress()).c_str());
#endif #endif
// if(params->itvl_min < 24) { /** 1.25ms units */ // if(params->itvl_min < 24) { /** 1.25ms units */
@ -1315,7 +1315,7 @@ class BLEAdvCallbacks: public NimBLEAdvertisedDeviceCallbacks {
} }
} catch(const std::exception& e){ } catch(const std::exception& e){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: exception in advertismentCallbacks")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: exception in advertismentCallbacks"));
#endif #endif
} }
} }
@ -1334,18 +1334,18 @@ static BLESensorCallback BLESensorCB;
static void BLEscanEndedCB(NimBLEScanResults results){ static void BLEscanEndedCB(NimBLEScanResults results){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Scan ended")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Scan ended"));
#endif #endif
for (int i = 0; i < scancompleteCallbacks.size(); i++){ for (int i = 0; i < scancompleteCallbacks.size(); i++){
try { try {
SCANCOMPLETE_CALLBACK *pFn = scancompleteCallbacks[i]; SCANCOMPLETE_CALLBACK *pFn = scancompleteCallbacks[i];
int callbackres = pFn(results); int callbackres = pFn(results);
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: scancompleteCallbacks %d %d"), i, callbackres); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: scancompleteCallbacks %d %d"), i, callbackres);
#endif #endif
} catch(const std::exception& e){ } catch(const std::exception& e){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: exception in operationsCallbacks")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: exception in operationsCallbacks"));
#endif #endif
} }
} }
@ -1367,21 +1367,21 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui
if (!pRemoteCharacteristic){ if (!pRemoteCharacteristic){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Notify: no remote char!!??")); AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Notify: no remote char!!??"));
#endif #endif
return; return;
} }
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Notified length: %u"),length); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Notified length: %u"),length);
#endif #endif
// find the operation this is associated with // find the operation this is associated with
NimBLERemoteService *pSvc = pRemoteCharacteristic->getRemoteService(); NimBLERemoteService *pSvc = pRemoteCharacteristic->getRemoteService();
if (!pSvc){ if (!pSvc){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Notify: no remote service found")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Notify: no remote service found"));
#endif #endif
return; return;
} }
@ -1389,7 +1389,7 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui
pRClient = pSvc->getClient(); pRClient = pSvc->getClient();
if (!pRClient){ if (!pRClient){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Notify: no remote client!!??")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Notify: no remote client!!??"));
#endif #endif
return; return;
} }
@ -1404,7 +1404,7 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui
generic_sensor_t *op = currentOperations[i]; generic_sensor_t *op = currentOperations[i];
if (!op){ if (!op){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Notify: null op in currentOperations!!??")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Notify: null op in currentOperations!!??"));
#endif #endif
} else { } else {
if (devaddr == op->addr){ if (devaddr == op->addr){
@ -1420,7 +1420,7 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui
if (!thisop){ if (!thisop){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: no op for notify")); AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: no op for notify"));
#endif #endif
return; return;
} }
@ -1452,21 +1452,21 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui
void registerForAdvertismentCallbacks(const char *tag, BLE_ESP32::ADVERTISMENT_CALLBACK* pFn){ void registerForAdvertismentCallbacks(const char *tag, BLE_ESP32::ADVERTISMENT_CALLBACK* pFn){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: registerForAdvertismentCallbacks %s:%x"), tag, (uint32_t) pFn); AddLog(LOG_LEVEL_INFO,PSTR("BLE: registerForAdvertismentCallbacks %s:%x"), tag, (uint32_t) pFn);
#endif #endif
advertismentCallbacks.push_back(pFn); advertismentCallbacks.push_back(pFn);
} }
void registerForOpCallbacks(const char *tag, BLE_ESP32::OPCOMPLETE_CALLBACK* pFn){ void registerForOpCallbacks(const char *tag, BLE_ESP32::OPCOMPLETE_CALLBACK* pFn){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: registerForOpCallbacks %s:%x"), tag, (uint32_t) pFn); AddLog(LOG_LEVEL_INFO,PSTR("BLE: registerForOpCallbacks %s:%x"), tag, (uint32_t) pFn);
#endif #endif
operationsCallbacks.push_back(pFn); operationsCallbacks.push_back(pFn);
} }
void registerForScanCallbacks(const char *tag, BLE_ESP32::SCANCOMPLETE_CALLBACK* pFn){ void registerForScanCallbacks(const char *tag, BLE_ESP32::SCANCOMPLETE_CALLBACK* pFn){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: registerForScnCallbacks %s:%x"), tag, (uint32_t) pFn); AddLog(LOG_LEVEL_INFO,PSTR("BLE: registerForScnCallbacks %s:%x"), tag, (uint32_t) pFn);
#endif #endif
scancompleteCallbacks.push_back(pFn); scancompleteCallbacks.push_back(pFn);
} }
@ -1490,7 +1490,7 @@ static void BLEInit(void) {
TasmotaGlobal.wifi_stay_asleep = true; TasmotaGlobal.wifi_stay_asleep = true;
if (WiFi.getSleep() == false) { if (WiFi.getSleep() == false) {
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Put WiFi modem in sleep mode"),"BLE"); AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Put WiFi modem in sleep mode"),"BLE");
WiFi.setSleep(true); // Sleep WiFi.setSleep(true); // Sleep
} }
@ -1524,7 +1524,7 @@ static void BLEOperationTask(void *pvParameters);
static void BLEStartOperationTask(){ static void BLEStartOperationTask(){
if (BLERunning == false){ if (BLERunning == false){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: %s: Start operations"),D_CMND_BLE); AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: %s: Start operations"),D_CMND_BLE);
#endif #endif
BLERunning = true; BLERunning = true;
@ -1547,25 +1547,25 @@ static void BLEStartOperationTask(){
static void BLETaskStopStartNimBLE(NimBLEClient **ppClient, bool start = true){ static void BLETaskStopStartNimBLE(NimBLEClient **ppClient, bool start = true){
if (*ppClient){ if (*ppClient){
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Task:Stopping NimBLE")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Task:Stopping NimBLE"));
(*ppClient)->setClientCallbacks(nullptr, false); (*ppClient)->setClientCallbacks(nullptr, false);
try { try {
if ((*ppClient)->isConnected()){ if ((*ppClient)->isConnected()){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: disconnecting connected client")); AddLog(LOG_LEVEL_INFO,PSTR("BLE: disconnecting connected client"));
#endif #endif
(*ppClient)->disconnect(); (*ppClient)->disconnect();
} }
NimBLEDevice::deleteClient((*ppClient)); NimBLEDevice::deleteClient((*ppClient));
(*ppClient) = nullptr; (*ppClient) = nullptr;
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: deleted client")); AddLog(LOG_LEVEL_INFO,PSTR("BLE: deleted client"));
#endif #endif
} catch(const std::exception& e){ } catch(const std::exception& e){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Stopping NimBLE:exception in delete client")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Stopping NimBLE:exception in delete client"));
#endif #endif
} }
@ -1582,7 +1582,7 @@ static void BLETaskStopStartNimBLE(NimBLEClient **ppClient, bool start = true){
BLERunningScan = 0; BLERunningScan = 0;
if (start){ if (start){
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: BLETask:Starting NimBLE")); AddLog(LOG_LEVEL_INFO,PSTR("BLE: BLETask:Starting NimBLE"));
NimBLEDevice::init("BLE_ESP32"); NimBLEDevice::init("BLE_ESP32");
*ppClient = NimBLEDevice::createClient(); *ppClient = NimBLEDevice::createClient();
@ -1623,7 +1623,7 @@ int BLETaskStartScan(int time){
} }
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: Startscan")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: Startscan"));
#endif #endif
//vTaskDelay(500/ portTICK_PERIOD_MS); //vTaskDelay(500/ portTICK_PERIOD_MS);
ble32Scan->setActiveScan(BLEScanActiveMode ? 1: 0); ble32Scan->setActiveScan(BLEScanActiveMode ? 1: 0);
@ -1652,7 +1652,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
*pCurrentOperation = nextOperation(&queuedOperations); *pCurrentOperation = nextOperation(&queuedOperations);
if (*pCurrentOperation){ if (*pCurrentOperation){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: new currentOperation")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: new currentOperation"));
#endif #endif
BLEOpCount++; BLEOpCount++;
generic_sensor_t* temp = *pCurrentOperation; generic_sensor_t* temp = *pCurrentOperation;
@ -1673,7 +1673,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
diff = diff/1000; diff = diff/1000;
if (diff > 20000){ // 20s if (diff > 20000){ // 20s
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: notify timeout")); AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: notify timeout"));
#endif #endif
(*pCurrentOperation)->state = GEN_STATE_FAILED_NOTIFYTIMEOUT; (*pCurrentOperation)->state = GEN_STATE_FAILED_NOTIFYTIMEOUT;
(*pCurrentOperation)->notifytimer = 0; (*pCurrentOperation)->notifytimer = 0;
@ -1690,7 +1690,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
(*pCurrentOperation)->state = GEN_STATE_NOTIFIED; (*pCurrentOperation)->state = GEN_STATE_NOTIFIED;
// just stay here until this is removed by the main thread // just stay here until this is removed by the main thread
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: notify operation complete")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: notify operation complete"));
#endif #endif
BLE_ESP32::BLETaskRunTaskDoneOperation(pCurrentOperation, ppClient); BLE_ESP32::BLETaskRunTaskDoneOperation(pCurrentOperation, ppClient);
pClient = *ppClient; pClient = *ppClient;
@ -1701,7 +1701,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
case GEN_STATE_NOTIFIED: // - may have completed DURING our read/write to get here case GEN_STATE_NOTIFIED: // - may have completed DURING our read/write to get here
// just stay here until this is removed by the main thread // just stay here until this is removed by the main thread
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: operation complete")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: operation complete"));
#endif #endif
BLE_ESP32::BLETaskRunTaskDoneOperation(pCurrentOperation, ppClient); BLE_ESP32::BLETaskRunTaskDoneOperation(pCurrentOperation, ppClient);
pClient = *ppClient; pClient = *ppClient;
@ -1721,7 +1721,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
if ((*pCurrentOperation)->state <= GEN_STATE_FAILED){ if ((*pCurrentOperation)->state <= GEN_STATE_FAILED){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: BLETask: op failed %d"), (*pCurrentOperation)->state); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: BLETask: op failed %d"), (*pCurrentOperation)->state);
#endif #endif
BLE_ESP32::BLETaskRunTaskDoneOperation(pCurrentOperation, ppClient); BLE_ESP32::BLETaskRunTaskDoneOperation(pCurrentOperation, ppClient);
pClient = *ppClient; pClient = *ppClient;
@ -1735,7 +1735,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
if (pClient->isConnected()){ if (pClient->isConnected()){
// don't do anything if we are still connected // don't do anything if we are still connected
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: still connected")); AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: still connected"));
#endif #endif
return; return;
} }
@ -1755,7 +1755,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
op->state = GEN_STATE_STARTED; op->state = GEN_STATE_STARTED;
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: attempt connect %s"), ((std::string)op->addr).c_str()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: attempt connect %s"), ((std::string)op->addr).c_str());
#endif #endif
if (!op->serviceUUID.bitSize()){ if (!op->serviceUUID.bitSize()){
@ -1766,7 +1766,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
if (pClient->connect(op->addr, true)) { if (pClient->connect(op->addr, true)) {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: connected %s -> getservice"), ((std::string)op->addr).c_str()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: connected %s -> getservice"), ((std::string)op->addr).c_str());
#endif #endif
NimBLERemoteService *pService = pClient->getService(op->serviceUUID); NimBLERemoteService *pService = pClient->getService(op->serviceUUID);
int waitNotify = false; int waitNotify = false;
@ -1775,7 +1775,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
if (pService != nullptr) { if (pService != nullptr) {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: got service")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: got service"));
#endif #endif
// pre-set to fail if no operations requested // pre-set to fail if no operations requested
//newstate = GEN_STATE_FAILED_NOREADWRITE; //newstate = GEN_STATE_FAILED_NOREADWRITE;
@ -1792,13 +1792,13 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
pService->getCharacteristic(op->notificationCharacteristicUUID); pService->getCharacteristic(op->notificationCharacteristicUUID);
if (pNCharacteristic != nullptr) { if (pNCharacteristic != nullptr) {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: got notify characteristic")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: got notify characteristic"));
#endif #endif
op->notifylen = 0; op->notifylen = 0;
if(pNCharacteristic->canNotify()) { if(pNCharacteristic->canNotify()) {
if(pNCharacteristic->subscribe(true, BLE_ESP32::BLEGenNotifyCB)) { if(pNCharacteristic->subscribe(true, BLE_ESP32::BLEGenNotifyCB)) {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for notify")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for notify"));
#endif #endif
uint64_t now = esp_timer_get_time(); uint64_t now = esp_timer_get_time();
op->notifytimer = now; op->notifytimer = now;
@ -1808,7 +1808,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
waitNotify = true; waitNotify = true;
} else { } else {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for notify")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for notify"));
#endif #endif
newstate = GEN_STATE_FAILED_NOTIFY; newstate = GEN_STATE_FAILED_NOTIFY;
} }
@ -1816,7 +1816,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
if(pNCharacteristic->canIndicate()) { if(pNCharacteristic->canIndicate()) {
if(pNCharacteristic->subscribe(false, BLE_ESP32::BLEGenNotifyCB)) { if(pNCharacteristic->subscribe(false, BLE_ESP32::BLEGenNotifyCB)) {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for indicate")); AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for indicate"));
#endif #endif
notifystate = GEN_STATE_WAITINDICATE; notifystate = GEN_STATE_WAITINDICATE;
uint64_t now = esp_timer_get_time(); uint64_t now = esp_timer_get_time();
@ -1824,21 +1824,21 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
waitNotify = true; waitNotify = true;
} else { } else {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for indicate")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for indicate"));
#endif #endif
newstate = GEN_STATE_FAILED_INDICATE; newstate = GEN_STATE_FAILED_INDICATE;
} }
} else { } else {
newstate = GEN_STATE_FAILED_CANTNOTIFYORINDICATE; newstate = GEN_STATE_FAILED_CANTNOTIFYORINDICATE;
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: characteristic can't notify")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: characteristic can't notify"));
#endif #endif
} }
} }
} else { } else {
newstate = GEN_STATE_FAILED_NONOTIFYCHAR; newstate = GEN_STATE_FAILED_NONOTIFYCHAR;
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: notify characteristic not found")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: notify characteristic not found"));
#endif #endif
} }
@ -1855,7 +1855,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
pCharacteristic = pService->getCharacteristic(op->characteristicUUID); pCharacteristic = pService->getCharacteristic(op->characteristicUUID);
if (pCharacteristic != nullptr) { if (pCharacteristic != nullptr) {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: got read/write characteristic")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: got read/write characteristic"));
#endif #endif
newstate = GEN_STATE_FAILED_NOREADWRITE; // overwritten on failure newstate = GEN_STATE_FAILED_NOREADWRITE; // overwritten on failure
@ -1875,12 +1875,12 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
if (op->readmodifywritecallback){ if (op->readmodifywritecallback){
READ_CALLBACK *pFn = (READ_CALLBACK *)op->readmodifywritecallback; READ_CALLBACK *pFn = (READ_CALLBACK *)op->readmodifywritecallback;
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: read characteristic with readmodifywritecallback")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: read characteristic with readmodifywritecallback"));
#endif #endif
pFn(op); pFn(op);
} else { } else {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: read characteristic")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: read characteristic"));
#endif #endif
} }
@ -1896,12 +1896,12 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
if (!pCharacteristic->writeValue(op->dataToWrite, op->writelen, true)){ if (!pCharacteristic->writeValue(op->dataToWrite, op->writelen, true)){
newstate = GEN_STATE_FAILED_WRITE; newstate = GEN_STATE_FAILED_WRITE;
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: characteristic write fail")); AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: characteristic write fail"));
#endif #endif
} else { } else {
if (!waitNotify) newstate = GEN_STATE_WRITEDONE; if (!waitNotify) newstate = GEN_STATE_WRITEDONE;
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: write characteristic")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: write characteristic"));
#endif #endif
} }
} else { } else {
@ -1913,7 +1913,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
} else { } else {
newstate = GEN_STATE_FAILED_NO_RW_CHAR; newstate = GEN_STATE_FAILED_NO_RW_CHAR;
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: r/w characteristic not found")); AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: r/w characteristic not found"));
#endif #endif
} }
} }
@ -1934,7 +1934,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
newstate = GEN_STATE_FAILED_NOSERVICE; newstate = GEN_STATE_FAILED_NOSERVICE;
// failed to get a service // failed to get a service
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: failed - svc not on device?")); AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: failed - svc not on device?"));
#endif #endif
} }
@ -1946,14 +1946,14 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
switch (rc){ switch (rc){
case (0x0200+BLE_ERR_CONN_LIMIT ): case (0x0200+BLE_ERR_CONN_LIMIT ):
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Hit connection limit? - restarting NimBLE")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Hit connection limit? - restarting NimBLE"));
#endif #endif
BLERestartNimBLE = 1; BLERestartNimBLE = 1;
BLERestartBLEReason = BLE_RESTART_BLE_REASON_CONN_LIMIT; BLERestartBLEReason = BLE_RESTART_BLE_REASON_CONN_LIMIT;
break; break;
case (0x0200+BLE_ERR_ACL_CONN_EXISTS): case (0x0200+BLE_ERR_ACL_CONN_EXISTS):
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Connection exists? - restarting NimBLE")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Connection exists? - restarting NimBLE"));
#endif #endif
BLERestartNimBLE = 1; BLERestartNimBLE = 1;
BLERestartBLEReason = BLE_RESTART_BLE_REASON_CONN_EXISTS; BLERestartBLEReason = BLE_RESTART_BLE_REASON_CONN_EXISTS;
@ -1963,7 +1963,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
// failed to connect // failed to connect
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: failed to connect to device %d"), rc); AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: failed to connect to device %d"), rc);
#endif #endif
} }
op->state = newstate; op->state = newstate;
@ -1979,7 +1979,7 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE
try { try {
if ((*ppClient)->isConnected()){ if ((*ppClient)->isConnected()){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: runTaskDoneOperation: disconnecting connected client")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: runTaskDoneOperation: disconnecting connected client"));
#endif #endif
(*ppClient)->disconnect(); (*ppClient)->disconnect();
// wait for 1/2 second after disconnect // wait for 1/2 second after disconnect
@ -1990,7 +1990,7 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE
//(*ppClient)->disconnect(); //(*ppClient)->disconnect();
// we will stall here forever!!! - as testing // we will stall here forever!!! - as testing
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d"), waits); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d"), waits);
#endif #endif
vTaskDelay(500/ portTICK_PERIOD_MS); vTaskDelay(500/ portTICK_PERIOD_MS);
} }
@ -1999,11 +1999,11 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE
int conn_id = (*ppClient)->getConnId(); int conn_id = (*ppClient)->getConnId();
ble_gap_conn_broken(conn_id, -1); ble_gap_conn_broken(conn_id, -1);
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d - kill connection"), waits); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d - kill connection"), waits);
#endif #endif
} }
if (waits == 60){ if (waits == 60){
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: >60s waiting -> BLE Failed, restart Tasmota %d"), waits); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: >60s waiting -> BLE Failed, restart Tasmota %d"), waits);
BLEStop = 1; BLEStop = 1;
BLEStopAt = esp_timer_get_time(); BLEStopAt = esp_timer_get_time();
@ -2015,7 +2015,7 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE
} }
} catch(const std::exception& e){ } catch(const std::exception& e){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: runTaskDoneOperation: exception in disconnect")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: runTaskDoneOperation: exception in disconnect"));
#endif #endif
} }
@ -2035,7 +2035,7 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE
// by adding it to this list, this will cause it to be sent to MQTT // by adding it to this list, this will cause it to be sent to MQTT
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: runTaskDoneOperation: add to completedOperations")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: runTaskDoneOperation: add to completedOperations"));
#endif #endif
addOperation(&completedOperations, op); addOperation(&completedOperations, op);
return; return;
@ -2096,7 +2096,7 @@ static void BLEOperationTask(void *pvParameters){
BLERestartNimBLE = 0; BLERestartNimBLE = 0;
BLERestartTasmota = 10; BLERestartTasmota = 10;
BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_RESTARTING_BLE_TIMEOUT; BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_RESTARTING_BLE_TIMEOUT;
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: BLETask: Restart NimBLE - restart Tasmota in 10 if not complt")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: BLETask: Restart NimBLE - restart Tasmota in 10 if not complt"));
BLE_ESP32::BLETaskStopStartNimBLE(&pClient); BLE_ESP32::BLETaskStopStartNimBLE(&pClient);
BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_UNKNOWN; BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_UNKNOWN;
BLERestartTasmota = 0; BLERestartTasmota = 0;
@ -2110,7 +2110,7 @@ static void BLEOperationTask(void *pvParameters){
vTaskDelay(100/ portTICK_PERIOD_MS); vTaskDelay(100/ portTICK_PERIOD_MS);
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLEOperationTask: Left task")); AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLEOperationTask: Left task"));
#endif #endif
deleteSeenDevices(); deleteSeenDevices();
@ -2159,7 +2159,7 @@ static void BLEEverySecond(bool restart){
BLEMasterEnable = Settings.flag5.mi32_enable; BLEMasterEnable = Settings.flag5.mi32_enable;
} }
} }
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: MasterEnable->%d"), BLEMasterEnable); AddLog(LOG_LEVEL_INFO,PSTR("BLE: MasterEnable->%d"), BLEMasterEnable);
} }
@ -2192,11 +2192,11 @@ static void BLEEverySecond(bool restart){
if (!BLERestartTasmotaReason) BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_UNKNOWN; if (!BLERestartTasmotaReason) BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_UNKNOWN;
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"reboot\":\"%s\"}"), BLERestartTasmotaReason); snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"reboot\":\"%s\"}"), BLERestartTasmotaReason);
MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain); MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain);
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting Tasmota in %d seconds because %s"), BLERestartTasmota, BLERestartTasmotaReason); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting Tasmota in %d seconds because %s"), BLERestartTasmota, BLERestartTasmotaReason);
} }
if (!BLERestartTasmota){ if (!BLERestartTasmota){
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting Tasmota because %s"), BLERestartTasmotaReason); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting Tasmota because %s"), BLERestartTasmotaReason);
// just a normal restart // just a normal restart
TasmotaGlobal.restart_flag = 1; TasmotaGlobal.restart_flag = 1;
} }
@ -2205,7 +2205,7 @@ static void BLEEverySecond(bool restart){
if (BLERestartBLEReason){ // just use the ptr as the trigger to send MQTT if (BLERestartBLEReason){ // just use the ptr as the trigger to send MQTT
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"blerestart\":\"%s\"}"), BLERestartBLEReason); snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"blerestart\":\"%s\"}"), BLERestartBLEReason);
MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain); MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain);
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting BLE Stack because %s"), BLERestartBLEReason); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting BLE Stack because %s"), BLERestartBLEReason);
BLERestartBLEReason = nullptr; BLERestartBLEReason = nullptr;
} }
@ -2250,9 +2250,9 @@ int addOperation(std::deque<generic_sensor_t*> *ops, generic_sensor_t** op){
} }
} }
if (res){ if (res){
//AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: added operation")); //AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: added operation"));
} else { } else {
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: op - no room")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: op - no room"));
} }
return res; return res;
} }
@ -2260,7 +2260,7 @@ int addOperation(std::deque<generic_sensor_t*> *ops, generic_sensor_t** op){
int newOperation(BLE_ESP32::generic_sensor_t** op){ int newOperation(BLE_ESP32::generic_sensor_t** op){
if (!op) { if (!op) {
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: op inv in newOperation")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: op inv in newOperation"));
return 0; return 0;
} }
@ -2299,7 +2299,7 @@ int freeOperation(BLE_ESP32::generic_sensor_t** op){
int extQueueOperation(BLE_ESP32::generic_sensor_t** op){ int extQueueOperation(BLE_ESP32::generic_sensor_t** op){
if (!op || !(*op)) { if (!op || !(*op)) {
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: op invalid")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: op invalid"));
return 0; return 0;
} }
(*op)->state = GEN_STATE_START; // trigger request later (*op)->state = GEN_STATE_START; // trigger request later
@ -2307,7 +2307,7 @@ int extQueueOperation(BLE_ESP32::generic_sensor_t** op){
int res = addOperation(&queuedOperations, op); int res = addOperation(&queuedOperations, op);
if (!res){ if (!res){
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: extQueueOperation: op added id %d failed"), (lastopid-1)); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: extQueueOperation: op added id %d failed"), (lastopid-1));
} }
return res; return res;
} }
@ -2427,7 +2427,7 @@ static int StartBLE(void) {
BLE_ESP32::BLEStartOperationTask(); BLE_ESP32::BLEStartOperationTask();
return 1; return 1;
} }
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: StartBLE - wait as BLEStop==1")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: StartBLE - wait as BLEStop==1"));
return 0; return 0;
} }
@ -2436,16 +2436,16 @@ static int StopBLE(void){
if (BLERunning){ if (BLERunning){
if (BLEStop != 1){ if (BLEStop != 1){
BLEStop = 1; BLEStop = 1;
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: StopBLE - BLEStop->1")); AddLog(LOG_LEVEL_INFO,PSTR("BLE: StopBLE - BLEStop->1"));
BLEStopAt = esp_timer_get_time(); BLEStopAt = esp_timer_get_time();
// give a little time for it to stop. // give a little time for it to stop.
vTaskDelay(1000/ portTICK_PERIOD_MS); vTaskDelay(1000/ portTICK_PERIOD_MS);
return 1; return 1;
} }
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: StopBLE - wait as BLEStop==1")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: StopBLE - wait as BLEStop==1"));
return 0; return 0;
} else { } else {
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: StopBLE - was not running")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: StopBLE - was not running"));
return 1; return 1;
} }
} }
@ -2686,7 +2686,7 @@ void CmndBLEDetails(void){
void CmndBLEAlias(void){ void CmndBLEAlias(void){
#ifdef BLE_ESP32_ALIASES #ifdef BLE_ESP32_ALIASES
int op = XdrvMailbox.index; int op = XdrvMailbox.index;
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Alias %d %s"), op, XdrvMailbox.data); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Alias %d %s"), op, XdrvMailbox.data);
int res = -1; int res = -1;
switch(op){ switch(op){
@ -2705,7 +2705,7 @@ void CmndBLEAlias(void){
char *mac = p; char *mac = p;
int len = fromHex(addr, p, sizeof(addr)); int len = fromHex(addr, p, sizeof(addr));
if (len != 6){ if (len != 6){
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Alias invalid mac %s"), p); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Alias invalid mac %s"), p);
ResponseCmndChar("invalidmac"); ResponseCmndChar("invalidmac");
return; return;
} }
@ -2726,7 +2726,7 @@ void CmndBLEAlias(void){
return; return;
} }
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Add Alias mac %s = name %s"), mac, p); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Add Alias mac %s = name %s"), mac, p);
if (addAlias( addr, name )){ if (addAlias( addr, name )){
added++; added++;
} }
@ -2734,7 +2734,7 @@ void CmndBLEAlias(void){
} while (p); } while (p);
if (added){ if (added){
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Added %d Aliases"), added); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Added %d Aliases"), added);
BLEAliasListResp(); BLEAliasListResp();
} else { } else {
BLEAliasListResp(); BLEAliasListResp();
@ -2742,7 +2742,7 @@ void CmndBLEAlias(void){
return; return;
} break; } break;
case 2:{ // clear case 2:{ // clear
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Alias clearing %d"), aliases.size()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Alias clearing %d"), aliases.size());
for (int i = aliases.size()-1; i >= 0; i--){ for (int i = aliases.size()-1; i >= 0; i--){
BLE_ESP32::ble_alias_t *alias = aliases[i]; BLE_ESP32::ble_alias_t *alias = aliases[i];
aliases.pop_back(); aliases.pop_back();
@ -2773,14 +2773,14 @@ void CmndBLEName(void) {
if (addrres){ if (addrres){
if (addrres == 2){ if (addrres == 2){
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: addr used alias: %s"), p); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: addr used alias: %s"), p);
} }
//#ifdef EQ3_DEBUG //#ifdef EQ3_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: cmd addr: %s -> %s"), p, addr.toString().c_str()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: cmd addr: %s -> %s"), p, addr.toString().c_str());
//#endif //#endif
} else { } else {
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: addr invalid: %s"), p); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: addr invalid: %s"), p);
ResponseCmndIdxChar(PSTR("invalidaddr")); ResponseCmndIdxChar(PSTR("invalidaddr"));
return; return;
} }
@ -2789,11 +2789,11 @@ void CmndBLEName(void) {
// ALWAYS use this function to create a new one. // ALWAYS use this function to create a new one.
int res = BLE_ESP32::newOperation(&op); int res = BLE_ESP32::newOperation(&op);
if (!res){ if (!res){
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Can't get a newOperation")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Can't get a newOperation"));
ResponseCmndChar(PSTR("FAIL")); ResponseCmndChar(PSTR("FAIL"));
return; return;
} else { } else {
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: got a newOperation from BLE")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: got a newOperation from BLE"));
} }
op->addr = addr; op->addr = addr;
@ -2804,29 +2804,29 @@ void CmndBLEName(void) {
char *name = strtok(nullptr, " "); char *name = strtok(nullptr, " ");
bool write = false; bool write = false;
if (name && *name){ if (name && *name){
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: write name %s"), name); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: write name %s"), name);
op->writelen = strlen(name); op->writelen = strlen(name);
memcpy(op->dataToWrite, name, op->writelen); memcpy(op->dataToWrite, name, op->writelen);
write = true; write = true;
} else { } else {
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: read name")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: read name"));
op->readlen = 1; op->readlen = 1;
} }
res = BLE_ESP32::extQueueOperation(&op); res = BLE_ESP32::extQueueOperation(&op);
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: queue res %d"), res); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: queue res %d"), res);
if (!res){ if (!res){
// if it fails to add to the queue, do please delete it // if it fails to add to the queue, do please delete it
BLE_ESP32::freeOperation(&op); BLE_ESP32::freeOperation(&op);
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failed to queue new operation - deleted")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Failed to queue new operation - deleted"));
ResponseCmndChar(PSTR("QUEUEFAIL")); ResponseCmndChar(PSTR("QUEUEFAIL"));
return; return;
} }
if (write){ if (write){
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: will write name")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: will write name"));
} else { } else {
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: will read name")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: will read name"));
} }
ResponseCmndDone(); ResponseCmndDone();
return; return;
@ -2856,7 +2856,7 @@ void CmndBLEOperation(void){
int op = XdrvMailbox.index; int op = XdrvMailbox.index;
//AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: op %d"), op); //AddLog(LOG_LEVEL_INFO,PSTR("BLE: op %d"), op);
int res = -1; int res = -1;
@ -2864,7 +2864,7 @@ void CmndBLEOperation(void){
switch(op) { switch(op) {
case 0: case 0:
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: preview")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: preview"));
#endif #endif
BLEPostMQTTTrigger = 1; BLEPostMQTTTrigger = 1;
break; break;
@ -2875,7 +2875,7 @@ void CmndBLEOperation(void){
int opres = BLE_ESP32::newOperation(&prepOperation); int opres = BLE_ESP32::newOperation(&prepOperation);
if (!opres){ if (!opres){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Could not create new operation")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Could not create new operation"));
#endif #endif
ResponseCmndChar("FailCreate"); ResponseCmndChar("FailCreate");
return; return;
@ -2933,14 +2933,14 @@ void CmndBLEOperation(void){
// this means you could retry with another BLEOp10. // this means you could retry with another BLEOp10.
// it WOULD be deleted if you sent another BELOP1 <MAC> // it WOULD be deleted if you sent another BELOP1 <MAC>
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Could not queue new operation")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Could not queue new operation"));
#endif #endif
ResponseCmndChar("FailQueue"); ResponseCmndChar("FailQueue");
return; return;
} else { } else {
// NOTE: prepOperation has been set to null if we queued sucessfully. // NOTE: prepOperation has been set to null if we queued sucessfully.
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Operations queued:%d"), queuedOperations.size()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: Operations queued:%d"), queuedOperations.size());
#endif #endif
char temp[40]; char temp[40];
sprintf(temp, "{\"opid\":%d,\"u\":%d}", lastopid-1, u); sprintf(temp, "{\"opid\":%d,\"u\":%d}", lastopid-1, u);
@ -2969,13 +2969,13 @@ void CmndBLEOperation(void){
// this means you could retry with another BLEOp10. // this means you could retry with another BLEOp10.
// it WOULD be deleted if you sent another BELOP1 <MAC> // it WOULD be deleted if you sent another BELOP1 <MAC>
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Could not queue new operation")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Could not queue new operation"));
#endif #endif
ResponseCmndChar("FailQueue"); ResponseCmndChar("FailQueue");
} else { } else {
// NOTE: prepOperation has been set to null if we queued sucessfully. // NOTE: prepOperation has been set to null if we queued sucessfully.
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Operations queued:%d"), queuedOperations.size()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: Operations queued:%d"), queuedOperations.size());
#endif #endif
char temp[40]; char temp[40];
sprintf(temp, "{\"opid\":%d,\"u\":%d}", lastopid-1, u); sprintf(temp, "{\"opid\":%d,\"u\":%d}", lastopid-1, u);
@ -3026,20 +3026,20 @@ static void BLEPostMQTT(bool onlycompleted) {
if (prepOperation || completedOperations.size() || queuedOperations.size() || currentOperations.size()){ if (prepOperation || completedOperations.size() || queuedOperations.size() || currentOperations.size()){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: some to show")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: some to show"));
#endif #endif
if (prepOperation && !onlycompleted){ if (prepOperation && !onlycompleted){
std::string out = BLETriggerResponse(prepOperation); std::string out = BLETriggerResponse(prepOperation);
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str()); snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str());
MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain); MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain);
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: prep sent %s"), out.c_str()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: prep sent %s"), out.c_str());
#endif #endif
} }
if (queuedOperations.size() && !onlycompleted){ if (queuedOperations.size() && !onlycompleted){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: queued %d"), queuedOperations.size()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: queued %d"), queuedOperations.size());
#endif #endif
for (int i = 0; i < queuedOperations.size(); i++){ for (int i = 0; i < queuedOperations.size(); i++){
TasAutoMutex localmutex(&BLEOperationsRecursiveMutex, "BLEPost1"); TasAutoMutex localmutex(&BLEOperationsRecursiveMutex, "BLEPost1");
@ -3053,7 +3053,7 @@ static void BLEPostMQTT(bool onlycompleted) {
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str()); snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str());
MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain); MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain);
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: queued %d sent %s"), i, out.c_str()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: queued %d sent %s"), i, out.c_str());
#endif #endif
//break; //break;
} }
@ -3062,7 +3062,7 @@ static void BLEPostMQTT(bool onlycompleted) {
if (currentOperations.size() && !onlycompleted){ if (currentOperations.size() && !onlycompleted){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: current %d"), currentOperations.size()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: current %d"), currentOperations.size());
#endif #endif
for (int i = 0; i < currentOperations.size(); i++){ for (int i = 0; i < currentOperations.size(); i++){
TasAutoMutex localmutex(&BLEOperationsRecursiveMutex, "BLEPost2"); TasAutoMutex localmutex(&BLEOperationsRecursiveMutex, "BLEPost2");
@ -3075,7 +3075,7 @@ static void BLEPostMQTT(bool onlycompleted) {
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str()); snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str());
MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain); MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain);
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: curr %d sent %s"), i, out.c_str()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: curr %d sent %s"), i, out.c_str());
#endif #endif
//break; //break;
} }
@ -3084,7 +3084,7 @@ static void BLEPostMQTT(bool onlycompleted) {
if (completedOperations.size()){ if (completedOperations.size()){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: completed %d"), completedOperations.size()); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: completed %d"), completedOperations.size());
#endif #endif
do { do {
generic_sensor_t *toSend = nextOperation(&completedOperations); generic_sensor_t *toSend = nextOperation(&completedOperations);
@ -3092,7 +3092,7 @@ static void BLEPostMQTT(bool onlycompleted) {
break; // break from while loop break; // break from while loop
} else { } else {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: completedOperation removed")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: completedOperation removed"));
#endif #endif
std::string out = BLETriggerResponse(toSend); std::string out = BLETriggerResponse(toSend);
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str()); snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str());
@ -3121,11 +3121,11 @@ static void mainThreadBLETimeouts() {
if (BLEStop == 1){ if (BLEStop == 1){
if (BLEStopAt + 30L*1000L*1000L < now){ // if asked to stop > 30s ago... if (BLEStopAt + 30L*1000L*1000L < now){ // if asked to stop > 30s ago...
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Stop Timeout - restart Tasmota")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Stop Timeout - restart Tasmota"));
BLERestartTasmota = 2; BLERestartTasmota = 2;
BLEStopAt = now; BLEStopAt = now;
} }
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Awaiting BLEStop")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Awaiting BLEStop"));
return; return;
} }
@ -3135,7 +3135,7 @@ static void mainThreadBLETimeouts() {
if (BLEScanLastAdvertismentAt + adTimeout < now){ if (BLEScanLastAdvertismentAt + adTimeout < now){
BLEScanLastAdvertismentAt = now; // initialise the time of the last advertisment BLEScanLastAdvertismentAt = now; // initialise the time of the last advertisment
BLERestartNimBLE = 1; BLERestartNimBLE = 1;
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: scan stall? no adverts > 120s, restart BLE")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: scan stall? no adverts > 120s, restart BLE"));
BLERestartBLEReason = BLE_RESTART_BLE_REASON_ADVERT_BLE_TIMEOUT; BLERestartBLEReason = BLE_RESTART_BLE_REASON_ADVERT_BLE_TIMEOUT;
} }
@ -3146,7 +3146,7 @@ static void mainThreadBLETimeouts() {
if (BLELastLoopTime + bleLoopTimeout < now){ if (BLELastLoopTime + bleLoopTimeout < now){
BLELastLoopTime = now; // initialise the time of the last advertisment BLELastLoopTime = now; // initialise the time of the last advertisment
BLERestartTasmota = 10; BLERestartTasmota = 10;
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask stall > 120s, restart Tasmota in 10s")); AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask stall > 120s, restart Tasmota in 10s"));
BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_BLE_LOOP_STALLED; BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_BLE_LOOP_STALLED;
} }
} }
@ -3154,7 +3154,7 @@ static void mainThreadBLETimeouts() {
static void mainThreadOpCallbacks() { static void mainThreadOpCallbacks() {
if (completedOperations.size()){ if (completedOperations.size()){
//AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: completed %d"), completedOperations.size()); //AddLog(LOG_LEVEL_INFO,PSTR("BLE: completed %d"), completedOperations.size());
TasAutoMutex localmutex(&BLEOperationsRecursiveMutex, "BLEMainCB"); TasAutoMutex localmutex(&BLEOperationsRecursiveMutex, "BLEMainCB");
// find this operation in currentOperations, and remove it. // find this operation in currentOperations, and remove it.
@ -3169,11 +3169,11 @@ static void mainThreadOpCallbacks() {
OPCOMPLETE_CALLBACK *pFn = (OPCOMPLETE_CALLBACK *)(op->completecallback); OPCOMPLETE_CALLBACK *pFn = (OPCOMPLETE_CALLBACK *)(op->completecallback);
callbackres = pFn(op); callbackres = pFn(op);
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: op->completecallback %d"), callbackres); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: op->completecallback %d"), callbackres);
#endif #endif
} catch(const std::exception& e){ } catch(const std::exception& e){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: exception in op->completecallback")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: exception in op->completecallback"));
#endif #endif
} }
} }
@ -3184,14 +3184,14 @@ static void mainThreadOpCallbacks() {
OPCOMPLETE_CALLBACK *pFn = operationsCallbacks[i]; OPCOMPLETE_CALLBACK *pFn = operationsCallbacks[i];
callbackres = pFn(op); callbackres = pFn(op);
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: operationsCallbacks %d %d"), i, callbackres); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: operationsCallbacks %d %d"), i, callbackres);
#endif #endif
if (callbackres){ if (callbackres){
break; // this callback ate the op. break; // this callback ate the op.
} }
} catch(const std::exception& e){ } catch(const std::exception& e){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: exception in operationsCallbacks")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: exception in operationsCallbacks"));
#endif #endif
} }
} }
@ -3200,7 +3200,7 @@ static void mainThreadOpCallbacks() {
// if some callback told us not to send on MQTT, then remove from completed and delete the data // if some callback told us not to send on MQTT, then remove from completed and delete the data
if (callbackres){ if (callbackres){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: callbackres true -> delete op")); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: callbackres true -> delete op"));
#endif #endif
completedOperations.erase(completedOperations.begin() + i); completedOperations.erase(completedOperations.begin() + i);
delete op; delete op;
@ -3214,7 +3214,7 @@ static void BLEShow(bool json)
{ {
if (json){ if (json){
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: show json %d"),json); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: show json %d"),json);
#endif #endif
uint32_t totalCount = BLEAdvertisment.totalCount; uint32_t totalCount = BLEAdvertisment.totalCount;
uint32_t deviceCount = seenDevices.size(); uint32_t deviceCount = seenDevices.size();
@ -3372,30 +3372,30 @@ void HandleBleConfiguration(void)
{ {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: HandleBleConfiguration")); AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: HandleBleConfiguration"));
#endif #endif
if (!HttpCheckPriviledgedAccess()) { if (!HttpCheckPriviledgedAccess()) {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: !HttpCheckPriviledgedAccess()")); AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: !HttpCheckPriviledgedAccess()"));
#endif #endif
return; return;
} }
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_BLE)); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_BLE));
#endif #endif
char tmp[20]; char tmp[20];
WebGetArg("en", tmp, sizeof(tmp)); WebGetArg("en", tmp, sizeof(tmp));
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: arg en is %s"), tmp); if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: arg en is %s"), tmp);
#endif #endif
if (Webserver->hasArg("save")) { if (Webserver->hasArg("save")) {
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: SETTINGS SAVE")); AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: SETTINGS SAVE"));
#endif #endif
Settings.flag5.mi32_enable = Webserver->hasArg("e0"); // Settings.flag5.mi32_enable = Webserver->hasArg("e0"); //
BLEScanActiveMode = (Webserver->hasArg("e1")?1:0); // BLEScanActiveMode = (Webserver->hasArg("e1")?1:0); //
@ -3405,7 +3405,7 @@ void HandleBleConfiguration(void)
return; return;
} }
#ifdef BLE_ESP32_DEBUG #ifdef BLE_ESP32_DEBUG
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: !SAVE")); AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: !SAVE"));
#endif #endif
char str[TOPSZ]; char str[TOPSZ];
@ -3460,7 +3460,7 @@ void HandleBleConfiguration(void)
\*********************************************************************************************/ \*********************************************************************************************/
int ExtStopBLE(){ int ExtStopBLE(){
AddLog_P(LOG_LEVEL_INFO, PSTR("BLE: Stopping if active")); AddLog(LOG_LEVEL_INFO, PSTR("BLE: Stopping if active"));
BLE_ESP32::BLEMode = BLE_ESP32::BLEModeDisabled; BLE_ESP32::BLEMode = BLE_ESP32::BLEModeDisabled;
BLE_ESP32::StopBLE(); BLE_ESP32::StopBLE();
return 0; return 0;
@ -3548,13 +3548,13 @@ int myAdvertCallback(BLE_ESP32::ble_advertisment_t *pStruct) {
// this one is used to demonstrate processing ALL operations // this one is used to demonstrate processing ALL operations
int myOpCallback(BLE_ESP32::generic_sensor_t *pStruct){ int myOpCallback(BLE_ESP32::generic_sensor_t *pStruct){
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: myOpCallback")); AddLog(LOG_LEVEL_INFO,PSTR("BLE: myOpCallback"));
return 0; // return true to block MQTT broadcast return 0; // return true to block MQTT broadcast
} }
// this one is used to demonstrate processing of ONE specific operation // this one is used to demonstrate processing of ONE specific operation
int myOpCallback2(BLE_ESP32::generic_sensor_t *pStruct){ int myOpCallback2(BLE_ESP32::generic_sensor_t *pStruct){
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: myOpCallback2")); AddLog(LOG_LEVEL_INFO,PSTR("BLE: myOpCallback2"));
return 1; // return true to block MQTT broadcast return 1; // return true to block MQTT broadcast
} }
#endif #endif
@ -3577,7 +3577,7 @@ void sendExample(){
BLE_ESP32::generic_sensor_t *op = nullptr; BLE_ESP32::generic_sensor_t *op = nullptr;
int res = BLE_ESP32::newOperation(&op); int res = BLE_ESP32::newOperation(&op);
if (!res){ if (!res){
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Could not create new operation")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Could not create new operation"));
return; return;
} }
strncpy(op->MAC, "001A22092EE0", sizeof(op->MAC)); strncpy(op->MAC, "001A22092EE0", sizeof(op->MAC));
@ -3592,7 +3592,7 @@ void sendExample(){
if (!res){ if (!res){
// if it fails to add to the queue, do please delete it // if it fails to add to the queue, do please delete it
BLE_ESP32::freeOperation(&op); BLE_ESP32::freeOperation(&op);
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failed to queue new operation - deleted")); AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Failed to queue new operation - deleted"));
return; return;
} }