Changed logging message handling

Changed logging message handling
This commit is contained in:
Theo Arends 2019-03-08 15:15:42 +01:00
parent fb9b1c83f3
commit 06a9fbd792
66 changed files with 259 additions and 512 deletions

View File

@ -1,6 +1,7 @@
/* 6.4.1.20 20190304 /* 6.4.1.20 20190304
* Changed webserver content handling from single String to small Chunks increasing RAM * Changed webserver content handling from single String to small Chunks increasing RAM
* * Changed logging message handling
*
* 6.4.1.19 20190222 * 6.4.1.19 20190222
* Add command SetOption37 for RGBCW color mapping (#5326) * Add command SetOption37 for RGBCW color mapping (#5326)
* Add Korean language translations (#5344) * Add Korean language translations (#5344)

View File

@ -435,9 +435,8 @@ void SettingsSave(uint8_t rotate)
delay(1); delay(1);
} }
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_CONFIG D_SAVED_TO_FLASH_AT " %X, " D_COUNT " %d, " D_BYTES " %d"),
settings_location, Settings.save_flag, sizeof(SYSCFG)); AddLog_P2(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(SYSCFG));
AddLog(LOG_LEVEL_DEBUG);
settings_crc = Settings.cfg_crc; settings_crc = Settings.cfg_crc;
} }
@ -482,9 +481,7 @@ void SettingsLoad(void)
} }
if (settings_location > 0) { if (settings_location > 0) {
ESP.flashRead(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG)); ESP.flashRead(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %d"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %d"), settings_location, Settings.save_flag);
settings_location, Settings.save_flag);
AddLog(LOG_LEVEL_DEBUG);
} }
#ifndef FIRMWARE_MINIMAL #ifndef FIRMWARE_MINIMAL
@ -516,8 +513,7 @@ void SettingsErase(uint8_t type)
bool _serialoutput = (LOG_LEVEL_DEBUG_MORE <= seriallog_level); bool _serialoutput = (LOG_LEVEL_DEBUG_MORE <= seriallog_level);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_ERASE " %d " D_UNIT_SECTORS), _sectorEnd - _sectorStart); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " %d " D_UNIT_SECTORS), _sectorEnd - _sectorStart);
AddLog(LOG_LEVEL_DEBUG);
for (uint32_t _sector = _sectorStart; _sector < _sectorEnd; _sector++) { for (uint32_t _sector = _sectorStart; _sector < _sectorEnd; _sector++) {
result = ESP.flashEraseSector(_sector); result = ESP.flashEraseSector(_sector);

View File

@ -473,9 +473,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
if (topicBuf[0] != '/') { ShowSource(SRC_MQTT); } if (topicBuf[0] != '/') { ShowSource(SRC_MQTT); }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_RESULT D_RECEIVED_TOPIC " %s, " D_DATA_SIZE " %d, " D_DATA " %s"), AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_RESULT D_RECEIVED_TOPIC " %s, " D_DATA_SIZE " %d, " D_DATA " %s"), topicBuf, data_len, dataBuf);
topicBuf, data_len, dataBuf);
AddLog(LOG_LEVEL_DEBUG_MORE);
// if (LOG_LEVEL_DEBUG_MORE <= seriallog_level) { Serial.println(dataBuf); } // if (LOG_LEVEL_DEBUG_MORE <= seriallog_level) { Serial.println(dataBuf); }
if (XdrvMqttData(topicBuf, sizeof(topicBuf), dataBuf, sizeof(dataBuf))) { return; } if (XdrvMqttData(topicBuf, sizeof(topicBuf), dataBuf, sizeof(dataBuf))) { return; }
@ -503,9 +501,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
type[i] = '\0'; type[i] = '\0';
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_RESULT D_GROUP " %d, " D_INDEX " %d, " D_COMMAND " %s, " D_DATA " %s"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_RESULT D_GROUP " %d, " D_INDEX " %d, " D_COMMAND " %s, " D_DATA " %s"), grpflg, index, type, dataBuf);
grpflg, index, type, dataBuf);
AddLog(LOG_LEVEL_DEBUG);
if (type != NULL) { if (type != NULL) {
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_COMMAND "\":\"" D_JSON_ERROR "\"}")); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_COMMAND "\":\"" D_JSON_ERROR "\"}"));
@ -526,8 +522,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
int temp_payload = GetStateNumber(dataBuf); int temp_payload = GetStateNumber(dataBuf);
if (temp_payload > -1) { payload = temp_payload; } if (temp_payload > -1) { payload = temp_payload; }
// snprintf_P(log_data, sizeof(log_data), PSTR("RSLT: Payload %d, Payload16 %d"), payload, payload16); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RSLT: Payload %d, Payload16 %d"), payload, payload16);
// AddLog(LOG_LEVEL_DEBUG);
int command_code = GetCommandCode(command, sizeof(command), type, kTasmotaCommands); int command_code = GetCommandCode(command, sizeof(command), type, kTasmotaCommands);
if (-1 == command_code) { if (-1 == command_code) {
@ -1793,8 +1788,7 @@ void PerformEverySecond(void)
RtcRebootSave(); RtcRebootSave();
Settings.bootcount++; // Moved to here to stop flash writes during start-up Settings.bootcount++; // Moved to here to stop flash writes during start-up
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount);
AddLog(LOG_LEVEL_DEBUG);
} }
if ((4 == uptime) && (SONOFF_IFAN02 == my_module_type)) { // Microcontroller needs 3 seconds before accepting commands if ((4 == uptime) && (SONOFF_IFAN02 == my_module_type)) { // Microcontroller needs 3 seconds before accepting commands
@ -2001,8 +1995,7 @@ void Every250mSeconds(void)
} }
} }
#endif // FIRMWARE_MINIMAL #endif // FIRMWARE_MINIMAL
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "%s"), mqtt_data); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "%s"), mqtt_data);
AddLog(LOG_LEVEL_DEBUG);
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) #if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(mqtt_data)); ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(mqtt_data));
#else #else
@ -2013,8 +2006,7 @@ void Every250mSeconds(void)
if (!ota_result) { if (!ota_result) {
#ifndef FIRMWARE_MINIMAL #ifndef FIRMWARE_MINIMAL
int ota_error = ESPhttpUpdate.getLastError(); int ota_error = ESPhttpUpdate.getLastError();
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Ota error %d"), ota_error); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Ota error %d"), ota_error);
// AddLog(LOG_LEVEL_DEBUG);
if ((HTTP_UE_TOO_LESS_SPACE == ota_error) || (HTTP_UE_BIN_FOR_WRONG_FLASH == ota_error)) { if ((HTTP_UE_TOO_LESS_SPACE == ota_error) || (HTTP_UE_BIN_FOR_WRONG_FLASH == ota_error)) {
RtcSettings.ota_loader = 1; // Try minimal image next RtcSettings.ota_loader = 1; // Try minimal image next
} }
@ -2145,8 +2137,7 @@ void ArduinoOTAInit(void)
AriluxRfDisable(); // Prevent restart exception on Arilux Interrupt routine AriluxRfDisable(); // Prevent restart exception on Arilux Interrupt routine
#endif // USE_ARILUX_RF #endif // USE_ARILUX_RF
if (Settings.flag.mqtt_enabled) { MqttDisconnect(); } if (Settings.flag.mqtt_enabled) { MqttDisconnect(); }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Arduino OTA " D_UPLOAD_STARTED)); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_UPLOAD_STARTED));
AddLog(LOG_LEVEL_INFO);
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
@ -2177,22 +2168,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);
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Arduino OTA %s. " D_RESTARTING), error_str); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA %s. " D_RESTARTING), error_str);
AddLog(LOG_LEVEL_INFO);
EspRestart(); EspRestart();
}); });
ArduinoOTA.onEnd([]() ArduinoOTA.onEnd([]()
{ {
if ((LOG_LEVEL_DEBUG <= seriallog_level)) { Serial.println(); } if ((LOG_LEVEL_DEBUG <= seriallog_level)) { Serial.println(); }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Arduino OTA " D_SUCCESSFUL ". " D_RESTARTING)); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_SUCCESSFUL ". " D_RESTARTING));
AddLog(LOG_LEVEL_INFO);
EspRestart(); EspRestart();
}); });
ArduinoOTA.begin(); ArduinoOTA.begin();
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Arduino OTA " D_ENABLED " " D_PORT " 8266")); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_ENABLED " " D_PORT " 8266"));
AddLog(LOG_LEVEL_INFO);
} }
#endif // USE_ARDUINO_OTA #endif // USE_ARDUINO_OTA
@ -2268,8 +2256,7 @@ void SerialInput(void)
else if (!Settings.flag.mqtt_serial && (serial_in_byte == '\n')) { else if (!Settings.flag.mqtt_serial && (serial_in_byte == '\n')) {
serial_in_buffer[serial_in_byte_counter] = 0; // Serial data completed serial_in_buffer[serial_in_byte_counter] = 0; // Serial data completed
seriallog_level = (Settings.seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings.seriallog_level; seriallog_level = (Settings.seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings.seriallog_level;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_COMMAND "%s"), serial_in_buffer); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), serial_in_buffer);
AddLog(LOG_LEVEL_INFO);
ExecuteCommand(serial_in_buffer, SRC_SERIAL); ExecuteCommand(serial_in_buffer, SRC_SERIAL);
serial_in_byte_counter = 0; serial_in_byte_counter = 0;
serial_polling_window = 0; serial_polling_window = 0;
@ -2338,8 +2325,7 @@ void GpioInit(void)
for (uint8_t i = 0; i < sizeof(my_module.io); i++) { for (uint8_t i = 0; i < sizeof(my_module.io); i++) {
mpin = ValidPin(i, my_module.io[i]); mpin = ValidPin(i, my_module.io[i]);
// snprintf_P(log_data, sizeof(log_data), PSTR("DBG: gpio pin %d, mpin %d"), i, mpin); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DBG: gpio pin %d, mpin %d"), i, mpin);
// AddLog(LOG_LEVEL_DEBUG);
if (mpin) { if (mpin) {
if ((mpin >= GPIO_SWT1_NP) && (mpin < (GPIO_SWT1_NP + MAX_SWITCHES))) { if ((mpin >= GPIO_SWT1_NP) && (mpin < (GPIO_SWT1_NP + MAX_SWITCHES))) {
@ -2584,8 +2570,7 @@ void setup(void)
Settings.module = SONOFF_BASIC; // Reset module to Sonoff Basic Settings.module = SONOFF_BASIC; // Reset module to Sonoff Basic
// Settings.last_module = SONOFF_BASIC; // Settings.last_module = SONOFF_BASIC;
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_LOG_SOME_SETTINGS_RESET " (%d)"), RtcReboot.fast_reboot_count); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_LOG_SOME_SETTINGS_RESET " (%d)"), RtcReboot.fast_reboot_count);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
@ -2651,12 +2636,9 @@ void setup(void)
} }
blink_powersave = power; blink_powersave = power;
snprintf_P(log_data, sizeof(log_data), PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_ESP8266_RELEASE), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_ESP8266_RELEASE), PROJECT, Settings.friendlyname[0], my_version, my_image);
PROJECT, Settings.friendlyname[0], my_version, my_image);
AddLog(LOG_LEVEL_INFO);
#ifdef FIRMWARE_MINIMAL #ifdef FIRMWARE_MINIMAL
snprintf_P(log_data, sizeof(log_data), PSTR(D_WARNING_MINIMAL_VERSION)); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION));
AddLog(LOG_LEVEL_INFO);
#endif // FIRMWARE_MINIMAL #endif // FIRMWARE_MINIMAL
RtcInit(); RtcInit();

View File

@ -47,8 +47,7 @@ void OsWatchTicker(void)
unsigned long last_run = abs(t - oswatch_last_loop_time); unsigned long last_run = abs(t - oswatch_last_loop_time);
#ifdef DEBUG_THEO #ifdef DEBUG_THEO
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_OSWATCH " FreeRam %d, rssi %d, last_run %d"), ESP.getFreeHeap(), WifiGetRssiAsQuality(WiFi.RSSI()), last_run); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_OSWATCH " FreeRam %d, rssi %d, last_run %d"), ESP.getFreeHeap(), WifiGetRssiAsQuality(WiFi.RSSI()), last_run);
AddLog(LOG_LEVEL_DEBUG);
#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_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_OSWATCH " " D_BLOCKED_LOOP ". " D_RESTARTING)); // Save iram space
@ -645,8 +644,7 @@ void SetSerialBaudrate(int baudrate)
Settings.baudrate = baudrate / 1200; Settings.baudrate = baudrate / 1200;
if (Serial.baudRate() != baudrate) { if (Serial.baudRate() != baudrate) {
if (seriallog_level) { if (seriallog_level) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_SET_BAUDRATE_TO " %d"), baudrate); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SET_BAUDRATE_TO " %d"), baudrate);
AddLog(LOG_LEVEL_INFO);
} }
delay(100); delay(100);
Serial.flush(); Serial.flush();
@ -695,8 +693,7 @@ void ShowSource(int source)
{ {
if ((source > 0) && (source < SRC_MAX)) { if ((source > 0) && (source < SRC_MAX)) {
char stemp1[20]; char stemp1[20];
snprintf_P(log_data, sizeof(log_data), PSTR("SRC: %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource)); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SRC: %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource));
AddLog(LOG_LEVEL_DEBUG);
} }
} }
@ -1171,8 +1168,7 @@ bool I2cDevice(uint8_t addr)
* Syslog * Syslog
* *
* Example: * Example:
* snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_LOG "Any value %d"), value); * AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_LOG "Any value %d"), value);
* AddLog(LOG_LEVEL_DEBUG);
* *
\*********************************************************************************************/ \*********************************************************************************************/
@ -1228,8 +1224,7 @@ void Syslog(void)
} else { } else {
syslog_level = 0; syslog_level = 0;
syslog_timer = SYSLOG_TIMER; syslog_timer = SYSLOG_TIMER;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_SYSLOG_HOST_NOT_FOUND ". " D_RETRY_IN " %d " D_UNIT_SECOND), SYSLOG_TIMER); AddLog_P2(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);
} }
} }
@ -1281,7 +1276,6 @@ void AddLog_P(uint8_t loglevel, const char *formatP, const char *formatP2)
void AddLog_P2(uint8_t loglevel, PGM_P formatP, ...) void AddLog_P2(uint8_t loglevel, PGM_P formatP, ...)
{ {
// This uses char strings. Be aware of sending %% if % is needed
va_list arg; va_list arg;
va_start(arg, formatP); va_start(arg, formatP);
int len = vsnprintf_P(log_data, sizeof(log_data), formatP, arg); int len = vsnprintf_P(log_data, sizeof(log_data), formatP, arg);
@ -1306,6 +1300,5 @@ void AddLogSerial(uint8_t loglevel)
void AddLogMissed(char *sensor, uint8_t misses) void AddLogMissed(char *sensor, uint8_t misses)
{ {
snprintf_P(log_data, sizeof(log_data), PSTR("SNS: %s missed %d"), sensor, SENSOR_MAX_MISS - misses); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SNS: %s missed %d"), sensor, SENSOR_MAX_MISS - misses);
AddLog(LOG_LEVEL_DEBUG);
} }

View File

@ -103,8 +103,7 @@ void ButtonHandler(void)
if (!button_index && ((SONOFF_DUAL == my_module_type) || (CH4 == my_module_type))) { if (!button_index && ((SONOFF_DUAL == my_module_type) || (CH4 == my_module_type))) {
button_present = 1; button_present = 1;
if (dual_button_code) { if (dual_button_code) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON " " D_CODE " %04X"), dual_button_code); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON " " D_CODE " %04X"), dual_button_code);
AddLog(LOG_LEVEL_DEBUG);
button = PRESSED; button = PRESSED;
if (0xF500 == dual_button_code) { // Button hold if (0xF500 == dual_button_code) { // Button hold
holdbutton[button_index] = (loops_per_second * Settings.param[P_HOLD_TIME] / 10) -1; holdbutton[button_index] = (loops_per_second * Settings.param[P_HOLD_TIME] / 10) -1;
@ -130,14 +129,12 @@ void ButtonHandler(void)
bool button_pressed = false; bool button_pressed = false;
if ((PRESSED == button) && (NOT_PRESSED == lastbutton[button_index])) { if ((PRESSED == button) && (NOT_PRESSED == lastbutton[button_index])) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_10), button_index +1); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_10), button_index +1);
AddLog(LOG_LEVEL_DEBUG);
holdbutton[button_index] = loops_per_second; holdbutton[button_index] = loops_per_second;
button_pressed = true; button_pressed = true;
} }
if ((NOT_PRESSED == button) && (PRESSED == lastbutton[button_index])) { if ((NOT_PRESSED == button) && (PRESSED == lastbutton[button_index])) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_01), button_index +1); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_01), button_index +1);
AddLog(LOG_LEVEL_DEBUG);
if (!holdbutton[button_index]) { button_pressed = true; } // Do not allow within 1 second if (!holdbutton[button_index]) { button_pressed = true; } // Do not allow within 1 second
} }
if (button_pressed) { if (button_pressed) {
@ -149,15 +146,13 @@ void ButtonHandler(void)
else { else {
if ((PRESSED == button) && (NOT_PRESSED == lastbutton[button_index])) { if ((PRESSED == button) && (NOT_PRESSED == lastbutton[button_index])) {
if (Settings.flag.button_single) { // Allow only single button press for immediate action if (Settings.flag.button_single) { // Allow only single button press for immediate action
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_IMMEDIATE), button_index +1); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_IMMEDIATE), button_index +1);
AddLog(LOG_LEVEL_DEBUG);
if (!SendKey(0, button_index +1, POWER_TOGGLE)) { // Execute Toggle command via MQTT if ButtonTopic is set if (!SendKey(0, 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
} }
} else { } else {
multipress[button_index] = (multiwindow[button_index]) ? multipress[button_index] +1 : 1; multipress[button_index] = (multiwindow[button_index]) ? multipress[button_index] +1 : 1;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_MULTI_PRESS " %d"), button_index +1, multipress[button_index]); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_MULTI_PRESS " %d"), button_index +1, multipress[button_index]);
AddLog(LOG_LEVEL_DEBUG);
multiwindow[button_index] = loops_per_second / 2; // 0.5 second multi press window multiwindow[button_index] = loops_per_second / 2; // 0.5 second multi press window
} }
blinks = 201; blinks = 201;

View File

@ -115,8 +115,7 @@ void RotaryHandler(void)
if (t > 500) { if (t > 500) {
t = 500; t = 500;
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_CMND_COLORTEMPERATURE " %d"), rotary_position - rotary_last_position); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_CMND_COLORTEMPERATURE " %d"), rotary_position - rotary_last_position);
AddLog(LOG_LEVEL_DEBUG);
LightSetColorTemp((uint16_t)t); LightSetColorTemp((uint16_t)t);
} else { } else {
int8_t d = Settings.light_dimmer; int8_t d = Settings.light_dimmer;
@ -127,8 +126,7 @@ void RotaryHandler(void)
if (d > 100) { if (d > 100) {
d = 100; d = 100;
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_CMND_DIMMER " %d"), rotary_position - rotary_last_position); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_CMND_DIMMER " %d"), rotary_position - rotary_last_position);
AddLog(LOG_LEVEL_DEBUG);
LightSetDimmer((uint8_t)d); LightSetDimmer((uint8_t)d);
Settings.light_dimmer = d; Settings.light_dimmer = d;

View File

@ -364,9 +364,7 @@ void RtcSecond(void)
RtcTime.year = tmpTime.year + 1970; RtcTime.year = tmpTime.year + 1970;
daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year); daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year);
standard_time = RuleToTime(Settings.tflag[0], RtcTime.year); standard_time = RuleToTime(Settings.tflag[0], RtcTime.year);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "(" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "(" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
AddLog(LOG_LEVEL_DEBUG);
if (local_time < 1451602800) { // 2016-01-01 if (local_time < 1451602800) { // 2016-01-01
rules_flag.time_init = 1; rules_flag.time_init = 1;
} else { } else {

View File

@ -107,8 +107,7 @@ void WifiWpsStatusCallback(wps_cb_status status)
if (WPS_CB_ST_SUCCESS == wps_result) { if (WPS_CB_ST_SUCCESS == wps_result) {
wifi_wps_disable(); wifi_wps_disable();
} else { } else {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_WPS_FAILED_WITH_STATUS " %d"), wps_result); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WPS_FAILED_WITH_STATUS " %d"), wps_result);
AddLog(LOG_LEVEL_DEBUG);
wifi_config_counter = 2; wifi_config_counter = 2;
} }
} }
@ -247,9 +246,8 @@ void WifiBegin(uint8_t flag, uint8_t channel)
} else { } else {
WiFi.begin(Settings.sta_ssid[Settings.sta_active], Settings.sta_pwd[Settings.sta_active]); WiFi.begin(Settings.sta_ssid[Settings.sta_active], Settings.sta_pwd[Settings.sta_active]);
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s " D_IN_MODE " 11%c " D_AS " %s..."), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s " D_IN_MODE " 11%c " D_AS " %s..."),
Settings.sta_active +1, Settings.sta_ssid[Settings.sta_active], kWifiPhyMode[WiFi.getPhyMode() & 0x3], my_hostname); Settings.sta_active +1, Settings.sta_ssid[Settings.sta_active], kWifiPhyMode[WiFi.getPhyMode() & 0x3], my_hostname);
AddLog(LOG_LEVEL_INFO);
} }
void WifiBeginAfterScan() void WifiBeginAfterScan()
@ -324,9 +322,8 @@ void WifiBeginAfterScan()
break; break;
} }
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI "Network %d, AP%c, SSId %s, Channel %d, BSSId %02X:%02X:%02X:%02X:%02X:%02X, RSSI %d, Encryption %d"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Network %d, AP%c, SSId %s, Channel %d, BSSId %02X:%02X:%02X:%02X:%02X:%02X, RSSI %d, Encryption %d"),
i, (known) ? (j) ? '2' : '1' : '-', ssid_scan.c_str(), chan_scan, bssid_scan[0], bssid_scan[1], bssid_scan[2], bssid_scan[3], bssid_scan[4], bssid_scan[5], rssi_scan, (sec_scan == ENC_TYPE_NONE) ? 0 : 1); i, (known) ? (j) ? '2' : '1' : '-', ssid_scan.c_str(), chan_scan, bssid_scan[0], bssid_scan[1], bssid_scan[2], bssid_scan[3], bssid_scan[4], bssid_scan[5], rssi_scan, (sec_scan == ENC_TYPE_NONE) ? 0 : 1);
AddLog(LOG_LEVEL_DEBUG);
delay(0); delay(0);
} }
WiFi.scanDelete(); // Clean up Ram WiFi.scanDelete(); // Clean up Ram
@ -490,8 +487,7 @@ void WifiCheck(uint8_t param)
strlcpy(Settings.sta_pwd[0], WiFi.psk().c_str(), sizeof(Settings.sta_pwd[0])); strlcpy(Settings.sta_pwd[0], WiFi.psk().c_str(), sizeof(Settings.sta_pwd[0]));
} }
Settings.sta_active = 0; Settings.sta_active = 0;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_WCFG_1_SMARTCONFIG D_CMND_SSID "1 %s"), Settings.sta_ssid[0]); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_1_SMARTCONFIG D_CMND_SSID "1 %s"), Settings.sta_ssid[0]);
AddLog(LOG_LEVEL_INFO);
} }
} }
if (!wifi_config_counter) { if (!wifi_config_counter) {
@ -534,8 +530,7 @@ void WifiCheck(uint8_t param)
// } else { // } else {
// mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START]; // mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START];
mdns_begun = (uint8_t)MDNS.begin(my_hostname); mdns_begun = (uint8_t)MDNS.begin(my_hostname);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MDNS "%s"), (mdns_begun) ? D_INITIALIZED : D_FAILED); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS "%s"), (mdns_begun) ? D_INITIALIZED : D_FAILED);
AddLog(LOG_LEVEL_INFO);
// } // }
} }
} }

View File

@ -466,8 +466,7 @@ void ShowWebSource(int source)
{ {
if ((source > 0) && (source < SRC_MAX)) { if ((source > 0) && (source < SRC_MAX)) {
char stemp1[20]; char stemp1[20];
snprintf_P(log_data, sizeof(log_data), PSTR("SRC: %s from %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource), WebServer->client().remoteIP().toString().c_str()); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SRC: %s from %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource), WebServer->client().remoteIP().toString().c_str());
AddLog(LOG_LEVEL_DEBUG);
} }
} }
@ -513,9 +512,7 @@ void StartWebserver(int type, IPAddress ipweb)
WebServer->begin(); // Web server start WebServer->begin(); // Web server start
} }
if (webserver_state != type) { if (webserver_state != type) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"), my_hostname, (mdns_begun) ? ".local" : "", ipweb.toString().c_str());
my_hostname, (mdns_begun) ? ".local" : "", ipweb.toString().c_str());
AddLog(LOG_LEVEL_INFO);
} }
if (type) { webserver_state = type; } if (type) { webserver_state = type; }
} }
@ -638,8 +635,7 @@ void WSContentSendLl(const String& content) // Low level sendContent for a
ShowFreeMem(PSTR("WSContentSend")); ShowFreeMem(PSTR("WSContentSend"));
// snprintf_P(log_data, sizeof(log_data), PSTR("WEB: Chunk size %d"), len); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("WEB: Chunk size %d"), len);
// AddLog(LOG_LEVEL_DEBUG);
} }
void WSContentFlush() void WSContentFlush()
@ -1201,8 +1197,7 @@ void ModuleSaveSettings(void)
} }
} }
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MODULE "%s " D_CMND_MODULE "%s"), ModuleName().c_str(), gpios.c_str()); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MODULE "%s " D_CMND_MODULE "%s"), ModuleName().c_str(), gpios.c_str());
AddLog(LOG_LEVEL_INFO);
} }
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
@ -1270,8 +1265,7 @@ void HandleWifiConfiguration(void)
cssid = WiFi.SSID(indices[i]); cssid = WiFi.SSID(indices[i]);
for (int j = i + 1; j < n; j++) { for (int j = i + 1; j < n; j++) {
if (cssid == WiFi.SSID(indices[j])) { if (cssid == WiFi.SSID(indices[j])) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_DUPLICATE_ACCESSPOINT " %s"), WiFi.SSID(indices[j]).c_str()); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_DUPLICATE_ACCESSPOINT " %s"), WiFi.SSID(indices[j]).c_str());
AddLog(LOG_LEVEL_DEBUG);
indices[j] = -1; // set dup aps to index -1 indices[j] = -1; // set dup aps to index -1
} }
} }
@ -1281,8 +1275,7 @@ void HandleWifiConfiguration(void)
//display networks in page //display networks in page
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
if (-1 == indices[i]) { continue; } // skip dups if (-1 == indices[i]) { continue; } // skip dups
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_SSID " %s, " D_BSSID " %s, " D_CHANNEL " %d, " D_RSSI " %d"), WiFi.SSID(indices[i]).c_str(), WiFi.BSSIDstr(indices[i]).c_str(), WiFi.channel(indices[i]), WiFi.RSSI(indices[i])); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_SSID " %s, " D_BSSID " %s, " D_CHANNEL " %d, " D_RSSI " %d"), WiFi.SSID(indices[i]).c_str(), WiFi.BSSIDstr(indices[i]).c_str(), WiFi.channel(indices[i]), WiFi.RSSI(indices[i]));
AddLog(LOG_LEVEL_DEBUG);
int quality = WifiGetRssiAsQuality(WiFi.RSSI(indices[i])); int quality = WifiGetRssiAsQuality(WiFi.RSSI(indices[i]));
if (minimum_signal_quality == -1 || minimum_signal_quality < quality) { if (minimum_signal_quality == -1 || minimum_signal_quality < quality) {
@ -1341,9 +1334,7 @@ void WifiSaveSettings(void)
strlcpy(Settings.sta_pwd[0], (!strlen(tmp)) ? "" : (strlen(tmp) < 5) ? Settings.sta_pwd[0] : tmp, sizeof(Settings.sta_pwd[0])); strlcpy(Settings.sta_pwd[0], (!strlen(tmp)) ? "" : (strlen(tmp) < 5) ? Settings.sta_pwd[0] : tmp, sizeof(Settings.sta_pwd[0]));
WebGetArg("p2", tmp, sizeof(tmp)); WebGetArg("p2", tmp, sizeof(tmp));
strlcpy(Settings.sta_pwd[1], (!strlen(tmp)) ? "" : (strlen(tmp) < 5) ? Settings.sta_pwd[1] : tmp, sizeof(Settings.sta_pwd[1])); strlcpy(Settings.sta_pwd[1], (!strlen(tmp)) ? "" : (strlen(tmp) < 5) ? Settings.sta_pwd[1] : tmp, sizeof(Settings.sta_pwd[1]));
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_CMND_HOSTNAME " %s, " D_CMND_SSID "1 %s, " D_CMND_SSID "2 %s"), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CMND_HOSTNAME " %s, " D_CMND_SSID "1 %s, " D_CMND_SSID "2 %s"), Settings.hostname, Settings.sta_ssid[0], Settings.sta_ssid[1]);
Settings.hostname, Settings.sta_ssid[0], Settings.sta_ssid[1]);
AddLog(LOG_LEVEL_INFO);
} }
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
@ -1406,9 +1397,8 @@ void LoggingSaveSettings(void)
if ((Settings.tele_period > 0) && (Settings.tele_period < 10)) { if ((Settings.tele_period > 0) && (Settings.tele_period < 10)) {
Settings.tele_period = 10; // Do not allow periods < 10 seconds Settings.tele_period = 10; // Do not allow periods < 10 seconds
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_LOG D_CMND_SERIALLOG " %d, " D_CMND_WEBLOG " %d, " D_CMND_SYSLOG " %d, " D_CMND_LOGHOST " %s, " D_CMND_LOGPORT " %d, " D_CMND_TELEPERIOD " %d"), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_LOG D_CMND_SERIALLOG " %d, " D_CMND_WEBLOG " %d, " D_CMND_SYSLOG " %d, " D_CMND_LOGHOST " %s, " D_CMND_LOGPORT " %d, " D_CMND_TELEPERIOD " %d"),
Settings.seriallog_level, Settings.weblog_level, Settings.syslog_level, Settings.syslog_host, Settings.syslog_port, Settings.tele_period); Settings.seriallog_level, Settings.weblog_level, Settings.syslog_level, Settings.syslog_host, Settings.syslog_port, Settings.tele_period);
AddLog(LOG_LEVEL_INFO);
} }
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
@ -1756,8 +1746,7 @@ void HandleUploadDone(void)
snprintf_P(error, sizeof(error), PSTR(D_UPLOAD_ERROR_CODE " %d"), upload_error); snprintf_P(error, sizeof(error), PSTR(D_UPLOAD_ERROR_CODE " %d"), upload_error);
} }
WSContentSend(error); WSContentSend(error);
snprintf_P(log_data, sizeof(log_data), PSTR(D_UPLOAD ": %s"), error); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_UPLOAD ": %s"), error);
AddLog(LOG_LEVEL_DEBUG);
stop_flash_rotate = Settings.flag.stop_flash_rotate; stop_flash_rotate = Settings.flag.stop_flash_rotate;
} else { } else {
WSContentSend(F("green'>" D_SUCCESSFUL "</font></b><br/>")); WSContentSend(F("green'>" D_SUCCESSFUL "</font></b><br/>"));
@ -1791,8 +1780,7 @@ void HandleUploadLoop(void)
return; return;
} }
SettingsSave(1); // Free flash for upload SettingsSave(1); // Free flash for upload
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD D_FILE " %s ..."), upload.filename.c_str()); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_FILE " %s ..."), upload.filename.c_str());
AddLog(LOG_LEVEL_INFO);
if (UPL_SETTINGS == upload_file_type) { if (UPL_SETTINGS == upload_file_type) {
if (!SettingsBufferAlloc()) { if (!SettingsBufferAlloc()) {
upload_error = 2; // Not enough space upload_error = 2; // Not enough space
@ -1951,8 +1939,7 @@ void HandleUploadLoop(void)
} }
} }
if (!upload_error) { if (!upload_error) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD D_SUCCESSFUL " %u bytes. " D_RESTARTING), upload.totalSize); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_SUCCESSFUL " %u bytes. " D_RESTARTING), upload.totalSize);
AddLog(LOG_LEVEL_INFO);
} }
} else if (UPLOAD_FILE_ABORTED == upload.status) { } else if (UPLOAD_FILE_ABORTED == upload.status) {
restart_flag = 0; restart_flag = 0;
@ -2059,8 +2046,7 @@ void HandleConsoleRefresh(void)
String svalue = WebServer->arg("c1"); String svalue = WebServer->arg("c1");
if (svalue.length() && (svalue.length() < INPUT_BUFFER_SIZE)) { if (svalue.length() && (svalue.length() < INPUT_BUFFER_SIZE)) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_COMMAND "%s"), svalue.c_str()); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), svalue.c_str());
AddLog(LOG_LEVEL_INFO);
ExecuteWebCommand((char*)svalue.c_str(), SRC_WEBCONSOLE); ExecuteWebCommand((char*)svalue.c_str(), SRC_WEBCONSOLE);
} }
@ -2107,8 +2093,7 @@ void HandleConsoleRefresh(void)
void HandleNotFound(void) void HandleNotFound(void)
{ {
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP "Not fount (%s)"), WebServer->uri().c_str()); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Not fount (%s)"), WebServer->uri().c_str());
// AddLog(LOG_LEVEL_DEBUG);
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.
@ -2226,8 +2211,7 @@ int WebSend(char *buffer)
} }
url += command; // url = |http://192.168.178.86/cm?cmnd=POWER1 ON| url += command; // url = |http://192.168.178.86/cm?cmnd=POWER1 ON|
//snprintf_P(log_data, sizeof(log_data), PSTR("DBG: Uri |%s|"), url.c_str()); //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DBG: Uri |%s|"), url.c_str());
//AddLog(LOG_LEVEL_DEBUG);
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) #if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
HTTPClient http; HTTPClient http;

View File

@ -234,8 +234,7 @@ void MqttDiscoverServer(void)
int n = MDNS.queryService("mqtt", "tcp"); // Search for mqtt service int n = MDNS.queryService("mqtt", "tcp"); // Search for mqtt service
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MDNS D_QUERY_DONE " %d"), n); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_QUERY_DONE " %d"), n);
AddLog(LOG_LEVEL_INFO);
if (n > 0) { if (n > 0) {
uint8_t i = 0; // If the hostname isn't set, use the first record found. uint8_t i = 0; // If the hostname isn't set, use the first record found.
@ -249,9 +248,7 @@ void MqttDiscoverServer(void)
snprintf_P(Settings.mqtt_host, sizeof(Settings.mqtt_host), MDNS.IP(i).toString().c_str()); snprintf_P(Settings.mqtt_host, sizeof(Settings.mqtt_host), MDNS.IP(i).toString().c_str());
Settings.mqtt_port = MDNS.port(i); Settings.mqtt_port = MDNS.port(i);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MDNS D_MQTT_SERVICE_FOUND " %s, " D_IP_ADDRESS " %s, " D_PORT " %d"), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_MQTT_SERVICE_FOUND " %s, " D_IP_ADDRESS " %s, " D_PORT " %d"), MDNS.hostname(i).c_str(), Settings.mqtt_host, Settings.mqtt_port);
MDNS.hostname(i).c_str(), Settings.mqtt_host, Settings.mqtt_port);
AddLog(LOG_LEVEL_INFO);
} }
} }
#endif // MQTT_HOST_DISCOVERY #endif // MQTT_HOST_DISCOVERY
@ -269,15 +266,13 @@ void MqttRetryCounter(uint8_t value)
void MqttSubscribe(const char *topic) void MqttSubscribe(const char *topic)
{ {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_SUBSCRIBE_TO " %s"), topic); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_SUBSCRIBE_TO " %s"), topic);
AddLog(LOG_LEVEL_DEBUG);
MqttSubscribeLib(topic); MqttSubscribeLib(topic);
} }
void MqttUnsubscribe(const char *topic) void MqttUnsubscribe(const char *topic)
{ {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_UNSUBSCRIBE_FROM " %s"), topic); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_UNSUBSCRIBE_FROM " %s"), topic);
AddLog(LOG_LEVEL_DEBUG);
MqttUnsubscribeLib(topic); MqttUnsubscribeLib(topic);
} }
@ -308,8 +303,8 @@ void MqttPublishDirect(const char* topic, bool retained)
snprintf_P(log_data, sizeof(log_data), PSTR("%s ..."), log_data); snprintf_P(log_data, sizeof(log_data), PSTR("%s ..."), log_data);
} }
snprintf_P(log_data, sizeof(log_data), PSTR("%s%s"), log_data, sretained); snprintf_P(log_data, sizeof(log_data), PSTR("%s%s"), log_data, sretained);
AddLog(LOG_LEVEL_INFO); AddLog(LOG_LEVEL_INFO);
if (Settings.ledstate &0x04) { if (Settings.ledstate &0x04) {
blinks++; blinks++;
} }
@ -413,9 +408,7 @@ void MqttDisconnected(int state)
mqtt_connected = false; mqtt_connected = false;
mqtt_retry_counter = Settings.mqtt_retry; mqtt_retry_counter = Settings.mqtt_retry;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_CONNECT_FAILED_TO " %s:%d, rc %d. " D_RETRY_IN " %d " D_UNIT_SECOND), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CONNECT_FAILED_TO " %s:%d, rc %d. " D_RETRY_IN " %d " D_UNIT_SECOND), Settings.mqtt_host, Settings.mqtt_port, state, mqtt_retry_counter);
Settings.mqtt_host, Settings.mqtt_port, state, mqtt_retry_counter);
AddLog(LOG_LEVEL_INFO);
rules_flag.mqtt_disconnected = 1; rules_flag.mqtt_disconnected = 1;
} }
@ -500,9 +493,7 @@ bool MqttCheckTls(void)
//#endif //#endif
if (!EspClient.connect(Settings.mqtt_host, Settings.mqtt_port)) { if (!EspClient.connect(Settings.mqtt_host, Settings.mqtt_port)) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_TLS_CONNECT_FAILED_TO " %s:%d. " D_RETRY_IN " %d " D_UNIT_SECOND), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_TLS_CONNECT_FAILED_TO " %s:%d. " D_RETRY_IN " %d " D_UNIT_SECOND), Settings.mqtt_host, Settings.mqtt_port, mqtt_retry_counter);
Settings.mqtt_host, Settings.mqtt_port, mqtt_retry_counter);
AddLog(LOG_LEVEL_DEBUG);
} else { } else {
#ifdef USE_MQTT_TLS_CA_CERT #ifdef USE_MQTT_TLS_CA_CERT
unsigned char tls_ca_cert[] = MQTT_TLS_CA_CERT; unsigned char tls_ca_cert[] = MQTT_TLS_CA_CERT;
@ -972,9 +963,8 @@ void MqttSaveSettings(void)
strlcpy(Settings.mqtt_user, (!strlen(tmp)) ? MQTT_USER : (!strcmp(tmp,"0")) ? "" : tmp, sizeof(Settings.mqtt_user)); strlcpy(Settings.mqtt_user, (!strlen(tmp)) ? MQTT_USER : (!strcmp(tmp,"0")) ? "" : tmp, sizeof(Settings.mqtt_user));
WebGetArg("mp", tmp, sizeof(tmp)); WebGetArg("mp", tmp, sizeof(tmp));
strlcpy(Settings.mqtt_pwd, (!strlen(tmp)) ? "" : (!strcmp(tmp, D_ASTERISK_PWD)) ? Settings.mqtt_pwd : tmp, sizeof(Settings.mqtt_pwd)); strlcpy(Settings.mqtt_pwd, (!strlen(tmp)) ? "" : (!strcmp(tmp, D_ASTERISK_PWD)) ? Settings.mqtt_pwd : tmp, sizeof(Settings.mqtt_pwd));
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_CMND_MQTTHOST " %s, " D_CMND_MQTTPORT " %d, " D_CMND_MQTTCLIENT " %s, " D_CMND_MQTTUSER " %s, " D_CMND_TOPIC " %s, " D_CMND_FULLTOPIC " %s"), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CMND_MQTTHOST " %s, " D_CMND_MQTTPORT " %d, " D_CMND_MQTTCLIENT " %s, " D_CMND_MQTTUSER " %s, " D_CMND_TOPIC " %s, " D_CMND_FULLTOPIC " %s"),
Settings.mqtt_host, Settings.mqtt_port, Settings.mqtt_client, Settings.mqtt_user, Settings.mqtt_topic, Settings.mqtt_fulltopic); Settings.mqtt_host, Settings.mqtt_port, Settings.mqtt_client, Settings.mqtt_user, Settings.mqtt_topic, Settings.mqtt_fulltopic);
AddLog(LOG_LEVEL_INFO);
} }
#endif // USE_WEBSERVER #endif // USE_WEBSERVER

View File

@ -199,8 +199,7 @@ void EnergyMarginCheck(void)
energy_voltage_u = (uint16_t)(energy_voltage); energy_voltage_u = (uint16_t)(energy_voltage);
energy_current_u = (uint16_t)(energy_current * 1000); energy_current_u = (uint16_t)(energy_current * 1000);
// snprintf_P(log_data, sizeof(log_data), PSTR("NRG: W %d, U %d, I %d"), energy_power_u, energy_voltage_u, energy_current_u); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("NRG: W %d, U %d, I %d"), energy_power_u, energy_voltage_u, energy_current_u);
// AddLog(LOG_LEVEL_DEBUG);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{")); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{"));
jsonflg = false; jsonflg = false;

View File

@ -205,8 +205,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];
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_RFR D_HOST D_CODE " 0x%04X, " D_RECEIVED " 0x%06X"), stored_hostcode, arilux_rf_received_value); AddLog_P2(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);
if (hostcode == stored_hostcode) { if (hostcode == stored_hostcode) {
char command[33]; char command[33];
@ -406,8 +405,7 @@ void SM16716_Update(uint8_t duty_r, uint8_t duty_g, uint8_t duty_b)
uint8_t sm16716_should_enable = (duty_r | duty_g | duty_b); uint8_t sm16716_should_enable = (duty_r | duty_g | duty_b);
if (!sm16716_enabled && sm16716_should_enable) { if (!sm16716_enabled && sm16716_should_enable) {
#ifdef D_LOG_SM16716 #ifdef D_LOG_SM16716
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_SM16716 "turning color on")); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_SM16716 "turning color on"));
AddLog(LOG_LEVEL_DEBUG);
#endif // D_LOG_SM16716 #endif // D_LOG_SM16716
sm16716_enabled = 1; sm16716_enabled = 1;
digitalWrite(sm16716_pin_sel, HIGH); digitalWrite(sm16716_pin_sel, HIGH);
@ -418,18 +416,14 @@ void SM16716_Update(uint8_t duty_r, uint8_t duty_g, uint8_t duty_b)
} }
else if (sm16716_enabled && !sm16716_should_enable) { else if (sm16716_enabled && !sm16716_should_enable) {
#ifdef D_LOG_SM16716 #ifdef D_LOG_SM16716
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_SM16716 "turning color off")); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_SM16716 "turning color off"));
AddLog(LOG_LEVEL_DEBUG);
#endif // D_LOG_SM16716 #endif // D_LOG_SM16716
sm16716_enabled = 0; sm16716_enabled = 0;
digitalWrite(sm16716_pin_sel, LOW); digitalWrite(sm16716_pin_sel, LOW);
} }
} }
#ifdef D_LOG_SM16716 #ifdef D_LOG_SM16716
snprintf_P(log_data, sizeof(log_data), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_SM16716 "Update; rgb=%02x%02x%02x"), duty_r, duty_g, duty_b);
PSTR(D_LOG_SM16716 "Update; rgb=%02x%02x%02x"),
duty_r, duty_g, duty_b);
AddLog(LOG_LEVEL_DEBUG);
#endif // D_LOG_SM16716 #endif // D_LOG_SM16716
// send start bit // send start bit
@ -454,10 +448,7 @@ bool SM16716_ModuleSelected(void)
sm16716_pin_dat = pin[GPIO_SM16716_DAT]; sm16716_pin_dat = pin[GPIO_SM16716_DAT];
sm16716_pin_sel = pin[GPIO_SM16716_SEL]; sm16716_pin_sel = pin[GPIO_SM16716_SEL];
#ifdef D_LOG_SM16716 #ifdef D_LOG_SM16716
snprintf_P(log_data, sizeof(log_data), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_SM16716 "ModuleSelected; clk_pin=%d, dat_pin=%d)"), sm16716_pin_clk, sm16716_pin_dat);
PSTR(D_LOG_SM16716 "ModuleSelected; clk_pin=%d, dat_pin=%d)"),
sm16716_pin_clk, sm16716_pin_dat);
AddLog(LOG_LEVEL_DEBUG);
#endif // D_LOG_SM16716 #endif // D_LOG_SM16716
return (sm16716_pin_clk < 99) && (sm16716_pin_dat < 99); return (sm16716_pin_clk < 99) && (sm16716_pin_dat < 99);
} }
@ -598,8 +589,7 @@ void LightUpdateColorMapping(void)
light_ct_rgb_linked = !(Settings.param[P_RGB_REMAP] & 128); light_ct_rgb_linked = !(Settings.param[P_RGB_REMAP] & 128);
light_update = 1; light_update = 1;
//snprintf_P(log_data, sizeof(log_data), "%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_P2(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);
} }
void LightSetColorTemp(uint16_t ct) void LightSetColorTemp(uint16_t ct)
@ -707,8 +697,7 @@ void LightSetSignal(uint16_t lo, uint16_t hi, uint16_t value)
signal = 255; signal = 255;
} }
} }
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "Light signal %d"), signal); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Light signal %d"), signal);
// AddLog(LOG_LEVEL_DEBUG);
light_signal_color[0] = signal; light_signal_color[0] = signal;
light_signal_color[1] = 255 - signal; light_signal_color[1] = 255 - signal;
light_signal_color[2] = 0; light_signal_color[2] = 0;
@ -1015,8 +1004,7 @@ void LightAnimate(void)
cur_col[i] = 0xFC; // Fix unwanted blinking and PWM watchdog errors for values close to pwm_range (H801, Arilux and BN-SZ01) cur_col[i] = 0xFC; // Fix unwanted blinking and PWM watchdog errors for values close to pwm_range (H801, Arilux and BN-SZ01)
} }
uint16_t curcol = cur_col[i] * (Settings.pwm_range / 255); uint16_t curcol = cur_col[i] * (Settings.pwm_range / 255);
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "Cur_Col%d %d, CurCol %d"), i, cur_col[i], curcol); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d %d, CurCol %d"), i, cur_col[i], curcol);
// AddLog(LOG_LEVEL_DEBUG);
analogWrite(pin[GPIO_PWM1 +i], bitRead(pwm_inverted, i) ? Settings.pwm_range - curcol : curcol); analogWrite(pin[GPIO_PWM1 +i], bitRead(pwm_inverted, i) ? Settings.pwm_range - curcol : curcol);
} }
} }
@ -1044,8 +1032,7 @@ void LightAnimate(void)
cur_col[i] = 0xFC; // Fix unwanted blinking and PWM watchdog errors for values close to pwm_range (H801, Arilux and BN-SZ01) cur_col[i] = 0xFC; // Fix unwanted blinking and PWM watchdog errors for values close to pwm_range (H801, Arilux and BN-SZ01)
} }
uint16_t curcol = cur_col[i] * (Settings.pwm_range / 255); uint16_t curcol = cur_col[i] * (Settings.pwm_range / 255);
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "Cur_Col%d %d, CurCol %d"), i, cur_col[i], curcol); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d %d, CurCol %d"), i, cur_col[i], curcol);
// AddLog(LOG_LEVEL_DEBUG);
analogWrite(pin[GPIO_PWM1 +i-3], bitRead(pwm_inverted, i-3) ? Settings.pwm_range - curcol : curcol); analogWrite(pin[GPIO_PWM1 +i-3], bitRead(pwm_inverted, i-3) ? Settings.pwm_range - curcol : curcol);
} }
} }

View File

@ -114,9 +114,8 @@ void IrReceiveCheck(void)
if (irrecv->decode(&results)) { if (irrecv->decode(&results)) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_IRR "Echo %d, RawLen %d, Overflow %d, Bits %d, Value %08X, Decode %d"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_IRR "Echo %d, RawLen %d, Overflow %d, Bits %d, Value %08X, Decode %d"),
irsend_active, results.rawlen, results.overflow, results.bits, results.value, results.decode_type); irsend_active, results.rawlen, results.overflow, results.bits, results.value, results.decode_type);
AddLog(LOG_LEVEL_DEBUG);
unsigned long now = millis(); unsigned long now = millis();
// if ((now - ir_lasttime > IR_TIME_AVOID_DUPLICATE) && (UNKNOWN != results.decode_type) && (results.bits > 0)) { // if ((now - ir_lasttime > IR_TIME_AVOID_DUPLICATE) && (UNKNOWN != results.decode_type) && (results.bits > 0)) {
@ -314,9 +313,8 @@ bool IrHvacMitsubishi(const char *HVAC_Mode, const char *HVAC_FanMode, bool HVAC
mitsubir->setVane(MITSUBISHI_AC_VANE_AUTO); mitsubir->setVane(MITSUBISHI_AC_VANE_AUTO);
mitsubir->send(); mitsubir->send();
// snprintf_P(log_data, sizeof(log_data), PSTR("IRHVAC: Mitsubishi Power %d, Mode %d, FanSpeed %d, Temp %d, VaneMode %d"), // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRHVAC: Mitsubishi Power %d, Mode %d, FanSpeed %d, Temp %d, VaneMode %d"),
// mitsubir->getPower(), mitsubir->getMode(), mitsubir->getFan(), mitsubir->getTemp(), mitsubir->getVane()); // mitsubir->getPower(), mitsubir->getMode(), mitsubir->getFan(), mitsubir->getTemp(), mitsubir->getVane());
// AddLog(LOG_LEVEL_DEBUG);
return false; return false;
} }
@ -381,8 +379,7 @@ bool IrHvacLG(const char *HVAC_Mode, const char *HVAC_FanMode, bool HVAC_Power,
hvacOn = true; hvacOn = true;
} }
// snprintf_P(log_data, sizeof(log_data), PSTR("IRHVAC: HvacMode %s, ModeVal %d, Code %d"), p, mode, data[3]); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRHVAC: HvacMode %s, ModeVal %d, Code %d"), p, mode, data[3]);
// AddLog(LOG_LEVEL_DEBUG);
// Set code for HVAC temperature - data[4] // Set code for HVAC temperature - data[4]
if (HVAC_Temp > 30) { if (HVAC_Temp > 30) {
@ -414,8 +411,7 @@ bool IrHvacLG(const char *HVAC_Mode, const char *HVAC_FanMode, bool HVAC_Power,
data[5] = (mode * 2) - 2; // Low = 0x00, Mid = 0x02, High = 0x04 data[5] = (mode * 2) - 2; // Low = 0x00, Mid = 0x02, High = 0x04
} }
// snprintf_P(log_data, sizeof(log_data), PSTR("IRHVAC: FanMode %s, ModeVal %d, Code %d"), p, mode, data[5]); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRHVAC: FanMode %s, ModeVal %d, Code %d"), p, mode, data[5]);
// AddLog(LOG_LEVEL_DEBUG);
// Set CRC code - data[6] // Set CRC code - data[6]
data[6] = (data[3] + data[4] + data[5]) & 0x0f; // CRC data[6] = (data[3] + data[4] + data[5]) & 0x0f; // CRC
@ -428,8 +424,7 @@ bool IrHvacLG(const char *HVAC_Mode, const char *HVAC_FanMode, bool HVAC_Power,
} }
LG_Code = LG_Code + data[6]; LG_Code = LG_Code + data[6];
// snprintf_P(log_data, sizeof(log_data), PSTR("IRHVAC: LG_Code %d"), LG_Code); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRHVAC: LG_Code %d"), LG_Code);
// AddLog(LOG_LEVEL_DEBUG);
// Send LG IR Code // Send LG IR Code
// noInterrupts(); // noInterrupts();
@ -449,8 +444,7 @@ bool IrHvacFujitsu(const char *HVAC_Mode, const char *HVAC_FanMode, bool HVAC_Po
{ {
const char kFujitsuHvacModeOptions[] = "HDCAF"; const char kFujitsuHvacModeOptions[] = "HDCAF";
// snprintf_P(log_data, sizeof(log_data), PSTR("FUJITSU: mode:%s, fan:%s, power:%u, temp:%u"), HVAC_Mode, HVAC_FanMode, HVAC_Power, HVAC_Temp); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("FUJITSU: mode:%s, fan:%s, power:%u, temp:%u"), HVAC_Mode, HVAC_FanMode, HVAC_Power, HVAC_Temp);
// AddLog(LOG_LEVEL_DEBUG);
IRFujitsuAC ac(pin[GPIO_IRSEND]); IRFujitsuAC ac(pin[GPIO_IRSEND]);
@ -541,9 +535,7 @@ bool IrSendCommand(void)
raw_array[i++] = strtoul(str, NULL, 0); // Allow decimal (5246996) and hexadecimal (0x501014) input raw_array[i++] = strtoul(str, NULL, 0); // Allow decimal (5246996) and hexadecimal (0x501014) input
} }
// snprintf_P(log_data, sizeof(log_data), PSTR("IRS: Count %d, Freq %d, Arr[0] %d, Arr[count -1] %d"), // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRS: Count %d, Freq %d, Arr[0] %d, Arr[count -1] %d"), count, freq, raw_array[0], raw_array[count -1]);
// count, freq, raw_array[0], raw_array[count -1]);
// AddLog(LOG_LEVEL_DEBUG);
irsend_active = true; irsend_active = true;
irsend->sendRaw(raw_array, count, freq); irsend->sendRaw(raw_array, count, freq);
@ -573,9 +565,8 @@ bool IrSendCommand(void)
char protocol_text[20]; char protocol_text[20];
int protocol_code = GetCommandCode(protocol_text, sizeof(protocol_text), protocol, kIrRemoteProtocols); int protocol_code = GetCommandCode(protocol_text, sizeof(protocol_text), protocol, kIrRemoteProtocols);
snprintf_P(log_data, sizeof(log_data), PSTR("IRS: protocol_text %s, protocol %s, bits %d, data %u (0x%lX), protocol_code %d"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRS: protocol_text %s, protocol %s, bits %d, data %u (0x%lX), protocol_code %d"),
protocol_text, protocol, bits, data, data, protocol_code); protocol_text, protocol, bits, data, data, protocol_code);
AddLog(LOG_LEVEL_DEBUG);
irsend_active = true; irsend_active = true;
switch (protocol_code) { switch (protocol_code) {
@ -637,9 +628,7 @@ bool IrSendCommand(void)
HVAC_FanMode = root[D_JSON_IRHVAC_FANSPEED]; HVAC_FanMode = root[D_JSON_IRHVAC_FANSPEED];
HVAC_Temp = root[D_JSON_IRHVAC_TEMP]; HVAC_Temp = root[D_JSON_IRHVAC_TEMP];
// snprintf_P(log_data, sizeof(log_data), PSTR("IRHVAC: Received Vendor %s, Power %d, Mode %s, FanSpeed %s, Temp %d"), // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRHVAC: Received Vendor %s, Power %d, Mode %s, FanSpeed %s, Temp %d"), HVAC_Vendor, HVAC_Power, HVAC_Mode, HVAC_FanMode, HVAC_Temp);
// HVAC_Vendor, HVAC_Power, HVAC_Mode, HVAC_FanMode, HVAC_Temp);
// AddLog(LOG_LEVEL_DEBUG);
char vendor[20]; char vendor[20];
int vendor_code = GetCommandCode(vendor, sizeof(vendor), HVAC_Vendor, kIrHvacVendors); int vendor_code = GetCommandCode(vendor, sizeof(vendor), HVAC_Vendor, kIrHvacVendors);

View File

@ -206,8 +206,7 @@ bool DomoticzMqttData(void)
nvalue = domoticz["nvalue"]; nvalue = domoticz["nvalue"];
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DOMOTICZ "idx %d, nvalue %d"), idx, nvalue); AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ "idx %d, nvalue %d"), idx, nvalue);
AddLog(LOG_LEVEL_DEBUG_MORE);
if ((idx > 0) && (nvalue >= 0) && (nvalue <= 15)) { if ((idx > 0) && (nvalue >= 0) && (nvalue <= 15)) {
uint8_t maxdev = (devices_present > MAX_DOMOTICZ_IDX) ? MAX_DOMOTICZ_IDX : devices_present; uint8_t maxdev = (devices_present > MAX_DOMOTICZ_IDX) ? MAX_DOMOTICZ_IDX : devices_present;
@ -275,8 +274,7 @@ bool DomoticzMqttData(void)
return 1; return 1;
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DOMOTICZ D_RECEIVED_TOPIC " %s, " D_DATA " %s"), XdrvMailbox.topic, XdrvMailbox.data); AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ D_RECEIVED_TOPIC " %s, " D_DATA " %s"), XdrvMailbox.topic, XdrvMailbox.data);
AddLog(LOG_LEVEL_DEBUG_MORE);
domoticz_update_flag = 0; domoticz_update_flag = 0;
} }
@ -515,12 +513,11 @@ void DomoticzSaveSettings(void)
WebGetArg("ut", tmp, sizeof(tmp)); WebGetArg("ut", tmp, sizeof(tmp));
Settings.domoticz_update_timer = (!strlen(tmp)) ? DOMOTICZ_UPDATE_TIMER : atoi(tmp); Settings.domoticz_update_timer = (!strlen(tmp)) ? DOMOTICZ_UPDATE_TIMER : atoi(tmp);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DOMOTICZ D_CMND_IDX " %d,%d,%d,%d, " D_CMND_KEYIDX " %d,%d,%d,%d, " D_CMND_SWITCHIDX " %d,%d,%d,%d, " D_CMND_SENSORIDX " %s, " D_CMND_UPDATETIMER " %d"), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_DOMOTICZ D_CMND_IDX " %d,%d,%d,%d, " D_CMND_KEYIDX " %d,%d,%d,%d, " D_CMND_SWITCHIDX " %d,%d,%d,%d, " D_CMND_SENSORIDX " %s, " D_CMND_UPDATETIMER " %d"),
Settings.domoticz_relay_idx[0], Settings.domoticz_relay_idx[1], Settings.domoticz_relay_idx[2], Settings.domoticz_relay_idx[3], Settings.domoticz_relay_idx[0], Settings.domoticz_relay_idx[1], Settings.domoticz_relay_idx[2], Settings.domoticz_relay_idx[3],
Settings.domoticz_key_idx[0], Settings.domoticz_key_idx[1], Settings.domoticz_key_idx[2], Settings.domoticz_key_idx[3], Settings.domoticz_key_idx[0], Settings.domoticz_key_idx[1], Settings.domoticz_key_idx[2], Settings.domoticz_key_idx[3],
Settings.domoticz_switch_idx[0], Settings.domoticz_switch_idx[1], Settings.domoticz_switch_idx[2], Settings.domoticz_switch_idx[3], Settings.domoticz_switch_idx[0], Settings.domoticz_switch_idx[1], Settings.domoticz_switch_idx[2], Settings.domoticz_switch_idx[3],
ssensor_indices, Settings.domoticz_update_timer); ssensor_indices, Settings.domoticz_update_timer);
AddLog(LOG_LEVEL_INFO);
} }
#endif // USE_WEBSERVER #endif // USE_WEBSERVER

View File

@ -237,9 +237,8 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule)
double value = 0; double value = 0;
const char* str_value = root[rule_task][rule_name]; const char* str_value = root[rule_task][rule_name];
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Task %s, Name %s, Value |%s|, TrigCnt %d, TrigSt %d, Source %s, Json %s"), //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Task %s, Name %s, Value |%s|, TrigCnt %d, TrigSt %d, Source %s, Json %s"),
// rule_task.c_str(), rule_name.c_str(), rule_svalue, rules_trigger_count[rule_set], bitRead(rules_triggers[rule_set], rules_trigger_count[rule_set]), event.c_str(), (str_value) ? str_value : "none"); // rule_task.c_str(), rule_name.c_str(), rule_svalue, rules_trigger_count[rule_set], bitRead(rules_triggers[rule_set], rules_trigger_count[rule_set]), event.c_str(), (str_value) ? str_value : "none");
//AddLog(LOG_LEVEL_DEBUG);
if (!root[rule_task][rule_name].success()) { return false; } if (!root[rule_task][rule_name].success()) { return false; }
// No value but rule_name is ok // No value but rule_name is ok
@ -305,8 +304,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
delay(0); // Prohibit possible loop software watchdog delay(0); // Prohibit possible loop software watchdog
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Event = %s, Rule = %s"), event_saved.c_str(), Settings.rules[rule_set]); //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event = %s, Rule = %s"), event_saved.c_str(), Settings.rules[rule_set]);
//AddLog(LOG_LEVEL_DEBUG);
String rules = Settings.rules[rule_set]; String rules = Settings.rules[rule_set];
@ -341,8 +339,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
rules_event_value = ""; rules_event_value = "";
String event = event_saved; String event = event_saved;
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Event |%s|, Rule |%s|, Command(s) |%s|"), event.c_str(), event_trigger.c_str(), commands.c_str()); //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event |%s|, Rule |%s|, Command(s) |%s|"), event.c_str(), event_trigger.c_str(), commands.c_str());
//AddLog(LOG_LEVEL_DEBUG);
if (RulesRuleMatch(rule_set, event, event_trigger)) { if (RulesRuleMatch(rule_set, event, event_trigger)) {
commands.trim(); commands.trim();
@ -370,8 +367,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
char command[commands.length() +1]; char command[commands.length() +1];
snprintf(command, sizeof(command), commands.c_str()); snprintf(command, sizeof(command), commands.c_str());
snprintf_P(log_data, sizeof(log_data), PSTR("RUL: %s performs \"%s\""), event_trigger.c_str(), command); AddLog_P2(LOG_LEVEL_INFO, PSTR("RUL: %s performs \"%s\""), event_trigger.c_str(), command);
AddLog(LOG_LEVEL_INFO);
// snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, D_CMND_RULE, D_JSON_INITIATED); // snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, D_CMND_RULE, D_JSON_INITIATED);
// MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_CMND_RULE)); // MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_CMND_RULE));
@ -396,8 +392,7 @@ bool RulesProcessEvent(char *json_event)
String event_saved = json_event; String event_saved = json_event;
event_saved.toUpperCase(); event_saved.toUpperCase();
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Event %s"), event_saved.c_str()); //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event %s"), event_saved.c_str());
//AddLog(LOG_LEVEL_DEBUG);
for (uint8_t i = 0; i < MAX_RULE_SETS; i++) { for (uint8_t i = 0; i < MAX_RULE_SETS; i++) {
if (strlen(Settings.rules[i]) && bitRead(Settings.rule_enabled, i)) { if (strlen(Settings.rules[i]) && bitRead(Settings.rule_enabled, i)) {
@ -608,15 +603,13 @@ bool RulesMqttData(void)
} }
String sTopic = XdrvMailbox.topic; String sTopic = XdrvMailbox.topic;
String sData = XdrvMailbox.data; String sData = XdrvMailbox.data;
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: MQTT Topic %s, Event %s"), XdrvMailbox.topic, XdrvMailbox.data); //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: MQTT Topic %s, Event %s"), XdrvMailbox.topic, XdrvMailbox.data);
//AddLog(LOG_LEVEL_DEBUG);
MQTT_Subscription event_item; MQTT_Subscription event_item;
//Looking for matched topic //Looking for matched topic
for (int index = 0; index < subscriptions.size(); index++) { for (int index = 0; index < subscriptions.size(); index++) {
event_item = subscriptions.get(index); event_item = subscriptions.get(index);
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Match MQTT message Topic %s with subscription topic %s"), sTopic.c_str(), event_item.Topic.c_str()); //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Match MQTT message Topic %s with subscription topic %s"), sTopic.c_str(), event_item.Topic.c_str());
//AddLog(LOG_LEVEL_DEBUG);
if (sTopic.startsWith(event_item.Topic)) { if (sTopic.startsWith(event_item.Topic)) {
//This topic is subscribed by us, so serve it //This topic is subscribed by us, so serve it
serviced = true; serviced = true;
@ -686,8 +679,7 @@ String RulesSubscribe(const char *data, int data_len)
} }
} }
} }
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Subscribe command with parameters: %s, %s, %s."), event_name.c_str(), topic.c_str(), key.c_str()); //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Subscribe command with parameters: %s, %s, %s."), event_name.c_str(), topic.c_str(), key.c_str());
//AddLog(LOG_LEVEL_DEBUG);
event_name.toUpperCase(); event_name.toUpperCase();
if (event_name.length() > 0 && topic.length() > 0) { if (event_name.length() > 0 && topic.length() > 0) {
//Search all subscriptions //Search all subscriptions
@ -708,8 +700,7 @@ String RulesSubscribe(const char *data, int data_len)
topic.concat("/#"); topic.concat("/#");
} }
} }
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: New topic: %s."), topic.c_str()); //AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: New topic: %s."), topic.c_str());
//AddLog(LOG_LEVEL_DEBUG);
//MQTT Subscribe //MQTT Subscribe
subscription_item.Event = event_name; subscription_item.Event = event_name;
subscription_item.Topic = topic.substring(0, topic.length() - 2); //Remove "/#" so easy to match subscription_item.Topic = topic.substring(0, topic.length() - 2); //Remove "/#" so easy to match

View File

@ -247,11 +247,10 @@ void KNX_ADD_GA( uint8_t GAop, uint8_t GA_FNUM, uint8_t GA_AREA, uint8_t GA_FDEF
Settings.knx_GA_registered++; Settings.knx_GA_registered++;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_ADD " GA #%d: %s " D_TO " %d/%d/%d"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ADD " GA #%d: %s " D_TO " %d/%d/%d"),
Settings.knx_GA_registered, Settings.knx_GA_registered,
device_param_ga[GAop-1], device_param_ga[GAop-1],
GA_FNUM, GA_AREA, GA_FDEF ); GA_FNUM, GA_AREA, GA_FDEF );
AddLog(LOG_LEVEL_DEBUG);
} }
@ -297,9 +296,8 @@ void KNX_DEL_GA( uint8_t GAnum )
Settings.knx_GA_registered--; Settings.knx_GA_registered--;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_DELETE " GA #%d"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " GA #%d"),
GAnum ); GAnum );
AddLog(LOG_LEVEL_DEBUG);
} }
@ -330,11 +328,10 @@ void KNX_ADD_CB( uint8_t CBop, uint8_t CB_FNUM, uint8_t CB_AREA, uint8_t CB_FDEF
Settings.knx_CB_registered++; Settings.knx_CB_registered++;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_ADD " CB #%d: %d/%d/%d " D_TO " %s"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ADD " CB #%d: %d/%d/%d " D_TO " %s"),
Settings.knx_CB_registered, Settings.knx_CB_registered,
CB_FNUM, CB_AREA, CB_FDEF, CB_FNUM, CB_AREA, CB_FDEF,
device_param_cb[CBop-1] ); device_param_cb[CBop-1] );
AddLog(LOG_LEVEL_DEBUG);
} }
@ -387,8 +384,7 @@ void KNX_DEL_CB( uint8_t CBnum )
device_param[oldparam-1].CB_id = KNX_Empty; device_param[oldparam-1].CB_id = KNX_Empty;
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_DELETE " CB #%d"), CBnum ); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " CB #%d"), CBnum );
AddLog(LOG_LEVEL_DEBUG);
} }
@ -445,8 +441,7 @@ bool KNX_CONFIG_NOT_MATCH(void)
void KNXStart(void) void KNXStart(void)
{ {
knx.start(nullptr); knx.start(nullptr);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_START)); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_START));
AddLog(LOG_LEVEL_DEBUG);
} }
@ -522,8 +517,7 @@ void KNX_INIT(void)
if (KNX_CONFIG_NOT_MATCH()) { if (KNX_CONFIG_NOT_MATCH()) {
Settings.knx_GA_registered = 0; Settings.knx_GA_registered = 0;
Settings.knx_CB_registered = 0; Settings.knx_CB_registered = 0;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_DELETE " " D_KNX_PARAMETERS )); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " " D_KNX_PARAMETERS));
AddLog(LOG_LEVEL_DEBUG);
} }
// Register Group Addresses to listen to // Register Group Addresses to listen to
@ -555,22 +549,18 @@ void KNX_CB_Action(message_t const &msg, void *arg)
if (msg.data_len == 1) { if (msg.data_len == 1) {
// COMMAND // COMMAND
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_RECEIVED_FROM " %d.%d.%d " D_COMMAND " %s: %d " D_TO " %s"), tempchar[0] = msg.data[0];
msg.received_on.ga.area, msg.received_on.ga.line, msg.received_on.ga.member, tempchar[1] = '\0';
(msg.ct == KNX_CT_WRITE) ? D_KNX_COMMAND_WRITE : (msg.ct == KNX_CT_READ) ? D_KNX_COMMAND_READ : D_KNX_COMMAND_OTHER,
msg.data[0],
device_param_cb[(chan->type)-1]);
} else { } else {
// VALUE // VALUE
float tempvar = knx.data_to_2byte_float(msg.data); float tempvar = knx.data_to_2byte_float(msg.data);
dtostrfd(tempvar,2,tempchar); dtostrfd(tempvar,2,tempchar);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_RECEIVED_FROM " %d.%d.%d " D_COMMAND " %s: %s " D_TO " %s"),
msg.received_on.ga.area, msg.received_on.ga.line, msg.received_on.ga.member,
(msg.ct == KNX_CT_WRITE) ? D_KNX_COMMAND_WRITE : (msg.ct == KNX_CT_READ) ? D_KNX_COMMAND_READ : D_KNX_COMMAND_OTHER,
tempchar,
device_param_cb[(chan->type)-1]);
} }
AddLog(LOG_LEVEL_INFO); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX D_RECEIVED_FROM " %d.%d.%d " D_COMMAND " %s: %s " D_TO " %s"),
msg.received_on.ga.area, msg.received_on.ga.line, msg.received_on.ga.member,
(msg.ct == KNX_CT_WRITE) ? D_KNX_COMMAND_WRITE : (msg.ct == KNX_CT_READ) ? D_KNX_COMMAND_READ : D_KNX_COMMAND_OTHER,
tempchar,
device_param_cb[(chan->type)-1]);
switch (msg.ct) switch (msg.ct)
{ {
@ -668,10 +658,9 @@ void KnxUpdatePowerState(uint8_t device, power_t state)
knx.write_1bit(KNX_addr, device_param[device -1].last_state); knx.write_1bit(KNX_addr, device_param[device -1].last_state);
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"),
device_param_ga[device -1], device_param[device -1].last_state, device_param_ga[device -1], device_param[device -1].last_state,
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member); KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
AddLog(LOG_LEVEL_INFO);
i = KNX_GA_Search(device, i + 1); i = KNX_GA_Search(device, i + 1);
} }
@ -701,10 +690,9 @@ void KnxSendButtonPower(uint8_t key, uint8_t device, uint8_t state)
knx.write_1bit(KNX_addr, !(state == 0)); knx.write_1bit(KNX_addr, !(state == 0));
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"),
device_param_ga[device + 7], !(state == 0), device_param_ga[device + 7], !(state == 0),
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member); KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
AddLog(LOG_LEVEL_INFO);
i = KNX_GA_Search(device + 8, i + 1); i = KNX_GA_Search(device + 8, i + 1);
} }
@ -733,10 +721,9 @@ void KnxSensor(uint8_t sensor_type, float value)
knx.write_2byte_float(KNX_addr, value); knx.write_2byte_float(KNX_addr, value);
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "%s " D_SENT_TO " %d.%d.%d "), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s " D_SENT_TO " %d.%d.%d "),
device_param_ga[sensor_type -1], device_param_ga[sensor_type -1],
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member); KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
AddLog(LOG_LEVEL_INFO);
i = KNX_GA_Search(sensor_type, i+1); i = KNX_GA_Search(sensor_type, i+1);
} }
@ -960,9 +947,8 @@ void KNX_Save_Settings(void)
Settings.flag.knx_enabled = WebServer->hasArg("b1"); Settings.flag.knx_enabled = WebServer->hasArg("b1");
Settings.flag.knx_enable_enhancement = WebServer->hasArg("b2"); Settings.flag.knx_enable_enhancement = WebServer->hasArg("b2");
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_ENABLED ": %d, " D_KNX_ENHANCEMENT ": %d"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ENABLED ": %d, " D_KNX_ENHANCEMENT ": %d"),
Settings.flag.knx_enabled, Settings.flag.knx_enable_enhancement ); Settings.flag.knx_enabled, Settings.flag.knx_enable_enhancement );
AddLog(LOG_LEVEL_DEBUG);
stmp = WebServer->arg("area"); stmp = WebServer->arg("area");
KNX_addr.pa.area = stmp.toInt(); KNX_addr.pa.area = stmp.toInt();
@ -972,33 +958,29 @@ void KNX_Save_Settings(void)
KNX_addr.pa.member = stmp.toInt(); KNX_addr.pa.member = stmp.toInt();
Settings.knx_physsical_addr = KNX_addr.value; Settings.knx_physsical_addr = KNX_addr.value;
knx.physical_address_set( KNX_addr ); // Set Physical KNX Address of the device knx.physical_address_set( KNX_addr ); // Set Physical KNX Address of the device
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_KNX_PHYSICAL_ADDRESS ": %d.%d.%d "), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_KNX_PHYSICAL_ADDRESS ": %d.%d.%d "),
KNX_addr.pa.area, KNX_addr.pa.line, KNX_addr.pa.member ); KNX_addr.pa.area, KNX_addr.pa.line, KNX_addr.pa.member );
AddLog(LOG_LEVEL_DEBUG);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "GA: %d"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "GA: %d"),
Settings.knx_GA_registered ); Settings.knx_GA_registered );
AddLog(LOG_LEVEL_DEBUG);
for (uint8_t i = 0; i < Settings.knx_GA_registered ; ++i) for (uint8_t i = 0; i < Settings.knx_GA_registered ; ++i)
{ {
KNX_addr.value = Settings.knx_GA_addr[i]; KNX_addr.value = Settings.knx_GA_addr[i];
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "GA #%d: %s " D_TO " %d/%d/%d"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "GA #%d: %s " D_TO " %d/%d/%d"),
i+1, device_param_ga[Settings.knx_GA_param[i]-1], i+1, device_param_ga[Settings.knx_GA_param[i]-1],
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member ); KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member );
AddLog(LOG_LEVEL_DEBUG);
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "CB: %d"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "CB: %d"),
Settings.knx_CB_registered ); Settings.knx_CB_registered );
AddLog(LOG_LEVEL_DEBUG);
for (uint8_t i = 0; i < Settings.knx_CB_registered ; ++i) for (uint8_t i = 0; i < Settings.knx_CB_registered ; ++i)
{ {
KNX_addr.value = Settings.knx_CB_addr[i]; KNX_addr.value = Settings.knx_CB_addr[i];
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "CB #%d: %d/%d/%d " D_TO " %s"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "CB #%d: %d/%d/%d " D_TO " %s"),
i+1, i+1,
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member, KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member,
device_param_cb[Settings.knx_CB_param[i]-1] ); device_param_cb[Settings.knx_CB_param[i]-1] );
AddLog(LOG_LEVEL_DEBUG);
} }
} }
@ -1028,10 +1010,9 @@ bool KnxCommand(void)
knx.write_1bit(KNX_addr, !(XdrvMailbox.payload == 0)); knx.write_1bit(KNX_addr, !(XdrvMailbox.payload == 0));
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"),
device_param_ga[index + KNX_SLOT1 -2], !(XdrvMailbox.payload == 0), device_param_ga[index + KNX_SLOT1 -2], !(XdrvMailbox.payload == 0),
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member); KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
AddLog(LOG_LEVEL_INFO);
i = KNX_GA_Search(index + KNX_SLOT1 -1, i + 1); i = KNX_GA_Search(index + KNX_SLOT1 -1, i + 1);
} }
@ -1057,10 +1038,9 @@ bool KnxCommand(void)
knx.write_2byte_float(KNX_addr, tempvar); knx.write_2byte_float(KNX_addr, tempvar);
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "%s = %s " D_SENT_TO " %d.%d.%d"), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %s " D_SENT_TO " %d.%d.%d"),
device_param_ga[index + KNX_SLOT1 -2], XdrvMailbox.data, device_param_ga[index + KNX_SLOT1 -2], XdrvMailbox.data,
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member); KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
AddLog(LOG_LEVEL_INFO);
i = KNX_GA_Search(index + KNX_SLOT1 -1, i + 1); i = KNX_GA_Search(index + KNX_SLOT1 -1, i + 1);
} }

View File

@ -172,10 +172,8 @@ int try_snprintf_P(char *s, size_t n, const char *format, ... )
va_start(args, format); va_start(args, format);
int len = vsnprintf_P(NULL, 0, format, args); int len = vsnprintf_P(NULL, 0, format, args);
if (len >= n) { if (len >= n) {
snprintf_P(log_data, sizeof(log_data), AddLog_P2(LOG_LEVEL_ERROR, PSTR("ERROR: MQTT discovery failed due to too long topic or friendly name. "
PSTR("ERROR: MQTT discovery failed due to too long topic or friendly name. " "Please shorten topic and friendly name. Failed to format(%u/%u):"), len, n);
"Please shorten topic and friendly name. Failed to format(%u/%u):"), len, n);
AddLog(LOG_LEVEL_ERROR);
va_start(args, format); va_start(args, format);
vsnprintf_P(log_data, sizeof(log_data), format, args); vsnprintf_P(log_data, sizeof(log_data), format, args);
AddLog(LOG_LEVEL_ERROR); AddLog(LOG_LEVEL_ERROR);
@ -479,16 +477,14 @@ void HAssAnnounceSensors(void)
StaticJsonBuffer<500> jsonBuffer; StaticJsonBuffer<500> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(sensordata); JsonObject& root = jsonBuffer.parseObject(sensordata);
if (!root.success()) { if (!root.success()) {
snprintf_P(log_data, sizeof(log_data), PSTR("HASS: failed to parse '%s'"), sensordata); AddLog_P2(LOG_LEVEL_ERROR, PSTR("HASS: failed to parse '%s'"), sensordata);
AddLog(LOG_LEVEL_ERROR);
continue; continue;
} }
for (auto sensor : root) { for (auto sensor : root) {
const char* sensorname = sensor.key; const char* sensorname = sensor.key;
JsonObject& sensors = sensor.value.as<JsonObject>(); JsonObject& sensors = sensor.value.as<JsonObject>();
if (!sensors.success()) { if (!sensors.success()) {
snprintf_P(log_data, sizeof(log_data), PSTR("HASS: failed to parse '%s'"), sensordata); AddLog_P2(LOG_LEVEL_ERROR, PSTR("HASS: failed to parse '%s'"), sensordata);
AddLog(LOG_LEVEL_ERROR);
continue; continue;
} }
for (auto subsensor : sensors) { for (auto subsensor : sensors) {

View File

@ -746,8 +746,7 @@ void DisplayJsonValue(const char* topic, const char* device, const char* mkey, c
} }
snprintf_P(buffer, sizeof(buffer), PSTR("%s %s"), source, svalue); snprintf_P(buffer, sizeof(buffer), PSTR("%s %s"), source, svalue);
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "mkey [%s], source [%s], value [%s], quantity_code %d, log_buffer [%s]"), mkey, source, value, quantity_code, buffer); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "mkey [%s], source [%s], value [%s], quantity_code %d, log_buffer [%s]"), mkey, source, value, quantity_code, buffer);
// AddLog(LOG_LEVEL_DEBUG);
DisplayLogBufferAdd(buffer); DisplayLogBufferAdd(buffer);
} }
@ -777,8 +776,7 @@ void DisplayAnalyzeJson(char *topic, char *json)
tempunit = root[D_JSON_TEMPERATURE_UNIT]; tempunit = root[D_JSON_TEMPERATURE_UNIT];
if (tempunit) { if (tempunit) {
snprintf_P(disp_temp, sizeof(disp_temp), PSTR("%s"), tempunit); snprintf_P(disp_temp, sizeof(disp_temp), PSTR("%s"), tempunit);
// snprintf_P(log_data, sizeof(log_data), disp_temp); // AddLog_P2(LOG_LEVEL_DEBUG, disp_temp);
// AddLog(LOG_LEVEL_DEBUG);
} }
for (JsonObject::iterator it = root.begin(); it != root.end(); ++it) { for (JsonObject::iterator it = root.begin(); it != root.end(); ++it) {
@ -883,8 +881,7 @@ void DisplayInitDriver(void)
{ {
XdspCall(FUNC_DISPLAY_INIT_DRIVER); XdspCall(FUNC_DISPLAY_INIT_DRIVER);
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model);
// AddLog(LOG_LEVEL_DEBUG);
if (Settings.display_model) { if (Settings.display_model) {
devices_present++; devices_present++;

View File

@ -45,8 +45,7 @@ void PCA9685_Detect(void)
if (I2cValidRead8(&buffer, USE_PCA9685_ADDR, PCA9685_REG_MODE1)) { if (I2cValidRead8(&buffer, USE_PCA9685_ADDR, PCA9685_REG_MODE1)) {
if (0x20 == buffer) { if (0x20 == buffer) {
pca9685_detected = 1; pca9685_detected = 1;
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "PCA9685", USE_PCA9685_ADDR); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "PCA9685", USE_PCA9685_ADDR);
AddLog(LOG_LEVEL_DEBUG);
PCA9685_Reset(); // Reset the controller PCA9685_Reset(); // Reset the controller
} }
} }
@ -101,7 +100,7 @@ void PCA9685_SetPWM(uint8_t pin, uint16_t pwm, bool inverted) {
pca9685_pin_pwm_value[pin] = pwm; pca9685_pin_pwm_value[pin] = pwm;
} }
bool PCA9685_Command(void) bool PCA9685_Command(void)
{ {
bool serviced = true; bool serviced = true;
bool validpin = false; bool validpin = false;

View File

@ -123,8 +123,7 @@ bool TuyaSetPower(void)
if (source != SRC_SWITCH && TuyaSerial) { // ignore to prevent loop from pushing state from faceplate interaction if (source != SRC_SWITCH && TuyaSerial) { // ignore to prevent loop from pushing state from faceplate interaction
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: SetDevicePower.rpower=%d"), rpower); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: SetDevicePower.rpower=%d"), rpower);
AddLog(LOG_LEVEL_DEBUG);
TuyaSendBool(TUYA_POWER_ID, rpower); TuyaSendBool(TUYA_POWER_ID, rpower);
@ -146,16 +145,14 @@ void LightSerialDuty(uint8_t duty)
duty = 25; // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself duty = 25; // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself
} }
snprintf_P(log_data, sizeof(log_data), PSTR( "TYA: Send Serial Packet Dim Value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]); AddLog_P2(LOG_LEVEL_DEBUG, PSTR( "TYA: Send Serial Packet Dim Value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]);
AddLog(LOG_LEVEL_DEBUG);
TuyaSendValue(Settings.param[P_TUYA_DIMMER_ID], duty); TuyaSendValue(Settings.param[P_TUYA_DIMMER_ID], duty);
} else { } else {
tuya_ignore_dim = false; // reset flag tuya_ignore_dim = false; // reset flag
snprintf_P(log_data, sizeof(log_data), PSTR( "TYA: Send Dim Level skipped due to 0 or already set. Value=%d"), duty); AddLog_P2(LOG_LEVEL_DEBUG, PSTR( "TYA: Send Dim Level skipped due to 0 or already set. Value=%d"), duty);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
@ -164,8 +161,7 @@ void TuyaRequestState(void){
if(TuyaSerial) { if(TuyaSerial) {
// Get current status of MCU // Get current status of MCU
snprintf_P(log_data, sizeof(log_data), "TYA: Request MCU state"); AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Request MCU state"));
AddLog(LOG_LEVEL_DEBUG);
TuyaSendCmd(TUYA_CMD_QUERY_STATE); TuyaSendCmd(TUYA_CMD_QUERY_STATE);
} }
@ -197,8 +193,7 @@ void TuyaPacketProcess(void)
case TUYA_CMD_STATE: case TUYA_CMD_STATE:
if (tuya_buffer[5] == 5) { // on/off packet if (tuya_buffer[5] == 5) { // on/off packet
snprintf_P(log_data, sizeof(log_data),PSTR("TYA: RX - %s State"),tuya_buffer[10]?"On":"Off"); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX - %s State"),tuya_buffer[10]?"On":"Off");
AddLog(LOG_LEVEL_DEBUG);
if((power || Settings.light_dimmer > 0) && (power != tuya_buffer[10])) { if((power || Settings.light_dimmer > 0) && (power != tuya_buffer[10])) {
ExecuteCommandPower(1, tuya_buffer[10], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction ExecuteCommandPower(1, tuya_buffer[10], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
@ -206,12 +201,10 @@ void TuyaPacketProcess(void)
} }
else if (tuya_buffer[5] == 8) { // dim packet else if (tuya_buffer[5] == 8) { // dim packet
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: RX Dim State=%d"), tuya_buffer[13]); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Dim State=%d"), tuya_buffer[13]);
AddLog(LOG_LEVEL_DEBUG);
if (!Settings.param[P_TUYA_DIMMER_ID]) { if (!Settings.param[P_TUYA_DIMMER_ID]) {
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Autoconfiguring Dimmer ID %d"), tuya_buffer[6]); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Autoconfiguring Dimmer ID %d"), tuya_buffer[6]);
AddLog(LOG_LEVEL_DEBUG);
Settings.param[P_TUYA_DIMMER_ID] = tuya_buffer[6]; Settings.param[P_TUYA_DIMMER_ID] = tuya_buffer[6];
} }
@ -220,8 +213,7 @@ void TuyaPacketProcess(void)
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), tuya_new_dim ); snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), tuya_new_dim );
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Send CMND_DIMMER_STR=%s"), scmnd ); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Send CMND_DIMMER_STR=%s"), scmnd );
AddLog(LOG_LEVEL_DEBUG);
tuya_ignore_dim = true; tuya_ignore_dim = true;
ExecuteCommand(scmnd, SRC_SWITCH); ExecuteCommand(scmnd, SRC_SWITCH);
@ -297,8 +289,7 @@ void TuyaInit(void)
if (TuyaSerial->begin(9600)) { if (TuyaSerial->begin(9600)) {
if (TuyaSerial->hardwareSerial()) { ClaimSerial(); } if (TuyaSerial->hardwareSerial()) { ClaimSerial(); }
// Get MCU Configuration // Get MCU Configuration
snprintf_P(log_data, sizeof(log_data), "TYA: Request MCU configuration"); AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Request MCU configuration"));
AddLog(LOG_LEVEL_DEBUG);
TuyaSendCmd(TUYA_CMD_MCU_CONF); TuyaSendCmd(TUYA_CMD_MCU_CONF);
} }
@ -364,8 +355,7 @@ void TuyaSerialInput(void)
bool TuyaButtonPressed(void) bool TuyaButtonPressed(void)
{ {
if (!XdrvMailbox.index && ((PRESSED == XdrvMailbox.payload) && (NOT_PRESSED == lastbutton[XdrvMailbox.index]))) { if (!XdrvMailbox.index && ((PRESSED == XdrvMailbox.payload) && (NOT_PRESSED == lastbutton[XdrvMailbox.index]))) {
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Reset GPIO triggered")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Reset GPIO triggered"));
AddLog(LOG_LEVEL_DEBUG);
TuyaResetWifi(); TuyaResetWifi();
return true; // Reset GPIO served here return true; // Reset GPIO served here
} }
@ -387,8 +377,7 @@ void TuyaSetWifiLed(void){
break; break;
} }
snprintf_P(log_data, sizeof(log_data), "TYA: Set WiFi LED to state %d (%d)", wifi_state, WifiState()); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Set WiFi LED to state %d (%d)"), wifi_state, WifiState());
AddLog(LOG_LEVEL_DEBUG);
TuyaSendCmd(TUYA_CMD_WIFI_STATE, &wifi_state, 1); TuyaSendCmd(TUYA_CMD_WIFI_STATE, &wifi_state, 1);
} }

View File

@ -49,8 +49,7 @@ void RfReceiveCheck(void)
int protocol = mySwitch.getReceivedProtocol(); int protocol = mySwitch.getReceivedProtocol();
int delay = mySwitch.getReceivedDelay(); int delay = mySwitch.getReceivedDelay();
snprintf_P(log_data, sizeof(log_data), PSTR("RFR: Data %lX (%u), Bits %d, Protocol %d, Delay %d"), data, data, bits, protocol, delay); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RFR: Data %lX (%u), Bits %d, Protocol %d, Delay %d"), data, data, bits, protocol, delay);
AddLog(LOG_LEVEL_DEBUG);
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)) {

View File

@ -58,13 +58,11 @@ void LightSerial2Duty(uint8_t duty1, uint8_t duty2)
ArmtronixSerial->print("\nDimmer2:"); ArmtronixSerial->print("\nDimmer2:");
ArmtronixSerial->println(duty2); ArmtronixSerial->println(duty2);
snprintf_P(log_data, sizeof(log_data), PSTR( "ARM: Send Serial Packet Dim Values=%d,%d"), armtronix_dimState[0],armtronix_dimState[1]); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ARM: Send Serial Packet Dim Values=%d,%d"), armtronix_dimState[0],armtronix_dimState[1]);
AddLog(LOG_LEVEL_DEBUG);
} else { } else {
armtronix_ignore_dim = false; armtronix_ignore_dim = false;
snprintf_P(log_data, sizeof(log_data), PSTR( "ARM: Send Dim Level skipped due to already set. Value=%d,%d"), armtronix_dimState[0],armtronix_dimState[1]); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ARM: Send Dim Level skipped due to already set. Value=%d,%d"), armtronix_dimState[0],armtronix_dimState[1]);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
@ -73,8 +71,7 @@ void ArmtronixRequestState(void)
{ {
if (ArmtronixSerial) { if (ArmtronixSerial) {
// Get current status of MCU // Get current status of MCU
snprintf_P(log_data, sizeof(log_data), "TYA: Request MCU state"); AddLog_P(LOG_LEVEL_DEBUG, PSTR("ARM: Request MCU state"));
AddLog(LOG_LEVEL_DEBUG);
ArmtronixSerial->println("Status"); ArmtronixSerial->println("Status");
} }
@ -123,8 +120,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);
snprintf_P(log_data, sizeof(log_data), PSTR("ARM: Send CMND_CHANNEL=%s"), scmnd ); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ARM: Send CMND_CHANNEL=%s"), scmnd );
AddLog(LOG_LEVEL_DEBUG);
} }
commaIndex = answer.indexOf(',',commaIndex+1); commaIndex = answer.indexOf(',',commaIndex+1);
} }
@ -152,8 +148,7 @@ void ArmtronixSetWifiLed(void)
break; break;
} }
snprintf_P(log_data, sizeof(log_data), "ARM: Set WiFi LED to state %d (%d)", wifi_state, WifiState()); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ARM: Set WiFi LED to state %d (%d)"), wifi_state, WifiState());
AddLog(LOG_LEVEL_DEBUG);
char state = '0' + ((wifi_state & 1) > 0); char state = '0' + ((wifi_state & 1) > 0);
ArmtronixSerial->print("Setled:"); ArmtronixSerial->print("Setled:");

View File

@ -67,8 +67,7 @@ void PS16DZSendCommand(char type = 0, uint8_t value = 0)
break; break;
} }
snprintf_P(log_data, sizeof(log_data), PSTR( "PSZ: Send serial command: %s"), ps16dz_tx_buffer ); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: Send serial command: %s"), ps16dz_tx_buffer );
AddLog(LOG_LEVEL_DEBUG);
PS16DZSerial->print(ps16dz_tx_buffer); PS16DZSerial->print(ps16dz_tx_buffer);
PS16DZSerial->write(0x1B); PS16DZSerial->write(0x1B);
@ -109,8 +108,7 @@ void PS16DZSerialDuty(uint8_t duty)
} else { } else {
ps16dz_ignore_dim = false; // reset flag ps16dz_ignore_dim = false; // reset flag
snprintf_P(log_data, sizeof(log_data), PSTR( "PSZ: Send Dim Level skipped due to 0 or already set. Value=%d"), duty); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: Send Dim Level skipped due to 0 or already set. Value=%d"), duty);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
@ -165,8 +163,7 @@ void PS16DZSerialInput(void)
} }
else { else {
ps16dz_rx_buffer[ps16dz_byte_counter++] = 0x00; ps16dz_rx_buffer[ps16dz_byte_counter++] = 0x00;
snprintf_P(log_data, sizeof(log_data), PSTR("PSZ: command received: %s"), ps16dz_rx_buffer); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: command received: %s"), ps16dz_rx_buffer);
AddLog(LOG_LEVEL_DEBUG);
if(!strncmp(ps16dz_rx_buffer+3, "UPDATE", 6) || !strncmp(ps16dz_rx_buffer+3, "RESULT", 6)) { if(!strncmp(ps16dz_rx_buffer+3, "UPDATE", 6) || !strncmp(ps16dz_rx_buffer+3, "RESULT", 6)) {
char *end_str; char *end_str;
char *string = ps16dz_rx_buffer+10; char *string = ps16dz_rx_buffer+10;
@ -177,22 +174,19 @@ void PS16DZSerialInput(void)
char* token3 = strtok_r(NULL, ":", &end_token); char* token3 = strtok_r(NULL, ":", &end_token);
if(!strncmp(token2, "\"switch\"", 8)){ if(!strncmp(token2, "\"switch\"", 8)){
bool ps16dz_power = !strncmp(token3, "\"on\"", 4)?true:false; bool ps16dz_power = !strncmp(token3, "\"on\"", 4)?true:false;
snprintf_P(log_data, sizeof(log_data), PSTR("PSZ: power received: %s"), token3); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: power received: %s"), token3);
AddLog(LOG_LEVEL_DEBUG);
if((power || Settings.light_dimmer > 0) && (power !=ps16dz_power)) { if((power || Settings.light_dimmer > 0) && (power !=ps16dz_power)) {
ExecuteCommandPower(1, ps16dz_power, SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction ExecuteCommandPower(1, ps16dz_power, SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
} }
} }
else if(!strncmp(token2, "\"bright\"", 8)){ else if(!strncmp(token2, "\"bright\"", 8)){
uint8_t ps16dz_bright = atoi(token3); uint8_t ps16dz_bright = atoi(token3);
snprintf_P(log_data, sizeof(log_data), PSTR("PSZ: brightness received: %d"), ps16dz_bright); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: brightness received: %d"), ps16dz_bright);
AddLog(LOG_LEVEL_DEBUG);
if(power && ps16dz_bright > 0 && ps16dz_bright != Settings.light_dimmer) { if(power && ps16dz_bright > 0 && ps16dz_bright != Settings.light_dimmer) {
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), ps16dz_bright ); snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), ps16dz_bright );
snprintf_P(log_data, sizeof(log_data), PSTR("PSZ: Send CMND_DIMMER_STR=%s"), scmnd ); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: Send CMND_DIMMER_STR=%s"), scmnd );
AddLog(LOG_LEVEL_DEBUG);
ps16dz_ignore_dim = true; ps16dz_ignore_dim = true;
ExecuteCommand(scmnd, SRC_SWITCH); ExecuteCommand(scmnd, SRC_SWITCH);
@ -200,15 +194,13 @@ void PS16DZSerialInput(void)
} }
else if(!strncmp(token2, "\"sequence\"", 10)){ else if(!strncmp(token2, "\"sequence\"", 10)){
//ps16dz_seq = strtoull(token3+1, NULL, 10); //ps16dz_seq = strtoull(token3+1, NULL, 10);
snprintf_P(log_data, sizeof(log_data), PSTR("PSZ: sequence received: %s"), token3); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: sequence received: %s"), token3);
AddLog(LOG_LEVEL_DEBUG);
} }
token = strtok_r(NULL, ",", &end_str); token = strtok_r(NULL, ",", &end_str);
} }
} }
else if(!strncmp(ps16dz_rx_buffer+3, "SETTING", 7)) { else if(!strncmp(ps16dz_rx_buffer+3, "SETTING", 7)) {
snprintf_P(log_data, sizeof(log_data), PSTR("PSZ: Reset")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("PSZ: Reset"));
AddLog(LOG_LEVEL_DEBUG);
PS16DZResetWifi(); PS16DZResetWifi();
} }
memset(ps16dz_rx_buffer, 0, PS16DZ_BUFFER_SIZE); memset(ps16dz_rx_buffer, 0, PS16DZ_BUFFER_SIZE);

View File

@ -138,8 +138,7 @@ bool LcdPrintLog(void)
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols); strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
DisplayFillScreen(last_row); DisplayFillScreen(last_row);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
AddLog(LOG_LEVEL_DEBUG);
lcd->setCursor(0, last_row); lcd->setCursor(0, last_row);
lcd->print(disp_screen_buffer[last_row]); lcd->print(disp_screen_buffer[last_row]);

View File

@ -154,8 +154,7 @@ void Ssd1306PrintLog(void)
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols); strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
DisplayFillScreen(last_row); DisplayFillScreen(last_row);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
AddLog(LOG_LEVEL_DEBUG);
oled->println(disp_screen_buffer[last_row]); oled->println(disp_screen_buffer[last_row]);
oled->display(); oled->display();

View File

@ -94,8 +94,7 @@ void MatrixScrollLeft(char* txt, int loop)
// Horiz. position of text -- starts off right edge // Horiz. position of text -- starts off right edge
mtx_x = 8 * mtx_matrices; mtx_x = 8 * mtx_matrices;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "[%s]"), txt); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), txt);
AddLog(LOG_LEVEL_DEBUG);
disp_refresh = Settings.display_refresh; disp_refresh = Settings.display_refresh;
case 2: case 2:
@ -261,8 +260,7 @@ void MatrixPrintLog(uint8_t direction)
i++; i++;
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "[%s]"), mtx_buffer); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), mtx_buffer);
AddLog(LOG_LEVEL_DEBUG);
mtx_done = 1; mtx_done = 1;
} }

View File

@ -178,8 +178,7 @@ void Ili9341PrintLog(void)
DisplayFillScreen(last_row); DisplayFillScreen(last_row);
tft->print(disp_screen_buffer[last_row]); tft->print(disp_screen_buffer[last_row]);
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "[%s]"), txt); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
} }

View File

@ -123,16 +123,14 @@ void EpdInitDriver(void)
epd.sclk_pin = pin[GPIO_SPI_CLK]; // 14 epd.sclk_pin = pin[GPIO_SPI_CLK]; // 14
epd.mosi_pin = pin[GPIO_SPI_MOSI]; // 13 epd.mosi_pin = pin[GPIO_SPI_MOSI]; // 13
EpdInitMode(); EpdInitMode();
snprintf_P(log_data, sizeof(log_data), PSTR("EPD: HardSPI CS %d, CLK %d, MOSI %d"), epd.cs_pin, epd.sclk_pin, epd.mosi_pin); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("EPD: HardSPI CS %d, CLK %d, MOSI %d"), epd.cs_pin, epd.sclk_pin, epd.mosi_pin);
AddLog(LOG_LEVEL_DEBUG);
} }
else if ((pin[GPIO_SSPI_CS] < 99) && (pin[GPIO_SSPI_SCLK] < 99) && (pin[GPIO_SSPI_MOSI] < 99)) { else if ((pin[GPIO_SSPI_CS] < 99) && (pin[GPIO_SSPI_SCLK] < 99) && (pin[GPIO_SSPI_MOSI] < 99)) {
epd.cs_pin = pin[GPIO_SSPI_CS]; epd.cs_pin = pin[GPIO_SSPI_CS];
epd.sclk_pin = pin[GPIO_SSPI_SCLK]; epd.sclk_pin = pin[GPIO_SSPI_SCLK];
epd.mosi_pin = pin[GPIO_SSPI_MOSI]; epd.mosi_pin = pin[GPIO_SSPI_MOSI];
EpdInitMode(); EpdInitMode();
snprintf_P(log_data, sizeof(log_data), PSTR("EPD: SoftSPI CS %d, CLK %d, MOSI %d"), epd.cs_pin, epd.sclk_pin, epd.mosi_pin); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("EPD: SoftSPI CS %d, CLK %d, MOSI %d"), epd.cs_pin, epd.sclk_pin, epd.mosi_pin);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
} }
@ -221,8 +219,7 @@ void EpdPrintLog(void)
EpdDrawStringAt(0, epd_scroll, disp_screen_buffer[last_row], COLORED, 0); EpdDrawStringAt(0, epd_scroll, disp_screen_buffer[last_row], COLORED, 0);
// EpdDisplayFrame(); // EpdDisplayFrame();
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "[%s]"), txt); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
} }

View File

@ -152,9 +152,8 @@ void HlwEvery200ms(void)
} }
} }
unsigned long median = hlw_debug[(hlw_cf1_pulse_counter +1) / 2]; unsigned long median = hlw_debug[(hlw_cf1_pulse_counter +1) / 2];
snprintf_P(log_data, sizeof(log_data), PSTR("NRG: power %d, ui %d, cnt %d, smpl%s, sum %d, mean %d, median %d"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR("NRG: power %d, ui %d, cnt %d, smpl%s, sum %d, mean %d, median %d"),
hlw_cf_power_pulse_length, hlw_select_ui_flag, hlw_cf1_pulse_counter, stemp, hlw_cf1_summed_pulse_length, cf1_pulse_length, median); hlw_cf_power_pulse_length, hlw_select_ui_flag, hlw_cf1_pulse_counter, stemp, hlw_cf1_summed_pulse_length, cf1_pulse_length, median);
AddLog(LOG_LEVEL_DEBUG);
#endif #endif
if (hlw_select_ui_flag == hlw_ui_flag) { if (hlw_select_ui_flag == hlw_ui_flag) {

View File

@ -49,8 +49,7 @@ void PzemAcEverySecond(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, (buffer[2]) ? buffer[2] +5 : sizeof(buffer)); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, (buffer[2]) ? buffer[2] +5 : sizeof(buffer));
if (error) { if (error) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "PzemAc response error %d"), error); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "PzemAc response error %d"), error);
AddLog(LOG_LEVEL_DEBUG);
} else { } else {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
// 01 04 14 08 D1 00 6C 00 00 00 F4 00 00 00 26 00 00 01 F4 00 64 00 00 51 34 // 01 04 14 08 D1 00 6C 00 00 00 F4 00 00 00 26 00 00 01 F4 00 64 00 00 51 34

View File

@ -49,8 +49,7 @@ void PzemDcEverySecond(void)
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, (buffer[2]) ? buffer[2] +5 : sizeof(buffer)); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, (buffer[2]) ? buffer[2] +5 : sizeof(buffer));
if (error) { if (error) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "PzemDc response error %d"), error); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "PzemDc response error %d"), error);
AddLog(LOG_LEVEL_DEBUG);
} else { } else {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// 01 04 10 05 40 00 0A 00 0D 00 00 00 02 00 00 00 00 00 00 D6 29 // 01 04 10 05 40 00 0A 00 0D 00 00 00 02 00 00 00 00 00 00 D6 29

View File

@ -95,9 +95,8 @@ void WemoRespondToMSearch(int echo_type)
} else { } else {
snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE)); snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE));
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPNP D_WEMO " " D_JSON_TYPE " %d, %s " D_TO " %s:%d"), AddLog_P2(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);
AddLog(LOG_LEVEL_DEBUG);
udp_response_mutex = false; udp_response_mutex = false;
} }
@ -186,9 +185,8 @@ void HueRespondToMSearch(void)
} else { } else {
snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE)); snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE));
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPNP D_HUE " %s " D_TO " %s:%d"), AddLog_P2(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);
AddLog(LOG_LEVEL_DEBUG);
udp_response_mutex = false; udp_response_mutex = false;
} }
@ -537,8 +535,7 @@ void HandleUpnpSetupHue(void)
void HueNotImplemented(String *path) void HueNotImplemented(String *path)
{ {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP D_HUE_API_NOT_IMPLEMENTED " (%s)"), path->c_str()); AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API_NOT_IMPLEMENTED " (%s)"), path->c_str());
AddLog(LOG_LEVEL_DEBUG_MORE);
WSSend(200, CT_JSON, "{}"); WSSend(200, CT_JSON, "{}");
} }
@ -819,12 +816,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();
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP D_HUE_API " (%s)"), path->c_str()); AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API " (%s)"), path->c_str()); // HTP: Hue API (//lights/1/state
AddLog(LOG_LEVEL_DEBUG_MORE); // HTP: Hue API (//lights/1/state)
for (args = 0; args < WebServer->args(); args++) { for (args = 0; args < WebServer->args(); args++) {
String json = WebServer->arg(args); String json = WebServer->arg(args);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP D_HUE_POST_ARGS " (%s)"), json.c_str()); AddLog_P2(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); // HTP: Hue POST args ({"on":false})
} }
if (path->endsWith("/invalid/")) {} // Just ignore if (path->endsWith("/invalid/")) {} // Just ignore

View File

@ -36,8 +36,7 @@ void CounterUpdate(uint8_t index)
RtcSettings.pulse_counter[index -1]++; RtcSettings.pulse_counter[index -1]++;
} }
// snprintf_P(log_data, sizeof(log_data), PSTR("CNTR: Interrupt %d"), index); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("CNTR: Interrupt %d"), index);
// AddLog(LOG_LEVEL_DEBUG);
} }
} }

View File

@ -61,8 +61,7 @@ void SonoffScSend(const char *data)
{ {
Serial.write(data); Serial.write(data);
Serial.write('\x1B'); Serial.write('\x1B');
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_SERIAL D_TRANSMIT " %s"), data); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_SERIAL D_TRANSMIT " %s"), data);
AddLog(LOG_LEVEL_DEBUG);
} }
void SonoffScInit(void) void SonoffScInit(void)
@ -78,8 +77,7 @@ void SonoffScSerialInput(char *rcvstat)
char *str; char *str;
uint16_t value[5] = { 0 }; uint16_t value[5] = { 0 };
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_SERIAL D_RECEIVED " %s"), rcvstat); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_SERIAL D_RECEIVED " %s"), rcvstat);
AddLog(LOG_LEVEL_DEBUG);
if (!strncasecmp_P(rcvstat, PSTR("AT+UPDATE="), 10)) { if (!strncasecmp_P(rcvstat, PSTR("AT+UPDATE="), 10)) {
int8_t i = -1; int8_t i = -1;

View File

@ -287,8 +287,7 @@ void Ds18x20Init(void)
} }
} }
} }
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DSB D_SENSORS_FOUND " %d"), ds18x20_sensors); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSORS_FOUND " %d"), ds18x20_sensors);
AddLog(LOG_LEVEL_DEBUG);
} }
void Ds18x20Convert(void) void Ds18x20Convert(void)

View File

@ -125,9 +125,8 @@ bool DhtRead(uint8_t sensor)
uint8_t checksum = (dht_data[0] + dht_data[1] + dht_data[2] + dht_data[3]) & 0xFF; uint8_t checksum = (dht_data[0] + dht_data[1] + dht_data[2] + dht_data[3]) & 0xFF;
if (dht_data[4] != checksum) { if (dht_data[4] != checksum) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DHT D_CHECKSUM_FAILURE " %02X, %02X, %02X, %02X, %02X =? %02X"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT D_CHECKSUM_FAILURE " %02X, %02X, %02X, %02X, %02X =? %02X"),
dht_data[0], dht_data[1], dht_data[2], dht_data[3], dht_data[4], checksum); dht_data[0], dht_data[1], dht_data[2], dht_data[3], dht_data[4], checksum);
AddLog(LOG_LEVEL_DEBUG);
return false; return false;
} }

View File

@ -224,8 +224,7 @@ void HtuDetect(void)
htu_delay_humidity = 23; htu_delay_humidity = 23;
} }
GetTextIndexed(htu_types, sizeof(htu_types), index, kHtuTypes); GetTextIndexed(htu_types, sizeof(htu_types), index, kHtuTypes);
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, htu_types, htu_address); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, htu_types, htu_address);
AddLog(LOG_LEVEL_DEBUG);
} }
} }

View File

@ -482,8 +482,7 @@ void BmpDetect(void)
} }
if (success) { if (success) {
GetTextIndexed(bmp_sensors[bmp_count].bmp_name, sizeof(bmp_sensors[bmp_count].bmp_name), bmp_sensors[bmp_count].bmp_model, kBmpTypes); GetTextIndexed(bmp_sensors[bmp_count].bmp_name, sizeof(bmp_sensors[bmp_count].bmp_name), bmp_sensors[bmp_count].bmp_model, kBmpTypes);
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, bmp_sensors[bmp_count].bmp_name, bmp_sensors[bmp_count].bmp_address); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, bmp_sensors[bmp_count].bmp_name, bmp_sensors[bmp_count].bmp_address);
AddLog(LOG_LEVEL_DEBUG);
bmp_count++; bmp_count++;
} }
} }

View File

@ -65,8 +65,7 @@ void Bh1750Detect(void)
Wire.write(BH1750_CONTINUOUS_HIGH_RES_MODE); Wire.write(BH1750_CONTINUOUS_HIGH_RES_MODE);
if (!Wire.endTransmission()) { if (!Wire.endTransmission()) {
bh1750_type = 1; bh1750_type = 1;
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, bh1750_types, bh1750_address); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, bh1750_types, bh1750_address);
AddLog(LOG_LEVEL_DEBUG);
break; break;
} }
} }

View File

@ -31,7 +31,7 @@
Version Date Action Description Version Date Action Description
-------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------
1.0.0.3 20181006 fixed - missing "" around the UV Index text 1.0.0.3 20181006 fixed - missing "" around the UV Index text
- thanks to Lisa she had tested it on here mqtt system. - thanks to Lisa she had tested it on here mqtt system.
-- --
1.0.0.2 20180928 tests - same as in version 1.0.0.1 1.0.0.2 20180928 tests - same as in version 1.0.0.1
@ -140,8 +140,7 @@ void Veml6070Detect(void)
veml6070_type = 1; veml6070_type = 1;
uint8_t veml_model = 0; uint8_t veml_model = 0;
GetTextIndexed(veml6070_name, sizeof(veml6070_name), veml_model, kVemlTypes); GetTextIndexed(veml6070_name, sizeof(veml6070_name), veml_model, kVemlTypes);
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "VEML6070", VEML6070_ADDR_L); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "VEML6070", VEML6070_ADDR_L);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
@ -156,13 +155,11 @@ void Veml6070UvTableInit(void)
uv_risk_map[i] = ( (USE_VEML6070_RSET / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1); uv_risk_map[i] = ( (USE_VEML6070_RSET / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1);
} else { } else {
uv_risk_map[i] = ( (VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1); uv_risk_map[i] = ( (VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "VEML6070 resistor error %d"), USE_VEML6070_RSET); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 resistor error %d"), USE_VEML6070_RSET);
AddLog(LOG_LEVEL_DEBUG);
} }
#else #else
uv_risk_map[i] = ( (VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1); uv_risk_map[i] = ( (VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "VEML6070 resistor default used %d"), VEML6070_RSET_DEFAULT); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 resistor default used %d"), VEML6070_RSET_DEFAULT);
AddLog(LOG_LEVEL_DEBUG);
#endif #endif
} }
} }
@ -196,8 +193,7 @@ void Veml6070ModeCmd(bool mode_cmd)
uint8_t status = Wire.endTransmission(); uint8_t status = Wire.endTransmission();
// action on status // action on status
if (!status) { if (!status) {
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "VEML6070 mode_cmd", VEML6070_ADDR_L); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "VEML6070 mode_cmd", VEML6070_ADDR_L);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
@ -241,8 +237,7 @@ double Veml6070UvRiskLevel(uint16_t uv_level)
// out of range and much to high - it must be outerspace or sensor damaged // out of range and much to high - it must be outerspace or sensor damaged
snprintf_P(str_uvrisk_text, sizeof(str_uvrisk_text), D_UV_INDEX_7); snprintf_P(str_uvrisk_text, sizeof(str_uvrisk_text), D_UV_INDEX_7);
return ( risk = 99 ); return ( risk = 99 );
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "VEML6070 out of range %d"), risk); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 out of range %d"), risk);
AddLog(LOG_LEVEL_DEBUG);
} }
} }

View File

@ -164,13 +164,12 @@ void Ads1115Detect(void)
for (uint8_t i = 0; i < sizeof(ads1115_addresses); i++) { for (uint8_t i = 0; i < sizeof(ads1115_addresses); i++) {
if (!ads1115_found[i]) { if (!ads1115_found[i]) {
ads1115_address = ads1115_addresses[i]; ads1115_address = ads1115_addresses[i];
if (I2cValidRead16(&buffer, ads1115_address, ADS1115_REG_POINTER_CONVERT) && if (I2cValidRead16(&buffer, ads1115_address, ADS1115_REG_POINTER_CONVERT) &&
I2cValidRead16(&buffer, ads1115_address, ADS1115_REG_POINTER_CONFIG)) { I2cValidRead16(&buffer, ads1115_address, ADS1115_REG_POINTER_CONFIG)) {
Ads1115StartComparator(i, ADS1115_REG_CONFIG_MODE_CONTIN); Ads1115StartComparator(i, ADS1115_REG_CONFIG_MODE_CONTIN);
ads1115_type = 1; ads1115_type = 1;
ads1115_found[i] = 1; ads1115_found[i] = 1;
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "ADS1115", ads1115_address); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "ADS1115", ads1115_address);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
} }
@ -182,8 +181,7 @@ void Ads1115GetValues(uint8_t address)
ads1115_address = address; ads1115_address = address;
for (uint8_t i = 0; i < 4; i++) { for (uint8_t i = 0; i < 4; i++) {
ads1115_values[i] = Ads1115GetConversion(i); ads1115_values[i] = Ads1115GetConversion(i);
//snprintf_P(log_data, sizeof(log_data), "Logging ADS1115 %02x (%i) = %i", address, i, ads1115_values[i] ); //AddLog_P2(LOG_LEVEL_INFO, "Logging ADS1115 %02x (%i) = %i", address, i, ads1115_values[i] );
//AddLog(LOG_LEVEL_INFO);
} }
ads1115_address = old_address; ads1115_address = old_address;
} }
@ -220,8 +218,7 @@ void Ads1115Show(bool json)
char *comma = (char*)""; char *comma = (char*)"";
for (uint8_t t = 0; t < sizeof(ads1115_addresses); t++) { for (uint8_t t = 0; t < sizeof(ads1115_addresses); t++) {
//snprintf_P(log_data, sizeof(log_data), "Logging ADS1115 %02x", ads1115_addresses[t]); //AddLog_P2(LOG_LEVEL_INFO, "Logging ADS1115 %02x", ads1115_addresses[t]);
//AddLog(LOG_LEVEL_INFO);
if (ads1115_found[t]) { if (ads1115_found[t]) {
Ads1115GetValues(ads1115_addresses[t]); Ads1115GetValues(ads1115_addresses[t]);
if (json) { if (json) {

View File

@ -90,8 +90,7 @@ void Ads1115Detect(void)
adc0.setRate(ADS1115_RATE_860); adc0.setRate(ADS1115_RATE_860);
adc0.setMode(ADS1115_MODE_CONTINUOUS); adc0.setMode(ADS1115_MODE_CONTINUOUS);
ads1115_type = 1; ads1115_type = 1;
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "ADS1115", ads1115_address); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "ADS1115", ads1115_address);
AddLog(LOG_LEVEL_DEBUG);
break; break;
} }
} }

View File

@ -198,8 +198,7 @@ void Ina219Detect(void)
ina219_address = ina219_addresses[i]; ina219_address = ina219_addresses[i];
if (Ina219SetCalibration(Settings.ina219_mode)) { if (Ina219SetCalibration(Settings.ina219_mode)) {
ina219_type = 1; ina219_type = 1;
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, ina219_types, ina219_address); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, ina219_types, ina219_address);
AddLog(LOG_LEVEL_DEBUG);
break; break;
} }
} }

View File

@ -86,8 +86,7 @@ void Sht3xDetect(void)
if (Sht3xRead(t, h, sht3x_addresses[i])) { if (Sht3xRead(t, h, sht3x_addresses[i])) {
sht3x_sensors[sht3x_count].address = sht3x_addresses[i]; sht3x_sensors[sht3x_count].address = sht3x_addresses[i];
GetTextIndexed(sht3x_sensors[sht3x_count].types, sizeof(sht3x_sensors[sht3x_count].types), i, kShtTypes); GetTextIndexed(sht3x_sensors[sht3x_count].types, sizeof(sht3x_sensors[sht3x_count].types), i, kShtTypes);
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, sht3x_sensors[sht3x_count].types, sht3x_sensors[sht3x_count].address); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, sht3x_sensors[sht3x_count].types, sht3x_sensors[sht3x_count].address);
AddLog(LOG_LEVEL_DEBUG);
sht3x_count++; sht3x_count++;
} }
} }

View File

@ -123,8 +123,7 @@ size_t MhzSendCmd(uint8_t command_id)
memcpy_P(&mhz_send[6], kMhzCommands[command_id] + sizeof(uint16_t), sizeof(uint16_t)); memcpy_P(&mhz_send[6], kMhzCommands[command_id] + sizeof(uint16_t), sizeof(uint16_t));
mhz_send[8] = MhzCalculateChecksum(mhz_send); mhz_send[8] = MhzCalculateChecksum(mhz_send);
// snprintf_P(log_data, sizeof(log_data), PSTR("Final MhzCommand: %x %x %x %x %x %x %x %x %x"),mhz_send[0],mhz_send[1],mhz_send[2],mhz_send[3],mhz_send[4],mhz_send[5],mhz_send[6],mhz_send[7],mhz_send[8]); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("Final MhzCommand: %x %x %x %x %x %x %x %x %x"),mhz_send[0],mhz_send[1],mhz_send[2],mhz_send[3],mhz_send[4],mhz_send[5],mhz_send[6],mhz_send[7],mhz_send[8]);
// AddLog(LOG_LEVEL_DEBUG);
return MhzSerial->write(mhz_send, sizeof(mhz_send)); return MhzSerial->write(mhz_send, sizeof(mhz_send));
} }

View File

@ -71,8 +71,7 @@ void Tsl2561Detect(void)
if (!Tsl.id(id)) return; if (!Tsl.id(id)) return;
if (Tsl.on()) { if (Tsl.on()) {
tsl2561_type = 1; tsl2561_type = 1;
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, tsl2561_types, Tsl.address(), id); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, tsl2561_types, Tsl.address(), id);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
} }

View File

@ -70,19 +70,16 @@ void Senseair250ms(void) // Every 250 mSec
if (data_ready) { if (data_ready) {
uint8_t error = SenseairModbus->Receive16BitRegister(&value); uint8_t error = SenseairModbus->Receive16BitRegister(&value);
if (error) { if (error) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SenseAir response error %d"), error); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir response error %d"), error);
AddLog(LOG_LEVEL_DEBUG);
} else { } else {
switch(senseair_read_state) { switch(senseair_read_state) {
case 0: // 0x1A (26) READ_TYPE_LOW - S8: fe 04 02 01 77 ec 92 case 0: // 0x1A (26) READ_TYPE_LOW - S8: fe 04 02 01 77 ec 92
senseair_type = 2; senseair_type = 2;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SenseAir type id low %04X"), value); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir type id low %04X"), value);
AddLog(LOG_LEVEL_DEBUG);
break; break;
case 1: // 0x00 (0) READ_ERRORLOG - fe 04 02 00 00 ad 24 case 1: // 0x00 (0) READ_ERRORLOG - fe 04 02 00 00 ad 24
if (value) { if (value) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SenseAir error %04X"), value); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir error %04X"), value);
AddLog(LOG_LEVEL_DEBUG);
} }
break; break;
case 2: // 0x03 (3) READ_CO2 - fe 04 02 06 2c af 59 case 2: // 0x03 (3) READ_CO2 - fe 04 02 06 2c af 59
@ -98,13 +95,11 @@ void Senseair250ms(void) // Every 250 mSec
case 5: // 0x1C (28) READ_RELAY_STATE - S8: fe 04 02 01 54 ad 4b - firmware version case 5: // 0x1C (28) READ_RELAY_STATE - S8: fe 04 02 01 54 ad 4b - firmware version
{ {
bool relay_state = value >> 8 & 1; bool relay_state = value >> 8 & 1;
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SenseAir relay state %d"), relay_state); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir relay state %d"), relay_state);
AddLog(LOG_LEVEL_DEBUG);
break; break;
} }
case 6: // 0x0A (10) READ_TEMP_ADJUSTMENT - S8: fe 84 02 f2 f1 - Illegal Data Address case 6: // 0x0A (10) READ_TEMP_ADJUSTMENT - S8: fe 84 02 f2 f1 - Illegal Data Address
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SenseAir temp adjustment %d"), value); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir temp adjustment %d"), value);
AddLog(LOG_LEVEL_DEBUG);
break; break;
} }
} }

View File

@ -42,8 +42,7 @@ bool MGSPrepare(void)
{ {
gas.begin(MGS_SENSOR_ADDR); gas.begin(MGS_SENSOR_ADDR);
if (!gas.isError()) { if (!gas.isError()) {
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "MultiGasSensor", MGS_SENSOR_ADDR); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "MultiGasSensor", MGS_SENSOR_ADDR);
AddLog(LOG_LEVEL_DEBUG);
return true; return true;
} else { } else {
return false; return false;

View File

@ -82,10 +82,9 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor
for (uint8_t i = 2; i < 17; i++) { for (uint8_t i = 2; i < 17; i++) {
novasds_cmnd[17] += novasds_cmnd[i]; novasds_cmnd[17] += novasds_cmnd[i];
} }
//~ snprintf_P(log_data, sizeof(log_data), PSTR("SDS: Send %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X"), //~ AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SDS: Send %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X"),
//~ novasds_cmnd[0],novasds_cmnd[1],novasds_cmnd[2],novasds_cmnd[3],novasds_cmnd[4],novasds_cmnd[5],novasds_cmnd[6],novasds_cmnd[7],novasds_cmnd[8],novasds_cmnd[9], //~ novasds_cmnd[0],novasds_cmnd[1],novasds_cmnd[2],novasds_cmnd[3],novasds_cmnd[4],novasds_cmnd[5],novasds_cmnd[6],novasds_cmnd[7],novasds_cmnd[8],novasds_cmnd[9],
//~ novasds_cmnd[10],novasds_cmnd[11],novasds_cmnd[12],novasds_cmnd[13],novasds_cmnd[14],novasds_cmnd[15],novasds_cmnd[16],novasds_cmnd[17],novasds_cmnd[18]); //~ novasds_cmnd[10],novasds_cmnd[11],novasds_cmnd[12],novasds_cmnd[13],novasds_cmnd[14],novasds_cmnd[15],novasds_cmnd[16],novasds_cmnd[17],novasds_cmnd[18]);
//~ AddLog(LOG_LEVEL_DEBUG);
// send cmnd // send cmnd
NovaSdsSerial->write(novasds_cmnd, sizeof(novasds_cmnd)); NovaSdsSerial->write(novasds_cmnd, sizeof(novasds_cmnd));
NovaSdsSerial->flush(); NovaSdsSerial->flush();

View File

@ -44,10 +44,8 @@ void Sgp30Update(void) // Perform every second to ensure proper operation of th
if (!sgp30_type) { if (!sgp30_type) {
if (sgp.begin()) { if (sgp.begin()) {
sgp30_type = 1; sgp30_type = 1;
// snprintf_P(log_data, sizeof(log_data), PSTR("SGP: Serialnumber 0x%04X-0x%04X-0x%04X"), sgp.serialnumber[0], sgp.serialnumber[1], sgp.serialnumber[2]); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SGP: Serialnumber 0x%04X-0x%04X-0x%04X"), sgp.serialnumber[0], sgp.serialnumber[1], sgp.serialnumber[2]);
// AddLog(LOG_LEVEL_DEBUG); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "SGP30", 0x58);
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "SGP30", 0x58);
AddLog(LOG_LEVEL_DEBUG);
} }
} else { } else {
if (!sgp.IAQmeasure()) return; // Measurement failed if (!sgp.IAQmeasure()) return; // Measurement failed
@ -59,8 +57,7 @@ void Sgp30Update(void) // Perform every second to ensure proper operation of th
uint16_t eCO2_base; uint16_t eCO2_base;
if (!sgp.getIAQBaseline(&eCO2_base, &TVOC_base)) return; // Failed to get baseline readings if (!sgp.getIAQBaseline(&eCO2_base, &TVOC_base)) return; // Failed to get baseline readings
// snprintf_P(log_data, sizeof(log_data), PSTR("SGP: Baseline values eCO2 0x%04X, TVOC 0x%04X"), eCO2_base, TVOC_base); // AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SGP: Baseline values eCO2 0x%04X, TVOC 0x%04X"), eCO2_base, TVOC_base);
// AddLog(LOG_LEVEL_DEBUG);
} }
sgp30_ready = 1; sgp30_ready = 1;
} }

View File

@ -165,8 +165,7 @@ void SDM120250ms(void) // Every 250 mSec
if (data_ready) { if (data_ready) {
uint8_t error = SDM120_ModbusReceive(&value); uint8_t error = SDM120_ModbusReceive(&value);
if (error) { if (error) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SDM120 response error %d"), error); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SDM120 response error %d"), error);
AddLog(LOG_LEVEL_DEBUG);
} else { } else {
switch(sdm120_read_state) { switch(sdm120_read_state) {
case 0: case 0:

View File

@ -310,8 +310,7 @@ void Si1145Update(void)
if (!si1145_type) { if (!si1145_type) {
if (Si1145Begin()) { if (Si1145Begin()) {
si1145_type = 1; si1145_type = 1;
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "SI1145", SI114X_ADDR); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "SI1145", SI114X_ADDR);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
} }

View File

@ -155,8 +155,7 @@ void SDM630250ms(void) // Every 250 mSec
if (data_ready) { if (data_ready) {
uint8_t error = SDM630_ModbusReceive(&value); uint8_t error = SDM630_ModbusReceive(&value);
if (error) { if (error) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SDM630 response error %d"), error); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SDM630 response error %d"), error);
AddLog(LOG_LEVEL_DEBUG);
} else { } else {
switch(sdm630_read_state) { switch(sdm630_read_state) {
case 0: case 0:

View File

@ -58,8 +58,7 @@ void LM75ADDetect(void)
if (I2cValidRead16(&buffer, lm75ad_address, LM75_THYST_REGISTER)) { if (I2cValidRead16(&buffer, lm75ad_address, LM75_THYST_REGISTER)) {
if (buffer == 0x4B00) { if (buffer == 0x4B00) {
lm75ad_type = 1; lm75ad_type = 1;
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "LM75AD", lm75ad_address); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "LM75AD", lm75ad_address);
AddLog(LOG_LEVEL_DEBUG);
break; break;
} }
} }

View File

@ -1518,8 +1518,7 @@ int16_t readGesture(void)
if (gesture_loop_counter == APDS9960_MAX_GESTURE_CYCLES){ // We will escape after a few loops if (gesture_loop_counter == APDS9960_MAX_GESTURE_CYCLES){ // We will escape after a few loops
disableGestureSensor(); // stop the sensor to prevent problems with power consumption/blocking and return to the main loop disableGestureSensor(); // stop the sensor to prevent problems with power consumption/blocking and return to the main loop
APDS9960_overload = true; // we report this as "long"-gesture APDS9960_overload = true; // we report this as "long"-gesture
snprintf_P(log_data, sizeof(log_data), PSTR("Sensor overload")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("Sensor overload"));
AddLog(LOG_LEVEL_DEBUG);
} }
gesture_loop_counter += 1; gesture_loop_counter += 1;
/* Wait some time to collect next batch of FIFO data */ /* Wait some time to collect next batch of FIFO data */
@ -1794,33 +1793,32 @@ void handleGesture(void) {
if (isGestureAvailable() ) { if (isGestureAvailable() ) {
switch (readGesture()) { switch (readGesture()) {
case DIR_UP: case DIR_UP:
snprintf_P(log_data, sizeof(log_data), PSTR("UP")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("UP"));
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Up")); snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Up"));
break; break;
case DIR_DOWN: case DIR_DOWN:
snprintf_P(log_data, sizeof(log_data), PSTR("DOWN")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("DOWN"));
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Down")); snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Down"));
break; break;
case DIR_LEFT: case DIR_LEFT:
snprintf_P(log_data, sizeof(log_data), PSTR("LEFT")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("LEFT"));
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Left")); snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Left"));
break; break;
case DIR_RIGHT: case DIR_RIGHT:
snprintf_P(log_data, sizeof(log_data), PSTR("RIGHT")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("RIGHT"));
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Right")); snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Right"));
break; break;
default: default:
if(APDS9960_overload) if(APDS9960_overload)
{ {
snprintf_P(log_data, sizeof(log_data), PSTR("LONG")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("LONG"));
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Long")); snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Long"));
} }
else{ else{
snprintf_P(log_data, sizeof(log_data), PSTR("NONE")); AddLog_P(LOG_LEVEL_DEBUG, PSTR("NONE"));
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("None")); snprintf_P(currentGesture, sizeof(currentGesture), PSTR("None"));
} }
} }
AddLog(LOG_LEVEL_DEBUG);
mqtt_data[0] = '\0'; mqtt_data[0] = '\0';
if (MqttShowSensor()) { if (MqttShowSensor()) {
@ -1908,8 +1906,7 @@ bool APDS9960_detect(void)
if (APDS9960type == APDS9960_CHIPID_1 || APDS9960type == APDS9960_CHIPID_2) { if (APDS9960type == APDS9960_CHIPID_1 || APDS9960type == APDS9960_CHIPID_2) {
strcpy_P(APDS9960stype, PSTR("APDS9960")); strcpy_P(APDS9960stype, PSTR("APDS9960"));
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, APDS9960stype, APDS9960_I2C_ADDR); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, APDS9960stype, APDS9960_I2C_ADDR);
AddLog(LOG_LEVEL_DEBUG);
if (APDS9960_init()) { if (APDS9960_init()) {
success = true; success = true;
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "APDS9960 initialized")); AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "APDS9960 initialized"));
@ -1919,12 +1916,10 @@ bool APDS9960_detect(void)
} }
else { else {
if (APDS9960type == APDS9930_CHIPID_1 || APDS9960type == APDS9930_CHIPID_2) { if (APDS9960type == APDS9930_CHIPID_1 || APDS9960type == APDS9930_CHIPID_2) {
snprintf_P(log_data, sizeof(log_data), PSTR("APDS9930 found at address 0x%x, unsupported chip"), APDS9960_I2C_ADDR); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("APDS9930 found at address 0x%x, unsupported chip"), APDS9960_I2C_ADDR);
AddLog(LOG_LEVEL_DEBUG);
} }
else{ else{
snprintf_P(log_data, sizeof(log_data), PSTR("APDS9960 not found at address 0x%x"), APDS9960_I2C_ADDR); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("APDS9960 not found at address 0x%x"), APDS9960_I2C_ADDR);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
currentGesture[0] = '\0'; currentGesture[0] = '\0';

View File

@ -81,7 +81,7 @@ void MCP230xx_CheckForIntCounter(void) {
} }
} }
} }
void MCP230xx_CheckForIntRetainer(void) { void MCP230xx_CheckForIntRetainer(void) {
uint8_t en = 0; uint8_t en = 0;
for (uint8_t ca=0;ca<16;ca++) { for (uint8_t ca=0;ca<16;ca++) {
@ -210,15 +210,13 @@ void MCP230xx_Detect(void)
if (I2cValidRead8(&buffer, USE_MCP230xx_ADDR, MCP230xx_IOCON)) { if (I2cValidRead8(&buffer, USE_MCP230xx_ADDR, MCP230xx_IOCON)) {
if (0x00 == buffer) { if (0x00 == buffer) {
mcp230xx_type = 1; // We have a MCP23008 mcp230xx_type = 1; // We have a MCP23008
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "MCP23008", USE_MCP230xx_ADDR); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "MCP23008", USE_MCP230xx_ADDR);
AddLog(LOG_LEVEL_DEBUG);
mcp230xx_pincount = 8; mcp230xx_pincount = 8;
MCP230xx_ApplySettings(); MCP230xx_ApplySettings();
} else { } else {
if (0x80 == buffer) { if (0x80 == buffer) {
mcp230xx_type = 2; // We have a MCP23017 mcp230xx_type = 2; // We have a MCP23017
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "MCP23017", USE_MCP230xx_ADDR); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "MCP23017", USE_MCP230xx_ADDR);
AddLog(LOG_LEVEL_DEBUG);
mcp230xx_pincount = 16; mcp230xx_pincount = 16;
// Reset bank mode to 0 // Reset bank mode to 0
I2cWrite8(USE_MCP230xx_ADDR, MCP230xx_IOCON, 0x00); I2cWrite8(USE_MCP230xx_ADDR, MCP230xx_IOCON, 0x00);
@ -498,8 +496,7 @@ bool MCP230xx_Command(void) {
if (Settings.mcp230xx_config[pin].int_count_en) { if (Settings.mcp230xx_config[pin].int_count_en) {
Settings.mcp230xx_config[pin].int_count_en=0; Settings.mcp230xx_config[pin].int_count_en=0;
MCP230xx_CheckForIntCounter(); MCP230xx_CheckForIntCounter();
snprintf_P(log_data, sizeof(log_data), PSTR("*** WARNING *** - Disabled INTCNT for pin D%i"),pin); AddLog_P2(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled INTCNT for pin D%i"),pin);
AddLog(LOG_LEVEL_INFO);
} }
snprintf_P(mqtt_data, sizeof(mqtt_data), MCP230XX_INTCFG_RESPONSE,"DEF",pin,Settings.mcp230xx_config[pin].int_report_defer); // "{\"MCP230xx_INT%s\":{\"D_%i\":%i}}"; snprintf_P(mqtt_data, sizeof(mqtt_data), MCP230XX_INTCFG_RESPONSE,"DEF",pin,Settings.mcp230xx_config[pin].int_report_defer); // "{\"MCP230xx_INT%s\":{\"D_%i\":%i}}";
return serviced; return serviced;
@ -537,17 +534,14 @@ bool MCP230xx_Command(void) {
Settings.mcp230xx_config[pin].int_count_en=intcnt; Settings.mcp230xx_config[pin].int_count_en=intcnt;
if (Settings.mcp230xx_config[pin].int_report_defer) { if (Settings.mcp230xx_config[pin].int_report_defer) {
Settings.mcp230xx_config[pin].int_report_defer=0; Settings.mcp230xx_config[pin].int_report_defer=0;
snprintf_P(log_data, sizeof(log_data), PSTR("*** WARNING *** - Disabled INTDEF for pin D%i"),pin); AddLog_P2(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled INTDEF for pin D%i"),pin);
AddLog(LOG_LEVEL_INFO);
} }
if (Settings.mcp230xx_config[pin].int_report_mode < 3) { if (Settings.mcp230xx_config[pin].int_report_mode < 3) {
Settings.mcp230xx_config[pin].int_report_mode=3; Settings.mcp230xx_config[pin].int_report_mode=3;
snprintf_P(log_data, sizeof(log_data), PSTR("*** WARNING *** - Disabled immediate interrupt/telemetry reporting for pin D%i"),pin); AddLog_P2(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled immediate interrupt/telemetry reporting for pin D%i"),pin);
AddLog(LOG_LEVEL_INFO);
} }
if ((Settings.mcp230xx_config[pin].int_count_en) && (!Settings.mcp230xx_int_timer)) { if ((Settings.mcp230xx_config[pin].int_count_en) && (!Settings.mcp230xx_int_timer)) {
snprintf_P(log_data, sizeof(log_data), PSTR("*** WARNING *** - INTCNT enabled for pin D%i but global INTTIMER is disabled!"),pin); AddLog_P2(LOG_LEVEL_INFO, PSTR("*** WARNING *** - INTCNT enabled for pin D%i but global INTTIMER is disabled!"),pin);
AddLog(LOG_LEVEL_INFO);
} }
MCP230xx_CheckForIntCounter(); // update register on whether or not we should be counting interrupts MCP230xx_CheckForIntCounter(); // update register on whether or not we should be counting interrupts
snprintf_P(mqtt_data, sizeof(mqtt_data), MCP230XX_INTCFG_RESPONSE,"CNT",pin,Settings.mcp230xx_config[pin].int_count_en); // "{\"MCP230xx_INT%s\":{\"D_%i\":%i}}"; snprintf_P(mqtt_data, sizeof(mqtt_data), MCP230XX_INTCFG_RESPONSE,"CNT",pin,Settings.mcp230xx_config[pin].int_count_en); // "{\"MCP230xx_INT%s\":{\"D_%i\":%i}}";
@ -605,7 +599,7 @@ bool MCP230xx_Command(void) {
} }
uint8_t pin = atoi(subStr(sub_string, XdrvMailbox.data, ",", 1)); uint8_t pin = atoi(subStr(sub_string, XdrvMailbox.data, ",", 1));
if (pin < mcp230xx_pincount) { if (pin < mcp230xx_pincount) {
if (0 == pin) { if (0 == pin) {
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1), "0")) validpin=true; if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1), "0")) validpin=true;
@ -767,7 +761,7 @@ void MCP230xx_Interrupt_Retain_Report(void) {
uint16_t retainresult = 0; uint16_t retainresult = 0;
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_TIME "\":\"%s\",\"MCP_INTRETAIN\": {"), GetDateAndTime(DT_LOCAL).c_str()); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_TIME "\":\"%s\",\"MCP_INTRETAIN\": {"), GetDateAndTime(DT_LOCAL).c_str());
for (uint8_t pinx = 0;pinx < mcp230xx_pincount;pinx++) { for (uint8_t pinx = 0;pinx < mcp230xx_pincount;pinx++) {
if (Settings.mcp230xx_config[pinx].int_retain_flag) { if (Settings.mcp230xx_config[pinx].int_retain_flag) {
snprintf_P(mqtt_data,sizeof(mqtt_data), PSTR("%s\"D%i\":%i,"),mqtt_data,pinx,mcp230xx_int_retainer[pinx]); snprintf_P(mqtt_data,sizeof(mqtt_data), PSTR("%s\"D%i\":%i,"),mqtt_data,pinx,mcp230xx_int_retainer[pinx]);
retainresult |= (((mcp230xx_int_retainer[pinx])&1) << pinx); retainresult |= (((mcp230xx_int_retainer[pinx])&1) << pinx);
mcp230xx_int_retainer[pinx]=0; mcp230xx_int_retainer[pinx]=0;

View File

@ -220,8 +220,7 @@ void Mpr121Init(struct mpr121 *pS)
if (pS->connected[i]) { if (pS->connected[i]) {
// Log sensor found // Log sensor found
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "MPR121(%c) " D_FOUND_AT " 0x%X"), pS->id[i], pS->i2c_addr[i]); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_I2C "MPR121(%c) " D_FOUND_AT " 0x%X"), pS->id[i], pS->i2c_addr[i]);
AddLog(LOG_LEVEL_INFO);
// Set thresholds for registers 0x41 - 0x5A (ExTTH and ExRTH) // Set thresholds for registers 0x41 - 0x5A (ExTTH and ExRTH)
for (uint8_t j = 0; j < 13; j++) { for (uint8_t j = 0; j < 13; j++) {
@ -283,12 +282,9 @@ void Mpr121Init(struct mpr121 *pS)
// Check if sensor is running // Check if sensor is running
pS->running[i] = (0x00 != I2cRead8(pS->i2c_addr[i], MPR121_ECR_REG)); pS->running[i] = (0x00 != I2cRead8(pS->i2c_addr[i], MPR121_ECR_REG));
if (pS->running[i]) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "MPR121%c: Running"), pS->id[i]); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_I2C "MPR121%c: %sRunning"), pS->id[i], (pS->running[i]) ? "" : "NOT");
} else {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "MPR121%c: NOT Running"), pS->id[i]);
}
AddLog(LOG_LEVEL_INFO);
} else { } else {
// Make sure running is false // Make sure running is false
@ -299,8 +295,7 @@ void Mpr121Init(struct mpr121 *pS)
// Display no sensor found message // Display no sensor found message
if (!(pS->connected[0] || pS->connected[1] || pS->connected[2] if (!(pS->connected[0] || pS->connected[1] || pS->connected[2]
|| pS->connected[3])) { || pS->connected[3])) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "MPR121: No sensors found")); AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_I2C "MPR121: No sensors found"));
AddLog(LOG_LEVEL_DEBUG);
} }
} // void Mpr121Init(struct mpr121 *s) } // void Mpr121Init(struct mpr121 *s)
@ -329,8 +324,7 @@ void Mpr121Show(struct mpr121 *pS, uint8_t function)
// Read data // Read data
if (!I2cValidRead16LE(&pS->current[i], pS->i2c_addr[i], MPR121_ELEX_REG)) { if (!I2cValidRead16LE(&pS->current[i], pS->i2c_addr[i], MPR121_ELEX_REG)) {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "MPR121%c: ERROR: Cannot read data!"), pS->id[i]); AddLog_P2(LOG_LEVEL_ERROR, PSTR(D_LOG_I2C "MPR121%c: ERROR: Cannot read data!"), pS->id[i]);
AddLog(LOG_LEVEL_ERROR);
Mpr121Init(pS); Mpr121Init(pS);
return; return;
} }
@ -339,9 +333,7 @@ void Mpr121Show(struct mpr121 *pS, uint8_t function)
// Clear OVCF bit // Clear OVCF bit
I2cWrite8(pS->i2c_addr[i], MPR121_ELEX_REG, 0x00); I2cWrite8(pS->i2c_addr[i], MPR121_ELEX_REG, 0x00);
snprintf_P(log_data, sizeof(log_data), AddLog_P2(LOG_LEVEL_ERROR, PSTR(D_LOG_I2C "MPR121%c: ERROR: Excess current detected! Fix circuits if it happens repeatedly! Soft-resetting MPR121 ..."), pS->id[i]);
PSTR(D_LOG_I2C "MPR121%c: ERROR: Excess current detected! Fix circuits if it happens repeatedly! Soft-resetting MPR121 ..."), pS->id[i]);
AddLog(LOG_LEVEL_ERROR);
Mpr121Init(pS); Mpr121Init(pS);
return; return;
} }

View File

@ -52,11 +52,9 @@ void CCS811Update(void) // Perform every n second
sint8_t res = ccs.begin(CCS811_ADDRESS); sint8_t res = ccs.begin(CCS811_ADDRESS);
if (!res) { if (!res) {
CCS811_type = 1; CCS811_type = 1;
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "CCS811", 0x5A); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "CCS811", 0x5A);
AddLog(LOG_LEVEL_DEBUG);
} else { } else {
//snprintf_P(log_data, sizeof(log_data), "CCS811 init failed: %d",res); //AddLog_P2(LOG_LEVEL_DEBUG, "CCS811 init failed: %d",res);
//AddLog(LOG_LEVEL_DEBUG);
} }
} else { } else {
if (ccs.available()) { if (ccs.available()) {

View File

@ -134,12 +134,12 @@ void MPU_6050Detect(void)
mpu6050.setXGyroOffset(220); mpu6050.setXGyroOffset(220);
mpu6050.setYGyroOffset(76); mpu6050.setYGyroOffset(76);
mpu6050.setZGyroOffset(-85); mpu6050.setZGyroOffset(-85);
mpu6050.setZAccelOffset(1788); mpu6050.setZAccelOffset(1788);
if (MPU6050_dmp.devStatus == 0) { if (MPU6050_dmp.devStatus == 0) {
mpu6050.setDMPEnabled(true); mpu6050.setDMPEnabled(true);
MPU6050_dmp.packetSize = mpu6050.dmpGetFIFOPacketSize(); MPU6050_dmp.packetSize = mpu6050.dmpGetFIFOPacketSize();
MPU_6050_found = true; MPU_6050_found = true;
} }
#else #else
mpu6050.initialize(); mpu6050.initialize();
MPU_6050_found = mpu6050.testConnection(); MPU_6050_found = mpu6050.testConnection();
@ -150,8 +150,7 @@ void MPU_6050Detect(void)
if (MPU_6050_found) if (MPU_6050_found)
{ {
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, D_SENSOR_MPU6050, MPU_6050_address); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, D_SENSOR_MPU6050, MPU_6050_address);
AddLog(LOG_LEVEL_DEBUG);
} }
} }

View File

@ -73,12 +73,11 @@ void DS3231Detect(void)
{ {
DS3231chipDetected = false; DS3231chipDetected = false;
if (I2cValidRead(USE_RTC_ADDR, RTC_STATUS, 1)) { if (I2cValidRead(USE_RTC_ADDR, RTC_STATUS, 1)) {
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "DS3231", USE_RTC_ADDR); AddLog_P2(LOG_LEVEL_INFO, S_LOG_I2C_FOUND_AT, "DS3231", USE_RTC_ADDR);
DS3231chipDetected = true; DS3231chipDetected = true;
} else { } else {
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "%s *NOT* " D_FOUND_AT " 0x%x"), "DS3231", USE_RTC_ADDR); AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_I2C "DS3231 NOT " D_FOUND_AT " 0x%x"), USE_RTC_ADDR);
} }
AddLog(LOG_LEVEL_INFO);
} }
/*----------------------------------------------------------------------* /*----------------------------------------------------------------------*
@ -155,9 +154,8 @@ bool Xsns33(uint8_t function)
RtcTime.year = tmpTime.year + 1970; RtcTime.year = tmpTime.year + 1970;
daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year); daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year);
standard_time = RuleToTime(Settings.tflag[0], RtcTime.year); standard_time = RuleToTime(Settings.tflag[0], RtcTime.year);
snprintf_P(log_data, sizeof(log_data), PSTR("Set time from DS3231 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), AddLog_P2(LOG_LEVEL_INFO, PSTR("Set time from DS3231 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str()); GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
AddLog(LOG_LEVEL_INFO);
if (local_time < 1451602800) { // 2016-01-01 if (local_time < 1451602800) { // 2016-01-01
rules_flag.time_init = 1; rules_flag.time_init = 1;
} else { } else {
@ -165,9 +163,8 @@ bool Xsns33(uint8_t function)
} }
} }
else if (!ds3231WriteStatus && DS3231chipDetected && utc_time > 1451602800 && abs(utc_time - ReadFromDS3231()) > 60) {//if time is valid and is drift from RTC in more that 60 second else if (!ds3231WriteStatus && DS3231chipDetected && utc_time > 1451602800 && abs(utc_time - ReadFromDS3231()) > 60) {//if time is valid and is drift from RTC in more that 60 second
snprintf_P(log_data, sizeof(log_data), PSTR("Write Time TO DS3231 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), AddLog_P2(LOG_LEVEL_INFO, PSTR("Write Time TO DS3231 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str()); GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
AddLog(LOG_LEVEL_INFO);
SetDS3231Time (utc_time); //update the DS3231 time SetDS3231Time (utc_time); //update the DS3231 time
ds3231WriteStatus = true; ds3231WriteStatus = true;
} }

View File

@ -454,9 +454,7 @@ void HxLogUpdates(void)
char weigth_item_chr[33]; char weigth_item_chr[33];
dtostrfd((float)Settings.weight_item / 10000, 4, weigth_item_chr); dtostrfd((float)Settings.weight_item / 10000, 4, weigth_item_chr);
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_JSON_WEIGHT_REF " %s, " D_JSON_WEIGHT_ITEM " %s"), AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_JSON_WEIGHT_REF " %s, " D_JSON_WEIGHT_ITEM " %s"), weigth_ref_chr, weigth_item_chr);
weigth_ref_chr, weigth_item_chr);
AddLog(LOG_LEVEL_INFO);
} }
#endif // USE_HX711_GUI #endif // USE_HX711_GUI

View File

@ -501,13 +501,11 @@ bool MGC3130_detect(void)
success = MGC3130_receiveMessage(); // This should read the firmware info success = MGC3130_receiveMessage(); // This should read the firmware info
if (success) { if (success) {
strcpy_P(MGC3130stype, PSTR("MGC3130")); strcpy_P(MGC3130stype, PSTR("MGC3130"));
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, MGC3130stype, MGC3130_I2C_ADDR); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, MGC3130stype, MGC3130_I2C_ADDR);
AddLog(LOG_LEVEL_DEBUG);
MGC3130_currentGesture[0] = '\0'; MGC3130_currentGesture[0] = '\0';
MGC3130_type = true; MGC3130_type = true;
} else { } else {
snprintf_P(log_data, sizeof(log_data), PSTR("MGC3130 did not respond at address 0x%x"), MGC3130_I2C_ADDR); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("MGC3130 did not respond at address 0x%x"), MGC3130_I2C_ADDR);
AddLog(LOG_LEVEL_DEBUG);
} }
return success; return success;
} }

View File

@ -251,9 +251,8 @@ void RfSnsAnalyzeTheov2(void)
break; break;
} }
snprintf_P(log_data, sizeof(log_data), PSTR("RFS: TheoV2, ChkCalc %d, Chksum %d, id %d, Type %d, Ch %d, Volt %d, BattLo %d, Pld1 %d, Pld2 %d"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RFS: TheoV2, ChkCalc %d, Chksum %d, id %d, Type %d, Ch %d, Volt %d, BattLo %d, Pld1 %d, Pld2 %d"),
chksum, Checksum, id, Type, Channel +1, Payload3, (Voltage & 0x80) >> 7, Payload1, Payload2); chksum, Checksum, id, Type, Channel +1, Payload3, (Voltage & 0x80) >> 7, Payload1, Payload2);
AddLog(LOG_LEVEL_DEBUG);
} }
void RfSnsTheoV2Show(bool json) void RfSnsTheoV2Show(bool json)
@ -507,9 +506,8 @@ void RfSnsAnalyzeAlectov2()
rfsns_alecto_v2->wdir = data[8] & 0xf; rfsns_alecto_v2->wdir = data[8] & 0xf;
} }
snprintf_P(log_data, sizeof(log_data), PSTR("RFS: " D_ALECTOV2 ", ChkCalc %d, Chksum %d, rc %d, Temp %d, Hum %d, Rain %d, Wind %d, Gust %d, Dir %d, Factor %s"), AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RFS: " D_ALECTOV2 ", ChkCalc %d, Chksum %d, rc %d, Temp %d, Hum %d, Rain %d, Wind %d, Gust %d, Dir %d, Factor %s"),
checksumcalc, checksum, rc, ((data[1] & 0x3) * 256 + data[2]) - 400, data[3], (data[6] * 256) + data[7], data[4], data[5], data[8] & 0xf, dtostrfd(factor, 3, buf1)); checksumcalc, checksum, rc, ((data[1] & 0x3) * 256 + data[2]) - 400, data[3], (data[6] * 256) + data[7], data[4], data[5], data[8] & 0xf, dtostrfd(factor, 3, buf1));
AddLog(LOG_LEVEL_DEBUG);
} }
void RfSnsAlectoResetRain(void) void RfSnsAlectoResetRain(void)
@ -627,8 +625,7 @@ void RfSnsInit(void)
void RfSnsAnalyzeRawSignal(void) void RfSnsAnalyzeRawSignal(void)
{ {
snprintf_P(log_data, sizeof(log_data), PSTR("RFS: Pulses %d"), (int)rfsns_raw_signal->Number); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RFS: Pulses %d"), (int)rfsns_raw_signal->Number);
AddLog(LOG_LEVEL_DEBUG);
#ifdef USE_THEO_V2 #ifdef USE_THEO_V2
RfSnsAnalyzeTheov2(); RfSnsAnalyzeTheov2();

View File

@ -76,8 +76,7 @@ void PN532_Init(void)
PN532_setPassiveActivationRetries(0xFF); PN532_setPassiveActivationRetries(0xFF);
PN532_SAMConfig(); PN532_SAMConfig();
pn532_model = 1; pn532_model = 1;
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC Reader detected (V%u.%u)",(ver>>16) & 0xFF, (ver>>8) & 0xFF); AddLog_P2(LOG_LEVEL_INFO,"NFC: PN532 NFC Reader detected (V%u.%u)",(ver>>16) & 0xFF, (ver>>8) & 0xFF);
AddLog(LOG_LEVEL_INFO);
} }
} }
} }
@ -446,8 +445,7 @@ void PN532_ScanForTag(void)
} }
if (mifareclassic_WriteDataBlock(1, card_data)) { if (mifareclassic_WriteDataBlock(1, card_data)) {
erase_success = true; erase_success = true;
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Erase success"); AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Erase success"));
AddLog(LOG_LEVEL_INFO);
memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string
} }
} }
@ -456,8 +454,7 @@ void PN532_ScanForTag(void)
memcpy(&card_data,&pn532_newdata,sizeof(card_data)); memcpy(&card_data,&pn532_newdata,sizeof(card_data));
if (mifareclassic_WriteDataBlock(1, card_data)) { if (mifareclassic_WriteDataBlock(1, card_data)) {
set_success = true; set_success = true;
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Data write successful"); AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data write successful"));
AddLog(LOG_LEVEL_INFO);
memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string
} }
#else #else
@ -472,13 +469,11 @@ void PN532_ScanForTag(void)
card_data[pn532_newdata_len] = '\0'; // Enforce null termination card_data[pn532_newdata_len] = '\0'; // Enforce null termination
if (mifareclassic_WriteDataBlock(1, card_data)) { if (mifareclassic_WriteDataBlock(1, card_data)) {
set_success = true; set_success = true;
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Data write successful"); AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data write successful"));
AddLog(LOG_LEVEL_INFO);
memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string
} }
} else { } else {
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Data must be alphanumeric"); AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data must be alphanumeric"));
AddLog(LOG_LEVEL_INFO);
} }
#endif // USE_PN532_DATA_RAW #endif // USE_PN532_DATA_RAW
} }
@ -489,14 +484,12 @@ void PN532_ScanForTag(void)
switch (pn532_function) { switch (pn532_function) {
case 0x01: case 0x01:
if (!erase_success) { if (!erase_success) {
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Erase fail - exiting erase mode"); AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Erase fail - exiting erase mode"));
AddLog(LOG_LEVEL_INFO);
} }
break; break;
case 0x02: case 0x02:
if (!set_success) { if (!set_success) {
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Write failed - exiting set mode"); AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Write failed - exiting set mode"));
AddLog(LOG_LEVEL_INFO);
} }
default: default:
break; break;
@ -550,8 +543,7 @@ bool PN532_Command(void)
UpperCase(XdrvMailbox.data,XdrvMailbox.data); UpperCase(XdrvMailbox.data,XdrvMailbox.data);
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"E")) { if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"E")) {
pn532_function = 1; // Block 1 of next card/tag will be reset to 0x00... pn532_function = 1; // Block 1 of next card/tag will be reset to 0x00...
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Next scanned tag data block 1 will be erased"); AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be erased"));
AddLog(LOG_LEVEL_INFO);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_TIME "\":\"%s\""), GetDateAndTime(DT_LOCAL).c_str()); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_TIME "\":\"%s\""), GetDateAndTime(DT_LOCAL).c_str());
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"PN532\":{\"COMMAND\":\"E\"\"}}"), mqtt_data); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"PN532\":{\"COMMAND\":\"E\"\"}}"), mqtt_data);
return serviced; return serviced;
@ -568,8 +560,7 @@ bool PN532_Command(void)
memcpy(&pn532_newdata,&sub_string_tmp,pn532_newdata_len); memcpy(&pn532_newdata,&sub_string_tmp,pn532_newdata_len);
pn532_newdata[pn532_newdata_len] = 0x00; // Null terminate the string pn532_newdata[pn532_newdata_len] = 0x00; // Null terminate the string
pn532_function = 2; pn532_function = 2;
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Next scanned tag data block 1 will be set to '%s'",pn532_newdata); AddLog_P2(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be set to '%s'"), pn532_newdata);
AddLog(LOG_LEVEL_INFO);
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_TIME "\":\"%s\""), GetDateAndTime(DT_LOCAL).c_str()); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_TIME "\":\"%s\""), GetDateAndTime(DT_LOCAL).c_str());
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"PN532\":{\"COMMAND\":\"S\"\"}}"), mqtt_data); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"PN532\":{\"COMMAND\":\"S\"\"}}"), mqtt_data);
return serviced; return serviced;

View File

@ -94,8 +94,7 @@ void Max4409Detect(void)
Wire.write(MAX44009_CONTINUOUS_AUTO_MODE); Wire.write(MAX44009_CONTINUOUS_AUTO_MODE);
if (0 == Wire.endTransmission()) { if (0 == Wire.endTransmission()) {
max44009_found = 1; max44009_found = 1;
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, max44009_types, max44009_address); AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, max44009_types, max44009_address);
AddLog(LOG_LEVEL_DEBUG);
break; break;
} }
} }

View File

@ -305,8 +305,7 @@ bool XsnsCall(uint8_t Function)
uint32_t profile_millis = millis() - profile_start_millis; uint32_t profile_millis = millis() - profile_start_millis;
if (profile_millis) { if (profile_millis) {
if (FUNC_EVERY_SECOND == Function) { if (FUNC_EVERY_SECOND == Function) {
snprintf_P(log_data, sizeof(log_data), PSTR("PRF: At %08u XsnsCall %d to Sensor %d took %u mS"), uptime, Function, x, profile_millis); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PRF: At %08u XsnsCall %d to Sensor %d took %u mS"), uptime, Function, x, profile_millis);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
#endif // PROFILE_XSNS_SENSOR_EVERY_SECOND #endif // PROFILE_XSNS_SENSOR_EVERY_SECOND
@ -323,8 +322,7 @@ bool XsnsCall(uint8_t Function)
uint32_t profile_millis = millis() - profile_start_millis; uint32_t profile_millis = millis() - profile_start_millis;
if (profile_millis) { if (profile_millis) {
if (FUNC_EVERY_SECOND == Function) { if (FUNC_EVERY_SECOND == Function) {
snprintf_P(log_data, sizeof(log_data), PSTR("PRF: At %08u XsnsCall %d took %u mS"), uptime, Function, profile_millis); AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PRF: At %08u XsnsCall %d took %u mS"), uptime, Function, profile_millis);
AddLog(LOG_LEVEL_DEBUG);
} }
} }
#endif // PROFILE_XSNS_EVERY_SECOND #endif // PROFILE_XSNS_EVERY_SECOND