diff --git a/BUILDS.md b/BUILDS.md index e2d86b053..e882329d9 100644 --- a/BUILDS.md +++ b/BUILDS.md @@ -149,6 +149,7 @@ | USE_EZORGB | - | - | - | - | - | - | - | | USE_EZORTD | - | - | - | - | - | - | - | | USE_SEESAW_SOIL | - | - | - | - | - | - | - | +| USE_TOF10120 | - | - | - | - | - | - | - | | | | | | | | | | | Feature or Sensor | minimal | lite | tasmota | knx | sensors | ir | display | Remarks | USE_SPI | - | - | - | - | - | - | x | diff --git a/CHANGELOG.md b/CHANGELOG.md index a55fc03ee..e627937f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,14 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - Development -## [9.2.0.3] +## [9.2.0.4] +### Added +- Function ``AddLog`` to provide logging for up to 128 (LOGSZ) characters to save stack space + +### Changed +- Maximum chars in ``AddLog_P`` logging restored from 128 to 700 (MAX_LOGSZ) to solve broken error messages + +## [9.2.0.3] 20210122 ### Added - Support for time proportioned (``#define USE_TIMEPROP``) and optional PID (``#define USE_PID``) relay control (#10412) - Support rotary encoder on Shelly Dimmer (#10407) @@ -18,6 +25,8 @@ All notable changes to this project will be documented in this file. - Support for SM2135 current selection using GPIO ``SM2135 DAT`` index (#10634) - Basic support for ESP32 M5stack core2 16MB binary tasmota32-core2.bin (#10635) - Support for Sugar Valley NeoPool Controller by Norbert Richter (#10637) +- Rule trigger string comparisons for EndsWith ``$>``, StartsWith ``$<`` and Contains ``$|`` (#10538) +- Support for TOF10120 time of flight sensor by Cyril Pawelko (#10190) ### Breaking Changed - ESP32 switch from default SPIFFS to default LittleFS file system loosing current (zigbee) files @@ -26,6 +35,8 @@ All notable changes to this project will be documented in this file. ### Changed - Force initial default state ``SetOption57 1`` to scan wifi network every 44 minutes for strongest signal (#10395) - Command ``Sleep 0`` removes any sleep from wifi modem except when ESP32 BLE is active +- PubSubClient MQTT_SOCKET_TIMEOUT from 15 to 4 seconds +- Domoticz fixed 2 decimals resolution by user selectable ``TempRes``, ``HumRes`` and ``PressRes`` resolutions ## [9.2.0.2] 20210105 ### Added @@ -51,7 +62,7 @@ All notable changes to this project will be documented in this file. - Replaced RA8876 GPIO selection from ``SPI CS`` by ``RA8876 CS`` ### Changed -- Maximum chars in AddLog_P logging reduced from 700 to 128 (LOGSZ) to enhance stability +- Maximum chars in ``AddLog_P`` logging reduced from 700 to 128 (LOGSZ) to enhance stability - Disabled ``USE_LIGHT`` light support for ZBBridge saving 17.6kB (#10374) ## [9.2.0.1] 20201229 diff --git a/I2CDEVICES.md b/I2CDEVICES.md index 301b48111..60ee9608b 100644 --- a/I2CDEVICES.md +++ b/I2CDEVICES.md @@ -90,3 +90,4 @@ Index | Define | Driver | Device | Address(es) | Description 55 | USE_EZORGB | xsns_78 | EZORGB | 0x61 - 0x70 | Color sensor 55 | USE_EZOPMP | xsns_78 | EZOPMP | 0x61 - 0x70 | Peristaltic Pump 56 | USE_SEESAW_SOIL | xsns_81 | SEESOIL | 0x36 - 0x39 | Adafruit seesaw soil moisture sensor + 57 | USE_TOF10120 | xsns_84 | TOF10120 | 0x52 | Time-of-flight (ToF) distance sensor diff --git a/RELEASENOTES.md b/RELEASENOTES.md index ee4096131..baf6f75b9 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -56,7 +56,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota [Complete list](BUILDS.md) of available feature and sensors. -## Changelog v9.2.0.3 +## Changelog v9.2.0.4 ### Added - Command ``CTRange`` to specify the visible CT range the bulb is capable of [#10311](https://github.com/arendst/Tasmota/issues/10311) - Command ``RuleTimer0`` to access all RuleTimers at once [#10352](https://github.com/arendst/Tasmota/issues/10352) @@ -74,6 +74,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Support for FTC532 8-button touch controller by Peter Franck [#10222](https://github.com/arendst/Tasmota/issues/10222) - Support for BS814A-2 8-button touch buttons by Peter Franck [#10447](https://github.com/arendst/Tasmota/issues/10447) - Support for up to 4 I2C SEESAW_SOIL Capacitance & Temperature sensors by Peter Franck [#10481](https://github.com/arendst/Tasmota/issues/10481) +- Support for TOF10120 time of flight sensor by Cyril Pawelko [#10190](https://github.com/arendst/Tasmota/issues/10190) - Support for Afrikaans language translations by Christiaan Heerze - Support for IR inverted leds using ``#define IR_SEND_INVERTED true`` [#10301](https://github.com/arendst/Tasmota/issues/10301) - Support for disabling 38kHz IR modulation using ``#define IR_SEND_USE_MODULATION false`` [#10301](https://github.com/arendst/Tasmota/issues/10301) @@ -85,6 +86,8 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Support rotary encoder on Shelly Dimmer [#10407](https://github.com/arendst/Tasmota/issues/10407#issuecomment-756240920) - Support character `#` to be replaced by `space`-character in command ``Publish`` topic [#10258](https://github.com/arendst/Tasmota/issues/10258) - Basic support for ESP32 Odroid Go 16MB binary tasmota32-odroidgo.bin [#8630](https://github.com/arendst/Tasmota/issues/8630) +- Basic support for ESP32 M5stack core2 16MB binary tasmota32-core2.bin [#10635](https://github.com/arendst/Tasmota/issues/10635) +- Rule trigger string comparisons for EndsWith ``$>``, StartsWith ``$<`` and Contains ``$|`` [#10538](https://github.com/arendst/Tasmota/issues/10538) - SPI display driver SSD1331 Color oled by Jeroen Vermeulen [#10376](https://github.com/arendst/Tasmota/issues/10376) - Compile time option ``USE_MQTT_TLS_DROP_OLD_FINGERPRINT`` to drop old (less secure) TLS fingerprint @@ -105,6 +108,8 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota - Logging from heap to stack freeing 700 bytes RAM - Disabled ``USE_LIGHT`` light support for ZBBridge saving 17.6kB [#10374](https://github.com/arendst/Tasmota/issues/10374) - Force initial default state ``SetOption57 1`` to scan wifi network every 44 minutes for strongest signal [#10395](https://github.com/arendst/Tasmota/issues/10395) +- PubSubClient MQTT_SOCKET_TIMEOUT from 15 to 4 seconds +- Domoticz fixed 2 decimals resolution by user selectable ``TempRes``, ``HumRes`` and ``PressRes`` resolutions ### Fixed - Redesign syslog and mqttlog using log buffer [#10164](https://github.com/arendst/Tasmota/issues/10164) diff --git a/lib/default/Ext-printf/library.properties b/lib/default/Ext-printf/library.properties new file mode 100644 index 000000000..bdb00e650 --- /dev/null +++ b/lib/default/Ext-printf/library.properties @@ -0,0 +1,7 @@ +name=Ext-printf +version=1.0 +author=Stephan Hadinger +maintainer=Stephan +sentence=Extension of snprintf() and vsnprintf() +paragraph=This library provides extended types support for snprintf (float, uint64_t) +architectures=esp8266, esp32 diff --git a/lib/default/Ext-printf/src/ext_printf.cpp b/lib/default/Ext-printf/src/ext_printf.cpp new file mode 100644 index 000000000..908aae11a --- /dev/null +++ b/lib/default/Ext-printf/src/ext_printf.cpp @@ -0,0 +1,298 @@ +/* + ext_printf.ino - Extended printf for Arduino objects + + Copyright (C) 2021 Stephan Hadinger + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "ext_printf.h" +#include +#include + +/*********************************************************************************************\ + * va_list extended support + * + * va_list allows to get the next argument but not to get the address of this argument in the stack. + * + * We add `va_cur_ptr(va, TYPE)` to get a pointer to the current argument. + * This will allow to modify it in place and call back printf with altered arguments +\*********************************************************************************************/ + +// This code is heavily inspired by the gcc implementation of va_list +// https://github.com/gcc-mirror/gcc/blob/master/gcc/config/xtensa/xtensa.c + +// Here is the va_list structure: +// struct va_list { +// void * __va_stk; // offset 0 - pointer to arguments on the stack +// void * __va_reg; // offset 4 - pointer to arguments from registers +// uint32_t __va_ndx; // offset 8 - index in bytes of the argument (overshoot by sizeof(T)) +// } +// +// When `va_start()` is called, the first 6 arguments are passed through registers r2-r7 and +// are saved on the stack like local variables + +// The algorightm used by `va_arg()` is the following: +// /* Implement `va_arg'.  */ +// /* First align __va_ndx if necessary for this arg: +//     orig_ndx = (AP).__va_ndx; +//     if (__alignof__ (TYPE) > 4 ) +//       orig_ndx = ((orig_ndx + __alignof__ (TYPE) - 1) +// & -__alignof__ (TYPE)); */ +// /* Increment __va_ndx to point past the argument: +//     (AP).__va_ndx = orig_ndx + __va_size (TYPE); */ +// /* Check if the argument is in registers: +//     if ((AP).__va_ndx <= __MAX_ARGS_IN_REGISTERS * 4 +//         && !must_pass_in_stack (type)) +//       __array = (AP).__va_reg; */ +// /* ...otherwise, the argument is on the stack (never split between +//     registers and the stack -- change __va_ndx if necessary): +//     else +//       { +// if (orig_ndx <= __MAX_ARGS_IN_REGISTERS * 4) +//     (AP).__va_ndx = 32 + __va_size (TYPE); +// __array = (AP).__va_stk; +//       } */ +// /* Given the base array pointer (__array) and index to the subsequent +//     argument (__va_ndx), find the address: +//     __array + (AP).__va_ndx - (BYTES_BIG_ENDIAN && sizeof (TYPE) < 4 +// ? sizeof (TYPE) +// : __va_size (TYPE)) +//     The results are endian-dependent because values smaller than one word +//     are aligned differently.  */ + +// So we can simply get the argument address +#define MAX_ARGS_IN_REGISTERS 6 // ESP8266 passes 6 arguments by register, then on stack + +// #define va_cur_ptr(va,T) ( (T*) __va_cur_ptr(va,sizeof(T)) ) // we only support 4 bytes aligned arguments, so we don't need this one + +// void * __va_cur_ptr(va_list &va, size_t size) { +// size = (size + 3) & 0xFFFFFFFC; // round to upper 4 bytes boundary + +// uintptr_t * va_stk = (uintptr_t*) &va; +// uintptr_t * va_reg = 1 + (uintptr_t*) &va; +// uintptr_t * va_ndx = 2 + (uintptr_t*) &va; +// uintptr_t arr; + +// if (*va_ndx <= MAX_ARGS_IN_REGISTERS * 4) { +// arr = *va_reg; +// } else { +// arr = *va_stk; +// } +// return (void*) (arr + *va_ndx - size); +// } + +// reduced version when arguments are always 4 bytes +#define va_cur_ptr4(va,T) ( (T*) __va_cur_ptr4(va) ) +void * __va_cur_ptr4(va_list &va) { + uintptr_t * va_stk = (uintptr_t*) &va; + uintptr_t * va_reg = 1 + (uintptr_t*) &va; + uintptr_t * va_ndx = 2 + (uintptr_t*) &va; + uintptr_t arr; + + if (*va_ndx <= MAX_ARGS_IN_REGISTERS * 4) { + arr = *va_reg; + } else { + arr = *va_stk; + } + return (void*) (arr + *va_ndx - 4); +} + +// Example of logs with 8 arguments (+1 static argument) +// We see that the first 5 are from low in the stack (local variables) +// while the last 8 are upper in the stack pushed by caller +// +// Note 64 bits arguments cannot be split between registers and stack +// +// >>> Reading a_ptr=0x3FFFFD44 *a_ptr=1 +// >>> Reading a_ptr=0x3FFFFD48 *a_ptr=2 +// >>> Reading a_ptr=0x3FFFFD4C *a_ptr=3 +// >>> Reading a_ptr=0x3FFFFD50 *a_ptr=4 +// >>> Reading a_ptr=0x3FFFFD54 *a_ptr=5 +// >>> Reading a_ptr=0x3FFFFD70 *a_ptr=6 +// >>> Reading a_ptr=0x3FFFFD74 *a_ptr=7 +// >>> Reading a_ptr=0x3FFFFD78 *a_ptr=8 + +/*********************************************************************************************\ + * Genral function to convert u64 to hex +\*********************************************************************************************/ +// Simple function to print a 64 bits unsigned int +char * U64toHex(uint64_t value, char *str) { + // str must be at least 17 bytes long + str[16] = 0; // end of string + for (uint32_t i=0; i<16; i++) { // 16 digits + uint32_t n = value & 0x0F; + str[15 - i] = (n < 10) ? (char)n+'0' : (char)n-10+'A'; + value = value >> 4; + } + return str; +} + +/*********************************************************************************************\ + * snprintf extended + * +\*********************************************************************************************/ + +// get a fresh malloc allocated string based on the current pointer (can be in PROGMEM) +// It is the caller's responsibility to free the memory +char * copyStr(const char * str) { + if (str == nullptr) { return nullptr; } + char * cpy = (char*) malloc(strlen_P(str) + 1); + strcpy_P(cpy, str); + return cpy; +} + +int32_t ext_vsnprintf_P(char * buf, size_t buf_len, const char * fmt_P, va_list va) { + va_list va_cpy; + va_copy(va_cpy, va); + +#if defined(ESP8266) || defined(ESP32) // this works only for xtensa, other platforms needs va_list to be adapted + // iterate on fmt to extract arguments and patch them in place + char * fmt_cpy = copyStr(fmt_P); + if (fmt_cpy == nullptr) { return 0; } + char * fmt = fmt_cpy; + + const uint32_t ALLOC_SIZE = 12; + static char * allocs[ALLOC_SIZE] = {}; // initialized to zeroes + uint32_t alloc_idx = 0; + int32_t decimals = -2; // default to 2 decimals and remove trailing zeros + static char hex[20]; // buffer used for 64 bits, favor RAM instead of stack to remove pressure + + for (; *fmt != 0; ++fmt) { + if (alloc_idx >= ALLOC_SIZE) { break; } // buffer is full, don't continue parsing + if (*fmt == '%') { + fmt++; + char * fmt_start = fmt; + if (*fmt == '\0') { break; } // end of string + if (*fmt == '%') { continue; } // actual '%' char + if (*fmt == '*') { + va_arg(va, int32_t); // skip width argument as int + fmt++; + } + if (*fmt < 'A') { + decimals = strtol(fmt, nullptr, 10); + } + while (*fmt < 'A') { // brutal way to munch anything that is not a letter or '-' (or anything else) + // while ((*fmt >= '0' && *fmt <= '9') || (*fmt == '.') || (*fmt == '*') || (*fmt == '-' || (*fmt == ' ' || (*fmt == '+') || (*fmt == '#')))) { + fmt++; + } + + if (*fmt == '_') { // extension + for (; fmt_start <= fmt; fmt_start++) { + *fmt_start = '0'; + } + // *fmt = '0'; + fmt++; + uint32_t cur_val = va_arg(va, uint32_t); // current value + const char ** cur_val_ptr = va_cur_ptr4(va, const char*); // pointer to value on stack + char * new_val_str = (char*) ""; + switch (*fmt) { + // case 'D': + // decimals = *(int32_t*)cur_val_ptr; + // break; + + // `%_I` ouputs an IPv4 32 bits address passed as u32 into a decimal dotted format + case 'I': // Input is `uint32_t` 32 bits IP address, output is decimal dotted address + new_val_str = copyStr(IPAddress(cur_val).toString().c_str()); + allocs[alloc_idx++] = new_val_str; + break; + + // `%_f` or `%*_f` outputs a float with optionan number of decimals passed as first argument if `*` is present + // positive number of decimals means an exact number of decimals, can be `0` terminate + // negative number of decimals will suppress + // Ex: + // char c[128]; + // float f = 3.141f; + // ext_vsnprintf_P(c; szeof(c), "%_f %*_f %*_f", &f, 4, 1f, -4, %f); + // --> c will be "3.14 3.1410 3.141" + // Note: float MUST be passed by address, because C alsays promoted float to double when in vararg + case 'f': // input is `float`, printed to float with 2 decimals + { + bool truncate = false; + if (decimals < 0) { + decimals = -decimals; + truncate = true; + } + dtostrf(*(float*)cur_val, (decimals + 2), decimals, hex); + + if (truncate) { + uint32_t last = strlen(hex) - 1; + // remove trailing zeros + while (hex[last] == '0') { + hex[last--] = 0; // remove last char + } + // remove trailing dot + if (hex[last] == '.') { + hex[last] = 0; + } + } + new_val_str = copyStr(hex); + allocs[alloc_idx++] = new_val_str; + } + break; + // '%_X' outputs a 64 bits unsigned int to uppercase HEX with 16 digits + case 'X': // input is `uint64_t*`, printed as 16 hex digits (no prefix 0x) + { + U64toHex(*(uint64_t*)cur_val, hex); + new_val_str = copyStr(hex); + allocs[alloc_idx++] = new_val_str; + } + break; + // Trying to do String allocation alternatives, but not as interesting as I thought in the beginning + // case 's': + // { + // new_val_str = copyStr(((String*)cur_val)->c_str()); + // allocs[alloc_idx++] = new_val_str; + // } + // break; + // case 'S': + // { + // funcString_t * func_str = (funcString_t*) cur_val; + // new_val_str = copyStr((*func_str)().c_str()); + // allocs[alloc_idx++] = new_val_str; + // } + // break; + } + *cur_val_ptr = new_val_str; + *fmt = 's'; // replace `%_X` with `%0s` to display a string instead + + } else { + va_arg(va, int32_t); // munch one 32 bits argument and leave it unchanged + // we take the hypothesis here that passing 64 bits arguments is always unsupported in ESP8266 + } + fmt++; + } + } +#else // defined(ESP8266) || defined(ESP32) + #error "ext_printf is not suppoerted on this platform" +#endif // defined(ESP8266) || defined(ESP32) + int32_t ret = vsnprintf_P(buf, buf_len, fmt_cpy, va_cpy); + + va_end(va_cpy); + for (uint32_t i = 0; i < alloc_idx; i++) { + free(allocs[i]); + allocs[i] = nullptr; + } + free(fmt_cpy); + return ret; +} + +int32_t ext_snprintf_P(char * buf, size_t buf_len, const char * fmt, ...) { + va_list va; + va_start(va, fmt); + + int32_t ret = ext_vsnprintf_P(buf, buf_len, fmt, va); + va_end(va); + return ret; +} diff --git a/lib/default/Ext-printf/src/ext_printf.h b/lib/default/Ext-printf/src/ext_printf.h new file mode 100644 index 000000000..6dc4d4061 --- /dev/null +++ b/lib/default/Ext-printf/src/ext_printf.h @@ -0,0 +1,32 @@ +/* + ext_printf.ino - Extended printf for Arduino objects + + Copyright (C) 2021 Stephan Hadinger + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef EXT_PRINTF_H +#define EXT_PRINTF_H + +#include +#include +#include + +int32_t ext_vsnprintf_P(char * buf, size_t buf_len, const char * fmt_P, va_list va); +int32_t ext_snprintf_P(char * buf, size_t buf_len, const char * fmt, ...); + +// void test_ext_snprintf_P(void); + +#endif // EXT_PRINTF_H \ No newline at end of file diff --git a/lib/default/Ext-printf/test/test_ext_printf.cpp b/lib/default/Ext-printf/test/test_ext_printf.cpp new file mode 100644 index 000000000..d29e9e8e7 --- /dev/null +++ b/lib/default/Ext-printf/test/test_ext_printf.cpp @@ -0,0 +1,106 @@ +/* + ext_printf.ino - Extended printf for Arduino objects + + Copyright (C) 2021 Stephan Hadinger + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "ext_printf.h" +#include + +// DEBUG only + +// String test_string(void) { +// String s("This is the string"); + +// return s; +// } + +// String f_str(void) { return String("foobar"); } +// String k_str("foobar"); + +// void f1(String s) { +// Serial.printf("> %s\n", s.c_str()); +// } +// void f2(void) { +// f1(f_str()); +// } + +// void test_snprintf1(void) { +// char c[100]; +// snprintf_P(c, sizeof(c), PSTR("s1=%s, s2=%s"), k_str.c_str(), f_str().c_str()); +// } +// void test_snprintf2(void) { +// char c[100]; +// ext_snprintf_P(c, sizeof(c), PSTR("s1=%_s, s2=%_S"), &k_str, &f_str, &ResponseAppendTHD); +// } +void test_ext_snprintf_P(void) { +// test_snprintf1(); +// test_snprintf2(); +// if (0) { + // // testVarArg2("", 1, 2, 3, 4, 5, 6, 7, 8); + + char c[128]; + float fpi=-3333.1415926535f; + float f3 = 3333; + float f31 = 3333.1; + ext_snprintf_P(c, sizeof(c), "Int1 = %d, ip=%_I", 1, 0x10203040); + Serial.printf("--> out=%s\n", c); + + ext_snprintf_P(c, sizeof(c), "Float default=%_f %_f", &f3, &fpi); + Serial.printf("--> out=%s\n", c); + + ext_snprintf_P(c, sizeof(c), "Float default=%1_f, int(3)=%4_f, int(3)=%-4_f, int(3)=%-4_f, 6dec=%-8_f", &fpi, &f3, &f3, &f31, &fpi); + Serial.printf("--> out=%s\n", c); + uint64_t u641 = 0x1122334455667788LL; + uint64_t u642 = 0x0123456789ABCDEFLL; + uint64_t u643 = 0xFEDCBA9876543210LL; + ext_snprintf_P(c, sizeof(c), "Int64 0x%_X 0x%_X 0x%_X", &u641, &u642, &u643); + Serial.printf("--> out=%s\n", c); + + // String string("Foobar"); + // ext_snprintf_P(c, sizeof(c), "String 0x%08X %_s", &string, &string); + // Serial.printf("--> out=%s\n", c); + + // ext_snprintf_P(c, sizeof(c), "StringFunc 0x%08X %_S", &test_string, &test_string); + // Serial.printf("--> out=%s\n", c); + + // uint64_t u64 = 0x123456789ABCDEFLL; + // testVarArg2("", u64, 2, 3, 4, 5, 6, 7, 8); + + // // Serial.printf("+++ ld=%ld, lld=%lld\n", 1,2,3,4); + // // testVarArg("", 1, 2, 3, 4, 5, 6, 7, 8); + // } + // tprintf("%s", 12, "14"); +} + + +// void tprintf(const char* format) // base function +// { +// Serial.printf("%s\n", format); +// } + +// template +// void tprintf(const char* format, T value, Targs... Fargs) // recursive variadic function +// { +// for ( ; *format != '\0'; format++ ) { +// if ( *format == '%' ) { +// Serial.printf("%d", (uint32_t) value); +// tprintf(format+1, Fargs...); // recursive call +// return; +// } +// Serial.printf("%s", format); +// } +// } diff --git a/lib/default/PubSubClient-EspEasy-2.7.12/library.json b/lib/default/PubSubClient-EspEasy-2.7.12/library.json index 8a36a1c5e..e675ecff3 100644 --- a/lib/default/PubSubClient-EspEasy-2.7.12/library.json +++ b/lib/default/PubSubClient-EspEasy-2.7.12/library.json @@ -10,8 +10,5 @@ "exclude": "tests", "examples": "examples/*/*.ino", "frameworks": "arduino", - "platforms": [ - "atmelavr", - "espressif" - ] + "platforms": ["espressif8266", "espressif32"] } diff --git a/lib/default/PubSubClient-EspEasy-2.7.12/src/PubSubClient.h b/lib/default/PubSubClient-EspEasy-2.7.12/src/PubSubClient.h index 612029665..19b35160a 100644 --- a/lib/default/PubSubClient-EspEasy-2.7.12/src/PubSubClient.h +++ b/lib/default/PubSubClient-EspEasy-2.7.12/src/PubSubClient.h @@ -25,19 +25,20 @@ #ifndef MQTT_MAX_PACKET_SIZE //#define MQTT_MAX_PACKET_SIZE 128 //#define MQTT_MAX_PACKET_SIZE 1000 // Tasmota v5.11.1c -#define MQTT_MAX_PACKET_SIZE 1200 // Tasmota v8.1.0.8 +#define MQTT_MAX_PACKET_SIZE 1200 // Tasmota v8.1.0.8 #endif // MQTT_KEEPALIVE : keepAlive interval in Seconds // Keepalive timeout for default MQTT Broker is 10s #ifndef MQTT_KEEPALIVE //#define MQTT_KEEPALIVE 10 -#define MQTT_KEEPALIVE 30 // Tasmota v6.5.0.14 enabling AWS-iot +#define MQTT_KEEPALIVE 30 // Tasmota v6.5.0.14 enabling AWS-iot #endif // MQTT_SOCKET_TIMEOUT: socket timeout interval in Seconds #ifndef MQTT_SOCKET_TIMEOUT -#define MQTT_SOCKET_TIMEOUT 15 +//#define MQTT_SOCKET_TIMEOUT 15 +#define MQTT_SOCKET_TIMEOUT 4 // Tasmota 20210120 #endif // MQTT_MAX_TRANSFER_SIZE : limit how much data is passed to the network client diff --git a/lib/lib_basic/OneWire-Stickbreaker-20190506-1.1/library.properties b/lib/lib_basic/OneWire-Stickbreaker-20190506-1.1/library.properties index 2a8b08e53..89313ddaa 100644 --- a/lib/lib_basic/OneWire-Stickbreaker-20190506-1.1/library.properties +++ b/lib/lib_basic/OneWire-Stickbreaker-20190506-1.1/library.properties @@ -6,5 +6,5 @@ sentence=Access 1-wire temperature sensors, memory and other chips. paragraph= Mod of Paul Stoffregen code to support ESP32 category=Communication url=http://www.pjrc.com/teensy/td_libs_OneWire.html -architectures=esp32 +architectures=esp8266,esp32 diff --git a/lib/lib_basic/TasmotaModbus-1.2.0/library.json b/lib/lib_basic/TasmotaModbus-1.2.0/library.json index 6de11d0e0..3c28959ea 100644 --- a/lib/lib_basic/TasmotaModbus-1.2.0/library.json +++ b/lib/lib_basic/TasmotaModbus-1.2.0/library.json @@ -11,5 +11,5 @@ "url": "https://github.com/arendst/Tasmota/lib/TasmotaModbus" }, "frameworks": "arduino", - "platforms": "espressif8266" + "platforms": ["espressif8266", "espressif32"] } diff --git a/lib/lib_basic/TasmotaModbus-1.2.0/library.properties b/lib/lib_basic/TasmotaModbus-1.2.0/library.properties index 9197e7cfe..7ac182843 100644 --- a/lib/lib_basic/TasmotaModbus-1.2.0/library.properties +++ b/lib/lib_basic/TasmotaModbus-1.2.0/library.properties @@ -6,4 +6,4 @@ sentence=Basic modbus wrapper for TasmotaSerial for ESP8266. paragraph= category=Signal Input/Output url= -architectures=esp8266 +architectures=esp8266,esp32 diff --git a/lib/lib_display/FT5206_Library/library.properties b/lib/lib_display/FT5206_Library/library.properties index e28709e5c..14b3e2e94 100644 --- a/lib/lib_display/FT5206_Library/library.properties +++ b/lib/lib_display/FT5206_Library/library.properties @@ -7,4 +7,3 @@ paragraph=Arduino library for FT5206 chip. Tested with ESP32 category=Communication url=https://github.com/lewisxhe/FT5206_Library architectures=* -architectures=esp32 \ No newline at end of file diff --git a/lib/lib_display/LiquidCrystal_I2C-1.1.3/library.json b/lib/lib_display/LiquidCrystal_I2C-1.1.3/library.json index 5a23a3989..1553b6e44 100644 --- a/lib/lib_display/LiquidCrystal_I2C-1.1.3/library.json +++ b/lib/lib_display/LiquidCrystal_I2C-1.1.3/library.json @@ -10,6 +10,6 @@ "frameworks": "arduino", "platforms": [ - "atmelavr" + "*" ] -} \ No newline at end of file +} diff --git a/lib/lib_display/esp-epaper-29-ws-20171230-gemu-1.1/library.properties b/lib/lib_display/esp-epaper-29-ws-20171230-gemu-1.1/library.properties index 488cfdda2..29a16c0e7 100644 --- a/lib/lib_display/esp-epaper-29-ws-20171230-gemu-1.1/library.properties +++ b/lib/lib_display/esp-epaper-29-ws-20171230-gemu-1.1/library.properties @@ -6,4 +6,4 @@ sentence=ESP8266 library for Waveshare e-paper display. paragraph= category=Display url=https://github.com/gemu2015/Sonoff-Tasmota/tree/displays/lib/esp-epaper-29-ws-20171230-gemu-1.0# -architectures=esp8266 +architectures=* diff --git a/lib/lib_i2c/Adafruit_TSL2591_Library/Adafruit_TSL2591.cpp b/lib/lib_i2c/Adafruit_TSL2591_Library/Adafruit_TSL2591.cpp index 230ef6294..1cd9a9de3 100644 --- a/lib/lib_i2c/Adafruit_TSL2591_Library/Adafruit_TSL2591.cpp +++ b/lib/lib_i2c/Adafruit_TSL2591_Library/Adafruit_TSL2591.cpp @@ -338,7 +338,15 @@ float Adafruit_TSL2591::calculateLux(uint16_t ch0, uint16_t ch1) // Alternate lux calculation 1 // See: https://github.com/adafruit/Adafruit_TSL2591_Library/issues/14 - lux = ( ((float)ch0 - (float)ch1 )) * (1.0F - ((float)ch1/(float)ch0) ) / cpl; + if(ch0 > 0) + { + lux = ( ((float)ch0 - (float)ch1 )) * (1.0F - ((float)ch1/(float)ch0) ) / cpl; + } + else + { + lux = 0.0F; + } + // Alternate lux calculation 2 //lux = ( (float)ch0 - ( 1.7F * (float)ch1 ) ) / cpl; diff --git a/lib/lib_i2c/BME680_driver-bme680_v3.5.9/library.properties b/lib/lib_i2c/BME680_driver-bme680_v3.5.9/library.properties index 93954f32d..bf0211d28 100644 --- a/lib/lib_i2c/BME680_driver-bme680_v3.5.9/library.properties +++ b/lib/lib_i2c/BME680_driver-bme680_v3.5.9/library.properties @@ -6,4 +6,4 @@ sentence=Sensor driver for BME680 sensor paragraph=Sensor driver for BME680 sensor category=Sensor url= -architectures=esp8266 +architectures=esp8266,esp32 diff --git a/lib/lib_i2c/I2Cdevlib-Core/.library.json b/lib/lib_i2c/I2Cdevlib-Core/.library.json index 258acc176..14886c889 100644 --- a/lib/lib_i2c/I2Cdevlib-Core/.library.json +++ b/lib/lib_i2c/I2Cdevlib-Core/.library.json @@ -5,7 +5,7 @@ "type": "git" }, "platforms": [ - "atmelavr" + "*" ], "frameworks": [ "arduino" @@ -28,4 +28,4 @@ ], "id": 11, "description": "The I2C Device Library (I2Cdevlib) is a collection of uniform and well-documented classes to provide simple and intuitive interfaces to I2C devices." -} \ No newline at end of file +} diff --git a/lib/lib_i2c/I2Cdevlib-Core/library.json b/lib/lib_i2c/I2Cdevlib-Core/library.json index d45609604..5a2125b5b 100644 --- a/lib/lib_i2c/I2Cdevlib-Core/library.json +++ b/lib/lib_i2c/I2Cdevlib-Core/library.json @@ -9,5 +9,5 @@ "url": "https://github.com/jrowberg/i2cdevlib.git" }, "frameworks": "arduino", - "platforms": "atmelavr" + "platforms": "*" } diff --git a/lib/lib_rf/cc1101/library.properties b/lib/lib_rf/cc1101/library.properties index bfb8a65bc..73e393575 100644 --- a/lib/lib_rf/cc1101/library.properties +++ b/lib/lib_rf/cc1101/library.properties @@ -6,4 +6,4 @@ sentence=. paragraph= category= url= -architectures=esp8266 +architectures=esp8266,esp32 diff --git a/lib/lib_ssl/bearssl-esp8266/library.properties b/lib/lib_ssl/bearssl-esp8266/library.properties index 1d936cb88..032d4d247 100644 --- a/lib/lib_ssl/bearssl-esp8266/library.properties +++ b/lib/lib_ssl/bearssl-esp8266/library.properties @@ -6,4 +6,4 @@ sentence=BearSSL implementation of the SSL/TLS protocol optimized for ESP8266 by paragraph= category=Other url=https://github.com/earlephilhower/bearssl-esp8266.git -architectures=esp8266 +architectures=esp8266,esp32 diff --git a/lib/libesp32/CORE2_Library/library.properties b/lib/libesp32/CORE2_Library/library.properties new file mode 100644 index 000000000..09baffd9a --- /dev/null +++ b/lib/libesp32/CORE2_Library/library.properties @@ -0,0 +1,9 @@ +name=M5 Stack Core2 library +version=1.0 +author=Gerhard Mutz +maintainer=Gerhard Mutz +sentence=Allows Tasmota to use Core2 +paragraph=Allows Tasmota to Core2 for esp32 +category=ESP32 +url= +architectures=* diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index 03bd39b60..7685d45f3 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -40,14 +40,20 @@ lib_extra_dirs = lib/libesp32, lib/lib_basic extends = env:tasmota32 board = odroid_esp32 board_build.f_cpu = 240000000L +board_build.flash_mode = qio +board_build.f_flash = 80000000L +upload_speed = 2000000 board_build.partitions = esp32_partition_app1984k_spiffs12M.csv build_flags = ${common32.build_flags} -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -DFIRMWARE_ODROID_GO lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_i2c, lib/lib_rf, lib/lib_div, lib/lib_ssl, lib/lib_display [env:tasmota32-core2] extends = env:tasmota32 -board = m5stack-grey +board = odroid_esp32 board_build.f_cpu = 240000000L +board_build.flash_mode = qio +board_build.f_flash = 80000000L +upload_speed = 2000000 board_build.partitions = esp32_partition_app1984k_spiffs12M.csv build_flags = ${common32.build_flags} -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -DFIRMWARE_M5STACK_CORE2 lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_i2c, lib/lib_rf, lib/lib_div, lib/lib_ssl, lib/lib_display, lib/lib_audio diff --git a/tasmota/i18n.h b/tasmota/i18n.h index 3262bef09..0c7438907 100644 --- a/tasmota/i18n.h +++ b/tasmota/i18n.h @@ -156,6 +156,7 @@ #define D_JSON_SERIALRECEIVED "SerialReceived" #define D_JSON_SET "Set" #define D_JSON_SIGNAL "Signal" +#define D_JSON_SIZE "Size" #define D_JSON_SPEED "Speed" #define D_JSON_SPEED_UNIT "SpeedUnit" #define D_JSON_SSID "SSId" @@ -180,6 +181,7 @@ #define D_JSON_TOTAL_START_TIME "TotalStartTime" #define D_JSON_TVOC "TVOC" #define D_JSON_TYPE "Type" +#define D_JSON_UID "UID" #define D_JSON_UPTIME "Uptime" #define D_JSON_UTC_TIME "UTC" #define D_JSON_UV_INDEX "UvIndex" @@ -782,6 +784,7 @@ const char HTTP_SNS_GALLONS[] PROGMEM = "{s}%s " D_TOTAL_USAGE "{ const char HTTP_SNS_GPM[] PROGMEM = "{s}%s " D_FLOW_RATE "{m}%s " D_UNIT_GALLONS_PER_MIN "{e}"; const char HTTP_SNS_MOISTURE[] PROGMEM = "{s}%s " D_MOISTURE "{m}%d " D_UNIT_PERCENT "{e}"; const char HTTP_SNS_RANGE[] PROGMEM = "{s}%s " D_RANGE "{m}%d" "{e}"; +const char HTTP_SNS_DISTANCE[] PROGMEM = "{s}%s " D_DISTANCE "{m}%d " D_UNIT_MILLIMETER "{e}"; const char HTTP_SNS_VOLTAGE[] PROGMEM = "{s}" D_VOLTAGE "{m}%s " D_UNIT_VOLT "{e}"; const char HTTP_SNS_CURRENT[] PROGMEM = "{s}" D_CURRENT "{m}%s " D_UNIT_AMPERE "{e}"; const char HTTP_SNS_POWER[] PROGMEM = "{s}" D_POWERUSAGE "{m}%s " D_UNIT_WATT "{e}"; diff --git a/tasmota/language/it_IT.h b/tasmota/language/it_IT.h index 4a2f8316f..7d4c8a956 100644 --- a/tasmota/language/it_IT.h +++ b/tasmota/language/it_IT.h @@ -1,7 +1,7 @@ /* it-IT.h - localization for Italian - Italy for Tasmota - Copyright (C) 2021 Gennaro Tortone - some mods by Antonio Fragola - Updated by bovirus - rev. 17.01.2021 + Copyright (C) 2021 Gennaro Tortone - some mods by Antonio Fragola - Updated by bovirus - rev. 22.01.2021 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -959,54 +959,54 @@ // xsns_83_neopool.ino #define D_NEOPOOL_MACH_NONE "NeoPool" // Machine names -#define D_NEOPOOL_MACH_HIDROLIFE "Hidrolife (yellow)" -#define D_NEOPOOL_MACH_AQUASCENIC "Aquascenic (blue)" -#define D_NEOPOOL_MACH_OXILIFE "Oxilife (green)" -#define D_NEOPOOL_MACH_BIONET "Bionet (light blue)" -#define D_NEOPOOL_MACH_HIDRONISER "Hidroniser (red)" +#define D_NEOPOOL_MACH_HIDROLIFE "Hidrolife (giallo)" +#define D_NEOPOOL_MACH_AQUASCENIC "Aquascenic (blu)" +#define D_NEOPOOL_MACH_OXILIFE "Oxilife (verde)" +#define D_NEOPOOL_MACH_BIONET "Bionet (azzurro)" +#define D_NEOPOOL_MACH_HIDRONISER "Hidroniser (rosso)" #define D_NEOPOOL_MACH_UVSCENIC "UVScenic (lilac)" -#define D_NEOPOOL_MACH_STATION "Station (orange)" +#define D_NEOPOOL_MACH_STATION "Station (arancio)" #define D_NEOPOOL_MACH_BRILIX "Brilix" -#define D_NEOPOOL_MACH_GENERIC "Generic" +#define D_NEOPOOL_MACH_GENERIC "Generico" #define D_NEOPOOL_MACH_BAYROL "Bayrol" #define D_NEOPOOL_MACH_HAY "Hay" -#define D_NEOPOOL_FILTRATION_MANUAL "Manual" // Filtration modes -#define D_NEOPOOL_FILTRATION_AUTO "Auto" -#define D_NEOPOOL_FILTRATION_HEATING "Heating" -#define D_NEOPOOL_FILTRATION_SMART "Smart" -#define D_NEOPOOL_FILTRATION_INTELLIGENT "Intelligent" -#define D_NEOPOOL_FILTRATION_BACKWASH "Backwash" +#define D_NEOPOOL_FILTRATION_MANUAL "Manuale" // Filtration modes +#define D_NEOPOOL_FILTRATION_AUTO "Automatico" +#define D_NEOPOOL_FILTRATION_HEATING "Riscaldamento" +#define D_NEOPOOL_FILTRATION_SMART "Rapido" +#define D_NEOPOOL_FILTRATION_INTELLIGENT "Intelligente" +#define D_NEOPOOL_FILTRATION_BACKWASH "Contro lavaggio" #define D_NEOPOOL_FILTRATION_NONE "" // Filtration speed level -#define D_NEOPOOL_FILTRATION_SLOW "slow" -#define D_NEOPOOL_FILTRATION_MEDIUM "medium" -#define D_NEOPOOL_FILTRATION_FAST "fast" -#define D_NEOPOOL_TYPE "Type" // Sensor & relais names +#define D_NEOPOOL_FILTRATION_SLOW "lento" +#define D_NEOPOOL_FILTRATION_MEDIUM "medio" +#define D_NEOPOOL_FILTRATION_FAST "veloce" +#define D_NEOPOOL_TYPE "Tipo" // Sensor & relais names #define D_NEOPOOL_REDOX "Redox" -#define D_NEOPOOL_CHLORINE "Chlorine" -#define D_NEOPOOL_CONDUCTIVITY "Conductivity" -#define D_NEOPOOL_IONIZATION "Ionization" -#define D_NEOPOOL_HYDROLYSIS "Hydrolysis" +#define D_NEOPOOL_CHLORINE "Cloro" +#define D_NEOPOOL_CONDUCTIVITY "Conduttività" +#define D_NEOPOOL_IONIZATION "Ionizzazione" +#define D_NEOPOOL_HYDROLYSIS "Idrolisi" #define D_NEOPOOL_RELAY "Relay" -#define D_NEOPOOL_RELAY_FILTRATION "Filtration" -#define D_NEOPOOL_RELAY_LIGHT "Light" -#define D_NEOPOOL_RELAY_PH_ACID "Acid pump" -#define D_NEOPOOL_RELAY_PH_BASE "Base pump" -#define D_NEOPOOL_RELAY_RX "Redox level" -#define D_NEOPOOL_RELAY_CL "Chlorine pump" -#define D_NEOPOOL_RELAY_CD "Brine pump" -#define D_NEOPOOL_TIME "Time" -#define D_NEOPOOL_FILT_MODE "Filtration" +#define D_NEOPOOL_RELAY_FILTRATION "Filtrazione" +#define D_NEOPOOL_RELAY_LIGHT "Luce" +#define D_NEOPOOL_RELAY_PH_ACID "Pompa per acido" +#define D_NEOPOOL_RELAY_PH_BASE "Popa base" +#define D_NEOPOOL_RELAY_RX "Livello Redox" +#define D_NEOPOOL_RELAY_CL "Pompa cloro" +#define D_NEOPOOL_RELAY_CD "Pompa salamoia" +#define D_NEOPOOL_TIME "Orario" +#define D_NEOPOOL_FILT_MODE "Filtrazione" #define D_NEOPOOL_POLARIZATION "Pol" // Sensor status #define D_NEOPOOL_PR_OFF "PrOff" -#define D_NEOPOOL_SETPOINT_OK "Ok" -#define D_NEOPOOL_COVER "Cover" +#define D_NEOPOOL_SETPOINT_OK "OK" +#define D_NEOPOOL_COVER "Copertura" #define D_NEOPOOL_SHOCK "Shock" #define D_NEOPOOL_ALARM "! " #define D_NEOPOOL_LOW "Low" #define D_NEOPOOL_FLOW1 "FL1" #define D_NEOPOOL_FLOW2 "FL2" -#define D_NEOPOOL_PH_HIGH "too high" // ph Alarms -#define D_NEOPOOL_PH_LOW "too low" -#define D_NEOPOOL_PUMP_TIME_EXCEEDED "pump time exceeded" +#define D_NEOPOOL_PH_HIGH "troppo alto" // ph Alarms +#define D_NEOPOOL_PH_LOW "troppo basso" +#define D_NEOPOOL_PUMP_TIME_EXCEEDED "tempo pompa superato" #endif // _LANGUAGE_IT_IT_H_ diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index cd1d62cd7..7ba3f4237 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -558,7 +558,8 @@ // #define USE_SPS30 // [I2cDriver30] Enable Sensiron SPS30 particle sensor (I2C address 0x69) (+1.7 code) #define USE_ADE7953 // [I2cDriver7] Enable ADE7953 Energy monitor as used on Shelly 2.5 (I2C address 0x38) (+1k5) // #define USE_VL53L0X // [I2cDriver31] Enable VL53L0x time of flight sensor (I2C address 0x29) (+4k code) -// #define USE_VL53L1X // [I2cDriver54] Enable support for VL53L1X sensor (I2C address 0x29) using Pololu VL53L1X library (+2k9 code) +// #define USE_VL53L1X // [I2cDriver54] Enable VL53L1X time of flight sensor (I2C address 0x29) using Pololu VL53L1X library (+2k9 code) +// #define USE_TOF10120 // [I2cDriver57] Enable TOF10120 time of flight sensor (I2C address 0x52) (+0k6 code) // #define USE_MLX90614 // [I2cDriver32] Enable MLX90614 ir temp sensor (I2C address 0x5a) (+0.6k code) // #define USE_CHIRP // [I2cDriver33] Enable CHIRP soil moisture sensor (variable I2C address, default 0x20) // #define USE_PAJ7620 // [I2cDriver34] Enable PAJ7620 gesture sensor (I2C address 0x73) (+2.5k code) @@ -591,6 +592,7 @@ // #define USE_EZODO // [I2cDriver55] Enable support for EZO's DO sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code) // #define USE_EZORGB // [I2cDriver55] Enable support for EZO's RGB sensor (+0k5 code) - Shared EZO code required for any EZO device (+1k2 code) // #define USE_EZOPMP // [I2cDriver55] Enable support for EZO's PMP sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code) +// #define USE_SEESAW_SOIL // [I2cDriver56] Enable Capacitice Soil Moisture & Temperature Sensor (I2C addresses 0x36 - 0x39) (+1k3 code) // #define USE_DISPLAY // Add I2C Display Support (+2k code) #define USE_DISPLAY_MODES1TO5 // Enable display mode 1 to 5 in addition to mode 0 @@ -758,8 +760,8 @@ // Auto-binding constants, see `Z_autoAttributeReporting` // Below are the threshold for attribute reporting - #define USE_ZIGBEE_AUTOBIND_BATTVOLTAGE 0.1 // V - #define USE_ZIGBEE_AUTOBIND_BATTPERCENT 1 // % + #define USE_ZIGBEE_AUTOBIND_BATTVOLTAGE 0.2 // V + #define USE_ZIGBEE_AUTOBIND_BATTPERCENT 5 // % #define USE_ZIGBEE_AUTOBIND_TEMPERATURE 0.5 // °C #define USE_ZIGBEE_AUTOBIND_HEATDEMAND 10 // % #define USE_ZIGBEE_AUTOBIND_PRESSURE 1 // hPA diff --git a/tasmota/sendemail.ino b/tasmota/sendemail.ino index 788a52a5c..cd7f849ce 100644 --- a/tasmota/sendemail.ino +++ b/tasmota/sendemail.ino @@ -80,7 +80,7 @@ uint16_t SendMail(char *buffer) { cmd=endcmd+1; #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("mailsize: %d"),blen); + AddLog(LOG_LEVEL_INFO, PSTR("mailsize: %d"),blen); #endif mserv=strtok(params,":"); @@ -148,7 +148,7 @@ uint16_t SendMail(char *buffer) { #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("%s - %d - %s - %s"),mserv,port,user,passwd); + AddLog(LOG_LEVEL_INFO, PSTR("%s - %d - %s - %s"),mserv,port,user,passwd); #endif // 2 seconds timeout @@ -216,12 +216,12 @@ String buffer; client->setTimeout(timeout); // smtp connect #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("Connecting: %s on port %d"),host.c_str(),port); + AddLog(LOG_LEVEL_INFO, PSTR("Connecting: %s on port %d"),host.c_str(),port); #endif if (!client->connect(host.c_str(), port)) { #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("Connection failed")); + AddLog(LOG_LEVEL_INFO, PSTR("Connection failed")); #endif goto exit; } @@ -458,7 +458,7 @@ void attach_Array(char *aname) { g_client->print(F("Content-Type: text/plain\r\n")); if (array && alen) { #ifdef DEBUG_EMAIL_PORT - AddLog_P(LOG_LEVEL_INFO, PSTR("array found %d"),alen); + AddLog(LOG_LEVEL_INFO, PSTR("array found %d"),alen); #endif char buff[64]; sprintf_P(buff,PSTR("Content-Disposition: attachment; filename=\"%s.txt\"\r\n\r\n"), aname); @@ -545,7 +545,7 @@ uint16_t SendMail(char *buffer) { // return if not enough memory uint32_t mem=ESP.getFreeHeap(); - //AddLog_P(LOG_LEVEL_INFO, PSTR("heap: %d"),mem); + //AddLog(LOG_LEVEL_INFO, PSTR("heap: %d"),mem); if (mem 0x0606000A)) ? 3584 : sizeof(Settings); return GetCfgCrc16((uint8_t*)&Settings, size); } -uint32_t GetCfgCrc32(uint8_t *bytes, uint32_t size) -{ +uint32_t GetCfgCrc32(uint8_t *bytes, uint32_t size) { // https://create.stephan-brumme.com/crc32/#bitwise uint32_t crc = 0; @@ -295,13 +281,11 @@ uint32_t GetCfgCrc32(uint8_t *bytes, uint32_t size) return ~crc; } -uint32_t GetSettingsCrc32(void) -{ +uint32_t GetSettingsCrc32(void) { return GetCfgCrc32((uint8_t*)&Settings, sizeof(Settings) -4); // Skip crc32 } -void SettingsSaveAll(void) -{ +void SettingsSaveAll(void) { if (Settings.flag.save_state) { Settings.power = TasmotaGlobal.power; } else { @@ -338,7 +322,7 @@ void UpdateQuickPowerCycle(bool update) { } else { qpc_buffer[0] = 0; ESP.flashWrite(qpc_location + (counter * 4), (uint32*)&qpc_buffer, 4); - AddLog_P(LOG_LEVEL_INFO, PSTR("QPC: Count %d"), counter); + AddLog(LOG_LEVEL_INFO, PSTR("QPC: Count %d"), counter); } } else if ((qpc_buffer[0] != QPC_SIGNATURE) || (0 == qpc_buffer[1])) { @@ -346,7 +330,7 @@ void UpdateQuickPowerCycle(bool update) { // Assume flash is default all ones and setting a bit to zero does not need an erase if (ESP.flashEraseSector(qpc_sector)) { ESP.flashWrite(qpc_location, (uint32*)&qpc_buffer, 4); - AddLog_P(LOG_LEVEL_INFO, PSTR("QPC: Reset")); + AddLog(LOG_LEVEL_INFO, PSTR("QPC: Reset")); } } #endif // ESP8266 @@ -363,13 +347,13 @@ void UpdateQuickPowerCycle(bool update) { } else { pc_register = 0xFFA55AF0 | counter; QPCWrite(&pc_register, sizeof(pc_register)); - AddLog_P(LOG_LEVEL_INFO, PSTR("QPC: Count %d"), counter); + AddLog(LOG_LEVEL_INFO, PSTR("QPC: Count %d"), counter); } } else if (pc_register != QPC_SIGNATURE) { pc_register = QPC_SIGNATURE; QPCWrite(&pc_register, sizeof(pc_register)); - AddLog_P(LOG_LEVEL_INFO, PSTR("QPC: Reset")); + AddLog(LOG_LEVEL_INFO, PSTR("QPC: Reset")); } #endif // ESP32 @@ -430,12 +414,12 @@ bool SettingsUpdateText(uint32_t index, const char* replace_me) { uint32_t current_len = end_pos - start_pos; int diff = replace_len - current_len; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TST: start %d, end %d, len %d, current %d, replace %d, diff %d"), +// AddLog(LOG_LEVEL_DEBUG, PSTR("TST: start %d, end %d, len %d, current %d, replace %d, diff %d"), // start_pos, end_pos, char_len, current_len, replace_len, diff); int too_long = (char_len + diff) - settings_text_size; if (too_long > 0) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_CONFIG "Text overflow by %d char(s)"), too_long); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_CONFIG "Text overflow by %d char(s)"), too_long); return false; // Replace text too long } @@ -457,16 +441,15 @@ bool SettingsUpdateText(uint32_t index, const char* replace_me) { } #ifdef DEBUG_FUNC_SETTINGSUPDATETEXT - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "CR %d/%d, Busy %d, Id %02d = \"%s\""), GetSettingsTextLen(), settings_text_size, settings_text_busy_count, index_save, replace); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "CR %d/%d, Busy %d, Id %02d = \"%s\""), GetSettingsTextLen(), settings_text_size, settings_text_busy_count, index_save, replace); #else - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "CR %d/%d, Busy %d"), GetSettingsTextLen(), settings_text_size, settings_text_busy_count); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "CR %d/%d, Busy %d"), GetSettingsTextLen(), settings_text_size, settings_text_busy_count); #endif return true; } -char* SettingsText(uint32_t index) -{ +char* SettingsText(uint32_t index) { char* position = Settings.text_pool; if (index >= SET_MAX) { @@ -484,19 +467,16 @@ char* SettingsText(uint32_t index) * Config Save - Save parameters to Flash ONLY if any parameter has changed \*********************************************************************************************/ -void UpdateBackwardCompatibility(void) -{ +void UpdateBackwardCompatibility(void) { // Perform updates for backward compatibility strlcpy(Settings.user_template_name, SettingsText(SET_TEMPLATE_NAME), sizeof(Settings.user_template_name)); } -uint32_t GetSettingsAddress(void) -{ +uint32_t GetSettingsAddress(void) { return settings_location * SPI_FLASH_SEC_SIZE; } -void SettingsSave(uint8_t rotate) -{ +void SettingsSave(uint8_t rotate) { /* Save configuration in eeprom or one of 7 slots below * * rotate 0 = Save in next flash slot @@ -508,22 +488,20 @@ void SettingsSave(uint8_t rotate) #ifndef FIRMWARE_MINIMAL UpdateBackwardCompatibility(); if ((GetSettingsCrc32() != settings_crc32) || rotate) { - if (1 == rotate) { // Use eeprom flash slot only and disable flash rotate from now on (upgrade) + if (1 == rotate) { // Use eeprom flash slot only and disable flash rotate from now on (upgrade) TasmotaGlobal.stop_flash_rotate = 1; } - if (2 == rotate) { // Use eeprom flash slot and erase next flash slots if stop_flash_rotate is off (default) - settings_location = FLASH_EEPROM_START; - } - if (TasmotaGlobal.stop_flash_rotate) { - settings_location = FLASH_EEPROM_START; - } else { - if (settings_location == FLASH_EEPROM_START) { + + if (TasmotaGlobal.stop_flash_rotate || (2 == rotate)) { // Use eeprom flash slot and erase next flash slots if stop_flash_rotate is off (default) + settings_location = EEPROM_LOCATION; + } else { // Rotate flash slots + if (settings_location == EEPROM_LOCATION) { settings_location = SETTINGS_LOCATION; } else { settings_location--; } if (settings_location <= (SETTINGS_LOCATION - CFG_ROTATES)) { - settings_location = FLASH_EEPROM_START; + settings_location = EEPROM_LOCATION; } } @@ -534,7 +512,7 @@ void SettingsSave(uint8_t rotate) Settings.cfg_timestamp++; } Settings.cfg_size = sizeof(Settings); - Settings.cfg_crc = GetSettingsCrc(); // Keep for backward compatibility in case of fall-back just after upgrade + Settings.cfg_crc = GetSettingsCrc(); // Keep for backward compatibility in case of fall-back just after upgrade Settings.cfg_crc32 = GetSettingsCrc32(); #ifdef ESP8266 @@ -545,17 +523,17 @@ void SettingsSave(uint8_t rotate) ESP.flashWrite(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(Settings)); } - if (!TasmotaGlobal.stop_flash_rotate && rotate) { + if (!TasmotaGlobal.stop_flash_rotate && rotate) { // SetOption12 - (Settings) Switch between dynamic (0) or fixed (1) slot flash save location for (uint32_t i = 0; i < CFG_ROTATES; i++) { - ESP.flashEraseSector(SETTINGS_LOCATION -i); // Delete previous configurations by resetting to 0xFF + ESP.flashEraseSector(SETTINGS_LOCATION -i); // Delete previous configurations by resetting to 0xFF delay(1); } } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG D_SAVED_TO_FLASH_AT " %X, " D_COUNT " %d, " D_BYTES " %d"), settings_location, Settings.save_flag, sizeof(Settings)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG D_SAVED_TO_FLASH_AT " %X, " D_COUNT " %d, " D_BYTES " %d"), settings_location, Settings.save_flag, sizeof(Settings)); #endif // ESP8266 #ifdef ESP32 SettingsWrite(&Settings, sizeof(Settings)); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "Saved, " D_COUNT " %d, " D_BYTES " %d"), Settings.save_flag, sizeof(Settings)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG "Saved, " D_COUNT " %d, " D_BYTES " %d"), Settings.save_flag, sizeof(Settings)); #endif // ESP32 settings_crc32 = Settings.cfg_crc32; @@ -581,7 +559,7 @@ void SettingsLoad(void) { #endif // USE_UFILESYS while (slot <= max_slots) { // Read all config pages in search of valid and latest if (slot > 0) { - flash_location = (1 == slot) ? FLASH_EEPROM_START : (2 == slot) ? SETTINGS_LOCATION : flash_location -1; + flash_location = (1 == slot) ? EEPROM_LOCATION : (2 == slot) ? SETTINGS_LOCATION : flash_location -1; ESP.flashRead(flash_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(Settings)); } if ((Settings.cfg_crc32 != 0xFFFFFFFF) && (Settings.cfg_crc32 != 0x00000000) && (Settings.cfg_crc32 == GetSettingsCrc32())) { @@ -600,19 +578,19 @@ void SettingsLoad(void) { #ifdef USE_UFILESYS if (1 == settings_location) { TfsLoadFile(TASM_FILE_SETTINGS, (uint8_t*)&Settings, sizeof(Settings)); - AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded from File, " D_COUNT " %lu"), Settings.save_flag); + AddLog(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded from File, " D_COUNT " %lu"), Settings.save_flag); } else #endif // USE_UFILESYS { ESP.flashRead(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(Settings)); - AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %lu"), settings_location, Settings.save_flag); + AddLog(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %lu"), settings_location, Settings.save_flag); } } #endif // ESP8266 #ifdef ESP32 uint32_t source = SettingsRead(&Settings, sizeof(Settings)); if (source) { settings_location = 1; } - AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded from %s, " D_COUNT " %lu"), (source)?"File":"Nvm", Settings.save_flag); + AddLog(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded from %s, " D_COUNT " %lu"), (source)?"File":"Nvm", Settings.save_flag); #endif // ESP32 #ifndef FIRMWARE_MINIMAL @@ -620,7 +598,7 @@ void SettingsLoad(void) { #ifdef USE_UFILESYS if (TfsLoadFile(TASM_FILE_SETTINGS_LKG, (uint8_t*)&Settings, sizeof(Settings)) && (Settings.cfg_crc32 == GetSettingsCrc32())) { settings_location = 1; - AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded from LKG File, " D_COUNT " %lu"), Settings.save_flag); + AddLog(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG "Loaded from LKG File, " D_COUNT " %lu"), Settings.save_flag); } else #endif // USE_UFILESYS { @@ -639,8 +617,7 @@ uint32_t CfgTime(void) { } #ifdef ESP8266 -void SettingsErase(uint8_t type) -{ +void SettingsErase(uint8_t type) { /* For Arduino core and SDK: Erase only works from flash start address to SDK recognized flash end address (flashchip->chip_size = ESP.getFlashChipSize). @@ -672,7 +649,7 @@ void SettingsErase(uint8_t type) #endif */ EsptoolErase(_sectorStart, FLASH_FS_START); - _sectorStart = FLASH_EEPROM_START; + _sectorStart = EEPROM_LOCATION; _sectorEnd = ESP.getFlashChipSize() / SPI_FLASH_SEC_SIZE; // Flash size as seen by SDK } else if (3 == type) { // QPC Reached = QPC and Tasmota and SDK parameter area (0x0F3xxx - 0x0FFFFF) @@ -680,11 +657,11 @@ void SettingsErase(uint8_t type) TfsDeleteFile(TASM_FILE_SETTINGS); #endif EsptoolErase(SETTINGS_LOCATION - CFG_ROTATES, SETTINGS_LOCATION +1); - _sectorStart = FLASH_EEPROM_START; + _sectorStart = EEPROM_LOCATION; _sectorEnd = ESP.getFlashChipSize() / SPI_FLASH_SEC_SIZE; // Flash size as seen by SDK } else if (4 == type) { // WIFI_FORCE_RF_CAL_ERASE = SDK wifi calibration - _sectorStart = FLASH_EEPROM_START +1; // SDK phy area and Core calibration sector (0x0XFC000) + _sectorStart = EEPROM_LOCATION +1; // SDK phy area and Core calibration sector (0x0XFC000) _sectorEnd = _sectorStart +1; // SDK end of phy area and Core calibration sector (0x0XFCFFF) } @@ -693,8 +670,7 @@ void SettingsErase(uint8_t type) } #endif // ESP8266 -void SettingsSdkErase(void) -{ +void SettingsSdkErase(void) { WiFi.disconnect(false); // Delete SDK wifi config SettingsErase(1); delay(1000); @@ -702,16 +678,14 @@ void SettingsSdkErase(void) /********************************************************************************************/ -void SettingsDefault(void) -{ - AddLog_P(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_USE_DEFAULTS)); +void SettingsDefault(void) { + AddLog(LOG_LEVEL_NONE, PSTR(D_LOG_CONFIG D_USE_DEFAULTS)); SettingsDefaultSet1(); SettingsDefaultSet2(); SettingsSave(2); } -void SettingsDefaultSet1(void) -{ +void SettingsDefaultSet1(void) { memset(&Settings, 0x00, sizeof(Settings)); Settings.cfg_holder = (uint16_t)CFG_HOLDER; @@ -726,8 +700,7 @@ void SettingsDefaultSet1(void) const uint8_t default_fingerprint1[] PROGMEM = { MQTT_FINGERPRINT1 }; const uint8_t default_fingerprint2[] PROGMEM = { MQTT_FINGERPRINT2 }; -void SettingsDefaultSet2(void) -{ +void SettingsDefaultSet2(void) { memset((char*)&Settings +16, 0x00, sizeof(Settings) -16); // this little trick allows GCC to optimize the assignment by grouping values and doing only ORs @@ -1099,8 +1072,7 @@ void SettingsDefaultSet2(void) /********************************************************************************************/ -void SettingsResetStd(void) -{ +void SettingsResetStd(void) { Settings.tflag[0].hemis = TIME_STD_HEMISPHERE; Settings.tflag[0].week = TIME_STD_WEEK; Settings.tflag[0].dow = TIME_STD_DAY; @@ -1109,8 +1081,7 @@ void SettingsResetStd(void) Settings.toffset[0] = TIME_STD_OFFSET; } -void SettingsResetDst(void) -{ +void SettingsResetDst(void) { Settings.tflag[1].hemis = TIME_DST_HEMISPHERE; Settings.tflag[1].week = TIME_DST_WEEK; Settings.tflag[1].dow = TIME_DST_DAY; @@ -1119,16 +1090,14 @@ void SettingsResetDst(void) Settings.toffset[1] = TIME_DST_OFFSET; } -void SettingsDefaultWebColor(void) -{ +void SettingsDefaultWebColor(void) { char scolor[10]; for (uint32_t i = 0; i < COL_LAST; i++) { WebHexCode(i, GetTextIndexed(scolor, sizeof(scolor), i, kWebColors)); } } -void SettingsEnableAllI2cDrivers(void) -{ +void SettingsEnableAllI2cDrivers(void) { Settings.i2c_drivers[0] = 0xFFFFFFFF; Settings.i2c_drivers[1] = 0xFFFFFFFF; Settings.i2c_drivers[2] = 0xFFFFFFFF; @@ -1136,8 +1105,7 @@ void SettingsEnableAllI2cDrivers(void) /********************************************************************************************/ -void SettingsDelta(void) -{ +void SettingsDelta(void) { if (Settings.version != VERSION) { // Fix version dependent changes #ifdef ESP8266 diff --git a/tasmota/support.ino b/tasmota/support.ino index aac0aee21..3d4cd5338 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -49,10 +49,10 @@ void OsWatchTicker(void) #ifdef DEBUG_THEO int32_t rssi = WiFi.RSSI(); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_OSWATCH " FreeRam %d, rssi %d %% (%d dBm), last_run %d"), ESP_getFreeHeap(), WifiGetRssiAsQuality(rssi), rssi, last_run); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_OSWATCH " FreeRam %d, rssi %d %% (%d dBm), last_run %d"), ESP_getFreeHeap(), WifiGetRssiAsQuality(rssi), rssi, last_run); #endif // DEBUG_THEO if (last_run >= (OSWATCH_RESET_TIME * 1000)) { -// AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_OSWATCH " " D_BLOCKED_LOOP ". " D_RESTARTING)); // Save iram space +// AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_OSWATCH " " D_BLOCKED_LOOP ". " D_RESTARTING)); // Save iram space RtcSettings.oswatch_blocked_loop = 1; RtcSettingsSave(); @@ -322,26 +322,6 @@ int TextToInt(char *str) return strtol(str, &p, radix); } -char* ulltoa(unsigned long long value, char *str, int radix) -{ - char digits[64]; - char *dst = str; - int i = 0; - -// if (radix < 2 || radix > 36) { radix = 10; } - - do { - int n = value % radix; - digits[i++] = (n < 10) ? (char)n+'0' : (char)n-10+'A'; - value /= radix; - } while (value != 0); - - while (i > 0) { *dst++ = digits[--i]; } - - *dst = 0; - return str; -} - // see https://stackoverflow.com/questions/6357031/how-do-you-convert-a-byte-array-to-a-hexadecimal-string-in-c // char* ToHex_P(unsigned char * in, size_t insz, char * out, size_t outsz, char inbetween = '\0'); in tasmota_globals.h char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, char inbetween) @@ -363,24 +343,6 @@ char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, c return out; } -char* Uint64toHex(uint64_t value, char *str, uint16_t bits) -{ - ulltoa(value, str, 16); // Get 64bit value - - int fill = 8; - if ((bits > 3) && (bits < 65)) { - fill = bits / 4; // Max 16 - if (bits % 4) { fill++; } - } - int len = strlen(str); - fill -= len; - if (fill > 0) { - memmove(str + fill, str, len +1); - memset(str, '0', fill); - } - return str; -} - char* dtostrfd(double number, unsigned char prec, char *s) { if ((isnan(number)) || (isinf(number))) { // Fix for JSON output (https://stackoverflow.com/questions/1423081/json-left-out-infinity-and-nan-json-status-in-ecmascript) @@ -659,7 +621,6 @@ bool ValidIpAddress(const char* str) return ip_address.fromString(str); } - bool ParseIPv4(uint32_t* addr, const char* str_p) { uint8_t *part = (uint8_t*)addr; @@ -1042,7 +1003,7 @@ uint32_t GetSerialBaudrate(void) { void SetSerialBegin(void) { TasmotaGlobal.baudrate = Settings.baudrate * 300; - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_SERIAL "Set to %s %d bit/s"), GetSerialConfig().c_str(), TasmotaGlobal.baudrate); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_SERIAL "Set to %s %d bit/s"), GetSerialConfig().c_str(), TasmotaGlobal.baudrate); Serial.flush(); #ifdef ESP8266 Serial.begin(TasmotaGlobal.baudrate, (SerialConfig)pgm_read_byte(kTasmotaSerialConfig + Settings.serial_config)); @@ -1085,7 +1046,7 @@ void SetSerial(uint32_t baudrate, uint32_t serial_config) { void ClaimSerial(void) { TasmotaGlobal.serial_local = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("SNS: Hardware Serial")); + AddLog(LOG_LEVEL_INFO, PSTR("SNS: Hardware Serial")); SetSeriallog(LOG_LEVEL_NONE); TasmotaGlobal.baudrate = GetSerialBaudrate(); Settings.baudrate = TasmotaGlobal.baudrate / 300; @@ -1132,7 +1093,7 @@ void ShowSource(uint32_t source) { if ((source > 0) && (source < SRC_MAX)) { char stemp1[20]; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SRC: %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource)); + AddLog(LOG_LEVEL_DEBUG, PSTR("SRC: %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource)); } } @@ -1230,7 +1191,7 @@ int Response_P(const char* format, ...) // Content send snprintf_P char d // This uses char strings. Be aware of sending %% if % is needed va_list args; va_start(args, format); - int len = vsnprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), format, args); + int len = ext_vsnprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), format, args); va_end(args); return len; } @@ -1244,7 +1205,7 @@ int ResponseTime_P(const char* format, ...) // Content send snprintf_P char d ResponseGetTime(Settings.flag2.time_format, TasmotaGlobal.mqtt_data); int mlen = strlen(TasmotaGlobal.mqtt_data); - int len = vsnprintf_P(TasmotaGlobal.mqtt_data + mlen, sizeof(TasmotaGlobal.mqtt_data) - mlen, format, args); + int len = ext_vsnprintf_P(TasmotaGlobal.mqtt_data + mlen, sizeof(TasmotaGlobal.mqtt_data) - mlen, format, args); va_end(args); return len + mlen; } @@ -1255,7 +1216,7 @@ int ResponseAppend_P(const char* format, ...) // Content send snprintf_P char d va_list args; va_start(args, format); int mlen = strlen(TasmotaGlobal.mqtt_data); - int len = vsnprintf_P(TasmotaGlobal.mqtt_data + mlen, sizeof(TasmotaGlobal.mqtt_data) - mlen, format, args); + int len = ext_vsnprintf_P(TasmotaGlobal.mqtt_data + mlen, sizeof(TasmotaGlobal.mqtt_data) - mlen, format, args); va_end(args); return len + mlen; } @@ -1271,18 +1232,29 @@ int ResponseAppendTime(void) return ResponseAppendTimeFormat(Settings.flag2.time_format); } +// int ResponseAppendTHD(float f_temperature, float f_humidity) +// { +// char temperature[FLOATSZ]; +// dtostrfd(f_temperature, Settings.flag2.temperature_resolution, temperature); +// char humidity[FLOATSZ]; +// dtostrfd(f_humidity, Settings.flag2.humidity_resolution, humidity); +// char dewpoint[FLOATSZ]; +// dtostrfd(CalcTempHumToDew(f_temperature, f_humidity), Settings.flag2.temperature_resolution, dewpoint); + +// return ResponseAppend_P(PSTR("\"" D_JSON_TEMPERATURE "\":%s,\"" D_JSON_HUMIDITY "\":%s,\"" D_JSON_DEWPOINT "\":%s"), temperature, humidity, dewpoint); +// } + int ResponseAppendTHD(float f_temperature, float f_humidity) { - char temperature[FLOATSZ]; - dtostrfd(f_temperature, Settings.flag2.temperature_resolution, temperature); - char humidity[FLOATSZ]; - dtostrfd(f_humidity, Settings.flag2.humidity_resolution, humidity); - char dewpoint[FLOATSZ]; - dtostrfd(CalcTempHumToDew(f_temperature, f_humidity), Settings.flag2.temperature_resolution, dewpoint); + float dewpoint = CalcTempHumToDew(f_temperature, f_humidity); - return ResponseAppend_P(PSTR("\"" D_JSON_TEMPERATURE "\":%s,\"" D_JSON_HUMIDITY "\":%s,\"" D_JSON_DEWPOINT "\":%s"), temperature, humidity, dewpoint); + return ResponseAppend_P(PSTR("\"" D_JSON_TEMPERATURE "\":%*_f,\"" D_JSON_HUMIDITY "\":%*_f,\"" D_JSON_DEWPOINT "\":%*_f"), + Settings.flag2.temperature_resolution, &f_temperature, + Settings.flag2.humidity_resolution, &f_humidity, + Settings.flag2.temperature_resolution, &dewpoint); } + int ResponseJsonEnd(void) { return ResponseAppend_P(PSTR("}")); @@ -1321,7 +1293,7 @@ void TemplateConvert(uint8_t template8[], uint16_t template16[]) { } template16[(sizeof(mytmplt) / 2) -2] = Adc0Convert(template8[sizeof(mytmplt8285) -1]); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("FNC: TemplateConvert")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("FNC: TemplateConvert")); // AddLogBuffer(LOG_LEVEL_DEBUG, template8, sizeof(mytmplt8285)); // AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)template16, sizeof(mytmplt) / 2, 2); } @@ -1337,7 +1309,7 @@ void ConvertGpios(void) { Settings.my_gp.io[(sizeof(myio) / 2) -1] = Adc0Convert(Settings.ex_my_adc0); Settings.gpio16_converted = 0xF5A0; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("FNC: ConvertGpios")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("FNC: ConvertGpios")); // AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t *)&Settings.ex_my_gp8.io, sizeof(myio8)); // AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t *)&Settings.my_gp.io, sizeof(myio) / 2, 2); } @@ -1488,7 +1460,7 @@ String ModuleName(void) void GetInternalTemplate(void* ptr, uint32_t module, uint32_t option) { uint8_t module_template = pgm_read_byte(kModuleTemplateList + module); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Template %d, Option %d"), module_template, option); +// AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Template %d, Option %d"), module_template, option); // template8 = GPIO 0,1,2,3,4,5,9,10,12,13,14,15,16,Adc uint8_t template8[sizeof(mytmplt8285)] = { GPIO_NONE }; @@ -1520,7 +1492,7 @@ void GetInternalTemplate(void* ptr, uint32_t module, uint32_t option) { } memcpy(ptr, &template16[index], size); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("FNC: GetInternalTemplate option %d"), option); +// AddLog(LOG_LEVEL_DEBUG, PSTR("FNC: GetInternalTemplate option %d"), option); // AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t *)ptr, size / 2, 2); } #endif // ESP8266 @@ -1674,7 +1646,7 @@ bool JsonTemplate(char* dataBuf) } if (old_template) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TPL: Converting template ...")); + AddLog(LOG_LEVEL_DEBUG, PSTR("TPL: Converting template ...")); val = root[PSTR(D_JSON_FLAG)]; if (val) { @@ -1708,7 +1680,7 @@ bool JsonTemplate(char* dataBuf) Settings.user_template_base = base -1; // Default WEMOS } -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TPL: Converted")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("TPL: Converted")); // AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)&Settings.user_template, sizeof(Settings.user_template) / 2, 2); return true; @@ -1716,7 +1688,7 @@ bool JsonTemplate(char* dataBuf) void TemplateJson(void) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TPL: Show")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("TPL: Show")); // AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)&Settings.user_template, sizeof(Settings.user_template) / 2, 2); Response_P(PSTR("{\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), SettingsText(SET_TEMPLATE_NAME)); @@ -1989,7 +1961,7 @@ void I2cResetActive(uint32_t addr, uint32_t count = 1) i2c_active[addr / 32] &= ~(1 << (addr % 32)); addr++; } -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("I2C: Active %08X,%08X,%08X,%08X"), i2c_active[0], i2c_active[1], i2c_active[2], i2c_active[3]); +// AddLog(LOG_LEVEL_DEBUG, PSTR("I2C: Active %08X,%08X,%08X,%08X"), i2c_active[0], i2c_active[1], i2c_active[2], i2c_active[3]); } void I2cSetActive(uint32_t addr, uint32_t count = 1) @@ -2000,13 +1972,13 @@ void I2cSetActive(uint32_t addr, uint32_t count = 1) i2c_active[addr / 32] |= (1 << (addr % 32)); addr++; } -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("I2C: Active %08X,%08X,%08X,%08X"), i2c_active[0], i2c_active[1], i2c_active[2], i2c_active[3]); +// AddLog(LOG_LEVEL_DEBUG, PSTR("I2C: Active %08X,%08X,%08X,%08X"), i2c_active[0], i2c_active[1], i2c_active[2], i2c_active[3]); } void I2cSetActiveFound(uint32_t addr, const char *types) { I2cSetActive(addr); - AddLog_P(LOG_LEVEL_INFO, S_LOG_I2C_FOUND_AT, types, addr); + AddLog(LOG_LEVEL_INFO, S_LOG_I2C_FOUND_AT, types, addr); } bool I2cActive(uint32_t addr) @@ -2033,7 +2005,7 @@ bool I2cSetDevice(uint32_t addr) * Syslog * * Example: - * AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_LOG "Any value %d"), value); + * AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_LOG "Any value %d"), value); * \*********************************************************************************************/ @@ -2074,7 +2046,7 @@ void SyslogAsync(bool refresh) { if (!PortUdp.beginPacket(syslog_host_addr, Settings.syslog_port)) { TasmotaGlobal.syslog_level = 0; TasmotaGlobal.syslog_timer = SYSLOG_TIMER; - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_HOST_NOT_FOUND ". " D_RETRY_IN " %d " D_UNIT_SECOND), SYSLOG_TIMER); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_HOST_NOT_FOUND ". " D_RETRY_IN " %d " D_UNIT_SECOND), SYSLOG_TIMER); return; } char log_data[len +72]; // Hostname + Id + log data @@ -2204,13 +2176,13 @@ void AddLogData(uint32_t loglevel, const char* log_data) { } } -void AddLog_P(uint32_t loglevel, PGM_P formatP, ...) -{ +void AddLog(uint32_t loglevel, PGM_P formatP, ...) { + // To save stack space support logging for max text length of 128 characters char log_data[LOGSZ +4]; va_list arg; va_start(arg, formatP); - uint32_t len = vsnprintf_P(log_data, LOGSZ +1, formatP, arg); + uint32_t len = ext_vsnprintf_P(log_data, LOGSZ +1, formatP, arg); va_end(arg); if (len > LOGSZ) { strcat(log_data, "..."); } // Actual data is more @@ -2219,31 +2191,34 @@ void AddLog_P(uint32_t loglevel, PGM_P formatP, ...) static uint32_t max_len = 0; if (len > max_len) { max_len = len; - Serial.printf("PRF: AddLog_P %d\n", max_len); + Serial.printf("PRF: AddLog %d\n", max_len); } #endif AddLogData(loglevel, log_data); } +void AddLog_P(uint32_t loglevel, PGM_P formatP, ...) { + // Use more stack space to support logging for max text length of 700 characters + char log_data[MAX_LOGSZ]; + + va_list arg; + va_start(arg, formatP); + uint32_t len = ext_vsnprintf_P(log_data, sizeof(log_data), formatP, arg); + va_end(arg); + + AddLogData(loglevel, log_data); +} + void AddLog_Debug(PGM_P formatP, ...) { char log_data[MAX_LOGSZ]; va_list arg; va_start(arg, formatP); - uint32_t len = vsnprintf_P(log_data, sizeof(log_data), formatP, arg); + uint32_t len = ext_vsnprintf_P(log_data, sizeof(log_data), formatP, arg); va_end(arg); -#ifdef DEBUG_TASMOTA_CORE - // Profile max_len - static uint32_t max_len = 0; - if (len > max_len) { - max_len = len; - Serial.printf("PRF: AddLog_Debug %d\n", max_len); - } -#endif - AddLogData(LOG_LEVEL_DEBUG, log_data); } @@ -2260,7 +2235,7 @@ void AddLogSerial(uint32_t loglevel) void AddLogMissed(const char *sensor, uint32_t misses) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SNS: %s missed %d"), sensor, SENSOR_MAX_MISS - misses); + AddLog(LOG_LEVEL_DEBUG, PSTR("SNS: %s missed %d"), sensor, SENSOR_MAX_MISS - misses); } void AddLogBufferSize(uint32_t loglevel, uint8_t *buffer, uint32_t count, uint32_t size) { @@ -2283,15 +2258,15 @@ void AddLogSpi(bool hardware, uint32_t clk, uint32_t mosi, uint32_t miso) { uint32_t enabled = (hardware) ? TasmotaGlobal.spi_enabled : TasmotaGlobal.soft_spi_enabled; switch(enabled) { case SPI_MOSI: - AddLog_P(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK) and GPIO%02d(MOSI)"), + AddLog(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK) and GPIO%02d(MOSI)"), (hardware) ? PSTR("Hardware") : PSTR("Software"), clk, mosi); break; case SPI_MISO: - AddLog_P(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK) and GPIO%02d(MISO)"), + AddLog(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK) and GPIO%02d(MISO)"), (hardware) ? PSTR("Hardware") : PSTR("Software"), clk, miso); break; case SPI_MOSI_MISO: - AddLog_P(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK), GPIO%02d(MOSI) and GPIO%02d(MISO)"), + AddLog(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK), GPIO%02d(MOSI) and GPIO%02d(MISO)"), (hardware) ? PSTR("Hardware") : PSTR("Software"), clk, mosi, miso); break; } diff --git a/tasmota/support_button.ino b/tasmota/support_button.ino index f1bd22c0f..d5262f517 100644 --- a/tasmota/support_button.ino +++ b/tasmota/support_button.ino @@ -146,7 +146,7 @@ void ButtonHandler(void) { if (!button_index && ((SONOFF_DUAL == TasmotaGlobal.module_type) || (CH4 == TasmotaGlobal.module_type))) { button_present = 1; if (Button.dual_code) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON " " D_CODE " %04X"), Button.dual_code); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON " " D_CODE " %04X"), Button.dual_code); button = PRESSED; if (0xF500 == Button.dual_code) { // Button hold Button.hold_timer[button_index] = (loops_per_second * Settings.param[P_HOLD_TIME] / 10) -1; // SetOption32 (40) @@ -176,7 +176,7 @@ void ButtonHandler(void) { Button.touch_hits[button_index] = 0; } if (bitRead(TOUCH_BUTTON.calibration, button_index+1)) { - AddLog_P(LOG_LEVEL_INFO, PSTR("PLOT: %u, %u, %u,"), button_index+1, _value, Button.touch_hits[button_index]); // Button number (1..4), value, continuous hits under threshold + AddLog(LOG_LEVEL_INFO, PSTR("PLOT: %u, %u, %u,"), button_index+1, _value, Button.touch_hits[button_index]); // Button number (1..4), value, continuous hits under threshold } } else #endif // ESP32 @@ -206,12 +206,12 @@ void ButtonHandler(void) { bool button_pressed = false; if ((PRESSED == button) && (NOT_PRESSED == Button.last_state[button_index])) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_10), button_index +1); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_10), button_index +1); Button.hold_timer[button_index] = loops_per_second; button_pressed = true; } if ((NOT_PRESSED == button) && (PRESSED == Button.last_state[button_index])) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_01), button_index +1); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_01), button_index +1); if (!Button.hold_timer[button_index]) { button_pressed = true; } // Do not allow within 1 second } if (button_pressed) { @@ -230,7 +230,7 @@ void ButtonHandler(void) { if (Settings.flag.button_single) { // SetOption13 (0) - Allow only single button press for immediate action, if (!Settings.flag3.mqtt_buttons) { // SetOption73 (0) - Decouple button from relay and send just mqtt topic - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_IMMEDIATE), button_index +1); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_IMMEDIATE), button_index +1); if (!SendKey(KEY_BUTTON, button_index +1, POWER_TOGGLE)) { // Execute Toggle command via MQTT if ButtonTopic is set ExecuteCommandPower(button_index +1, POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally } @@ -239,7 +239,7 @@ void ButtonHandler(void) { } } else { Button.press_counter[button_index] = (Button.window_timer[button_index]) ? Button.press_counter[button_index] +1 : 1; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_MULTI_PRESS " %d"), button_index +1, Button.press_counter[button_index]); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_MULTI_PRESS " %d"), button_index +1, Button.press_counter[button_index]); Button.window_timer[button_index] = loops_per_second / 2; // 0.5 second multi press window } TasmotaGlobal.blinks = 201; @@ -327,7 +327,7 @@ void ButtonHandler(void) { #endif // ESP8266 if ((Button.press_counter[button_index] > 1) && valid_relay && (Button.press_counter[button_index] <= MAX_RELAY_BUTTON1)) { ExecuteCommandPower(button_index + Button.press_counter[button_index], POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Relay%d found on GPIO%d"), Button.press_counter[button_index], Pin(GPIO_REL1, Button.press_counter[button_index]-1)); +// AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Relay%d found on GPIO%d"), Button.press_counter[button_index], Pin(GPIO_REL1, Button.press_counter[button_index]-1)); } } } diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 5b3801538..1dd0cac0a 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -227,7 +227,7 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len) type[i] = '\0'; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CMD: " D_GROUP " %d, " D_INDEX " %d, " D_COMMAND " \"%s\", " D_DATA " \"%s\""), grpflg, index, type, dataBuf); + AddLog(LOG_LEVEL_DEBUG, PSTR("CMD: " D_GROUP " %d, " D_INDEX " %d, " D_COMMAND " \"%s\", " D_DATA " \"%s\""), grpflg, index, type, dataBuf); if (type != nullptr) { Response_P(PSTR("{\"" D_JSON_COMMAND "\":\"" D_JSON_ERROR "\"}")); @@ -744,7 +744,7 @@ void CmndRestart(void) CmndBlockedLoop(); break; case 99: - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING)); EspRestart(); break; default: @@ -1198,18 +1198,21 @@ void CmndGpio(void) sensor_names = kSensorNamesFixed; } char stemp1[TOPSZ]; - if ((ResponseAppend_P(PSTR("\"" D_CMND_GPIO "%d\":{\"%d\":\"%s%s\"}"), i, sensor_type, GetTextIndexed(stemp1, sizeof(stemp1), sensor_name_idx, sensor_names), sindex) > (MAX_LOGSZ - TOPSZ)) || (i == ARRAY_SIZE(Settings.my_gp.io) -1)) { + if ((ResponseAppend_P(PSTR("\"" D_CMND_GPIO "%d\":{\"%d\":\"%s%s\"}"), i, sensor_type, GetTextIndexed(stemp1, sizeof(stemp1), sensor_name_idx, sensor_names), sindex) > (MAX_LOGSZ - TOPSZ))) { ResponseJsonEnd(); MqttPublishPrefixTopic_P(RESULT_OR_STAT, XdrvMailbox.command); + ResponseClear(); jsflg2 = true; jsflg = false; } } } - if (jsflg2) { - ResponseClear(); + if (jsflg) { + ResponseJsonEnd(); } else { - ResponseCmndChar(PSTR(D_JSON_NOT_SUPPORTED)); + if (!jsflg2) { + ResponseCmndChar(PSTR(D_JSON_NOT_SUPPORTED)); + } } } } @@ -2117,7 +2120,7 @@ void CmndTouchCal(void) } Response_P(PSTR("{\"" D_CMND_TOUCH_CAL "\": %u"), TOUCH_BUTTON.calibration); ResponseJsonEnd(); - AddLog_P(LOG_LEVEL_INFO, PSTR("Button Touchvalue Hits,")); + AddLog(LOG_LEVEL_INFO, PSTR("Button Touchvalue Hits,")); } void CmndTouchThres(void) diff --git a/tasmota/support_device_groups.ino b/tasmota/support_device_groups.ino index 5ab856cd6..dc79de635 100644 --- a/tasmota/support_device_groups.ino +++ b/tasmota/support_device_groups.ino @@ -66,6 +66,13 @@ bool device_groups_up = false; bool building_status_message = false; bool ignore_dgr_sends = false; +char * IPAddressToString(const IPAddress& ip_address) +{ + static char buffer[16]; + sprintf_P(buffer, PSTR("%u.%u.%u.%u"), ip_address[0], ip_address[1], ip_address[2], ip_address[3]); + return buffer; +} + uint8_t * BeginDeviceGroupMessage(struct device_group * device_group, uint16_t flags, bool hold_sequence = false) { uint8_t * message_ptr = &device_group->message[device_group->message_header_length]; @@ -129,7 +136,7 @@ void DeviceGroupsInit(void) // Initialize the device information for each device group. device_groups = (struct device_group *)calloc(device_group_count, sizeof(struct device_group)); if (!device_groups) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("DGR: Error allocating %u-element array"), device_group_count); + AddLog(LOG_LEVEL_ERROR, PSTR("DGR: Error allocating %u-element array"), device_group_count); return; } @@ -169,7 +176,7 @@ void DeviceGroupsStart() // Subscribe to device groups multicasts. if (!device_groups_udp.beginMulticast(WiFi.localIP(), IPAddress(DEVICE_GROUPS_ADDRESS), DEVICE_GROUPS_PORT)) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("DGR: Error subscribing")); + AddLog(LOG_LEVEL_ERROR, PSTR("DGR: Error subscribing")); return; } device_groups_up = true; @@ -185,7 +192,7 @@ void DeviceGroupsStart() device_group->initial_status_requests_remaining = 10; device_group->next_ack_check_time = next_check_time; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: (Re)discovering members")); + AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: (Re)discovering members")); } } @@ -218,7 +225,7 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de flags |= *message_ptr++ << 8; // Initialize the log buffer. - log_length = sprintf(log_buffer, PSTR("DGR: %s %s message %s %s: seq=%u, flags=%u"), (received ? PSTR("Received") : PSTR("Sending")), device_group->group_name, (received ? PSTR("from") : PSTR("to")), (device_group_member ? device_group_member->ip_address.toString().c_str() : received ? PSTR("local") : PSTR("network")), message_sequence, flags); + log_length = sprintf(log_buffer, PSTR("DGR: %s %s message %s %s: seq=%u, flags=%u"), (received ? PSTR("Received") : PSTR("Sending")), device_group->group_name, (received ? PSTR("from") : PSTR("to")), (device_group_member ? IPAddressToString(device_group_member->ip_address) : received ? PSTR("local") : PSTR("network")), message_sequence, flags); log_ptr = log_buffer + log_length; log_remaining = sizeof(log_buffer) - log_length; @@ -318,7 +325,7 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de case DGR_ITEM_LIGHT_CHANNELS: break; default: - AddLog_P(LOG_LEVEL_ERROR, PSTR("DGR: *** Invalid item=%u"), item); + AddLog(LOG_LEVEL_ERROR, PSTR("DGR: *** Invalid item=%u"), item); } #endif // DEVICE_GROUPS_DEBUG @@ -439,12 +446,12 @@ write_log: } delay(10); } - if (attempt > 5) AddLog_P(LOG_LEVEL_ERROR, PSTR("DGR: Error sending message")); + if (attempt > 5) AddLog(LOG_LEVEL_ERROR, PSTR("DGR: Error sending message")); } goto cleanup; badmsg: - AddLog_P(LOG_LEVEL_ERROR, PSTR("%s ** incorrect length"), log_buffer); + AddLog(LOG_LEVEL_ERROR, PSTR("%s ** incorrect length"), log_buffer); cleanup: if (received) { @@ -476,7 +483,7 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes // Load the message header, sequence and flags. #ifdef DEVICE_GROUPS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Building %s %spacket"), device_group->group_name, (message_type == DGR_MSGTYP_FULL_STATUS ? PSTR("full status ") : PSTR(""))); + AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Building %s %spacket"), device_group->group_name, (message_type == DGR_MSGTYP_FULL_STATUS ? PSTR("full status ") : PSTR(""))); #endif // DEVICE_GROUPS_DEBUG uint16_t original_sequence = device_group->outgoing_sequence; uint16_t flags = 0; @@ -498,7 +505,12 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes building_status_message = true; // Call the drivers to build the status update. - SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_POWER, TasmotaGlobal.power); + power_t power = TasmotaGlobal.power; + if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups + power >>= device_group_index; + power &= 1; + } + SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_PARTIAL_UPDATE, DGR_ITEM_POWER, power); XdrvMailbox.index = 0; if (device_group_index == 0 && first_device_group_is_local) XdrvMailbox.index = DGR_FLAG_LOCAL; XdrvMailbox.command_code = DGR_ITEM_STATUS; @@ -647,7 +659,7 @@ bool _SendDeviceGroupMessage(uint8_t device_group_index, DevGroupMessageType mes previous_message_ptr += value; } #ifdef DEVICE_GROUPS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: %u items carried over"), kept_item_count); + AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: %u items carried over"), kept_item_count); #endif // DEVICE_GROUPS_DEBUG } @@ -765,12 +777,12 @@ void ProcessDeviceGroupMessage(uint8_t * message, int message_length) if (!device_group_member) { device_group_member = (struct device_group_member *)calloc(1, sizeof(struct device_group_member)); if (device_group_member == nullptr) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("DGR: Error allocating member block")); + AddLog(LOG_LEVEL_ERROR, PSTR("DGR: Error allocating member block")); return; } device_group_member->ip_address = remote_ip; *flink = device_group_member; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Member %s added"), remote_ip.toString().c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Member %s added"), IPAddressToString(remote_ip)); break; } else if (device_group_member->ip_address == remote_ip) { @@ -790,7 +802,7 @@ void DeviceGroupStatus(uint8_t device_group_index) struct device_group * device_group = &device_groups[device_group_index]; buffer[0] = buffer[1] = 0; for (struct device_group_member * device_group_member = device_group->device_group_members; device_group_member; device_group_member = device_group_member->flink) { - snprintf_P(buffer, sizeof(buffer), PSTR("%s,{\"IPAddress\":\"%s\",\"ResendCount\":%u,\"LastRcvdSeq\":%u,\"LastAckedSeq\":%u}"), buffer, device_group_member->ip_address.toString().c_str(), device_group_member->unicast_count, device_group_member->received_sequence, device_group_member->acked_sequence); + snprintf_P(buffer, sizeof(buffer), PSTR("%s,{\"IPAddress\":\"%s\",\"ResendCount\":%u,\"LastRcvdSeq\":%u,\"LastAckedSeq\":%u}"), buffer, IPAddressToString(device_group_member->ip_address), device_group_member->unicast_count, device_group_member->received_sequence, device_group_member->acked_sequence); member_count++; } Response_P(PSTR("{\"" D_CMND_DEVGROUPSTATUS "\":{\"Index\":%u,\"GroupName\":\"%s\",\"MessageSeq\":%u,\"MemberCount\":%d,\"Members\":[%s]}}"), device_group_index, device_group->group_name, device_group->outgoing_sequence, member_count, &buffer[1]); @@ -817,7 +829,7 @@ void DeviceGroupsLoop(void) // If it's time to check on things, iterate through the device groups. if ((long)(now - next_check_time) >= 0) { #ifdef DEVICE_GROUPS_DEBUG -AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next_check_time, now); +AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next_check_time, now); #endif // DEVICE_GROUPS_DEBUG next_check_time = now + DGR_ANNOUNCEMENT_INTERVAL * 2; @@ -834,7 +846,7 @@ AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next if (device_group->initial_status_requests_remaining) { if (--device_group->initial_status_requests_remaining) { #ifdef DEVICE_GROUPS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Sending initial status request for group %s"), device_group->group_name); + AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Sending initial status request for group %s"), device_group->group_name); #endif // DEVICE_GROUPS_DEBUG SendReceiveDeviceGroupMessage(device_group, nullptr, device_group->message, device_group->message_length, false); device_group->message[device_group->message_header_length + 2] = DGR_FLAG_STATUS_REQUEST; // The reset flag is on only for the first packet - turn it off now @@ -852,7 +864,7 @@ AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next // If we're done initializing, iterate through the group memebers, ... else { #ifdef DEVICE_GROUPS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Checking for ack's")); + AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Checking for ack's")); #endif // DEVICE_GROUPS_DEBUG bool acked = true; struct device_group_member ** flink = &device_group->device_group_members; @@ -867,7 +879,7 @@ AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next if ((long)(now - device_group->member_timeout_time) >= 0) { *flink = device_group_member->flink; free(device_group_member); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Member %s removed"), device_group_member->ip_address.toString().c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: Member %s removed"), IPAddressToString(device_group_member->ip_address)); continue; } @@ -905,7 +917,7 @@ AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: Checking next_check_time=%u, now=%u"), next // announcement interval plus a random number of milliseconds so that even if all the devices // booted at the same time, they don't all multicast their announcements at the same time. #ifdef DEVICE_GROUPS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DGR: next_announcement_time=%u, now=%u"), device_group->next_announcement_time, now); + AddLog(LOG_LEVEL_DEBUG, PSTR("DGR: next_announcement_time=%u, now=%u"), device_group->next_announcement_time, now); #endif // DEVICE_GROUPS_DEBUG if ((long)(now - device_group->next_announcement_time) >= 0) { SendReceiveDeviceGroupMessage(device_group, nullptr, device_group->message, BeginDeviceGroupMessage(device_group, DGR_FLAG_ANNOUNCEMENT, true) - device_group->message, false); diff --git a/tasmota/support_esp32.ino b/tasmota/support_esp32.ino index 7bbad6468..8e6415bbd 100644 --- a/tasmota/support_esp32.ino +++ b/tasmota/support_esp32.ino @@ -150,13 +150,13 @@ void SettingsErase(uint8_t type) { r1 = NvmErase("qpc"); r2 = NvmErase("main"); r3 = TfsDeleteFile(TASM_FILE_SETTINGS); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " Tasmota data (%d,%d,%d)"), r1, r2, r3); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " Tasmota data (%d,%d,%d)"), r1, r2, r3); break; case 1: // Reset 3 = SDK parameter area case 4: // WIFI_FORCE_RF_CAL_ERASE = SDK parameter area r1 = esp_phy_erase_cal_data_in_nvs(); // r1 = NvmErase("cal_data"); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " PHY data (%d)"), r1); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " PHY data (%d)"), r1); break; case 3: // QPC Reached = QPC, Tasmota and SDK parameter area (0x0F3xxx - 0x0FFFFF) // nvs_flash_erase(); // Erase RTC, PHY, sta.mac, ap.sndchan, ap.mac, Tasmota etc. @@ -164,9 +164,9 @@ void SettingsErase(uint8_t type) { r2 = NvmErase("main"); // r3 = esp_phy_erase_cal_data_in_nvs(); // r3 = NvmErase("cal_data"); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " Tasmota (%d,%d) and PHY data (%d)"), r1, r2, r3); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " Tasmota (%d,%d) and PHY data (%d)"), r1, r2, r3); r3 = TfsDeleteFile(TASM_FILE_SETTINGS); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " Tasmota data (%d,%d,%d)"), r1, r2, r3); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " Tasmota data (%d,%d,%d)"), r1, r2, r3); break; } } @@ -196,7 +196,7 @@ void QPCWrite(const void *pSettings, unsigned nSettingsLen) { void NvsInfo(void) { nvs_stats_t nvs_stats; nvs_get_stats(NULL, &nvs_stats); - AddLog_P(LOG_LEVEL_INFO, PSTR("NVS: Used %d/%d entries, NameSpaces %d"), + AddLog(LOG_LEVEL_INFO, PSTR("NVS: Used %d/%d entries, NameSpaces %d"), nvs_stats.used_entries, nvs_stats.total_entries, nvs_stats.namespace_count); } @@ -240,7 +240,7 @@ uint8_t* EspFlashMmap(uint32_t address) { int32_t err = spi_flash_mmap(address, 5 * SPI_FLASH_MMU_PAGE_SIZE, SPI_FLASH_MMAP_DATA, (const void **)&data, &handle); /* - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Spi_flash_map %d"), err); + AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Spi_flash_map %d"), err); spi_flash_mmap_dump(); */ @@ -258,7 +258,7 @@ int32_t EspPartitionMmap(uint32_t action) { if (!partition) { return 0; } err = esp_partition_mmap(partition, 0, 4 * SPI_FLASH_MMU_PAGE_SIZE, SPI_FLASH_MMAP_DATA, (const void **)&TasmotaGlobal_mmap_data, &handle); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Partition start 0x%08X, Partition end 0x%08X, Mmap data 0x%08X"), partition->address, partition->size, TasmotaGlobal_mmap_data); + AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Partition start 0x%08X, Partition end 0x%08X, Mmap data 0x%08X"), partition->address, partition->size, TasmotaGlobal_mmap_data); } else { spi_flash_munmap(handle); @@ -407,7 +407,7 @@ uint8_t* FlashDirectAccess(void) { uint32_t address = FlashWriteStartSector() * SPI_FLASH_SEC_SIZE; uint8_t* data = EspFlashMmap(address); /* - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Flash start address 0x%08X, Mmap address 0x%08X"), address, data); + AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Flash start address 0x%08X, Mmap address 0x%08X"), address, data); uint8_t buf[32]; memcpy(buf, data, sizeof(buf)); diff --git a/tasmota/support_esptool.ino b/tasmota/support_esptool.ino index a066838af..ebae51c75 100644 --- a/tasmota/support_esptool.ino +++ b/tasmota/support_esptool.ino @@ -95,7 +95,7 @@ bool EsptoolEraseSector(uint32_t sector) void EsptoolErase(uint32_t start_sector, uint32_t end_sector) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " from 0x%08X to 0x%08X"), start_sector * SPI_FLASH_SEC_SIZE, (end_sector * SPI_FLASH_SEC_SIZE) -1); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " from 0x%08X to 0x%08X"), start_sector * SPI_FLASH_SEC_SIZE, (end_sector * SPI_FLASH_SEC_SIZE) -1); int next_erase_sector = start_sector; int remaining_erase_sector = end_sector - start_sector; diff --git a/tasmota/support_features.ino b/tasmota/support_features.ino index a5134c1c1..1d17193e5 100644 --- a/tasmota/support_features.ino +++ b/tasmota/support_features.ino @@ -661,7 +661,6 @@ void ResponseAppendFeatures(void) #ifdef USE_AS608 feature7 |= 0x00000800; // xsns_79_as608.ino #endif - #if defined(USE_SHELLY_DIMMER) feature7 |= 0x00001000; // xdrv_45_shelly_dimmer.ino #endif @@ -701,7 +700,7 @@ void ResponseAppendFeatures(void) #ifdef USE_BS814A2 feature7 |= 0x01000000; // xdrv_51_bs814a2.ino #endif -#ifdef USE_SEESAW_SOIL +#if defined(USE_I2C) && defined(USE_SEESAW_SOIL) feature7 |= 0x02000000; // xsns_81_seesaw_soil.ino #endif #ifdef USE_WIEGAND @@ -710,15 +709,59 @@ void ResponseAppendFeatures(void) #ifdef USE_NEOPOOL feature7 |= 0x08000000; // xsns_83_neopool.ino #endif - -// feature7 |= 0x10000000; +#if defined(USE_I2C) && defined(USE_TOF10120) + feature7 |= 0x10000000; // xsns_84_tof10120 +#endif // feature7 |= 0x20000000; // feature7 |= 0x40000000; // feature7 |= 0x80000000; } + static uint32_t feature8 = 0x00000000; + if (!feature8) { // Only fill this once +// feature8 |= 0x00000001; +// feature8 |= 0x00000002; +// feature8 |= 0x00000004; +// feature8 |= 0x00000008; + +// feature8 |= 0x00000010; +// feature8 |= 0x00000020; +// feature8 |= 0x00000040; +// feature8 |= 0x00000080; + +// feature8 |= 0x00000100; +// feature8 |= 0x00000200; +// feature8 |= 0x00000400; +// feature8 |= 0x00000800; + +// feature8 |= 0x00001000; +// feature8 |= 0x00002000; +// feature8 |= 0x00004000; +// feature8 |= 0x00008000; + +// feature8 |= 0x00010000; +// feature8 |= 0x00020000; +// feature8 |= 0x00040000; +// feature8 |= 0x00080000; + +// feature8 |= 0x00100000; +// feature8 |= 0x00200000; +// feature8 |= 0x00400000; +// feature8 |= 0x00800000; + +// feature8 |= 0x01000000; +// feature8 |= 0x02000000; +// feature8 |= 0x04000000; +// feature8 |= 0x08000000; + +// feature8 |= 0x10000000; +// feature8 |= 0x20000000; +// feature8 |= 0x40000000; +// feature8 |= 0x80000000; + } + /*********************************************************************************************/ - ResponseAppend_P(PSTR(",\"" D_JSON_FEATURES "\":[\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\"]"), - LANGUAGE_LCID, feature1, feature2, feature3, feature4, feature5, feature6, feature7); + ResponseAppend_P(PSTR(",\"" D_JSON_FEATURES "\":[\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\",\"%08X\"]"), + LANGUAGE_LCID, feature1, feature2, feature3, feature4, feature5, feature6, feature7, feature8); } diff --git a/tasmota/support_float.ino b/tasmota/support_float.ino index 2bdf32ef2..e2877e5a3 100644 --- a/tasmota/support_float.ino +++ b/tasmota/support_float.ino @@ -136,7 +136,7 @@ double TaylorLog(double x) dtostrfd(log1, 8, log1s); char log2s[33]; dtostrfd(totalValue, 8, log2s); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("input %s, log %s, taylor %s"), logxs, log1s, log2s); + AddLog(LOG_LEVEL_DEBUG, PSTR("input %s, log %s, taylor %s"), logxs, log1s, log2s); */ return totalValue; } diff --git a/tasmota/support_network.ino b/tasmota/support_network.ino index e2b24d782..242c03121 100644 --- a/tasmota/support_network.ino +++ b/tasmota/support_network.ino @@ -32,13 +32,13 @@ void StartMdns(void) { if (Settings.flag3.mdns_enabled) { // SetOption55 - Control mDNS service if (!Mdns.begun) { // if (mdns_delayed_start) { -// AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_ATTEMPTING_CONNECTION)); +// AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_ATTEMPTING_CONNECTION)); // mdns_delayed_start--; // } else { // mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START]; MDNS.end(); // close existing or MDNS.begin will fail Mdns.begun = (uint8_t)MDNS.begin(TasmotaGlobal.hostname); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS "%s"), (Mdns.begun) ? PSTR(D_INITIALIZED) : PSTR(D_FAILED)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS "%s"), (Mdns.begun) ? PSTR(D_INITIALIZED) : PSTR(D_FAILED)); // } } } @@ -51,7 +51,7 @@ void MqttDiscoverServer(void) int n = MDNS.queryService("mqtt", "tcp"); // Search for mqtt service - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_QUERY_DONE " %d"), n); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_QUERY_DONE " %d"), n); if (n > 0) { uint32_t i = 0; // If the hostname isn't set, use the first record found. @@ -65,7 +65,7 @@ void MqttDiscoverServer(void) SettingsUpdateText(SET_MQTT_HOST, MDNS.hostname(i).c_str()); Settings.mqtt_port = MDNS.port(i); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_MQTT_SERVICE_FOUND " %s," D_PORT " %d"), SettingsText(SET_MQTT_HOST), Settings.mqtt_port); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_MQTT_SERVICE_FOUND " %s," D_PORT " %d"), SettingsText(SET_MQTT_HOST), Settings.mqtt_port); } } #endif // MQTT_HOST_DISCOVERY @@ -84,7 +84,7 @@ void MdnsUpdate(void) { if (2 == Mdns.begun) { MDNS.update(); // this is basically passpacket like a webserver // being called in main loop so no logging - // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_MDNS "MDNS.update")); + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_MDNS "MDNS.update")); } } #endif // ESP8266 diff --git a/tasmota/support_rotary.ino b/tasmota/support_rotary.ino index 7e32647cb..4f5eda5a6 100644 --- a/tasmota/support_rotary.ino +++ b/tasmota/support_rotary.ino @@ -209,7 +209,7 @@ void RotaryHandler(void) { bool button_pressed = (Button.hold_timer[index]); // Button is pressed: set color temperature if (button_pressed) { Encoder[index].changed = true; } -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("ROT: Button1 %d, Position %d"), button_pressed, rotary_position); +// AddLog(LOG_LEVEL_DEBUG, PSTR("ROT: Button1 %d, Position %d"), button_pressed, rotary_position); #ifdef USE_LIGHT if (!Settings.flag4.rotary_uses_rules) { // SetOption98 - Use rules instead of light control diff --git a/tasmota/support_rtc.ino b/tasmota/support_rtc.ino index 2f2403e7a..7355ae60b 100644 --- a/tasmota/support_rtc.ino +++ b/tasmota/support_rtc.ino @@ -395,8 +395,7 @@ void RtcSecond(void) Rtc.daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year); Rtc.standard_time = RuleToTime(Settings.tflag[0], RtcTime.year); - // Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9 - AddLog_P(LOG_LEVEL_DEBUG, PSTR("RTC: " D_UTC_TIME " %s, " D_DST_TIME " %s, " D_STD_TIME " %s"), + AddLog(LOG_LEVEL_DEBUG, PSTR("RTC: " D_UTC_TIME " %s, " D_DST_TIME " %s, " D_STD_TIME " %s"), GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str()); if (Rtc.local_time < START_VALID_TIME) { // 2016-01-01 @@ -410,8 +409,7 @@ void RtcSecond(void) Rtc.millis = millis(); if ((Rtc.utc_time > (2 * 60 * 60)) && (last_sync < Rtc.utc_time - (2 * 60 * 60))) { // Every two hours a warning - // Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9 - AddLog_P(LOG_LEVEL_DEBUG, PSTR("RTC: Not synced")); + AddLog(LOG_LEVEL_DEBUG, PSTR("RTC: Not synced")); last_sync = Rtc.utc_time; } @@ -476,7 +474,7 @@ void RtcSecond(void) void RtcSync(void) { Rtc.time_synced = true; RtcSecond(); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("RTC: Synced")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("RTC: Synced")); } void RtcSetTime(uint32_t epoch) { diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 40d5836ad..0761e504d 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -815,7 +815,7 @@ void PerformEverySecond(void) if (!(DeepSleepEnabled() && !Settings.flag3.bootcount_update)) { #endif Settings.bootcount++; // Moved to here to stop flash writes during start-up - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount); #ifdef USE_DEEPSLEEP } #endif @@ -832,7 +832,7 @@ void PerformEverySecond(void) TasmotaGlobal.seriallog_timer--; if (!TasmotaGlobal.seriallog_timer) { if (TasmotaGlobal.seriallog_level) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SERIAL_LOGGING_DISABLED)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SERIAL_LOGGING_DISABLED)); } TasmotaGlobal.seriallog_level = 0; } @@ -843,7 +843,7 @@ void PerformEverySecond(void) if (!TasmotaGlobal.syslog_timer) { TasmotaGlobal.syslog_level = Settings.syslog_level; if (Settings.syslog_level) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_LOGGING_REENABLED)); // Might trigger disable again (on purpose) + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_LOGGING_REENABLED)); // Might trigger disable again (on purpose) } } } @@ -1059,7 +1059,7 @@ void Every250mSeconds(void) char *ech = strchr(bch, '.'); // Find file type in filename (none, .ino.bin, .ino.bin.gz, .bin, .bin.gz or .gz) if (ech == nullptr) { ech = TasmotaGlobal.mqtt_data + strlen(TasmotaGlobal.mqtt_data); } // Point to '/0' at end of mqtt_data becoming an empty string -//AddLog_P(LOG_LEVEL_DEBUG, PSTR("OTA: File type [%s]"), ech); +//AddLog(LOG_LEVEL_DEBUG, PSTR("OTA: File type [%s]"), ech); char ota_url_type[strlen(ech) +1]; strncpy(ota_url_type, ech, sizeof(ota_url_type)); // Either empty, .ino.bin, .ino.bin.gz, .bin, .bin.gz or .gz @@ -1070,7 +1070,7 @@ void Every250mSeconds(void) snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s-" D_JSON_MINIMAL "%s"), TasmotaGlobal.mqtt_data, ota_url_type); // Minimal filename must be filename-minimal } #endif // FIRMWARE_MINIMAL - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "%s"), TasmotaGlobal.mqtt_data); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "%s"), TasmotaGlobal.mqtt_data); WiFiClient OTAclient; ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(OTAclient, TasmotaGlobal.mqtt_data)); if (!ota_result) { @@ -1189,7 +1189,7 @@ void Every250mSeconds(void) } TasmotaGlobal.restart_flag--; if (TasmotaGlobal.restart_flag <= 0) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "%s"), (TasmotaGlobal.restart_halt) ? PSTR("Halted") : PSTR(D_RESTARTING)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "%s"), (TasmotaGlobal.restart_halt) ? PSTR("Halted") : PSTR(D_RESTARTING)); EspRestart(); } } @@ -1300,7 +1300,7 @@ void ArduinoOTAInit(void) if (Settings.flag.mqtt_enabled) { MqttDisconnect(); // SetOption3 - Enable MQTT } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_UPLOAD_STARTED)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_UPLOAD_STARTED)); arduino_ota_triggered = true; arduino_ota_progress_dot_count = 0; delay(100); // Allow time for message xfer @@ -1331,19 +1331,19 @@ void ArduinoOTAInit(void) default: snprintf_P(error_str, sizeof(error_str), PSTR(D_UPLOAD_ERROR_CODE " %d"), error); } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA %s. " D_RESTARTING), error_str); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA %s. " D_RESTARTING), error_str); EspRestart(); }); ArduinoOTA.onEnd([]() { if ((LOG_LEVEL_DEBUG <= TasmotaGlobal.seriallog_level)) { Serial.println(); } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_SUCCESSFUL ". " D_RESTARTING)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_SUCCESSFUL ". " D_RESTARTING)); EspRestart(); }); ArduinoOTA.begin(); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_ENABLED " " D_PORT " 8266")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_ENABLED " " D_PORT " 8266")); } void ArduinoOtaLoop(void) @@ -1451,7 +1451,7 @@ void SerialInput(void) TasmotaGlobal.serial_in_buffer[TasmotaGlobal.serial_in_byte_counter] = 0; // Serial data completed TasmotaGlobal.seriallog_level = (Settings.seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings.seriallog_level; if (serial_buffer_overrun) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "Serial buffer overrun")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "Serial buffer overrun")); } else { AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), TasmotaGlobal.serial_in_buffer); ExecuteCommand(TasmotaGlobal.serial_in_buffer, SRC_SERIAL); @@ -1519,7 +1519,7 @@ void GpioInit(void) } SetModuleType(); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Used GPIOs %d"), GPIO_SENSOR_END); +// AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Used GPIOs %d"), GPIO_SENSOR_END); #ifdef ESP8266 ConvertGpios(); @@ -1685,7 +1685,7 @@ void GpioInit(void) for (uint32_t i = 0; i < ARRAY_SIZE(TasmotaGlobal.my_module.io); i++) { uint32_t mpin = ValidPin(i, TasmotaGlobal.my_module.io[i]); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("INI: gpio pin %d, mpin %d"), i, mpin); +// AddLog(LOG_LEVEL_DEBUG, PSTR("INI: gpio pin %d, mpin %d"), i, mpin); if (AGPIO(GPIO_OUTPUT_HI) == mpin) { pinMode(i, OUTPUT); digitalWrite(i, 1); diff --git a/tasmota/support_udp.ino b/tasmota/support_udp.ino index 07aa6736e..455b54b19 100644 --- a/tasmota/support_udp.ino +++ b/tasmota/support_udp.ino @@ -71,7 +71,7 @@ bool UdpDisconnect(void) // stop all WiFiUDP::stopAll(); #endif // !USE_DEVICE_GROUPS - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_MULTICAST_DISABLED)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_MULTICAST_DISABLED)); udp_connected = false; } return udp_connected; @@ -87,18 +87,18 @@ bool UdpConnect(void) ip_addr_t addr = IPADDR4_INIT(INADDR_ANY); if (UdpCtx.listen(&addr, 1900)) { // port 1900 // OK - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_REJOINED)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_REJOINED)); udp_connected = true; } #endif // ESP8266 #ifdef ESP32 if (PortUdp.beginMulticast(WiFi.localIP(), IPAddress(239,255,255,250), 1900)) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_REJOINED)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_REJOINED)); udp_connected = true; #endif // ESP32 } if (!udp_connected) { // if connection failed - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_JOIN_FAILED)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPNP D_MULTICAST_JOIN_FAILED)); } } return udp_connected; @@ -120,7 +120,7 @@ void PollUdp(void) packet->buf[packet->len] = 0; // add NULL at the end of the packet char * packet_buffer = (char*) &packet->buf; int32_t len = packet->len; - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d)"), len); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d)"), len); #endif // ESP8266 #ifdef ESP32 while (uint32_t pack_len = PortUdp.parsePacket()) { @@ -129,7 +129,7 @@ void PollUdp(void) int32_t len = PortUdp.read(packet_buffer, UDP_BUFFER_SIZE -1); packet_buffer[len] = 0; PortUdp.flush(); - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d/%d)"), len, pack_len); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: Packet (%d/%d)"), len, pack_len); #endif // ESP32 // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), packet_buffer); @@ -175,7 +175,7 @@ void PollUdp(void) #ifdef USE_EMULATION_HUE if (!udp_proccessed && (EMUL_HUE == Settings.flag2.emulation)) { - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: HUE")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("UDP: HUE")); if ((strstr_P(packet_buffer, PSTR(":device:basic:1")) != nullptr) || (strstr_P(packet_buffer, UPNP_ROOTDEVICE) != nullptr) || (strstr_P(packet_buffer, SSDPSEARCH_ALL) != nullptr) || diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino index 4c37b074a..1c6f1dbe6 100644 --- a/tasmota/support_wifi.ino +++ b/tasmota/support_wifi.ino @@ -102,11 +102,11 @@ void WifiConfig(uint8_t type) TasmotaGlobal.restart_flag = 2; } else if (WIFI_SERIAL == Wifi.config_type) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_6_SERIAL " " D_ACTIVE_FOR_3_MINUTES)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_6_SERIAL " " D_ACTIVE_FOR_3_MINUTES)); } #ifdef USE_WEBSERVER else if (WIFI_MANAGER == Wifi.config_type || WIFI_MANAGER_RESET_ONLY == Wifi.config_type) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_2_WIFIMANAGER " " D_ACTIVE_FOR_3_MINUTES)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_2_WIFIMANAGER " " D_ACTIVE_FOR_3_MINUTES)); WifiManagerBegin(WIFI_MANAGER_RESET_ONLY == Wifi.config_type); } #endif // USE_WEBSERVER @@ -125,7 +125,7 @@ void WifiSetMode(WiFiMode_t wifi_mode) uint32_t retry = 2; while (!WiFi.mode(wifi_mode) && retry--) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI "Retry set Mode...")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI "Retry set Mode...")); delay(100); } @@ -217,7 +217,7 @@ void WifiBegin(uint8_t flag, uint8_t channel) } else { WiFi.begin(SettingsText(SET_STASSID1 + Settings.sta_active), SettingsText(SET_STAPWD1 + Settings.sta_active)); } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s%s " D_IN_MODE " 11%c " D_AS " %s..."), + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s%s " D_IN_MODE " 11%c " D_AS " %s..."), Settings.sta_active +1, SettingsText(SET_STASSID1 + Settings.sta_active), stemp, pgm_read_byte(&kWifiPhyMode[WiFi.getPhyMode() & 0x3]), TasmotaGlobal.hostname); #if LWIP_IPV6 @@ -225,11 +225,11 @@ void WifiBegin(uint8_t flag, uint8_t channel) uint16_t cfgcnt = 0; for (auto addr : addrList) { if ((configured = !addr.isLocal() && addr.isV6()) || cfgcnt==30) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI "Got IPv6 global address %s"), addr.toString().c_str()); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI "Got IPv6 global address %s"), addr.toString().c_str()); break; // IPv6 is mandatory but stop after 15 seconds } delay(500); // Loop until real IPv6 address is aquired or too many tries failed - cfgcnt++; + cfgcnt++; } } #endif // LWIP_IPV6=1 @@ -260,7 +260,7 @@ void WifiBeginAfterScan(void) if (WiFi.scanComplete() != WIFI_SCAN_RUNNING) { WiFi.scanNetworks(true); // Start wifi scan async Wifi.scan_state++; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Network (re)scan started...")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Network (re)scan started...")); return; } } @@ -308,7 +308,7 @@ void WifiBeginAfterScan(void) } } char hex_char[18]; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Network %d, AP%c, SSId %s, Channel %d, BSSId %s, RSSI %d, Encryption %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Network %d, AP%c, SSId %s, Channel %d, BSSId %s, RSSI %d, Encryption %d"), i, (known) ? (j) ? '2' : '1' : '-', ssid_scan.c_str(), @@ -373,11 +373,11 @@ String WifiGetIPv6(void) // Check to see if we have any routable IP address inline bool WifiCheck_hasIP(IPAddress const & ip_address) { -#ifdef LWIP2_IPV6 +#ifdef LWIP2_IPV6 return !a.isLocal(); #else return static_cast(ip_address) != 0; -#endif +#endif } void WifiCheckIp(void) @@ -387,8 +387,8 @@ void WifiCheckIp(void) Wifi.counter = WIFI_CHECK_SEC; Wifi.retry = Wifi.retry_init; if (Wifi.status != WL_CONNECTED) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTED)); -// AddLog_P(LOG_LEVEL_INFO, PSTR("Wifi: Set IP addresses")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTED)); +// AddLog(LOG_LEVEL_INFO, PSTR("Wifi: Set IP addresses")); Settings.ipv4_address[1] = (uint32_t)WiFi.gatewayIP(); Settings.ipv4_address[2] = (uint32_t)WiFi.subnetMask(); Settings.ipv4_address[3] = (uint32_t)WiFi.dnsIP(); @@ -405,12 +405,12 @@ void WifiCheckIp(void) Wifi.status = WiFi.status(); switch (Wifi.status) { case WL_CONNECTED: - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_NO_IP_ADDRESS)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_NO_IP_ADDRESS)); Wifi.status = 0; Wifi.retry = Wifi.retry_init; break; case WL_NO_SSID_AVAIL: - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_AP_NOT_REACHED)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_AP_NOT_REACHED)); Settings.wifi_channel = 0; // Disable stored AP if (WIFI_WAIT == Settings.sta_config) { Wifi.retry = Wifi.retry_init; @@ -424,7 +424,7 @@ void WifiCheckIp(void) } break; case WL_CONNECT_FAILED: - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_WRONG_PASSWORD)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_WRONG_PASSWORD)); Settings.wifi_channel = 0; // Disable stored AP if (Wifi.retry > (Wifi.retry_init / 2)) { Wifi.retry = Wifi.retry_init / 2; @@ -435,7 +435,7 @@ void WifiCheckIp(void) break; default: // WL_IDLE_STATUS and WL_DISCONNECTED if (!Wifi.retry || ((Wifi.retry_init / 2) == Wifi.retry)) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_AP_TIMEOUT)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECT_FAILED_AP_TIMEOUT)); Settings.wifi_channel = 0; // Disable stored AP } else { if (!strlen(SettingsText(SET_STASSID1)) && !strlen(SettingsText(SET_STASSID2))) { @@ -443,7 +443,7 @@ void WifiCheckIp(void) wifi_config_tool = WIFI_MANAGER; // Skip empty SSIDs and start Wifi config tool Wifi.retry = 0; } else { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_ATTEMPTING_CONNECTION)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_ATTEMPTING_CONNECTION)); } } } @@ -491,7 +491,7 @@ void WifiCheck(uint8_t param) SettingsUpdateText(SET_STAPWD1, WiFi.psk().c_str()); } Settings.sta_active = 0; - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_2_WIFIMANAGER D_CMND_SSID "1 %s"), SettingsText(SET_STASSID1)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_2_WIFIMANAGER D_CMND_SSID "1 %s"), SettingsText(SET_STASSID1)); } } if (!Wifi.config_counter) { @@ -502,7 +502,7 @@ void WifiCheck(uint8_t param) if (Wifi.scan_state) { WifiBeginAfterScan(); } if (Wifi.counter <= 0) { - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_WIFI D_CHECKING_CONNECTION)); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_WIFI D_CHECKING_CONNECTION)); Wifi.counter = WIFI_CHECK_SEC; WifiCheckIp(); } @@ -584,7 +584,7 @@ void WifiConnect(void) #ifdef WIFI_RF_PRE_INIT if (rf_pre_init_flag) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Pre-init done")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Pre-init done")); } #endif // WIFI_RF_PRE_INIT } @@ -656,7 +656,7 @@ extern "C" { } void stationKeepAliveNow(void) { - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_WIFI "Sending Gratuitous ARP")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_WIFI "Sending Gratuitous ARP")); for (netif* interface = netif_list; interface != nullptr; interface = interface->next) if ( (interface->flags & NETIF_FLAG_LINK_UP) @@ -744,11 +744,11 @@ uint32_t WifiGetNtp(void) { ntp_server_id++; } if (!resolved_ip) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("NTP: No server found")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("NTP: No server found")); return 0; } -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("NTP: Name %s, IP %s"), ntp_server, time_server_ip.toString().c_str()); +// AddLog(LOG_LEVEL_DEBUG, PSTR("NTP: Name %s, IP %s"), ntp_server, time_server_ip.toString().c_str()); WiFiUDP udp; @@ -798,7 +798,7 @@ uint32_t WifiGetNtp(void) { if ((packet_buffer[0] & 0b11000000) == 0b11000000) { // Leap-Indicator: unknown (clock unsynchronized) // See: https://github.com/letscontrolit/ESPEasy/issues/2886#issuecomment-586656384 - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NTP: IP %s unsynched"), time_server_ip.toString().c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR("NTP: IP %s unsynched"), time_server_ip.toString().c_str()); ntp_server_id++; // Next server next time return 0; } @@ -818,7 +818,7 @@ uint32_t WifiGetNtp(void) { delay(10); } // Timeout. - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NTP: No reply")); + AddLog(LOG_LEVEL_DEBUG, PSTR("NTP: No reply")); udp.stop(); ntp_server_id++; // Next server next time return 0; diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 9772b0fbe..1a956fd0c 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -52,6 +52,7 @@ #include // Ota #include // Ota #include // Webserver, Updater +#include #include #include #ifdef USE_ARDUINO_OTA @@ -312,7 +313,7 @@ void setup(void) { Settings.module = Settings.fallback_module; // Reset module to fallback module // Settings.last_module = Settings.fallback_module; } - AddLog_P(LOG_LEVEL_INFO, PSTR("FRC: " D_LOG_SOME_SETTINGS_RESET " (%d)"), RtcReboot.fast_reboot_count); + AddLog(LOG_LEVEL_INFO, PSTR("FRC: " D_LOG_SOME_SETTINGS_RESET " (%d)"), RtcReboot.fast_reboot_count); } } @@ -339,10 +340,10 @@ void setup(void) { SetPowerOnState(); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_CORE_RELEASE "(%s)"), + AddLog(LOG_LEVEL_INFO, PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_CORE_RELEASE "(%s)"), PSTR(PROJECT), SettingsText(SET_DEVICENAME), TasmotaGlobal.version, TasmotaGlobal.image_name, GetBuildDateAndTime().c_str()); #ifdef FIRMWARE_MINIMAL - AddLog_P(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION)); + AddLog(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION)); #endif // FIRMWARE_MINIMAL RtcInit(); diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index 5dcce7502..fd04983ec 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -109,7 +109,8 @@ //#define USE_SPS30 // [I2cDriver30] Enable Sensiron SPS30 particle sensor (I2C address 0x69) (+1.7 code) #define USE_ADE7953 // [I2cDriver7] Enable ADE7953 Energy monitor as used on Shelly 2.5 (I2C address 0x38) (+1k5) //#define USE_VL53L0X // [I2cDriver31] Enable VL53L0x time of flight sensor (I2C address 0x29) (+4k code) -//#define USE_VL53L1X // [I2cDriver54] Enable support for VL53L1X sensor (I2C address 0x29) using Pololu VL53L1X library (+2k9 code) +//#define USE_VL53L1X // [I2cDriver54] Enable VL53L1X time of flight sensor (I2C address 0x29) using Pololu VL53L1X library (+2k9 code) +//#define USE_TOF10120 // [I2cDriver57] Enable TOF10120 time of flight sensor (I2C address 0x52) (+0k6 code) //#define USE_MLX90614 // [I2cDriver32] Enable MLX90614 ir temp sensor (I2C address 0x5a) (+0.6k code) //#define USE_CHIRP // [I2cDriver33] Enable CHIRP soil moisture sensor (variable I2C address, default 0x20) //#define USE_PAJ7620 // [I2cDriver34] Enable PAJ7620 gesture sensor (I2C address 0x73) (+2.5k code) @@ -140,6 +141,7 @@ //#define USE_EZODO // [I2cDriver55] Enable support for EZO's DO sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code) //#define USE_EZORGB // [I2cDriver55] Enable support for EZO's RGB sensor (+0k5 code) - Shared EZO code required for any EZO device (+1k2 code) //#define USE_EZOPMP // [I2cDriver55] Enable support for EZO's PMP sensor (+0k3 code) - Shared EZO code required for any EZO device (+1k2 code) +//#define USE_SEESAW_SOIL // [I2cDriver56] Enable Capacitice Soil Moisture & Temperature Sensor (I2C addresses 0x36 - 0x39) (+1k3 code) //#define USE_SPI // Hardware SPI using GPIO12(MISO), GPIO13(MOSI) and GPIO14(CLK) in addition to two user selectable GPIOs(CS and DC) //#define USE_RC522 // Add support for MFRC522 13.56Mhz Rfid reader (+6k code) @@ -194,8 +196,8 @@ //#define USE_MAX31865 // Add support for MAX31865 RTD sensors using softSPI #define USE_IR_REMOTE // Send IR remote commands using library IRremoteESP8266 and ArduinoJson (+4k code, 0k3 mem, 48 iram) #define USE_IR_RECEIVE // Support for IR receiver (+5k5 code, 264 iram) - #define USE_LMT01 // Add support for TI LMT01 temperature sensor, count pulses on single GPIO (+0k5 code) +//#define USE_WIEGAND // Add support for 24/26/32/34 bit RFID Wiegand interface (D0/D1) (+1k7 code) #define USE_TM1638 // Add support for TM1638 switches copying Switch1 .. Switch8 (+1k code) #define USE_HX711 // Add support for HX711 load cell (+1k5 code) //#define USE_HX711_GUI // Add optional web GUI to HX711 as scale (+1k8 code) diff --git a/tasmota/tasmota_version.h b/tasmota/tasmota_version.h index d4b504f4f..f0a110311 100644 --- a/tasmota/tasmota_version.h +++ b/tasmota/tasmota_version.h @@ -20,6 +20,6 @@ #ifndef _TASMOTA_VERSION_H_ #define _TASMOTA_VERSION_H_ -const uint32_t VERSION = 0x09020003; +const uint32_t VERSION = 0x09020004; #endif // _TASMOTA_VERSION_H_ diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index 62b4e30a5..991394762 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -392,7 +392,7 @@ void ShowWebSource(uint32_t source) { if ((source > 0) && (source < SRC_MAX)) { char stemp1[20]; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SRC: %s from %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource), Webserver->client().remoteIP().toString().c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR("SRC: %s from %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource), Webserver->client().remoteIP().toString().c_str()); } } @@ -475,14 +475,14 @@ void StartWebserver(int type, IPAddress ipweb) #if LWIP_IPV6 String ipv6_addr = WifiGetIPv6(); if (ipv6_addr!="") { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s and IPv6 global address %s "), + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s and IPv6 global address %s "), NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str(), ipv6_addr.c_str()); } else { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"), + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"), NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str()); } #else - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"), + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_ACTIVE_ON " %s%s " D_WITH_IP_ADDRESS " %s"), NetworkHostname(), (Mdns.begun) ? PSTR(".local") : "", ipweb.toString().c_str()); #endif // LWIP_IPV6 = 1 TasmotaGlobal.rules_flag.http_init = 1; @@ -495,7 +495,7 @@ void StopWebserver(void) if (Web.state) { Webserver->close(); Web.state = HTTP_OFF; - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_STOPPED)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_HTTP D_WEBSERVER_STOPPED)); } } @@ -505,11 +505,11 @@ void WifiManagerBegin(bool reset_only) if (!TasmotaGlobal.global_state.wifi_down) { // WiFi.mode(WIFI_AP_STA); WifiSetMode(WIFI_AP_STA); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WIFIMANAGER_SET_ACCESSPOINT_AND_STATION)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WIFIMANAGER_SET_ACCESSPOINT_AND_STATION)); } else { // WiFi.mode(WIFI_AP); WifiSetMode(WIFI_AP); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WIFIMANAGER_SET_ACCESSPOINT)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WIFIMANAGER_SET_ACCESSPOINT)); } StopWebserver(); @@ -624,7 +624,7 @@ void _WSContentSendBuffer(void) return; } else if (len == sizeof(TasmotaGlobal.mqtt_data)) { - AddLog_P(LOG_LEVEL_INFO, PSTR("HTP: Content too large")); + AddLog(LOG_LEVEL_INFO, PSTR("HTP: Content too large")); } else if (len < CHUNKED_BUFFER_SIZE) { // Append chunk buffer with small content Web.chunk_buffer += TasmotaGlobal.mqtt_data; @@ -644,7 +644,7 @@ void WSContentSend_P(const char* formatP, ...) // Content send snprintf_P ch // This uses char strings. Be aware of sending %% if % is needed va_list arg; va_start(arg, formatP); - int len = vsnprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), formatP, arg); + int len = ext_vsnprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), formatP, arg); va_end(arg); #ifdef DEBUG_TASMOTA_CORE @@ -662,7 +662,7 @@ void WSContentSend_PD(const char* formatP, ...) // Content send snprintf_P ch // This uses char strings. Be aware of sending %% if % is needed va_list arg; va_start(arg, formatP); - int len = vsnprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), formatP, arg); + int len = ext_vsnprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), formatP, arg); va_end(arg); #ifdef DEBUG_TASMOTA_CORE @@ -722,7 +722,7 @@ void WSContentSendStyle_P(const char* formatP, ...) // This uses char strings. Be aware of sending %% if % is needed va_list arg; va_start(arg, formatP); - int len = vsnprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), formatP, arg); + int len = ext_vsnprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), formatP, arg); va_end(arg); #ifdef DEBUG_TASMOTA_CORE @@ -819,7 +819,7 @@ void WebRestart(uint32_t type) // type 0 = restart // type 1 = restart after config change // type 2 = restart after config change with possible ip address change too - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESTART)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESTART)); bool reset_only = (HTTP_MANAGER_RESET_ONLY == Web.state); @@ -905,7 +905,7 @@ void HandleRoot(void) return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_MAIN_MENU)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_MAIN_MENU)); char stemp[33]; @@ -1284,7 +1284,7 @@ void HandleConfiguration(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURATION)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURATION)); WSContentStart_P(PSTR(D_CONFIGURATION)); WSContentSendStyle(); @@ -1403,7 +1403,7 @@ void HandleTemplateConfiguration(void) return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_TEMPLATE)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_TEMPLATE)); WSContentStart_P(PSTR(D_CONFIGURE_TEMPLATE)); WSContentSend_P(HTTP_SCRIPT_MODULE_TEMPLATE); @@ -1512,7 +1512,7 @@ void HandleModuleConfiguration(void) return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_MODULE)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_MODULE)); char stemp[30]; // Sensor name uint32_t midx; @@ -1592,7 +1592,7 @@ void ModuleSaveSettings(void) } } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MODULE "%s " D_CMND_MODULE "%s"), ModuleName().c_str(), gpios.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MODULE "%s " D_CMND_MODULE "%s"), ModuleName().c_str(), gpios.c_str()); } /*-------------------------------------------------------------------------------------------*/ @@ -1623,7 +1623,7 @@ void HandleWifiConfiguration(void) { if (!HttpCheckPriviledgedAccess(!WifiIsInManagerMode())) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_WIFI)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_WIFI)); if (Webserver->hasArg(F("save")) && HTTP_MANAGER_RESET_ONLY != Web.state) { WifiSaveSettings(); @@ -1645,10 +1645,10 @@ void HandleWifiConfiguration(void) UdpDisconnect(); #endif // USE_EMULATION int n = WiFi.scanNetworks(); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_SCAN_DONE)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_SCAN_DONE)); if (0 == n) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_NO_NETWORKS_FOUND)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_NO_NETWORKS_FOUND)); WSContentSend_P(PSTR(D_NO_NETWORKS_FOUND)); WSContentSend_P(PSTR(". " D_REFRESH_TO_SCAN_AGAIN ".")); } else { @@ -1710,10 +1710,9 @@ void HandleWifiConfiguration(void) } #else // No USE_ENHANCED_GUI_WIFI_SCAN // remove duplicates ( must be RSSI sorted ) - String cssid; for (uint32_t i = 0; i < n; i++) { if (-1 == indices[i]) { continue; } - cssid = WiFi.SSID(indices[i]); + String cssid = WiFi.SSID(indices[i]); uint32_t cschn = WiFi.channel(indices[i]); for (uint32_t j = i + 1; j < n; j++) { if ((cssid == WiFi.SSID(indices[j])) && (cschn == WiFi.channel(indices[j]))) { @@ -1802,7 +1801,7 @@ void HandleLoggingConfiguration(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_LOGGING)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_LOGGING)); if (Webserver->hasArg("save")) { LoggingSaveSettings(); @@ -1867,7 +1866,7 @@ void HandleOtherConfiguration(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_OTHER)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_OTHER)); if (Webserver->hasArg(F("save"))) { OtherSaveSettings(); @@ -1970,7 +1969,7 @@ void HandleBackupConfiguration(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_BACKUP_CONFIGURATION)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_BACKUP_CONFIGURATION)); if (!SettingsBufferAlloc()) { return; } @@ -2012,7 +2011,7 @@ void HandleResetConfiguration(void) { if (!HttpCheckPriviledgedAccess(!WifiIsInManagerMode())) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESET_CONFIGURATION)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESET_CONFIGURATION)); WSContentStart_P(PSTR(D_RESET_CONFIGURATION), !WifiIsInManagerMode()); WSContentSendStyle(); @@ -2030,7 +2029,7 @@ void HandleRestoreConfiguration(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESTORE_CONFIGURATION)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_RESTORE_CONFIGURATION)); WSContentStart_P(PSTR(D_RESTORE_CONFIGURATION)); WSContentSendStyle(); @@ -2052,7 +2051,7 @@ void HandleInformation(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_INFORMATION)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_INFORMATION)); char stopic[TOPSZ]; @@ -2111,9 +2110,9 @@ void HandleInformation(void) } } if (!TasmotaGlobal.global_state.network_down) { - WSContentSend_P(PSTR("}1" D_GATEWAY "}2%s"), IPAddress(Settings.ipv4_address[1]).toString().c_str()); - WSContentSend_P(PSTR("}1" D_SUBNET_MASK "}2%s"), IPAddress(Settings.ipv4_address[2]).toString().c_str()); - WSContentSend_P(PSTR("}1" D_DNS_SERVER "}2%s"), IPAddress(Settings.ipv4_address[3]).toString().c_str()); + WSContentSend_P(PSTR("}1" D_GATEWAY "}2%_I"), Settings.ipv4_address[1]); + WSContentSend_P(PSTR("}1" D_SUBNET_MASK "}2%_I"), Settings.ipv4_address[2]); + WSContentSend_P(PSTR("}1" D_DNS_SERVER "}2%_I"), Settings.ipv4_address[3]); } if ((WiFi.getMode() >= WIFI_AP) && (static_cast(WiFi.softAPIP()) != 0)) { WSContentSend_P(PSTR("}1
}2
")); @@ -2242,7 +2241,7 @@ uint32_t BUploadWriteBuffer(uint8_t *buf, size_t size) { void HandleUpgradeFirmware(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_FIRMWARE_UPGRADE)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_FIRMWARE_UPGRADE)); WSContentStart_P(PSTR(D_FIRMWARE_UPGRADE)); WSContentSendStyle(); @@ -2259,7 +2258,7 @@ void HandleUpgradeFirmwareStart(void) { char command[TOPSZ + 10]; // OtaUrl - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPGRADE_STARTED)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPGRADE_STARTED)); WifiConfigCounter(); char otaurl[TOPSZ]; @@ -2294,7 +2293,7 @@ void HandleUploadDone(void) { } #endif // USE_ZIGBEE_EZSP - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPLOAD_DONE)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPLOAD_DONE)); WifiConfigCounter(); UploadServices(1); @@ -2339,7 +2338,7 @@ void UploadServices(uint32_t start_service) { Web.upload_services_stopped = !start_service; if (start_service) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("UPL: Services enabled")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("UPL: Services enabled")); /* MqttRetryCounter(0); @@ -2355,7 +2354,7 @@ void UploadServices(uint32_t start_service) { #endif // USE_EMULATION } else { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("UPL: Services disabled")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("UPL: Services disabled")); #ifdef USE_BLE_ESP32 ExtStopBLE(); @@ -2390,7 +2389,7 @@ void HandleUploadLoop(void) { if (UPL_TASMOTA == Web.upload_file_type) { Update.end(); } UploadServices(1); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Upload error %d"), Web.upload_error); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Upload error %d"), Web.upload_error); upload_error_signalled = true; } @@ -2413,7 +2412,7 @@ void HandleUploadLoop(void) { } SettingsSave(1); // Free flash for upload - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_FILE " %s"), upload.filename.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_FILE " %s"), upload.filename.c_str()); if (UPL_SETTINGS == Web.upload_file_type) { if (!SettingsBufferAlloc()) { @@ -2492,7 +2491,7 @@ void HandleUploadLoop(void) { return; } } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "File type %d"), Web.upload_file_type); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "File type %d"), Web.upload_file_type); } // First block received if (UPL_SETTINGS == Web.upload_file_type) { @@ -2514,7 +2513,7 @@ void HandleUploadLoop(void) { #ifdef USE_WEB_FW_UPGRADE else if (BUpload.active) { // Write a block -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Size %d"), upload.currentSize); +// AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Size %d"), upload.currentSize); // AddLogBuffer(LOG_LEVEL_DEBUG, upload.buf, 32); Web.upload_error = BUploadWriteBuffer(upload.buf, upload.currentSize); if (Web.upload_error != 0) { return; } @@ -2525,7 +2524,7 @@ void HandleUploadLoop(void) { return; } if (upload.totalSize && !(upload.totalSize % 102400)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Progress %d kB"), upload.totalSize / 1024); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Progress %d kB"), upload.totalSize / 1024); } } @@ -2582,12 +2581,12 @@ void HandleUploadLoop(void) { // Done writing the data to SPI flash BUpload.active = false; - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Transfer %u bytes"), upload.totalSize); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Transfer %u bytes"), upload.totalSize); uint8_t* data = FlashDirectAccess(); // uint32_t* values = (uint32_t*)(data); // Only 4-byte access allowed -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Head 0x%08X"), values[0]); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Head 0x%08X"), values[0]); uint32_t error = 0; #ifdef USE_RF_FLASH @@ -2616,7 +2615,7 @@ void HandleUploadLoop(void) { } #endif // USE_ZIGBEE_EZSP if (error != 0) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Transfer error %d"), error); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Transfer error %d"), error); Web.upload_error = error + (100 * Web.upload_file_type); // Add offset to discriminate transfer errors return; } @@ -2626,7 +2625,7 @@ void HandleUploadLoop(void) { Web.upload_error = 6; // Upload failed. Enable logging 3 return; } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_SUCCESSFUL " %u bytes"), upload.totalSize); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_SUCCESSFUL " %u bytes"), upload.totalSize); } // ***** Step4: Abort upload file @@ -2658,7 +2657,7 @@ void HandleHttpCommand(void) { if (!HttpCheckPriviledgedAccess(false)) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_COMMAND)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_COMMAND)); if (!WebAuthenticate()) { // Prefer authorization via HTTP header (Basic auth), if it fails, use legacy method via GET parameters @@ -2717,7 +2716,7 @@ void HandleConsole(void) return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONSOLE)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONSOLE)); WSContentStart_P(PSTR(D_CONSOLE)); WSContentSend_P(HTTP_SCRIPT_CONSOL, Settings.web_refresh); @@ -2764,7 +2763,7 @@ void HandleConsoleRefresh(void) void HandleNotFound(void) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Not found (%s)"), Webserver->uri().c_str()); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Not found (%s)"), Webserver->uri().c_str()); if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the error page. @@ -2791,7 +2790,7 @@ bool CaptivePortal(void) { // Possible hostHeader: connectivitycheck.gstatic.com or 192.168.4.1 if ((WifiIsInManagerMode()) && !ValidIpAddress(Webserver->hostHeader().c_str())) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_REDIRECTED)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_REDIRECTED)); Webserver->sendHeader(F("Location"), String(F("http://")) + Webserver->client().localIP().toString(), true); WSSend(302, CT_PLAIN, ""); // Empty content inhibits Content-length header so we have to close the socket ourselves. diff --git a/tasmota/xdrv_02_mqtt.ino b/tasmota/xdrv_02_mqtt.ino index bf4a9e6f9..0c9779744 100644 --- a/tasmota/xdrv_02_mqtt.ino +++ b/tasmota/xdrv_02_mqtt.ino @@ -273,12 +273,12 @@ void MqttRetryCounter(uint8_t value) { } void MqttSubscribe(const char *topic) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_SUBSCRIBE_TO " %s"), topic); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_SUBSCRIBE_TO " %s"), topic); MqttSubscribeLib(topic); } void MqttUnsubscribe(const char *topic) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_UNSUBSCRIBE_FROM " %s"), topic); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_UNSUBSCRIBE_FROM " %s"), topic); MqttUnsubscribeLib(topic); } @@ -381,7 +381,7 @@ void MqttPublishPrefixTopic_P(uint32_t prefix, const char* subtopic, bool retain free(mqtt_save); bool result = MqttClient.publish(romram, TasmotaGlobal.mqtt_data, false); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Updated shadow: %s"), romram); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Updated shadow: %s"), romram); yield(); // #3313 } #endif // USE_MQTT_AWS_IOT @@ -475,7 +475,7 @@ void MqttDisconnected(int state) { MqttClient.disconnect(); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CONNECT_FAILED_TO " %s:%d, rc %d. " D_RETRY_IN " %d " D_UNIT_SECOND), SettingsText(SET_MQTT_HOST), Settings.mqtt_port, state, Mqtt.retry_counter); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CONNECT_FAILED_TO " %s:%d, rc %d. " D_RETRY_IN " %d " D_UNIT_SECOND), SettingsText(SET_MQTT_HOST), Settings.mqtt_port, state, Mqtt.retry_counter); TasmotaGlobal.rules_flag.mqtt_disconnected = 1; } @@ -483,7 +483,7 @@ void MqttConnected(void) { char stopic[TOPSZ]; if (Mqtt.allowed) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CONNECTED)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CONNECTED)); Mqtt.connected = true; Mqtt.retry_counter = 0; Mqtt.retry_counter_delay = 1; @@ -604,7 +604,7 @@ void MqttReconnect(void) { #endif #endif - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_ATTEMPTING_CONNECTION)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_ATTEMPTING_CONNECTION)); char *mqtt_user = nullptr; char *mqtt_pwd = nullptr; @@ -680,21 +680,21 @@ void MqttReconnect(void) { #ifdef USE_MQTT_TLS if (Mqtt.mqtt_tls) { #ifdef ESP8266 - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "TLS connected in %d ms, max ThunkStack used %d"), + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "TLS connected in %d ms, max ThunkStack used %d"), millis() - mqtt_connect_time, tlsClient->getMaxThunkStackUse()); #elif defined(ESP32) - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "TLS connected in %d ms, stack low mark %d"), + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "TLS connected in %d ms, stack low mark %d"), millis() - mqtt_connect_time, uxTaskGetStackHighWaterMark(nullptr)); #endif if (!tlsClient->getMFLNStatus()) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "MFLN not supported by TLS server")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "MFLN not supported by TLS server")); } #ifndef USE_MQTT_TLS_CA_CERT // don't bother with fingerprints if using CA validation const uint8_t *recv_fingerprint = tlsClient->getRecvPubKeyFingerprint(); // create a printable version of the fingerprint received char buf_fingerprint[64]; ToHex_P(recv_fingerprint, 20, buf_fingerprint, sizeof(buf_fingerprint), ' '); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Server fingerprint: %s"), buf_fingerprint); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Server fingerprint: %s"), buf_fingerprint); bool learned = false; @@ -713,7 +713,7 @@ void MqttReconnect(void) { } if (learned) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "Fingerprint learned: %s"), buf_fingerprint); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "Fingerprint learned: %s"), buf_fingerprint); SettingsSaveAll(); // save settings } @@ -724,7 +724,7 @@ void MqttReconnect(void) { } else { #ifdef USE_MQTT_TLS if (Mqtt.mqtt_tls) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "TLS connection error: %d"), tlsClient->getLastError()); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "TLS connection error: %d"), tlsClient->getLastError()); } #endif MqttDisconnected(MqttClient.state()); // status codes are documented here http://pubsubclient.knolleary.net/api.html#state @@ -1065,7 +1065,7 @@ void CmndSensorRetain(void) { \*********************************************************************************************/ #if defined(USE_MQTT_TLS) && defined(USE_MQTT_AWS_IOT) -// const static uint16_t tls_spi_start_sector = FLASH_EEPROM_START + 4; // 0xXXFF +// const static uint16_t tls_spi_start_sector = EEPROM_LOCATION + 4; // 0xXXFF // const static uint8_t* tls_spi_start = (uint8_t*) ((tls_spi_start_sector * SPI_FLASH_SEC_SIZE) + 0x40200000); // 0x40XFF000 const static uint16_t tls_spi_start_sector = 0xFF; // Force last bank of first MB const static uint8_t* tls_spi_start = (uint8_t*) 0x402FF000; // 0x402FF000 @@ -1128,7 +1128,7 @@ void CmndTlsKey(void) { // first copy SPI buffer into ram uint8_t *spi_buffer = (uint8_t*) malloc(tls_spi_len); if (!spi_buffer) { - AddLog_P(LOG_LEVEL_ERROR, ALLOCATE_ERROR); + AddLog(LOG_LEVEL_ERROR, ALLOCATE_ERROR); return; } memcpy_P(spi_buffer, tls_spi_start, tls_spi_len); @@ -1142,7 +1142,7 @@ void CmndTlsKey(void) { if (bin_len > 0) { bin_buf = (uint8_t*) malloc(bin_len + 4); if (!bin_buf) { - AddLog_P(LOG_LEVEL_ERROR, ALLOCATE_ERROR); + AddLog(LOG_LEVEL_ERROR, ALLOCATE_ERROR); free(spi_buffer); return; } @@ -1163,7 +1163,7 @@ void CmndTlsKey(void) { if (bin_len > 0) { if (bin_len != 32) { // no private key was previously stored, abort - AddLog_P(LOG_LEVEL_INFO, PSTR("TLSKey: Certificate must be 32 bytes: %d."), bin_len); + AddLog(LOG_LEVEL_INFO, PSTR("TLSKey: Certificate must be 32 bytes: %d."), bin_len); free(spi_buffer); free(bin_buf); return; @@ -1180,14 +1180,14 @@ void CmndTlsKey(void) { // Try to write Certificate if (TLS_NAME_SKEY != tls_dir.entry[0].name) { // no private key was previously stored, abort - AddLog_P(LOG_LEVEL_INFO, PSTR("TLSKey: cannot store Cert if no Key previously stored.")); + AddLog(LOG_LEVEL_INFO, PSTR("TLSKey: cannot store Cert if no Key previously stored.")); free(spi_buffer); free(bin_buf); return; } if (bin_len <= 256) { // Certificate lenght too short - AddLog_P(LOG_LEVEL_INFO, PSTR("TLSKey: Certificate length too short: %d."), bin_len); + AddLog(LOG_LEVEL_INFO, PSTR("TLSKey: Certificate length too short: %d."), bin_len); free(spi_buffer); free(bin_buf); return; @@ -1264,7 +1264,7 @@ void HandleMqttConfiguration(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_MQTT)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_MQTT)); if (Webserver->hasArg(F("save"))) { MqttSaveSettings(); diff --git a/tasmota/xdrv_03_energy.ino b/tasmota/xdrv_03_energy.ino index f57431203..dd302ebf1 100644 --- a/tasmota/xdrv_03_energy.ino +++ b/tasmota/xdrv_03_energy.ino @@ -227,7 +227,7 @@ void EnergyUpdateTotal(float value, bool kwh) { // char energy_total_chr[FLOATSZ]; // dtostrfd(value, 4, energy_total_chr); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: Energy Total %s %sWh"), energy_total_chr, (kwh) ? "k" : ""); +// AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Energy Total %s %sWh"), energy_total_chr, (kwh) ? "k" : ""); uint32_t multiplier = (kwh) ? 100000 : 100; // kWh or Wh to deca milli Wh @@ -244,7 +244,7 @@ void EnergyUpdateTotal(float value, bool kwh) Settings.energy_kWhtotal = RtcSettings.energy_kWhtotal; Energy.total = (float)(RtcSettings.energy_kWhtotal + Energy.kWhtoday_offset + Energy.kWhtoday) / 100000; Settings.energy_kWhtotal_time = (!Energy.kWhtoday_offset) ? LocalTime() : Midnight(); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: Energy Total updated with hardware value")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Energy Total updated with hardware value")); } EnergyUpdateToday(); } @@ -338,7 +338,7 @@ void EnergyMarginCheck(void) for (uint32_t phase = 0; phase < Energy.phase_count; phase++) { uint16_t active_power = (uint16_t)(Energy.active_power[phase]); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: APower %d, HPower0 %d, HPower1 %d, HPower2 %d"), active_power, Energy.power_history[phase][0], Energy.power_history[phase][1], Energy.power_history[phase][2]); +// AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: APower %d, HPower0 %d, HPower1 %d, HPower2 %d"), active_power, Energy.power_history[phase][0], Energy.power_history[phase][1], Energy.power_history[phase][2]); if (Settings.energy_power_delta[phase]) { power_diff[phase] = active_power - Energy.power_history[phase][0]; @@ -509,7 +509,7 @@ void EnergyEverySecond(void) char temperature[33]; dtostrfd(TasmotaGlobal.temperature_celsius, 1, temperature); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: GlobTemp %s"), temperature); + AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: GlobTemp %s"), temperature); SetAllPower(POWER_ALL_OFF, SRC_OVERTEMP); } @@ -537,7 +537,7 @@ void EnergyEverySecond(void) } if (!data_valid) { Energy.start_energy = 0; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: Energy reset by " STR(ENERGY_WATCHDOG) " seconds invalid data")); + AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Energy reset by " STR(ENERGY_WATCHDOG) " seconds invalid data")); XnrgCall(FUNC_ENERGY_RESET); } diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 7e0907dd1..5effa7f8d 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -324,7 +324,7 @@ class LightStateClass { public: LightStateClass() { - //AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::Constructor RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _bri); + //AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::Constructor RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _bri); } void setSubType(uint8_t sub_type) { @@ -371,7 +371,7 @@ class LightStateClass { if (0 == _briCT) { _briCT = maxbri; } } #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setColorMode prev_cm (%d) req_cm (%d) new_cm (%d)", prev_cm, cm, _color_mode); + AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setColorMode prev_cm (%d) req_cm (%d) new_cm (%d)", prev_cm, cm, _color_mode); #endif return prev_cm; } @@ -484,7 +484,7 @@ class LightStateClass { setBriRGB(_color_mode & LCM_RGB ? bri : 0); setBriCT(_color_mode & LCM_CT ? bri : 0); #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setBri RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB); + AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setBri RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB); #endif } @@ -530,7 +530,7 @@ class LightStateClass { addCTMode(); } #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setCT RGB raw (%d %d %d) HS (%d %d) briRGB (%d) briCT (%d) CT (%d)", _r, _g, _b, _hue, _sat, _briRGB, _briCT, _ct); + AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setCT RGB raw (%d %d %d) HS (%d %d) briRGB (%d) briCT (%d) CT (%d)", _r, _g, _b, _hue, _sat, _briRGB, _briCT, _ct); #endif } @@ -570,7 +570,7 @@ class LightStateClass { if (_color_mode & LCM_CT) { _briCT = free_range ? max : (sum > 255 ? 255 : sum); } } #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setCW CW (%d %d) CT (%d) briCT (%d)", c, w, _ct, _briCT); + AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setCW CW (%d %d) CT (%d) briCT (%d)", c, w, _ct, _briCT); #endif } @@ -579,7 +579,7 @@ class LightStateClass { uint16_t hue; uint8_t sat; #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setRGB RGB input (%d %d %d)", r, g, b); + AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setRGB RGB input (%d %d %d)", r, g, b); #endif uint32_t max = (r > g && r > b) ? r : (g > b) ? g : b; // 0..255 @@ -607,7 +607,7 @@ class LightStateClass { _hue = hue; _sat = sat; #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setRGB RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB); + AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setRGB RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB); #endif return max; } @@ -622,8 +622,8 @@ class LightStateClass { _sat = sat; addRGBMode(); #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setHS HS (%d %d) rgb (%d %d %d)", hue, sat, r, g, b); - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setHS RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB); + AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setHS HS (%d %d) rgb (%d %d %d)", hue, sat, r, g, b); + AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setHS RGB raw (%d %d %d) HS (%d %d) bri (%d)", _r, _g, _b, _hue, _sat, _briRGB); #endif } @@ -644,10 +644,10 @@ class LightStateClass { setRGB(channels[0], channels[1], channels[2]); setCW(channels[3], channels[4], true); // free range for WC and WW #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels (%d %d %d %d %d)", + AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels (%d %d %d %d %d)", channels[0], channels[1], channels[2], channels[3], channels[4]); - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels CT (%d) briRGB (%d) briCT (%d)", _ct, _briRGB, _briCT); - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels Actuals (%d %d %d %d %d)", + AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels CT (%d) briRGB (%d) briCT (%d)", _ct, _briRGB, _briCT); + AddLog(LOG_LEVEL_DEBUG_MORE, "LightStateClass::setChannels Actuals (%d %d %d %d %d)", _r, _g, _b, _wc, _ww); #endif } @@ -704,9 +704,9 @@ public: void debugLogs() { uint8_t r,g,b,c,w; _state->getActualRGBCW(&r,&g,&b,&c,&w); - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::debugLogs rgb (%d %d %d) cw (%d %d)", + AddLog(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::debugLogs rgb (%d %d %d) cw (%d %d)", r, g, b, c, w); - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::debugLogs lightCurrent (%d %d %d %d %d)", + AddLog(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::debugLogs lightCurrent (%d %d %d %d %d)", Light.current_color[0], Light.current_color[1], Light.current_color[2], Light.current_color[3], Light.current_color[4]); } @@ -714,10 +714,10 @@ public: void loadSettings() { #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::loadSettings Settings.light_color (%d %d %d %d %d - %d)", + AddLog(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::loadSettings Settings.light_color (%d %d %d %d %d - %d)", Settings.light_color[0], Settings.light_color[1], Settings.light_color[2], Settings.light_color[3], Settings.light_color[4], Settings.light_dimmer); - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::loadSettings light_type/sub (%d %d)", + AddLog(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::loadSettings light_type/sub (%d %d)", TasmotaGlobal.light_type, Light.subtype); #endif if (_pwm_multi_channels) { @@ -892,7 +892,7 @@ public: } } #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::saveSettings Settings.light_color (%d %d %d %d %d - %d)", + AddLog(LOG_LEVEL_DEBUG_MORE, "LightControllerClass::saveSettings Settings.light_color (%d %d %d %d %d - %d)", Settings.light_color[0], Settings.light_color[1], Settings.light_color[2], Settings.light_color[3], Settings.light_color[4], Settings.light_dimmer); #endif @@ -1074,7 +1074,7 @@ void LightCalcPWMRange(void) { Light.pwm_min = pwm_min; Light.pwm_max = pwm_max; - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("LightCalcPWMRange %d %d - %d %d"), Settings.dimmer_hw_min, Settings.dimmer_hw_max, Light.pwm_min, Light.pwm_max); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("LightCalcPWMRange %d %d - %d %d"), Settings.dimmer_hw_min, Settings.dimmer_hw_max, Light.pwm_min, Light.pwm_max); } void LightInit(void) @@ -1189,7 +1189,7 @@ void LightUpdateColorMapping(void) Light.color_remap[4] = tmp[1-param]; Light.update = true; - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%d colors: %d %d %d %d %d") ,Settings.param[P_RGB_REMAP], Light.color_remap[0],Light.color_remap[1],Light.color_remap[2],Light.color_remap[3],Light.color_remap[4]); + //AddLog(LOG_LEVEL_DEBUG, PSTR("%d colors: %d %d %d %d %d") ,Settings.param[P_RGB_REMAP], Light.color_remap[0],Light.color_remap[1],Light.color_remap[2],Light.color_remap[3],Light.color_remap[4]); } uint8_t LightGetDimmer(uint8_t dimmer) { @@ -1306,7 +1306,7 @@ void LightSetSignal(uint16_t lo, uint16_t hi, uint16_t value) */ if (Settings.flag.light_signal) { // SetOption18 - Pair light signal with CO2 sensor uint16_t signal = changeUIntScale(value, lo, hi, 0, 255); // 0..255 -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Light signal %d"), signal); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Light signal %d"), signal); light_controller.changeRGB(signal, 255 - signal, 0, true); // keep bri Settings.light_scheme = 0; if (0 == light_state.getBri()) { @@ -1423,7 +1423,7 @@ void ResponseLightState(uint8_t append) void LightPreparePower(power_t channels = 0xFFFFFFFF) { // 1 = only RGB, 2 = only CT, 3 = both RGB and CT #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG, "LightPreparePower power=%d Light.power=%d", TasmotaGlobal.power, Light.power); + AddLog(LOG_LEVEL_DEBUG, "LightPreparePower power=%d Light.power=%d", TasmotaGlobal.power, Light.power); #endif // If multi-channels, then we only switch off channels with a value of zero if (Light.pwm_multi_channels) { @@ -1486,7 +1486,7 @@ void LightPreparePower(power_t channels = 0xFFFFFFFF) { // 1 = only RGB, 2 = } #ifdef DEBUG_LIGHT - AddLog_P(LOG_LEVEL_DEBUG, "LightPreparePower End power=%d Light.power=%d", TasmotaGlobal.power, Light.power); + AddLog(LOG_LEVEL_DEBUG, "LightPreparePower End power=%d Light.power=%d", TasmotaGlobal.power, Light.power); #endif Light.power = TasmotaGlobal.power >> (Light.device - 1); // reset next state, works also with unlinked RGB/CT ResponseLightState(0); @@ -1543,7 +1543,7 @@ void LightCycleColor(int8_t direction) (Light.random > Light.wheel +128) ? 0 : 1; // Increment or Decrement and roll-over Light.random = (Light.random & 0xFE) | my_dir; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: random %d"), Light.random); +// AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: random %d"), Light.random); } // direction = (Light.random < Light.wheel) ? -1 : 1; direction = (Light.random &0x01) ? 1 : -1; @@ -1554,7 +1554,7 @@ void LightCycleColor(int8_t direction) Light.wheel += direction; uint16_t hue = changeUIntScale(Light.wheel, 0, 255, 0, 359); // Scale to hue to keep amount of steps low (max 255 instead of 359) -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: random %d, wheel %d, hue %d"), Light.random, Light.wheel, hue); +// AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: random %d, wheel %d, hue %d"), Light.random, Light.wheel, hue); if (!Light.pwm_multi_channels) { uint8_t sat; @@ -1696,7 +1696,7 @@ void LightAnimate(void) // Apply power modifiers to Light.new_color LightApplyPower(Light.new_color, Light.power); - // AddLog_P(LOG_LEVEL_INFO, PSTR("last_color (%02X%02X%02X%02X%02X) new_color (%02X%02X%02X%02X%02X) power %d"), + // AddLog(LOG_LEVEL_INFO, PSTR("last_color (%02X%02X%02X%02X%02X) new_color (%02X%02X%02X%02X%02X) power %d"), // Light.last_color[0], Light.last_color[1], Light.last_color[2], Light.last_color[3], Light.last_color[4], // Light.new_color[0], Light.new_color[1], Light.new_color[2], Light.new_color[3], Light.new_color[4], // Light.power @@ -1724,9 +1724,9 @@ void LightAnimate(void) if (Light.pwm_multi_channels) { calcGammaMultiChannels(cur_col_10); } else { - // AddLog_P(LOG_LEVEL_INFO, PSTR(">>> calcGammaBulbs In %03X,%03X,%03X,%03X,%03X"), cur_col_10[0], cur_col_10[1], cur_col_10[2], cur_col_10[3], cur_col_10[4]); + // AddLog(LOG_LEVEL_INFO, PSTR(">>> calcGammaBulbs In %03X,%03X,%03X,%03X,%03X"), cur_col_10[0], cur_col_10[1], cur_col_10[2], cur_col_10[3], cur_col_10[4]); rgbwwtable_applied_white = calcGammaBulbs(cur_col_10); // true means that one PWM channel is used for CT - // AddLog_P(LOG_LEVEL_INFO, PSTR(">>> calcGammaBulbs Out %03X,%03X,%03X,%03X,%03X"), cur_col_10[0], cur_col_10[1], cur_col_10[2], cur_col_10[3], cur_col_10[4]); + // AddLog(LOG_LEVEL_INFO, PSTR(">>> calcGammaBulbs Out %03X,%03X,%03X,%03X,%03X"), cur_col_10[0], cur_col_10[1], cur_col_10[2], cur_col_10[3], cur_col_10[4]); } // Apply RGBWWTable only if not Settings.flag4.white_blend_mode @@ -1768,7 +1768,7 @@ void LightAnimate(void) } if (Light.fade_running) { if (LightApplyFade()) { - // AddLog_P(LOG_LEVEL_INFO, PSTR("LightApplyFade %d %d %d %d %d"), + // AddLog(LOG_LEVEL_INFO, PSTR("LightApplyFade %d %d %d %d %d"), // Light.fade_cur_10[0], Light.fade_cur_10[1], Light.fade_cur_10[2], Light.fade_cur_10[3], Light.fade_cur_10[4]); LightSetOutputs(Light.fade_cur_10); @@ -1854,7 +1854,7 @@ bool LightApplyFade(void) { // did the value chanegd and needs to be applied if (Settings.save_data) { // Also postpone the save_data for the duration of the Fade (in seconds) uint32_t delay_seconds = 1 + (Light.fade_duration + 999) / 1000; // add one more second - // AddLog_P(LOG_LEVEL_INFO, PSTR("delay_seconds %d, save_data_counter %d"), delay_seconds, TasmotaGlobal.save_data_counter); + // AddLog(LOG_LEVEL_INFO, PSTR("delay_seconds %d, save_data_counter %d"), delay_seconds, TasmotaGlobal.save_data_counter); if (TasmotaGlobal.save_data_counter < delay_seconds) { TasmotaGlobal.save_data_counter = delay_seconds; // pospone } @@ -1904,7 +1904,7 @@ void LightApplyPower(uint8_t new_color[LST_MAX], power_t power) { } } // #ifdef DEBUG_LIGHT - // AddLog_P(LOG_LEVEL_DEBUG_MORE, "Animate>> Light.power=%d Light.new_color=[%d,%d,%d,%d,%d]", + // AddLog(LOG_LEVEL_DEBUG_MORE, "Animate>> Light.power=%d Light.new_color=[%d,%d,%d,%d,%d]", // Light.power, Light.new_color[0], Light.new_color[1], Light.new_color[2], // Light.new_color[3], Light.new_color[4]); // #endif @@ -1930,7 +1930,7 @@ void LightSetOutputs(const uint16_t *cur_col_10) { if (TasmotaGlobal.light_type < LT_PWM6) { // only for direct PWM lights, not for Tuya, Armtronix... for (uint32_t i = 0; i < (Light.subtype - Light.pwm_offset); i++) { if (PinUsed(GPIO_PWM1, i)) { - //AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d 10 bits %d"), i, cur_col_10[i]); + //AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d 10 bits %d"), i, cur_col_10[i]); uint16_t cur_col = cur_col_10[i + Light.pwm_offset]; if (!isChannelCT(i)) { // if CT don't use pwm_min and pwm_max cur_col = cur_col > 0 ? changeUIntScale(cur_col, 0, Settings.pwm_range, Light.pwm_min, Light.pwm_max) : 0; // shrink to the range of pwm_min..pwm_max @@ -1942,7 +1942,7 @@ void LightSetOutputs(const uint16_t *cur_col_10) { } } // char msg[24]; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: Channels %s"), ToHex_P((const unsigned char *)cur_col_10, 10, msg, sizeof(msg))); +// AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Channels %s"), ToHex_P((const unsigned char *)cur_col_10, 10, msg, sizeof(msg))); // Some devices need scaled RGB like Sonoff L1 uint32_t max = (cur_col_10[0] > cur_col_10[1] && cur_col_10[0] > cur_col_10[2]) ? cur_col_10[0] : (cur_col_10[1] > cur_col_10[2]) ? cur_col_10[1] : cur_col_10[2]; // 0..1023 @@ -1950,7 +1950,7 @@ void LightSetOutputs(const uint16_t *cur_col_10) { for (uint32_t i = 0; i < 3; i++) { scale_col[i] = (0 == max) ? 255 : changeUIntScale(cur_col_10[i], 0, max, 0, 255); } -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: CurCol %03X %03X %03X, ScaleCol %02X %02X %02X, Max %02X"), +// AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: CurCol %03X %03X %03X, ScaleCol %02X %02X %02X, Max %02X"), // cur_col_10[0], cur_col_10[1], cur_col_10[2], scale_col[0], scale_col[1], scale_col[2], max); uint8_t cur_col[LST_MAX]; @@ -2110,10 +2110,10 @@ bool calcGammaBulbs(uint16_t cur_col_10[5]) { calcGammaBulb5Channels_8(*(pivot+1), to10); vct_pivot_t *pivot1 = pivot + 1; - // AddLog_P(LOG_LEVEL_INFO, PSTR("+++ from_ct %d, to_ct %d [%03X,%03X,%03X,%03X,%03X] - [%03X,%03X,%03X,%03X,%03X]"), + // AddLog(LOG_LEVEL_INFO, PSTR("+++ from_ct %d, to_ct %d [%03X,%03X,%03X,%03X,%03X] - [%03X,%03X,%03X,%03X,%03X]"), // *from_ct, *(from_ct+1), (*pivot)[0], (*pivot)[1], (*pivot)[2], (*pivot)[3], (*pivot)[4], // (*pivot1)[0], (*pivot1)[1], (*pivot1)[2], (*pivot1)[3], (*pivot1)[4]); - // AddLog_P(LOG_LEVEL_INFO, PSTR("+++ from10 [%03X,%03X,%03X,%03X,%03X] - to 10 [%03X,%03X,%03X,%03X,%03X]"), + // AddLog(LOG_LEVEL_INFO, PSTR("+++ from10 [%03X,%03X,%03X,%03X,%03X] - to 10 [%03X,%03X,%03X,%03X,%03X]"), // from10[0],from10[0],from10[0],from10[0],from10[4], // to10[0],to10[0],to10[0],to10[0],to10[4]); diff --git a/tasmota/xdrv_04_light_utils.ino b/tasmota/xdrv_04_light_utils.ino index 8ab379d62..90c2f1dd3 100644 --- a/tasmota/xdrv_04_light_utils.ino +++ b/tasmota/xdrv_04_light_utils.ino @@ -132,7 +132,7 @@ void RgbToHsb(uint8_t ir, uint8_t ig, uint8_t ib, uint16_t *r_hue, uint8_t *r_sa if (r_hue) *r_hue = hue; if (r_sat) *r_sat = sat; if (r_bri) *r_bri = bri; - //AddLog_P(LOG_LEVEL_DEBUG_MORE, "RgbToHsb rgb (%d %d %d) hsb (%d %d %d)", r, g, b, hue, sat, bri); + //AddLog(LOG_LEVEL_DEBUG_MORE, "RgbToHsb rgb (%d %d %d) hsb (%d %d %d)", r, g, b, hue, sat, bri); } void HsToRgb(uint16_t hue, uint8_t sat, uint8_t *r_r, uint8_t *r_g, uint8_t *r_b) { diff --git a/tasmota/xdrv_05_irremote.ino b/tasmota/xdrv_05_irremote.ino index 44304c550..0cacb2161 100644 --- a/tasmota/xdrv_05_irremote.ino +++ b/tasmota/xdrv_05_irremote.ino @@ -76,6 +76,44 @@ const char kIrRemoteCommands[] PROGMEM = "|" D_CMND_IRSEND ; void (* const IrRemoteCommand[])(void) PROGMEM = { &CmndIrSend }; +char* ulltoa(unsigned long long value, char *str, int radix) +{ + char digits[64]; + char *dst = str; + int i = 0; + +// if (radix < 2 || radix > 36) { radix = 10; } + + do { + int n = value % radix; + digits[i++] = (n < 10) ? (char)n+'0' : (char)n-10+'A'; + value /= radix; + } while (value != 0); + + while (i > 0) { *dst++ = digits[--i]; } + + *dst = 0; + return str; +} + +char* Uint64toHex(uint64_t value, char *str, uint16_t bits) +{ + ulltoa(value, str, 16); // Get 64bit value + + int fill = 8; + if ((bits > 3) && (bits < 65)) { + fill = bits / 4; // Max 16 + if (bits % 4) { fill++; } + } + int len = strlen(str); + fill -= len; + if (fill > 0) { + memmove(str + fill, str, len +1); + memset(str, '0', fill); + } + return str; +} + /*********************************************************************************************\ * Class used to make a compact IR Raw format. * @@ -161,7 +199,7 @@ void IrReceiveInit(void) irrecv->setUnknownThreshold(Settings.param[P_IR_UNKNOW_THRESHOLD]); irrecv->enableIRIn(); // Start the receiver - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("IrReceive initialized")); + // AddLog(LOG_LEVEL_DEBUG, PSTR("IrReceive initialized")); } void IrReceiveCheck(void) @@ -190,7 +228,7 @@ void IrReceiveCheck(void) Uint64toHex(results.value, hvalue, 32); // UNKNOWN is always 32 bits hash } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_IRR "RawLen %d, Overflow %d, Bits %d, Value 0x%s, Decode %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_IRR "RawLen %d, Overflow %d, Bits %d, Value 0x%s, Decode %d"), results.rawlen, results.overflow, results.bits, hvalue, results.decode_type); unsigned long now = millis(); @@ -291,10 +329,10 @@ uint32_t IrRemoteCmndIrSendJson(void) char protocol_text[20]; int protocol_code = GetCommandCode(protocol_text, sizeof(protocol_text), protocol, kIrRemoteProtocols); - char dvalue[64]; - char hvalue[20]; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("IRS: protocol_text %s, protocol %s, bits %d, data %s (0x%s), repeat %d, protocol_code %d"), - protocol_text, protocol, bits, ulltoa(data, dvalue, 10), Uint64toHex(data, hvalue, bits), repeat, protocol_code); + // char dvalue[64]; + // char hvalue[20]; + // AddLog(LOG_LEVEL_DEBUG, PSTR("IRS: protocol_text %s, protocol %s, bits %d, data %s (0x%s), repeat %d, protocol_code %d"), + // protocol_text, protocol, bits, ulltoa(data, dvalue, 10), Uint64toHex(data, hvalue, bits), repeat, protocol_code); #ifdef USE_IR_RECEIVE if (!IR_RCV_WHILE_SENDING && (irrecv != nullptr)) { irrecv->disableIRIn(); } diff --git a/tasmota/xdrv_05_irremote_full.ino b/tasmota/xdrv_05_irremote_full.ino index bed0e8199..c88c19d8a 100644 --- a/tasmota/xdrv_05_irremote_full.ino +++ b/tasmota/xdrv_05_irremote_full.ino @@ -235,57 +235,36 @@ String sendACJsonState(const stdAc::state_t &state) { return payload; } -String sendIRJsonState(const struct decode_results &results) { - String json("{"); - json += "\"" D_JSON_IR_PROTOCOL "\":\""; - json += typeToString(results.decode_type); - json += "\",\"" D_JSON_IR_BITS "\":"; - json += results.bits; +void sendIRJsonState(const struct decode_results &results) { + Response_P(PSTR("\"" D_JSON_IR_PROTOCOL "\":\"%s\",\"" D_JSON_IR_BITS "\":%d"), + typeToString(results.decode_type).c_str(), + results.bits); if (hasACState(results.decode_type)) { - json += ",\"" D_JSON_IR_DATA "\":\""; - json += resultToHexidecimal(&results); - json += "\""; + ResponseAppend_P(PSTR(",\"" D_JSON_IR_DATA "\":\"%s\""), + resultToHexidecimal(&results).c_str()); } else { - if (UNKNOWN != results.decode_type) { - json += ",\"" D_JSON_IR_DATA "\":"; - } else { - json += ",\"" D_JSON_IR_HASH "\":"; - } + ResponseAppend_P(PSTR(",\"%s\":"), UNKNOWN != results.decode_type ? PSTR(D_JSON_IR_DATA) : PSTR(D_JSON_IR_HASH)); if (Settings.flag.ir_receive_decimal) { // SetOption29 - IR receive data format - char svalue[32]; - ulltoa(results.value, svalue, 10); - json += svalue; + ResponseAppend_P(PSTR("%u"), (uint32_t) results.value); } else { - char hvalue[64]; if (UNKNOWN != results.decode_type) { - Uint64toHex(results.value, hvalue, results.bits); // Get 64bit value as hex 0x00123456 - json += "\"0x"; - json += hvalue; - json += "\",\"" D_JSON_IR_DATALSB "\":\"0x"; - Uint64toHex(reverseBitsInBytes64(results.value), hvalue, results.bits); // Get 64bit value as hex 0x00123456, LSB - json += hvalue; - json += "\""; + uint64_t reverse = reverseBitsInBytes64(results.value); + ResponseAppend_P(PSTR("\"0x%_X\",\"" D_JSON_IR_DATALSB "\":\"0x%_X\""), + &results.value, &reverse); } else { // UNKNOWN - Uint64toHex(results.value, hvalue, 32); // Unknown is always 32 bits - json += "\"0x"; - json += hvalue; - json += "\""; + ResponseAppend_P(PSTR("\"0x08X\""), (uint32_t) results.value); // Unknown is always 32 bits } } } - json += ",\"" D_JSON_IR_REPEAT "\":"; - json += results.repeat; + ResponseAppend_P(PSTR(",\"" D_JSON_IR_REPEAT "\":%d"), results.repeat); stdAc::state_t new_state; if (IRAcUtils::decodeToState(&results, &new_state, irhvac_stateful && irac_prev_state.protocol == results.decode_type ? &irac_prev_state : nullptr)) { // we have a decoded state - json += ",\"" D_CMND_IRHVAC "\":"; - json += sendACJsonState(new_state); + ResponseAppend_P(PSTR(",\"" D_CMND_IRHVAC "\":%s"), sendACJsonState(new_state).c_str()); irac_prev_state = new_state; // store for next time } - - return json; } void IrReceiveCheck(void) @@ -298,7 +277,8 @@ void IrReceiveCheck(void) // if ((now - ir_lasttime > IR_TIME_AVOID_DUPLICATE) && (UNKNOWN != results.decode_type) && (results.bits > 0)) { if (now - ir_lasttime > IR_TIME_AVOID_DUPLICATE) { ir_lasttime = now; - Response_P(PSTR("{\"" D_JSON_IRRECEIVED "\":%s"), sendIRJsonState(results).c_str()); + Response_P(PSTR("{\"" D_JSON_IRRECEIVED "\":{")); + sendIRJsonState(results); IRRawTable raw_table; bool prev_number = false; // was the previous value a number, meaning we may need a comma prefix @@ -446,7 +426,7 @@ uint32_t IrRemoteCmndIrHvacJson(void) if (val = root[PSTR(D_JSON_IRHVAC_SWINGV)]) { state.swingv = IRac::strToSwingV(val.getStr()); } if (val = root[PSTR(D_JSON_IRHVAC_SWINGH)]) { state.swingh = IRac::strToSwingH(val.getStr()); } state.degrees = root.getFloat(PSTR(D_JSON_IRHVAC_TEMP), state.degrees); - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("model %d, mode %d, fanspeed %d, swingv %d, swingh %d"), + // AddLog(LOG_LEVEL_DEBUG, PSTR("model %d, mode %d, fanspeed %d, swingv %d, swingh %d"), // state.model, state.mode, state.fanspeed, state.swingv, state.swingh); // if and how we should handle the state for IRremote @@ -532,7 +512,7 @@ uint32_t IrRemoteCmndIrSendJson(void) char dvalue[32]; char hvalue[32]; - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("IRS: protocol %d, bits %d, data 0x%s (%s), repeat %d"), + // AddLog(LOG_LEVEL_DEBUG, PSTR("IRS: protocol %d, bits %d, data 0x%s (%s), repeat %d"), // protocol, bits, ulltoa(data, dvalue, 10), Uint64toHex(data, hvalue, bits), repeat); if (!IR_RCV_WHILE_SENDING && (irrecv != nullptr)) { irrecv->disableIRIn(); } @@ -617,7 +597,7 @@ uint32_t IrRemoteSendRawFormatted(char ** pp, uint32_t count, uint32_t repeat) { } if (!IR_RCV_WHILE_SENDING && (irrecv != nullptr)) { irrecv->disableIRIn(); } for (uint32_t r = 0; r <= repeat; r++) { - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("sendRaw count=%d, space=%d, mark=%d, freq=%d"), count, space, mark, freq); + // AddLog(LOG_LEVEL_DEBUG, PSTR("sendRaw count=%d, space=%d, mark=%d, freq=%d"), count, space, mark, freq); irsend->sendRaw(raw_array, i, freq); if (r < repeat) { // if it's not the last message irsend->space(40000); // since we don't know the inter-message gap, place an arbitrary 40ms gap @@ -644,7 +624,7 @@ uint32_t IrRemoteSendRawFormatted(char ** pp, uint32_t count, uint32_t repeat) { raw_array[i++] = parm[2]; // Trailing mark if (!IR_RCV_WHILE_SENDING && (irrecv != nullptr)) { irrecv->disableIRIn(); } for (uint32_t r = 0; r <= repeat; r++) { - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("sendRaw %d %d %d %d %d %d"), raw_array[0], raw_array[1], raw_array[2], raw_array[3], raw_array[4], raw_array[5]); + // AddLog(LOG_LEVEL_DEBUG, PSTR("sendRaw %d %d %d %d %d %d"), raw_array[0], raw_array[1], raw_array[2], raw_array[3], raw_array[4], raw_array[5]); irsend->sendRaw(raw_array, i, freq); if (r < repeat) { // if it's not the last message irsend->space(inter_message); // since we don't know the inter-message gap, place an arbitrary 40ms gap @@ -710,13 +690,13 @@ uint32_t IrRemoteSendRawStandard(char ** pp, uint16_t freq, uint32_t count, uint } else { count++; } - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("IrRemoteSendRawStandard: count_1 = %d"), count); + // AddLog(LOG_LEVEL_DEBUG, PSTR("IrRemoteSendRawStandard: count_1 = %d"), count); arr = (uint16_t*) malloc(count * sizeof(uint16_t)); if (nullptr == arr) { return IE_MEMORY; } count = IrRemoteParseRawCompact(*pp, arr, count); - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("IrRemoteSendRawStandard: count_2 = %d"), count); - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("Arr %d %d %d %d %d %d %d %d"), arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7]); + // AddLog(LOG_LEVEL_DEBUG, PSTR("IrRemoteSendRawStandard: count_2 = %d"), count); + // AddLog(LOG_LEVEL_DEBUG, PSTR("Arr %d %d %d %d %d %d %d %d"), arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7]); if (0 == count) { return IE_INVALID_RAWDATA; } if (!IR_RCV_WHILE_SENDING && (irrecv != nullptr)) { irrecv->disableIRIn(); } diff --git a/tasmota/xdrv_06_snfbridge.ino b/tasmota/xdrv_06_snfbridge.ino index bb77d64c2..405e5e74b 100644 --- a/tasmota/xdrv_06_snfbridge.ino +++ b/tasmota/xdrv_06_snfbridge.ino @@ -147,7 +147,7 @@ uint32_t SnfBrUpdateFirmware(uint8_t* data, uint32_t size) { uint32_t error = rf_erase_flash(); // 10, 11 if (error) { return error; } -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("RFB: Erased")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("RFB: Erased")); return rf_search_and_write(data, size); } diff --git a/tasmota/xdrv_07_domoticz.ino b/tasmota/xdrv_07_domoticz.ino index b982a58b1..96a6d4e3c 100644 --- a/tasmota/xdrv_07_domoticz.ino +++ b/tasmota/xdrv_07_domoticz.ino @@ -219,7 +219,7 @@ bool DomoticzMqttData(void) { uint32_t idx = domoticz.getUInt(PSTR("idx"), 0); int16_t nvalue = domoticz.getInt(PSTR("nvalue"), -1); - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ "idx %d, nvalue %d"), idx, nvalue); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ "idx %d, nvalue %d"), idx, nvalue); bool found = false; if ((idx > 0) && (nvalue >= 0) && (nvalue <= 15)) { @@ -371,7 +371,7 @@ void DomoticzSendData(uint32_t sensor_idx, uint32_t idx, char *data) { nvalue = position < 2 ? 0 : (position == 100 ? 1 : 2); } #endif // USE_SHUTTER - Response_P(DOMOTICZ_MESSAGE, + Response_P(DOMOTICZ_MESSAGE, // "{\"idx\":%d,\"nvalue\":%d,\"svalue\":\"%s\",\"Battery\":%d,\"RSSI\":%d}" idx, nvalue, data, DomoticzBatteryQuality(), DomoticzRssiQuality()); } MqttPublish(domoticz_in_topic); @@ -400,14 +400,14 @@ void DomoticzSensor(uint8_t idx, uint32_t value) { //void DomoticzTempHumPressureSensor(float temp, float hum, float baro = -1); void DomoticzTempHumPressureSensor(float temp, float hum, float baro) { char temperature[FLOATSZ]; - dtostrfd(temp, 2, temperature); + dtostrfd(temp, Settings.flag2.temperature_resolution, temperature); char humidity[FLOATSZ]; - dtostrfd(hum, 2, humidity); + dtostrfd(hum, Settings.flag2.humidity_resolution, humidity); char data[32]; if (baro > -1) { char pressure[FLOATSZ]; - dtostrfd(baro, 2, pressure); + dtostrfd(baro, Settings.flag2.pressure_resolution, pressure); snprintf_P(data, sizeof(data), PSTR("%s;%s;%d;%s;5"), temperature, humidity, DomoticzHumidityState(hum), pressure); DomoticzSensor(DZ_TEMP_HUM_BARO, data); @@ -544,7 +544,7 @@ const char HTTP_FORM_DOMOTICZ_TIMER[] PROGMEM = void HandleDomoticzConfiguration(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_DOMOTICZ)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_DOMOTICZ)); if (Webserver->hasArg(F("save"))) { DomoticzSaveSettings(); diff --git a/tasmota/xdrv_09_timers.ino b/tasmota/xdrv_09_timers.ino index a33204906..81b454cf5 100644 --- a/tasmota/xdrv_09_timers.ino +++ b/tasmota/xdrv_09_timers.ino @@ -839,7 +839,7 @@ void HandleTimerConfiguration(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_TIMER)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_TIMER)); if (Webserver->hasArg(F("save"))) { TimerSaveSettings(); diff --git a/tasmota/xdrv_10_rules.ino b/tasmota/xdrv_10_rules.ino index 4a6d3c9c1..80bdd95df 100644 --- a/tasmota/xdrv_10_rules.ino +++ b/tasmota/xdrv_10_rules.ino @@ -87,17 +87,20 @@ #define D_JSON_INITIATED "Initiated" -#define COMPARE_OPERATOR_NONE -1 -#define COMPARE_OPERATOR_EQUAL 0 -#define COMPARE_OPERATOR_BIGGER 1 -#define COMPARE_OPERATOR_SMALLER 2 -#define COMPARE_OPERATOR_EXACT_DIVISION 3 -#define COMPARE_OPERATOR_NUMBER_EQUAL 4 -#define COMPARE_OPERATOR_NOT_EQUAL 5 -#define COMPARE_OPERATOR_BIGGER_EQUAL 6 -#define COMPARE_OPERATOR_SMALLER_EQUAL 7 -#define MAXIMUM_COMPARE_OPERATOR COMPARE_OPERATOR_SMALLER_EQUAL -const char kCompareOperators[] PROGMEM = "=\0>\0<\0|\0==!=>=<="; +#define COMPARE_OPERATOR_NONE -1 +#define COMPARE_OPERATOR_EQUAL 0 +#define COMPARE_OPERATOR_BIGGER 1 +#define COMPARE_OPERATOR_SMALLER 2 +#define COMPARE_OPERATOR_EXACT_DIVISION 3 +#define COMPARE_OPERATOR_NUMBER_EQUAL 4 +#define COMPARE_OPERATOR_NOT_EQUAL 5 +#define COMPARE_OPERATOR_BIGGER_EQUAL 6 +#define COMPARE_OPERATOR_SMALLER_EQUAL 7 +#define COMPARE_OPERATOR_STRING_ENDS_WITH 8 +#define COMPARE_OPERATOR_STRING_STARTS_WITH 9 +#define COMPARE_OPERATOR_STRING_CONTAINS 10 +#define MAXIMUM_COMPARE_OPERATOR COMPARE_OPERATOR_STRING_CONTAINS +const char kCompareOperators[] PROGMEM = "=\0>\0<\0|\0==!=>=<=$>$<$|"; #ifdef USE_EXPRESSION #include // Import LinkedList library @@ -355,7 +358,7 @@ int32_t SetRule(uint32_t idx, const char *content, bool append = false) { len_uncompressed = strlen(Settings.rules[idx]); len_compressed = compressor.unishox_compress(Settings.rules[idx], len_uncompressed, nullptr /* dry-run */, MAX_RULE_SIZE + 8); - AddLog_P(LOG_LEVEL_INFO, PSTR("RUL: Stored uncompressed, would compress from %d to %d (-%d%%)"), len_uncompressed, len_compressed, 100 - changeUIntScale(len_compressed, 0, len_uncompressed, 0, 100)); + AddLog(LOG_LEVEL_INFO, PSTR("RUL: Stored uncompressed, would compress from %d to %d (-%d%%)"), len_uncompressed, len_compressed, 100 - changeUIntScale(len_compressed, 0, len_uncompressed, 0, 100)); } #endif // USE_UNISHOX_COMPRESSION @@ -384,9 +387,9 @@ int32_t SetRule(uint32_t idx, const char *content, bool append = false) { Settings.rules[idx][1] = (len_in + 7) / 8; // store original length in first bytes (4 bytes chuks) memcpy(&Settings.rules[idx][2], buf_out, len_compressed); Settings.rules[idx][len_compressed + 2] = 0; // add NULL termination - AddLog_P(LOG_LEVEL_INFO, PSTR("RUL: Compressed from %d to %d (-%d%%)"), len_in, len_compressed, 100 - changeUIntScale(len_compressed, 0, len_in, 0, 100)); - // AddLog_P(LOG_LEVEL_INFO, PSTR("RUL: First bytes: %02X%02X%02X%02X"), Settings.rules[idx][0], Settings.rules[idx][1], Settings.rules[idx][2], Settings.rules[idx][3]); - // AddLog_P(LOG_LEVEL_INFO, PSTR("RUL: GetRuleLenStorage = %d"), GetRuleLenStorage(idx)); + AddLog(LOG_LEVEL_INFO, PSTR("RUL: Compressed from %d to %d (-%d%%)"), len_in, len_compressed, 100 - changeUIntScale(len_compressed, 0, len_in, 0, 100)); + // AddLog(LOG_LEVEL_INFO, PSTR("RUL: First bytes: %02X%02X%02X%02X"), Settings.rules[idx][0], Settings.rules[idx][1], Settings.rules[idx][2], Settings.rules[idx][3]); + // AddLog(LOG_LEVEL_INFO, PSTR("RUL: GetRuleLenStorage = %d"), GetRuleLenStorage(idx)); } else { len_compressed = -1; // failed // clear rule cache, so it will be reloaded from Settings @@ -416,7 +419,7 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all // Step1: Analyse rule String rule_expr = rule; // "TELE-INA219#CURRENT>0.100" if (Rules.teleperiod) { - int ppos = rule_expr.indexOf(F("TELE-")); // "TELE-INA219#CURRENT>0.100" or "INA219#CURRENT>0.100" + int ppos = rule_expr.indexOf(F("TELE-")); // "TELE-INA219#CURRENT>0.100" or "INA219#CURRENT>0.100" if (ppos == -1) { return false; } // No pre-amble in rule rule_expr = rule.substring(5); // "INA219#CURRENT>0.100" or "SYSTEM#BOOT" } @@ -510,7 +513,7 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all JsonParserObject obj = parser.getRootObject(); if (!obj) { // AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL: Event too long (%d)"), event.length()); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("RUL: No valid JSON (%s)"), buf.c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR("RUL: No valid JSON (%s)"), buf.c_str()); return false; // No valid JSON data } String subtype; @@ -553,6 +556,7 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all value = CharToFloat((char*)str_value); int int_value = int(value); int int_rule_value = int(rule_value); + String str_str_value = String(str_value); switch (compareOperator) { case COMPARE_OPERATOR_EXACT_DIVISION: match = (int_rule_value && (int_value % int_rule_value) == 0); @@ -578,6 +582,15 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all case COMPARE_OPERATOR_SMALLER_EQUAL: match = (value <= rule_value); break; + case COMPARE_OPERATOR_STRING_ENDS_WITH: + match = str_str_value.endsWith(rule_svalue); + break; + case COMPARE_OPERATOR_STRING_STARTS_WITH: + match = str_str_value.startsWith(rule_svalue); + break; + case COMPARE_OPERATOR_STRING_CONTAINS: + match = (str_str_value.indexOf(rule_svalue) > 0); + break; default: match = true; } @@ -757,7 +770,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved) char command[commands.length() +1]; strlcpy(command, commands.c_str(), sizeof(command)); - AddLog_P(LOG_LEVEL_INFO, PSTR("RUL: %s performs \"%s\""), event_trigger.c_str(), command); + AddLog(LOG_LEVEL_INFO, PSTR("RUL: %s performs \"%s\""), event_trigger.c_str(), command); // Response_P(S_JSON_COMMAND_SVALUE, D_CMND_RULE, D_JSON_INITIATED); // MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_CMND_RULE)); @@ -1614,6 +1627,15 @@ bool evaluateComparisonExpression(const char *expression, int len) case COMPARE_OPERATOR_SMALLER_EQUAL: bResult = (leftValue <= rightValue); break; + case COMPARE_OPERATOR_STRING_ENDS_WITH: + bResult = leftExpr.endsWith(rightExpr); + break; + case COMPARE_OPERATOR_STRING_STARTS_WITH: + bResult = leftExpr.startsWith(rightExpr); + break; + case COMPARE_OPERATOR_STRING_CONTAINS: + bResult = (leftExpr.indexOf(rightExpr) > 0); + break; } return bResult; } @@ -2081,7 +2103,7 @@ void CmndRule(void) } int32_t res = SetRule(index - 1, ('"' == XdrvMailbox.data[0]) ? "" : XdrvMailbox.data, append); if (res < 0) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("RUL: Not enough space")); + AddLog(LOG_LEVEL_ERROR, PSTR("RUL: Not enough space")); } } Rules.triggers[index -1] = 0; // Reset once flag @@ -2101,7 +2123,7 @@ void CmndRule(void) } else { last_index = rule_len; // until the end of the rule } - AddLog_P(LOG_LEVEL_INFO, PSTR("RUL: Rule%d %s%s"), + AddLog(LOG_LEVEL_INFO, PSTR("RUL: Rule%d %s%s"), index, 0 == start_index ? PSTR("") : PSTR("+"), rule.substring(start_index, last_index).c_str()); start_index = last_index + 1; diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index b5f7a7890..e2d35b963 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -480,17 +480,6 @@ uint8_t fast_script=0; uint8_t glob_script=0; uint32_t script_lastmillis; -void Script_AddLog_P(uint32_t loglevel, PGM_P formatP, ...) { - char log_data[128]; - - va_list arg; - va_start(arg, formatP); - vsnprintf_P(log_data, sizeof(log_data), formatP, arg); - va_end(arg); - - AddLogData(loglevel, log_data); -} - void flt2char(float num, char *nbuff) { dtostrfd(num, glob_script_mem.script_dprec, nbuff); } @@ -905,7 +894,7 @@ char *script; } // variables usage info - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("Script: nv=%d, tv=%d, vns=%d, ram=%d"), nvars, svars, index, glob_script_mem.script_mem_size); + AddLog(LOG_LEVEL_INFO, PSTR("Script: nv=%d, tv=%d, vns=%d, ram=%d"), nvars, svars, index, glob_script_mem.script_mem_size); // copy string variables char *cp1 = glob_script_mem.glob_snp; @@ -1025,10 +1014,10 @@ void Script_Init_UDP() { if (glob_script_mem.udp_flags.udp_connected) return; if (Script_PortUdp.beginMulticast(WiFi.localIP(), IPAddress(239,255,255,250), SCRIPT_UDP_PORT)) { - Script_AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP "SCRIPT UDP started")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP "SCRIPT UDP started")); glob_script_mem.udp_flags.udp_connected = 1; } else { - Script_AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP "SCRIPT UDP failed")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP "SCRIPT UDP failed")); glob_script_mem.udp_flags.udp_connected = 0; } } @@ -1042,7 +1031,7 @@ void Script_PollUdp(void) { int32_t len = Script_PortUdp.read(packet_buffer, SCRIPT_UDP_BUFFER_SIZE - 1); packet_buffer[len] = 0; script_udp_remote_ip = Script_PortUdp.remoteIP(); - Script_AddLog_P(LOG_LEVEL_DEBUG, PSTR("UDP: Packet %s - %d - %s"), packet_buffer, len, script_udp_remote_ip.toString().c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR("UDP: Packet %s - %d - %s"), packet_buffer, len, script_udp_remote_ip.toString().c_str()); char *lp=packet_buffer; if (!strncmp(lp,"=>", 2)) { lp += 2; @@ -1061,10 +1050,10 @@ void Script_PollUdp(void) { uint32_t index; uint32_t res = match_vars(vnam, &fp, &sp, &index); if (res == NUM_RES) { - Script_AddLog_P(LOG_LEVEL_DEBUG, PSTR("num var found - %s - %d - %d"), vnam, res, index); + AddLog(LOG_LEVEL_DEBUG, PSTR("num var found - %s - %d - %d"), vnam, res, index); *fp=CharToFloat(cp + 1); } else if (res == STR_RES) { - Script_AddLog_P(LOG_LEVEL_DEBUG, PSTR("string var found - %s - %d - %d"), vnam, res, index); + AddLog(LOG_LEVEL_DEBUG, PSTR("string var found - %s - %d - %d"), vnam, res, index); strlcpy(sp, cp + 1, SCRIPT_MAXSSIZE); } else { // error var not found @@ -1098,10 +1087,10 @@ void script_udp_sendvar(char *vname,float *fp,char *sp) { char flstr[16]; dtostrfd(*fp, 8, flstr); strcat(sbuf, flstr); - Script_AddLog_P(LOG_LEVEL_DEBUG, PSTR("num var updated - %s"), sbuf); + AddLog(LOG_LEVEL_DEBUG, PSTR("num var updated - %s"), sbuf); } else { strcat(sbuf, sp); - Script_AddLog_P(LOG_LEVEL_DEBUG, PSTR("string var updated - %s"), sbuf); + AddLog(LOG_LEVEL_DEBUG, PSTR("string var updated - %s"), sbuf); } Script_PortUdp.beginPacket(IPAddress(239, 255, 255, 250), SCRIPT_UDP_PORT); // Udp.print(String("RET UC: ") + String(recv_Packet)); @@ -2014,7 +2003,7 @@ chknext: if (!glob_script_mem.file_flags[cnt].is_open) { if (mode==0) { #ifdef DEBUG_FS - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("open file for read %d"), cnt); + AddLog(LOG_LEVEL_INFO, PSTR("open file for read %d"), cnt); #endif glob_script_mem.files[cnt] = ufsp->open(str, FS_FILE_READ); if (glob_script_mem.files[cnt].isDirectory()) { @@ -2028,12 +2017,12 @@ chknext: if (mode==1) { glob_script_mem.files[cnt] = ufsp->open(str,FS_FILE_WRITE); #ifdef DEBUG_FS - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("open file for write %d"), cnt); + AddLog(LOG_LEVEL_INFO, PSTR("open file for write %d"), cnt); #endif } else { glob_script_mem.files[cnt] = ufsp->open(str,FS_FILE_APPEND); #ifdef DEBUG_FS - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("open file for append %d"), cnt); + AddLog(LOG_LEVEL_INFO, PSTR("open file for append %d"), cnt); #endif } } @@ -2041,7 +2030,7 @@ chknext: fvar = cnt; glob_script_mem.file_flags[cnt].is_open = 1; } else { - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("file open failed")); + AddLog(LOG_LEVEL_INFO, PSTR("file open failed")); } break; } @@ -2056,7 +2045,7 @@ chknext: uint8_t ind = fvar; if (ind>=SFS_MAX) ind = SFS_MAX - 1; #ifdef DEBUG_FS - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("closing file %d"), ind); + AddLog(LOG_LEVEL_INFO, PSTR("closing file %d"), ind); #endif glob_script_mem.files[ind].close(); glob_script_mem.file_flags[ind].is_open = 0; @@ -2192,7 +2181,7 @@ chknext: } else { fvar = 0; } - //Script_AddLog_P(LOG_LEVEL_INFO, PSTR("picture save: %d"), len); + //AddLog(LOG_LEVEL_INFO, PSTR("picture save: %d"), len); } else { fvar = 0; } @@ -3616,7 +3605,7 @@ void Replace_Cmd_Vars(char *srcbuf, uint32_t srcsize, char *dstbuf, uint32_t dst void toLog(const char *str) { if (!str) return; - Script_AddLog_P(LOG_LEVEL_INFO, str); + AddLog(LOG_LEVEL_INFO, str); } @@ -4328,7 +4317,7 @@ int16_t Run_script_sub(const char *type, int8_t tlen, JsonParserObject *jo) { } cmd[count] = *lp++; } - //Script_AddLog_P(LOG_LEVEL_INFO, tmp); + //AddLog(LOG_LEVEL_INFO, tmp); // replace vars in cmd char *tmp = cmdmem + SCRIPT_CMDMEM / 2; Replace_Cmd_Vars(cmd, 0, tmp, SCRIPT_CMDMEM / 2); @@ -4340,7 +4329,7 @@ int16_t Run_script_sub(const char *type, int8_t tlen, JsonParserObject *jo) { } else { if (!sflag) { tasm_cmd_activ = 1; - Script_AddLog_P(glob_script_mem.script_loglevel&0x7f, PSTR("Script: performs \"%s\""), tmp); + AddLog(glob_script_mem.script_loglevel&0x7f, PSTR("Script: performs \"%s\""), tmp); } else if (sflag==2) { // allow recursive call } else { @@ -4836,13 +4825,13 @@ uint8_t sc_state; // upload script and start immediately void script_upload_start(void) { - //Script_AddLog_P(LOG_LEVEL_INFO, PSTR("HTP: file upload execute")); + //AddLog(LOG_LEVEL_INFO, PSTR("HTP: file upload execute")); HTTPUpload& upload = Webserver->upload(); if (upload.status == UPLOAD_FILE_START) { - //Script_AddLog_P(LOG_LEVEL_INFO, PSTR("HTP: upload start")); + //AddLog(LOG_LEVEL_INFO, PSTR("HTP: upload start")); script_ex_ptr = (uint8_t*)glob_script_mem.script_ram; - //Script_AddLog_P(LOG_LEVEL_INFO, PSTR("HTP: upload file %s, %d"),upload.filename.c_str(),upload.totalSize); + //AddLog(LOG_LEVEL_INFO, PSTR("HTP: upload file %s, %d"),upload.filename.c_str(),upload.totalSize); if (strcmp(upload.filename.c_str(), "execute_script")) { Web.upload_error = 1; @@ -4860,7 +4849,7 @@ void script_upload_start(void) { bitWrite(Settings.rule_enabled, 0, 0); } else if(upload.status == UPLOAD_FILE_WRITE) { - //Script_AddLog_P(LOG_LEVEL_INFO, PSTR("HTP: upload write")); + //AddLog(LOG_LEVEL_INFO, PSTR("HTP: upload write")); uint32_t csiz = upload.currentSize; uint32_t tsiz = glob_script_mem.script_size - 1; if (uplsizeexists(file)) { - Script_AddLog_P(LOG_LEVEL_INFO,PSTR("file not found")); + AddLog(LOG_LEVEL_INFO,PSTR("file not found")); return 0; } download_file = ufsp->open(file, FS_FILE_READ); if (!download_file) { - Script_AddLog_P(LOG_LEVEL_INFO,PSTR("could not open file")); + AddLog(LOG_LEVEL_INFO,PSTR("could not open file")); return 0; } @@ -4980,7 +4969,7 @@ void HandleScriptConfiguration(void) { if (!HttpCheckPriviledgedAccess()) { return; } - Script_AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_SCRIPT)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_SCRIPT)); #ifdef USE_SCRIPT_FATFS if (Webserver->hasArg("d1")) { @@ -5080,7 +5069,7 @@ void ScriptSaveSettings(void) { strlcpy(glob_script_mem.script_ram, str.c_str(), glob_script_mem.script_size); if (glob_script_mem.script_ram[0]!='>' && glob_script_mem.script_ram[1]!='D') { - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("script error: must start with >D")); + AddLog(LOG_LEVEL_INFO, PSTR("script error: must start with >D")); bitWrite(Settings.rule_enabled, 0, 0); } @@ -5093,14 +5082,14 @@ void ScriptSaveSettings(void) { // uint32_t script_compress(char *dest, uint32_t size) { - //Script_AddLog_P(LOG_LEVEL_INFO,PSTR("in string: %s len = %d"),glob_script_mem.script_ram,strlen(glob_script_mem.script_ram)); + //AddLog(LOG_LEVEL_INFO,PSTR("in string: %s len = %d"),glob_script_mem.script_ram,strlen(glob_script_mem.script_ram)); uint32_t len_compressed = SCRIPT_COMPRESS(glob_script_mem.script_ram, strlen(glob_script_mem.script_ram), dest, size); if (len_compressed > 0) { dest[len_compressed] = 0; - Script_AddLog_P(LOG_LEVEL_INFO,PSTR("script compressed to %d bytes = %d %%"),len_compressed,len_compressed * 100 / strlen(glob_script_mem.script_ram)); + AddLog(LOG_LEVEL_INFO,PSTR("script compressed to %d bytes = %d %%"),len_compressed,len_compressed * 100 / strlen(glob_script_mem.script_ram)); return 0; } else { - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("script compress error: %d"), len_compressed); + AddLog(LOG_LEVEL_INFO, PSTR("script compress error: %d"), len_compressed); return 1; } } @@ -5123,7 +5112,7 @@ void SaveScriptEnd(void) { int16_t res = Init_Scripter(); if (res) { - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("script init error: %d"), res); + AddLog(LOG_LEVEL_INFO, PSTR("script init error: %d"), res); return; } @@ -5449,7 +5438,7 @@ void Script_Check_Hue(String *response) { } *response += String(EncodeLightId(hue_devs + TasmotaGlobal.devices_present + 1))+"\":"; Script_HueStatus(response, hue_devs); - //Script_AddLog_P(LOG_LEVEL_INFO, PSTR("Hue: %s - %d "),response->c_str(), hue_devs); + //AddLog(LOG_LEVEL_INFO, PSTR("Hue: %s - %d "),response->c_str(), hue_devs); } hue_devs++; @@ -5464,7 +5453,7 @@ void Script_Check_Hue(String *response) { } #if 0 if (response) { - Script_AddLog_P(LOG_LEVEL_DEBUG, PSTR("Hue: %d"), hue_devs); + AddLog(LOG_LEVEL_DEBUG, PSTR("Hue: %d"), hue_devs); toLog(">>>>"); toLog(response->c_str()); toLog(response->c_str()+MAX_LOGSZ); @@ -5609,7 +5598,7 @@ void Script_Handle_Hue(String *path) { } else { response = FPSTR(sHUE_ERROR_JSON); } - Script_AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Result (%s)"), response.c_str()); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Result (%s)"), response.c_str()); WSSend(code, CT_JSON, response); if (resp) { Run_Scripter(">E", 2, 0); @@ -5623,7 +5612,7 @@ bool Script_SubCmd(void) { if (!bitRead(Settings.rule_enabled, 0)) return false; if (tasm_cmd_activ) return false; - //Script_AddLog_P(LOG_LEVEL_INFO,PSTR(">> %s, %s, %d, %d "),XdrvMailbox.topic, XdrvMailbox.data, XdrvMailbox.payload, XdrvMailbox.index); + //AddLog(LOG_LEVEL_INFO,PSTR(">> %s, %s, %d, %d "),XdrvMailbox.topic, XdrvMailbox.data, XdrvMailbox.payload, XdrvMailbox.index); char command[CMDSZ]; strlcpy(command, XdrvMailbox.topic, CMDSZ); @@ -5651,7 +5640,7 @@ bool Script_SubCmd(void) { } //toLog(cmdbuff); uint32_t res = Run_Scripter(cmdbuff, tlen + 1, 0); - //Script_AddLog_P(LOG_LEVEL_INFO,">>%d",res); + //AddLog(LOG_LEVEL_INFO,">>%d",res); if (res) { return false; } @@ -5792,7 +5781,7 @@ uint32_t JsonParsePath(JsonParserObject *jobj, const char *spath, char delim, fl uint32_t res = 0; const char *cp = spath; #ifdef DEBUG_MQTT_EVENT -// Script_AddLog_P(LOG_LEVEL_INFO, PSTR("Script: parsing json key: %s from json: %s"), cp, jpath); +// AddLog(LOG_LEVEL_INFO, PSTR("Script: parsing json key: %s from json: %s"), cp, jpath); #endif JsonParserObject obj = *jobj; JsonParserObject lastobj = obj; @@ -5810,7 +5799,7 @@ uint32_t JsonParsePath(JsonParserObject *jobj, const char *spath, char delim, fl selem[sp] = *cp++; } #ifdef DEBUG_MQTT_EVENT - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("Script: cmp current key: %s"), selem); + AddLog(LOG_LEVEL_INFO, PSTR("Script: cmp current key: %s"), selem); #endif // check for array char *sp = strchr(selem,'['); @@ -5823,7 +5812,7 @@ uint32_t JsonParsePath(JsonParserObject *jobj, const char *spath, char delim, fl obj = obj[selem]; if (!obj.isValid()) { #ifdef DEBUG_MQTT_EVENT - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("Script: obj invalid: %s"), selem); + AddLog(LOG_LEVEL_INFO, PSTR("Script: obj invalid: %s"), selem); #endif JsonParserToken tok = lastobj[selem]; if (tok.isValid()) { @@ -5848,7 +5837,7 @@ uint32_t JsonParsePath(JsonParserObject *jobj, const char *spath, char delim, fl } #ifdef DEBUG_MQTT_EVENT - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("Script: token invalid: %s"), selem); + AddLog(LOG_LEVEL_INFO, PSTR("Script: token invalid: %s"), selem); #endif break; } @@ -5891,7 +5880,7 @@ bool ScriptMqttData(void) String sData = XdrvMailbox.data; #ifdef DEBUG_MQTT_EVENT - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("Script: MQTT Topic %s, Event %s"), XdrvMailbox.topic, XdrvMailbox.data); + AddLog(LOG_LEVEL_INFO, PSTR("Script: MQTT Topic %s, Event %s"), XdrvMailbox.topic, XdrvMailbox.data); #endif MQTT_Subscription event_item; @@ -5901,7 +5890,7 @@ bool ScriptMqttData(void) uint8_t json_valid = 0; #ifdef DEBUG_MQTT_EVENT - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("Script: Match MQTT message Topic %s with subscription topic %s and key %s"), sTopic.c_str(), event_item.Topic.c_str(),event_item.Key.c_str()); + AddLog(LOG_LEVEL_INFO, PSTR("Script: Match MQTT message Topic %s with subscription topic %s and key %s"), sTopic.c_str(), event_item.Topic.c_str(),event_item.Key.c_str()); #endif if (sTopic.startsWith(event_item.Topic)) { //This topic is subscribed by us, so serve it @@ -5958,7 +5947,7 @@ bool ScriptMqttData(void) snprintf_P(sbuffer, sizeof(sbuffer), PSTR(">%s=\"%s\"\n"), event_item.Event.c_str(), value.c_str()); } #ifdef DEBUG_MQTT_EVENT - Script_AddLog_P(LOG_LEVEL_INFO, PSTR("Script: setting script var %s"), sbuffer); + AddLog(LOG_LEVEL_INFO, PSTR("Script: setting script var %s"), sbuffer); #endif //toLog(sbuffer); execute_script(sbuffer); @@ -6007,7 +5996,7 @@ String ScriptSubscribe(const char *data, int data_len) } } } - //Script_AddLog_P(LOG_LEVEL_DEBUG, PSTR("Script: Subscribe command with parameters: %s, %s, %s."), event_name.c_str(), topic.c_str(), key.c_str()); + //AddLog(LOG_LEVEL_DEBUG, PSTR("Script: Subscribe command with parameters: %s, %s, %s."), event_name.c_str(), topic.c_str(), key.c_str()); //event_name.toUpperCase(); if (event_name.length() > 0 && topic.length() > 0) { //Search all subscriptions @@ -6028,7 +6017,7 @@ String ScriptSubscribe(const char *data, int data_len) topic.concat("/#"); } } - // Script_AddLog_P(LOG_LEVEL_DEBUG, PSTR("Script: New topic: %s."), topic.c_str()); + // AddLog(LOG_LEVEL_DEBUG, PSTR("Script: New topic: %s."), topic.c_str()); //MQTT Subscribe subscription_item.Event = event_name; subscription_item.Topic = topic.substring(0, topic.length() - 2); //Remove "/#" so easy to match @@ -7394,7 +7383,7 @@ bool Xdrv10(uint8_t function) #ifdef USE_UFILESYS if (ufs_type) { // we have a file system - Script_AddLog_P(LOG_LEVEL_INFO,PSTR("UFILESYSTEM OK!")); + AddLog(LOG_LEVEL_INFO,PSTR("UFILESYSTEM OK!")); char *script; script = (char*)calloc(UFSYS_SIZE + 4, 1); if (!script) break; @@ -7413,7 +7402,7 @@ bool Xdrv10(uint8_t function) // indicates scripter use no compression bitWrite(Settings.rule_once, 6, 0); } else { - Script_AddLog_P(LOG_LEVEL_INFO,PSTR("UFILESYSTEM fail, using compression!")); + AddLog(LOG_LEVEL_INFO,PSTR("UFILESYSTEM fail, using compression!")); int32_t len_decompressed; sprt = (char*)calloc(UNISHOXRSIZE + 8,1); if (!sprt) { break; } diff --git a/tasmota/xdrv_11_knx.ino b/tasmota/xdrv_11_knx.ino index 0a8442e3b..a474d058f 100644 --- a/tasmota/xdrv_11_knx.ino +++ b/tasmota/xdrv_11_knx.ino @@ -255,7 +255,7 @@ void KNX_ADD_GA( uint8_t GAop, uint8_t GA_FNUM, uint8_t GA_AREA, uint8_t GA_FDEF Settings.knx_GA_registered++; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ADD " GA #%d: %s " D_TO " %d/%d/%d"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ADD " GA #%d: %s " D_TO " %d/%d/%d"), Settings.knx_GA_registered, device_param_ga[GAop-1], GA_FNUM, GA_AREA, GA_FDEF ); @@ -304,7 +304,7 @@ void KNX_DEL_GA( uint8_t GAnum ) Settings.knx_GA_registered--; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " GA #%d"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " GA #%d"), GAnum ); } @@ -336,7 +336,7 @@ void KNX_ADD_CB( uint8_t CBop, uint8_t CB_FNUM, uint8_t CB_AREA, uint8_t CB_FDEF Settings.knx_CB_registered++; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ADD " CB #%d: %d/%d/%d " D_TO " %s"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ADD " CB #%d: %d/%d/%d " D_TO " %s"), Settings.knx_CB_registered, CB_FNUM, CB_AREA, CB_FDEF, device_param_cb[CBop-1] ); @@ -392,7 +392,7 @@ void KNX_DEL_CB( uint8_t CBnum ) device_param[oldparam-1].CB_id = KNX_Empty; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " CB #%d"), CBnum ); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " CB #%d"), CBnum ); } @@ -449,7 +449,7 @@ bool KNX_CONFIG_NOT_MATCH(void) void KNXStart(void) { knx.start(nullptr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_START)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_START)); } @@ -522,7 +522,7 @@ void KNX_INIT(void) if (KNX_CONFIG_NOT_MATCH()) { Settings.knx_GA_registered = 0; Settings.knx_CB_registered = 0; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " " D_KNX_PARAMETERS)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " " D_KNX_PARAMETERS)); } // Register Group Addresses to listen to @@ -564,7 +564,7 @@ void KNX_CB_Action(message_t const &msg, void *arg) float tempvar = knx.data_to_4byte_float(msg.data); dtostrfd(tempvar,2,tempchar); } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_KNX D_RECEIVED_FROM " %d.%d.%d " D_COMMAND " %s: %s " D_TO " %s"), + AddLog(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, @@ -748,7 +748,7 @@ void KnxUpdatePowerState(uint8_t device, power_t state) knx.write_1bit(KNX_addr, device_param[device -1].last_state); } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"), + AddLog(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, KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member); @@ -782,7 +782,7 @@ void KnxSendButtonPower(void) knx.write_1bit(KNX_addr, !(state == 0)); } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"), + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"), device_param_ga[device + 7], !(state == 0), KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member); @@ -813,7 +813,7 @@ void KnxSensor(uint8_t sensor_type, float value) knx.write_4byte_float(KNX_addr, value); } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s " D_SENT_TO " %d.%d.%d "), + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s " D_SENT_TO " %d.%d.%d "), device_param_ga[sensor_type -1], KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member); @@ -886,7 +886,7 @@ void HandleKNXConfiguration(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_KNX)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_KNX)); char tmp[100]; String stmp; @@ -1038,7 +1038,7 @@ void KNX_Save_Settings(void) Settings.flag.knx_enabled = Webserver->hasArg("b1"); Settings.flag.knx_enable_enhancement = Webserver->hasArg("b2"); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ENABLED ": %d, " D_KNX_ENHANCEMENT ": %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ENABLED ": %d, " D_KNX_ENHANCEMENT ": %d"), Settings.flag.knx_enabled, Settings.flag.knx_enable_enhancement ); stmp = Webserver->arg("area"); @@ -1049,26 +1049,26 @@ void KNX_Save_Settings(void) KNX_addr.pa.member = stmp.toInt(); Settings.knx_physsical_addr = KNX_addr.value; knx.physical_address_set( KNX_addr ); // Set Physical KNX Address of the device - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_KNX_PHYSICAL_ADDRESS ": %d.%d.%d "), + AddLog(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 ); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "GA: %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "GA: %d"), Settings.knx_GA_registered ); for (uint32_t i = 0; i < Settings.knx_GA_registered ; ++i) { KNX_addr.value = Settings.knx_GA_addr[i]; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "GA #%d: %s " D_TO " %d/%d/%d"), + AddLog(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], KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member ); } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "CB: %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "CB: %d"), Settings.knx_CB_registered ); for (uint32_t i = 0; i < Settings.knx_CB_registered ; ++i) { KNX_addr.value = Settings.knx_CB_addr[i]; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "CB #%d: %d/%d/%d " D_TO " %s"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "CB #%d: %d/%d/%d " D_TO " %s"), i+1, KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member, device_param_cb[Settings.knx_CB_param[i]-1] ); @@ -1097,7 +1097,7 @@ void CmndKnxTxCmnd(void) knx.write_1bit(KNX_addr, !(XdrvMailbox.payload == 0)); } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"), + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"), device_param_ga[XdrvMailbox.index + KNX_SLOT1 -2], !(XdrvMailbox.payload == 0), KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member); @@ -1126,7 +1126,7 @@ void CmndKnxTxVal(void) knx.write_4byte_float(KNX_addr, tempvar); } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %s " D_SENT_TO " %d.%d.%d"), + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %s " D_SENT_TO " %d.%d.%d"), device_param_ga[XdrvMailbox.index + KNX_SLOT1 -2], XdrvMailbox.data, KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member); @@ -1153,7 +1153,7 @@ void CmndKnxTxScene(void) knx.write_1byte_uint(KNX_addr, tempvar); } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %s " D_SENT_TO " %d.%d.%d"), + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %s " D_SENT_TO " %d.%d.%d"), device_param_ga[KNX_SCENE-1], XdrvMailbox.data, KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member); ResponseCmndIdxChar (XdrvMailbox.data); diff --git a/tasmota/xdrv_12_home_assistant.ino b/tasmota/xdrv_12_home_assistant.ino index 0120615e0..918431071 100644 --- a/tasmota/xdrv_12_home_assistant.ino +++ b/tasmota/xdrv_12_home_assistant.ino @@ -1025,7 +1025,7 @@ void HAssAnnounceDeviceInfoAndStatusSensor(void) if (!Settings.flag.hass_discovery) { TasmotaGlobal.masterlog_level = 0; - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_LOG "Home Assistant MQTT Discovery disabled.")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_LOG "Home Assistant MQTT Discovery disabled.")); } } diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index d2efd21c2..84a1d6058 100755 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -1289,7 +1289,7 @@ void DisplayInitDriver(void) } -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model); if (Settings.display_model) { TasmotaGlobal.devices_present++; @@ -1312,7 +1312,7 @@ void DisplaySetPower(void) { disp_power = bitRead(XdrvMailbox.index, disp_device -1); -//AddLog_P(LOG_LEVEL_DEBUG, PSTR("DSP: Power %d"), disp_power); +//AddLog(LOG_LEVEL_DEBUG, PSTR("DSP: Power %d"), disp_power); if (Settings.display_model) { if (!renderer) { @@ -2176,7 +2176,7 @@ uint8_t vbutt=0; if (!(tbstate[tbut] & 1)) { // pressed tbstate[tbut] |= 1; - //AddLog_P(LOG_LEVEL_INFO, PSTR("tbut: %d pressed"), tbut); + //AddLog(LOG_LEVEL_INFO, PSTR("tbut: %d pressed"), tbut); Touch_MQTT(tbut, "BIB", tbstate[tbut] & 1); } } @@ -2186,7 +2186,7 @@ uint8_t vbutt=0; rotconvert(&pLoc.x, &pLoc.y); - //AddLog_P(LOG_LEVEL_INFO, PSTR("touch %d - %d"), pLoc.x, pLoc.y); + //AddLog(LOG_LEVEL_INFO, PSTR("touch %d - %d"), pLoc.x, pLoc.y); // now must compare with defined buttons for (uint8_t count=0; countvpower.disable) { @@ -2233,7 +2233,7 @@ uint8_t vbutt=0; // released tbstate[tbut] &= 0xfe; Touch_MQTT(tbut, "BIB", tbstate[tbut] & 1); - //AddLog_P(LOG_LEVEL_INFO, PSTR("tbut: %d released"), tbut); + //AddLog(LOG_LEVEL_INFO, PSTR("tbut: %d released"), tbut); } } #endif diff --git a/tasmota/xdrv_14_mp3.ino b/tasmota/xdrv_14_mp3.ino index b0af75e57..2df04da58 100644 --- a/tasmota/xdrv_14_mp3.ino +++ b/tasmota/xdrv_14_mp3.ino @@ -19,6 +19,14 @@ -------------------------------------------------------------------------------------------- Version yyyymmdd Action Description -------------------------------------------------------------------------------------------- + 1.0.0.5 20210121 added - support for DY_SV17F Player (#define USE_DY_SV17F) + - cmds supported: + - track + - stop + - volume + - play + - play /path + 1.0.0.4 20181003 added - MP3Reset command in case that the player do rare things - and needs a reset, the default volume will be set again too added - MP3_CMD_RESET_VALUE for the player reset function @@ -148,6 +156,60 @@ void MP3PlayerInit(void) { return; } + +#ifdef USE_DY_SV17F + +/*********************************************************************************************\ + * specific for DY_SV17F + * create the MP3 commands payload, and send it via serial interface to the MP3 player + * only track,play,stop and volume supported +\*********************************************************************************************/ + +void MP3_SendCmd(uint8_t *scmd, uint8_t len) { +uint16_t sum = 0; + for (uint32_t cnt = 0; cnt < len; cnt++) { + sum += scmd[cnt]; + } + scmd[len] = sum; + MP3Player->write(scmd, len + 1); +} + +void MP3_CMD(uint8_t mp3cmd, uint16_t val) { + uint8_t scmd[8]; + uint8_t len = 0; + scmd[0]=0xAA; + switch (mp3cmd) { + case MP3_CMD_TRACK: + scmd[1]=0x07; + scmd[2]=0x02; + scmd[3]=val>>8; + scmd[4]=val; + MP3_SendCmd(scmd, 5); + case MP3_CMD_PLAY: + scmd[1]=0x02; + scmd[2]=0x00; + scmd[3]=0xAC; + len = 4; + break; + case MP3_CMD_STOP: + scmd[1]=0x10; + scmd[2]=0x00; + scmd[3]=0xBA; + len = 4; + break; + case MP3_CMD_VOLUME: + scmd[1]=0x13; + scmd[2]=0x01; + scmd[3]=val; + len = 4; + break; + default: + return; + } + MP3_SendCmd(scmd, len); +} + +#else /*********************************************************************************************\ * create the MP3 commands payload, and send it via serial interface to the MP3 player * data length is 6 = 6 bytes [FF 06 09 00 00 00] but not counting the start, end, and verification. @@ -173,7 +235,7 @@ void MP3_CMD(uint8_t mp3cmd,uint16_t val) { } return; } - +#endif // USE_DY_SV17F /*********************************************************************************************\ * check the MP3 commands \*********************************************************************************************/ @@ -202,7 +264,9 @@ bool MP3PlayerCmd(void) { } Response_P(S_JSON_MP3_COMMAND_NVALUE, command, XdrvMailbox.payload); break; +#ifndef USE_DY_SV17F case CMND_MP3_PLAY: +#endif // USE_DY_SV17F case CMND_MP3_PAUSE: case CMND_MP3_STOP: case CMND_MP3_RESET: @@ -213,6 +277,32 @@ bool MP3PlayerCmd(void) { if (command_code == CMND_MP3_RESET) { MP3_CMD(MP3_CMD_RESET, 0); } Response_P(S_JSON_MP3_COMMAND, command, XdrvMailbox.payload); break; + +#ifdef USE_DY_SV17F + case CMND_MP3_PLAY: + if (XdrvMailbox.data_len > 0) { + uint8_t scmd[64]; + scmd[0] = 0xAA; + scmd[1] = 0x08; + scmd[2] = XdrvMailbox.data_len + 1; + scmd[3] = 2; + char *cp = XdrvMailbox.data; + scmd[4] = *cp; + for (uint8_t i = 1; i < XdrvMailbox.data_len; i++) { + if (cp[i]=='.') { + scmd[i + 4] = '*'; + } else { + scmd[i + 4] = toupper(cp[i]); + } + } + MP3_SendCmd(scmd, XdrvMailbox.data_len + 4); + Response_P(S_JSON_COMMAND_SVALUE, command, XdrvMailbox.data); + } else { + MP3_CMD(MP3_CMD_PLAY, 0); + Response_P(S_JSON_MP3_COMMAND, command, XdrvMailbox.payload); + } + break; +#endif // USE_DY_SV17F default: // else for Unknown command serviced = false; diff --git a/tasmota/xdrv_16_tuyamcu.ino b/tasmota/xdrv_16_tuyamcu.ino index 7535d29c5..8dcddb380 100644 --- a/tasmota/xdrv_16_tuyamcu.ino +++ b/tasmota/xdrv_16_tuyamcu.ino @@ -148,7 +148,7 @@ void CmndTuyaSend(void) { TuyaRequestState(8); } else if (XdrvMailbox.index == 9) { // TuyaSend Topic Toggle Settings.tuyamcu_topic = !Settings.tuyamcu_topic; - AddLog_P(LOG_LEVEL_INFO, PSTR("TYA: TuyaMCU Stat Topic %s"), (Settings.tuyamcu_topic ? PSTR("enabled") : PSTR("disabled"))); + AddLog(LOG_LEVEL_INFO, PSTR("TYA: TuyaMCU Stat Topic %s"), (Settings.tuyamcu_topic ? PSTR("enabled") : PSTR("disabled"))); } else { if (XdrvMailbox.data_len > 0) { @@ -207,7 +207,7 @@ void CmndTuyaMcu(void) { TuyaAddMcuFunc(parm[0], parm[1]); TasmotaGlobal.restart_flag = 2; } else { - AddLog_P(LOG_LEVEL_ERROR, PSTR("TYA: TuyaMcu Invalid function id=%d"), parm[0]); + AddLog(LOG_LEVEL_ERROR, PSTR("TYA: TuyaMcu Invalid function id=%d"), parm[0]); } } @@ -626,9 +626,9 @@ void LightSerialDuty(uint16_t duty, char *hex_char, uint8_t TuyaIdx) } else { duty = changeUIntScale(duty, 0, 100, 0, Settings.dimmer_hw_max); } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Send dim skipped value %d for dpid %d"), duty, dpid); // due to 0 or already set + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Send dim skipped value %d for dpid %d"), duty, dpid); // due to 0 or already set } else { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Cannot set dimmer. Dimmer Id unknown")); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Cannot set dimmer. Dimmer Id unknown")); } } @@ -638,7 +638,7 @@ void LightSerialDuty(uint16_t duty, char *hex_char, uint8_t TuyaIdx) TuyaSendEnum(TuyaGetDpId(TUYA_MCU_FUNC_MODESET), 1); } TuyaSendString(dpid, hex_char); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: TX RGB hex %s to dpId %d"), hex_char, dpid); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: TX RGB hex %s to dpId %d"), hex_char, dpid); } } @@ -646,7 +646,7 @@ void TuyaRequestState(uint8_t state_type) { if (TuyaSerial) { // Get current status of MCU - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Read MCU state")); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Read MCU state")); Tuya.SuspendTopic = true; Tuya.ignore_topic_timeout = millis() + 1000; // suppress /STAT topic for 1000ms to limit data switch (state_type) { @@ -680,23 +680,23 @@ void TuyaProcessStatePacket(void) { dpDataLen = Tuya.buffer[dpidStart + 2] << 8 | Tuya.buffer[dpidStart + 3]; fnId = TuyaGetFuncId(Tuya.buffer[dpidStart]); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: fnId=%d is set for dpId=%d"), fnId, Tuya.buffer[dpidStart]); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: fnId=%d is set for dpId=%d"), fnId, Tuya.buffer[dpidStart]); if (Tuya.buffer[dpidStart + 1] == 1) { // Data Type 1 if (fnId >= TUYA_MCU_FUNC_REL1 && fnId <= TUYA_MCU_FUNC_REL8) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX Relay-%d --> MCU State: %s Current State:%s"), fnId - TUYA_MCU_FUNC_REL1 + 1, Tuya.buffer[dpidStart + 4]?"On":"Off",bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1)?"On":"Off"); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX Relay-%d --> MCU State: %s Current State:%s"), fnId - TUYA_MCU_FUNC_REL1 + 1, Tuya.buffer[dpidStart + 4]?"On":"Off",bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1)?"On":"Off"); if ((TasmotaGlobal.power || Settings.light_dimmer > 0) && (Tuya.buffer[dpidStart + 4] != bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1))) { if (!Tuya.buffer[dpidStart + 4]) { PowerOff = true; } ExecuteCommandPower(fnId - TUYA_MCU_FUNC_REL1 + 1, Tuya.buffer[dpidStart + 4], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction } } else if (fnId >= TUYA_MCU_FUNC_REL1_INV && fnId <= TUYA_MCU_FUNC_REL8_INV) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX Relay-%d-Inverted --> MCU State: %s Current State:%s"), fnId - TUYA_MCU_FUNC_REL1_INV + 1, Tuya.buffer[dpidStart + 4]?"Off":"On",bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1_INV) ^ 1?"Off":"On"); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX Relay-%d-Inverted --> MCU State: %s Current State:%s"), fnId - TUYA_MCU_FUNC_REL1_INV + 1, Tuya.buffer[dpidStart + 4]?"Off":"On",bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1_INV) ^ 1?"Off":"On"); if (Tuya.buffer[dpidStart + 4] != bitRead(TasmotaGlobal.power, fnId - TUYA_MCU_FUNC_REL1_INV) ^ 1) { ExecuteCommandPower(fnId - TUYA_MCU_FUNC_REL1_INV + 1, Tuya.buffer[dpidStart + 4] ^ 1, SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction if (Tuya.buffer[dpidStart + 4]) { PowerOff = true; } } } else if (fnId >= TUYA_MCU_FUNC_SWT1 && fnId <= TUYA_MCU_FUNC_SWT4) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX Switch-%d --> MCU State: %d Current State:%d"),fnId - TUYA_MCU_FUNC_SWT1 + 1,Tuya.buffer[dpidStart + 4], SwitchGetVirtual(fnId - TUYA_MCU_FUNC_SWT1)); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX Switch-%d --> MCU State: %d Current State:%d"),fnId - TUYA_MCU_FUNC_SWT1 + 1,Tuya.buffer[dpidStart + 4], SwitchGetVirtual(fnId - TUYA_MCU_FUNC_SWT1)); if (SwitchGetVirtual(fnId - TUYA_MCU_FUNC_SWT1) != Tuya.buffer[dpidStart + 4]) { SwitchSetVirtual(fnId - TUYA_MCU_FUNC_SWT1, Tuya.buffer[dpidStart + 4]); @@ -747,7 +747,7 @@ void TuyaProcessStatePacket(void) { Tuya.Levels[dimIndex] = changeUIntScale(packetValue, 0, Settings.dimmer_hw_max, 0, 100); } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX value %d from dpId %d "), packetValue, Tuya.buffer[dpidStart]); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX value %d from dpId %d "), packetValue, Tuya.buffer[dpidStart]); if ((fnId == TUYA_MCU_FUNC_DIMMER) || (fnId == TUYA_MCU_FUNC_REPORT1) || (fnId == TUYA_MCU_FUNC_DIMMER2) || (fnId == TUYA_MCU_FUNC_REPORT2) || @@ -787,13 +787,13 @@ void TuyaProcessStatePacket(void) { #ifdef USE_ENERGY_SENSOR else if (tuya_energy_enabled && fnId == TUYA_MCU_FUNC_VOLTAGE) { Energy.voltage[0] = (float)packetValue / 10; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Voltage=%d"), Tuya.buffer[dpidStart], packetValue); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Voltage=%d"), Tuya.buffer[dpidStart], packetValue); } else if (tuya_energy_enabled && fnId == TUYA_MCU_FUNC_CURRENT) { Energy.current[0] = (float)packetValue / 1000; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Current=%d"), Tuya.buffer[dpidStart], packetValue); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Current=%d"), Tuya.buffer[dpidStart], packetValue); } else if (tuya_energy_enabled && fnId == TUYA_MCU_FUNC_POWER) { Energy.active_power[0] = (float)packetValue / 10; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Active_Power=%d"), Tuya.buffer[dpidStart], packetValue); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Rx ID=%d Active_Power=%d"), Tuya.buffer[dpidStart], packetValue); if (RtcTime.valid) { if (Tuya.lastPowerCheckTime != 0 && Energy.active_power[0] > 0) { @@ -882,7 +882,7 @@ void TuyaLowPowerModePacketProcess(void) { void TuyaHandleProductInfoPacket(void) { uint16_t dataLength = Tuya.buffer[4] << 8 | Tuya.buffer[5]; char *data = &Tuya.buffer[6]; - AddLog_P(LOG_LEVEL_INFO, PSTR("TYA: MCU Product ID: %.*s"), dataLength, data); + AddLog(LOG_LEVEL_INFO, PSTR("TYA: MCU Product ID: %.*s"), dataLength, data); } void TuyaSendLowPowerSuccessIfNeeded(void) { @@ -903,9 +903,9 @@ void TuyaNormalPowerModePacketProcess(void) break; case TUYA_CMD_HEARTBEAT: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Heartbeat")); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Heartbeat")); if (Tuya.buffer[6] == 0) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Detected MCU restart")); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Detected MCU restart")); Tuya.wifi_state = -2; } break; @@ -916,17 +916,17 @@ void TuyaNormalPowerModePacketProcess(void) case TUYA_CMD_WIFI_RESET: case TUYA_CMD_WIFI_SELECT: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX WiFi Reset")); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX WiFi Reset")); TuyaResetWifi(); break; case TUYA_CMD_WIFI_STATE: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX WiFi LED set ACK")); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX WiFi LED set ACK")); Tuya.wifi_state = TuyaGetTuyaWifiState(); break; case TUYA_CMD_MCU_CONF: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX MCU configuration Mode=%d"), Tuya.buffer[5]); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX MCU configuration Mode=%d"), Tuya.buffer[5]); if (Tuya.buffer[5] == 2) { // Processing by ESP module mode uint8_t led1_gpio = Tuya.buffer[6]; @@ -954,7 +954,7 @@ void TuyaNormalPowerModePacketProcess(void) break; #endif default: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: RX unknown command")); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: RX unknown command")); } } @@ -1039,7 +1039,7 @@ void TuyaInit(void) // Get MCU Configuration Tuya.SuspendTopic = true; Tuya.ignore_topic_timeout = millis() + 1000; // suppress /STAT topic for 1000ms to avoid data overflow - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Request MCU configuration at %d bps"), baudrate); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Request MCU configuration at %d bps"), baudrate); } @@ -1175,7 +1175,7 @@ void TuyaSerialInput(void) bool TuyaButtonPressed(void) { if (!XdrvMailbox.index && ((PRESSED == XdrvMailbox.payload) && (NOT_PRESSED == Button.last_state[XdrvMailbox.index]))) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Reset GPIO triggered")); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Reset GPIO triggered")); TuyaResetWifi(); return true; // Reset GPIO served here } @@ -1204,7 +1204,7 @@ uint8_t TuyaGetTuyaWifiState(void) { void TuyaSetWifiLed(void) { Tuya.wifi_state = TuyaGetTuyaWifiState(); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Set WiFi LED %d (%d)"), Tuya.wifi_state, WifiState()); + AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Set WiFi LED %d (%d)"), Tuya.wifi_state, WifiState()); if (Tuya.low_power_mode) { TuyaSendCmd(TUYA_LOW_POWER_CMD_WIFI_STATE, &Tuya.wifi_state, 1); diff --git a/tasmota/xdrv_17_rcswitch.ino b/tasmota/xdrv_17_rcswitch.ino index 8877544df..402929b19 100644 --- a/tasmota/xdrv_17_rcswitch.ino +++ b/tasmota/xdrv_17_rcswitch.ino @@ -56,7 +56,7 @@ void RfReceiveCheck(void) { int protocol = mySwitch.getReceivedProtocol(); int delay = mySwitch.getReceivedDelay(); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("RFR: Data 0x%lX (%u), Bits %d, Protocol %d, Delay %d"), data, data, bits, protocol, delay); + AddLog(LOG_LEVEL_DEBUG, PSTR("RFR: Data 0x%lX (%u), Bits %d, Protocol %d, Delay %d"), data, data, bits, protocol, delay); uint32_t now = millis(); if ((now - rf_lasttime > RF_TIME_AVOID_DUPLICATE) && (data > 0)) { @@ -130,7 +130,7 @@ void CmndRfProtocol(void) { } } mySwitch.setReceiveProtocolMask(Settings.rf_protocol_mask); -// AddLog_P(LOG_LEVEL_INFO, PSTR("RFR: CmndRfProtocol:: Start responce")); +// AddLog(LOG_LEVEL_INFO, PSTR("RFR: CmndRfProtocol:: Start responce")); Response_P(PSTR("{\"" D_CMND_RFPROTOCOL "\":\"")); bool gotone = false; thisdat = 1; diff --git a/tasmota/xdrv_18_armtronix_dimmers.ino b/tasmota/xdrv_18_armtronix_dimmers.ino index 14fba8c7b..185cb98c0 100644 --- a/tasmota/xdrv_18_armtronix_dimmers.ino +++ b/tasmota/xdrv_18_armtronix_dimmers.ino @@ -61,11 +61,11 @@ void LightSerial2Duty(uint8_t duty1, uint8_t duty2) ArmtronixSerial->print("\nDimmer2:"); ArmtronixSerial->println(duty2); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ARM: Send Serial Packet Dim Values=%d,%d"), Armtronix.dim_state[0],Armtronix.dim_state[1]); + AddLog(LOG_LEVEL_DEBUG, PSTR("ARM: Send Serial Packet Dim Values=%d,%d"), Armtronix.dim_state[0],Armtronix.dim_state[1]); } else { Armtronix.ignore_dim = false; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ARM: Send Dim Level skipped due to already set. Value=%d,%d"), Armtronix.dim_state[0],Armtronix.dim_state[1]); + AddLog(LOG_LEVEL_DEBUG, PSTR("ARM: Send Dim Level skipped due to already set. Value=%d,%d"), Armtronix.dim_state[0],Armtronix.dim_state[1]); } } @@ -74,7 +74,7 @@ void ArmtronixRequestState(void) { if (ArmtronixSerial) { // Get current status of MCU - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ARM: Request MCU state")); + AddLog(LOG_LEVEL_DEBUG, PSTR("ARM: Request MCU state")); ArmtronixSerial->println("Status"); } @@ -124,7 +124,7 @@ void ArmtronixSerialInput(void) Armtronix.ignore_dim = true; snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_CHANNEL "%d %d"),i+1, temp); ExecuteCommand(scmnd,SRC_SWITCH); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ARM: Send CMND_CHANNEL=%s"), scmnd ); + AddLog(LOG_LEVEL_DEBUG, PSTR("ARM: Send CMND_CHANNEL=%s"), scmnd ); } commaIndex = answer.indexOf(',',commaIndex+1); } @@ -148,7 +148,7 @@ void ArmtronixSetWifiLed(void) break; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ARM: Set WiFi LED to state %d (%d)"), wifi_state, WifiState()); + AddLog(LOG_LEVEL_DEBUG, PSTR("ARM: Set WiFi LED to state %d (%d)"), wifi_state, WifiState()); char state = '0' + ((wifi_state & 1) > 0); ArmtronixSerial->print("Setled:"); diff --git a/tasmota/xdrv_19_ps16dz_dimmer.ino b/tasmota/xdrv_19_ps16dz_dimmer.ino index b44a6da1b..5c32168a2 100644 --- a/tasmota/xdrv_19_ps16dz_dimmer.ino +++ b/tasmota/xdrv_19_ps16dz_dimmer.ino @@ -43,7 +43,7 @@ struct PS16DZ { void PS16DZSerialSend(const char *tx_buffer) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("PSZ: Send %s"), tx_buffer); +// AddLog(LOG_LEVEL_DEBUG, PSTR("PSZ: Send %s"), tx_buffer); PS16DZSerial->print(tx_buffer); PS16DZSerial->write(0x1B); @@ -96,7 +96,7 @@ void PS16DZSerialInput(void) Ps16dz.rx_buffer[Ps16dz.byte_counter++] = 0x00; // AT+RESULT="sequence":"1554682835320" -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("PSZ: Rcvd %s"), Ps16dz.rx_buffer); +// AddLog(LOG_LEVEL_DEBUG, PSTR("PSZ: Rcvd %s"), Ps16dz.rx_buffer); if (!strncmp(Ps16dz.rx_buffer+3, "RESULT", 6)) { @@ -118,7 +118,7 @@ void PS16DZSerialInput(void) if (!strncmp(token2, "\"switch\"", 8)) { bool switch_state = !strncmp(token3, "\"on\"", 4) ? true : false; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("PSZ: Switch %d"), switch_state); +// AddLog(LOG_LEVEL_DEBUG, PSTR("PSZ: Switch %d"), switch_state); is_switch_change = (switch_state != TasmotaGlobal.power); if (is_switch_change) { @@ -128,7 +128,7 @@ void PS16DZSerialInput(void) else if (!strncmp(token2, "\"bright\"", 8)) { Ps16dz.dimmer = atoi(token3); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("PSZ: Brightness %d"), Ps16dz.dimmer); +// AddLog(LOG_LEVEL_DEBUG, PSTR("PSZ: Brightness %d"), Ps16dz.dimmer); is_brightness_change = Ps16dz.dimmer != Settings.light_dimmer; if (TasmotaGlobal.power && (Ps16dz.dimmer > 0) && is_brightness_change) { @@ -138,7 +138,7 @@ void PS16DZSerialInput(void) } else if (!strncmp(token2, "\"sequence\"", 10)) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("PSZ: Sequence %s"), token3); +// AddLog(LOG_LEVEL_DEBUG, PSTR("PSZ: Sequence %s"), token3); } token = strtok_r(nullptr, ",", &end_str); @@ -146,7 +146,7 @@ void PS16DZSerialInput(void) if (!is_brightness_change) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("PSZ: Update")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("PSZ: Update")); PS16DZSerialSendOk(); } diff --git a/tasmota/xdrv_20_hue.ino b/tasmota/xdrv_20_hue.ino index 013e22a98..4e677157d 100644 --- a/tasmota/xdrv_20_hue.ino +++ b/tasmota/xdrv_20_hue.ino @@ -222,8 +222,7 @@ void HueRespondToMSearch(void) } else { snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE)); } - // Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9 - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_HUE " %s " D_TO " %s:%d"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_HUE " %s " D_TO " %s:%d"), message, udp_remote_ip.toString().c_str(), udp_remote_port); } @@ -427,7 +426,7 @@ String GetHueUserId(void) void HandleUpnpSetupHue(void) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_HUE_BRIDGE_SETUP)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_HUE_BRIDGE_SETUP)); String description_xml = Decompress(HUE_DESCRIPTION_XML_COMPRESSED,HUE_DESCRIPTION_XML_SIZE); description_xml.replace(F("{x1"), WiFi.localIP().toString()); description_xml.replace(F("{x2"), HueUuid()); @@ -437,7 +436,7 @@ void HandleUpnpSetupHue(void) void HueNotImplemented(String *path) { - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API_NOT_IMPLEMENTED " (%s)"), path->c_str()); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API_NOT_IMPLEMENTED " (%s)"), path->c_str()); WSSend(200, CT_JSON, PSTR("{}")); } @@ -690,7 +689,7 @@ void HueAuthentication(String *path) snprintf_P(response, sizeof(response), PSTR("[{\"success\":{\"username\":\"%s\"}}]"), GetHueUserId().c_str()); WSSend(200, CT_JSON, response); - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Authentication Result (%s)"), response); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Authentication Result (%s)"), response); } #ifdef USE_LIGHT @@ -805,7 +804,7 @@ void HueLightsCommand(uint8_t device, uint32_t device_id, String &response) { RgbToHsb(rr, gg, bb, &hue, &sat, nullptr); prev_hue = changeUIntScale(hue, 0, 360, 0, 65535); // calculate back prev_hue prev_sat = (sat > 254 ? 254 : sat); - //AddLog_P(LOG_LEVEL_DEBUG_MORE, "XY RGB (%d %d %d) HS (%d %d)", rr,gg,bb,hue,sat); + //AddLog(LOG_LEVEL_DEBUG_MORE, "XY RGB (%d %d %d) HS (%d %d)", rr,gg,bb,hue,sat); if (resp) { response += ","; } snprintf_P(buf, buf_size, msg[HUE_RESP_XY], @@ -874,7 +873,7 @@ void HueLightsCommand(uint8_t device, uint32_t device_id, String &response) { if (change) { #ifdef USE_SHUTTER if (ShutterState(device)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Settings.shutter_invert: %d"), Settings.shutter_options[device-1] & 1); + AddLog(LOG_LEVEL_DEBUG, PSTR("Settings.shutter_invert: %d"), Settings.shutter_options[device-1] & 1); ShutterSetPosition(device, bri * 100.0f ); } else #endif @@ -962,7 +961,7 @@ void HueLights(String *path) } else if(path->indexOf(F("/lights/")) >= 0) { // Got /lights/ID - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("/lights path=%s"), path->c_str()); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("/lights path=%s"), path->c_str()); path->remove(0,8); // Remove /lights/ device_id = atoi(path->c_str()); device = DecodeLightId(device_id); @@ -996,7 +995,7 @@ void HueLights(String *path) code = 406; } exit: - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Result (%s)"), response.c_str()); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " Result (%s)"), response.c_str()); WSSend(code, CT_JSON, response); } @@ -1007,7 +1006,7 @@ void HueGroups(String *path) */ String response(F("{}")); uint8_t maxhue = (TasmotaGlobal.devices_present > MAX_HUE_DEVICES) ? MAX_HUE_DEVICES : TasmotaGlobal.devices_present; - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " HueGroups (%s)"), path->c_str()); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " HueGroups (%s)"), path->c_str()); if (path->endsWith(F("/0"))) { UnishoxStrings msg(HUE_LIGHTS); @@ -1029,7 +1028,7 @@ void HueGroups(String *path) response += F("}"); } - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " HueGroups Result (%s)"), path->c_str()); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " HueGroups Result (%s)"), path->c_str()); WSSend(200, CT_JSON, response); } @@ -1051,10 +1050,10 @@ void HandleHueApi(String *path) path->remove(0, 4); // remove /api uint16_t apilen = path->length(); - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API " (%s) from %s"), path->c_str(), Webserver->client().remoteIP().toString().c_str()); // HTP: Hue API (//lights/1/state) from 192.168.1.20 + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API " (%s) from %s"), path->c_str(), Webserver->client().remoteIP().toString().c_str()); // HTP: Hue API (//lights/1/state) from 192.168.1.20 for (args = 0; args < Webserver->args(); args++) { String json = Webserver->arg(args); - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_POST_ARGS " (%s)"), json.c_str()); // HTP: Hue POST args ({"on":false}) + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_POST_ARGS " (%s)"), json.c_str()); // HTP: Hue POST args ({"on":false}) } UnishoxStrings msg(HUE_API); diff --git a/tasmota/xdrv_21_wemo.ino b/tasmota/xdrv_21_wemo.ino index 18f793824..43ddd164d 100644 --- a/tasmota/xdrv_21_wemo.ino +++ b/tasmota/xdrv_21_wemo.ino @@ -73,8 +73,7 @@ void WemoRespondToMSearch(int echo_type) } else { snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE)); } - // Do not use AddLog_P( here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9 - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_WEMO " " D_JSON_TYPE " %d, %s " D_TO " %s:%d"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_WEMO " " D_JSON_TYPE " %d, %s " D_TO " %s:%d"), echo_type, message, udp_remote_ip.toString().c_str(), udp_remote_port); } @@ -265,7 +264,7 @@ const char WEMO_SETUP_XML[] PROGMEM = /********************************************************************************************/ void LogUpnpWithClient(const char *msg) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "%s from %s"), msg, Webserver->client().remoteIP().toString().c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "%s from %s"), msg, Webserver->client().remoteIP().toString().c_str()); } void HandleUpnpEvent(void) @@ -275,7 +274,7 @@ void HandleUpnpEvent(void) char event[500]; strlcpy(event, Webserver->arg(0).c_str(), sizeof(event)); -// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), event); +// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), event); //differentiate get and set state char state = 'G'; diff --git a/tasmota/xdrv_21_wemo_multi.ino b/tasmota/xdrv_21_wemo_multi.ino index 1a0b3ac6c..d6edfe5c0 100644 --- a/tasmota/xdrv_21_wemo_multi.ino +++ b/tasmota/xdrv_21_wemo_multi.ino @@ -256,7 +256,7 @@ public: _deviceId = deviceId; _webServer = webServer; #ifdef USE_EMULATION_WEMO_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: Device #%d listening on port %d"), _deviceId, _localPort); + AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Device #%d listening on port %d"), _deviceId, _localPort); #endif } @@ -264,7 +264,7 @@ public: _deviceId = deviceId; _localPort = localPort; #ifdef USE_EMULATION_WEMO_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: Device #%d listening on port %d"), _deviceId, _localPort); + AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Device #%d listening on port %d"), _deviceId, _localPort); #endif _webServer = new ESP8266WebServer(_localPort); @@ -278,7 +278,7 @@ public: } void WemoRespondToMSearch(int echo_type) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: WemoRespondToMSearch device #%d: %d"), _deviceId, echo_type); +// AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: WemoRespondToMSearch device #%d: %d"), _deviceId, echo_type); char message[TOPSZ]; @@ -294,14 +294,14 @@ public: PortUdp.write(response); PortUdp.endPacket(); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: Sending packet device %d: %s"), _deviceId, response); +// AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Sending packet device %d: %s"), _deviceId, response); snprintf_P(message, sizeof(message), PSTR(D_RESPONSE_SENT)); } else { snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE)); } // Do not use AddLog_P here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9 - AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: WeMo Type %d, %s to %s:%d"), + AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: WeMo Type %d, %s to %s:%d"), echo_type, message, udp_remote_ip.toString().c_str(), udp_remote_port); } @@ -319,7 +319,7 @@ private: } void LogUpnpWithClient(const char *msg) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "%s from %s"), msg, _webServer->client().remoteIP().toString().c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "%s from %s"), msg, _webServer->client().remoteIP().toString().c_str()); } void HandleUpnpEvent() { @@ -329,8 +329,8 @@ private: strlcpy(event, _webServer->arg(0).c_str(), sizeof(event)); #ifdef USE_EMULATION_WEMO_DEBUG - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), event); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: HandleUpnpEvent for deviceId %d: %s"), _deviceId, event); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("\n%s"), event); + AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: HandleUpnpEvent for deviceId %d: %s"), _deviceId, event); #endif //differentiate get and set state @@ -362,7 +362,7 @@ private: void HandleUpnpService(void) { #ifdef USE_EMULATION_WEMO_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: HandleUpnpService")); + AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: HandleUpnpService")); #endif LogUpnpWithClient(PSTR(D_WEMO_EVENT_SERVICE)); @@ -375,7 +375,7 @@ private: void HandleUpnpMetaService(void) { #ifdef USE_EMULATION_WEMO_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: HandleUpnpMetaService")); + AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: HandleUpnpMetaService")); #endif LogUpnpWithClient(PSTR(D_WEMO_META_SERVICE)); @@ -399,14 +399,14 @@ private: setup_xml.replace("{x3", WemoSerialnumber()); InternalWSSend(200, CT_XML, setup_xml); #ifdef USE_EMULATION_WEMO_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: Sending device #%d: %s"), _deviceId, setup_xml.c_str()); + AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Sending device #%d: %s"), _deviceId, setup_xml.c_str()); #endif } public: void RegisterHandlers(void) { #ifdef USE_EMULATION_WEMO_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: Register device #%d"), _deviceId); + AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Register device #%d"), _deviceId); #endif _webServer->on(F("/upnp/control/basicevent1"), [&]() { HandleUpnpEvent(); }); _webServer->on(F("/eventservice.xml"), [&]() { HandleUpnpService(); }); @@ -441,7 +441,7 @@ bool Xdrv21(uint8_t function) break; case FUNC_WEB_ADD_HANDLER: #ifdef USE_EMULATION_WEMO_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMO: Adding handlers for %d devices"), TasmotaGlobal.devices_present); + AddLog(LOG_LEVEL_DEBUG, PSTR("WMO: Adding handlers for %d devices"), TasmotaGlobal.devices_present); #endif // For the first device use the current webserver, for the others.. create a new one listening on a different PortUdp wemoDevice[numOfWemoSwitch] = new WemoSwitch(1, Webserver); diff --git a/tasmota/xdrv_23_zigbee_1_headers.ino b/tasmota/xdrv_23_zigbee_1_headers.ino index 27f2dd895..f3a88914d 100644 --- a/tasmota/xdrv_23_zigbee_1_headers.ino +++ b/tasmota/xdrv_23_zigbee_1_headers.ino @@ -105,7 +105,11 @@ public: ZB_RecvMsgFunc recv_func = nullptr; // function to call when message is expected ZB_RecvMsgFunc recv_unexpected = nullptr; // function called when unexpected message is received +#ifdef USE_ZIGBEE_EZSP uint32_t permit_end_time = 0; // timestamp when permit join ends +#elif defined(USE_ZIGBEE_ZNP) + bool permit_end_time = false; // in ZNP mode it's only a boolean +#endif #ifdef USE_ZIGBEE_EZSP Eeprom24C512 eeprom; // takes only 1 bytes of RAM @@ -129,16 +133,4 @@ uint32_t parseHex(const char **data, size_t max_len = 8) { return ret; } -// Since v9.2.0.2 Log buffer was reduced from 700 bytes to 120. This version is specific to Zigbee and restores the 700 bytes limit -void AddLogZ_P(uint32_t loglevel, PGM_P formatP, ...) { - char log_data[MAX_LOGSZ]; - - va_list arg; - va_start(arg, formatP); - vsnprintf_P(log_data, sizeof(log_data), formatP, arg); - va_end(arg); - - AddLogData(loglevel, log_data); -} - #endif // USE_ZIGBEE diff --git a/tasmota/xdrv_23_zigbee_1z_libs.ino b/tasmota/xdrv_23_zigbee_1z_libs.ino index a228798e2..7531b003e 100644 --- a/tasmota/xdrv_23_zigbee_1z_libs.ino +++ b/tasmota/xdrv_23_zigbee_1z_libs.ino @@ -399,9 +399,7 @@ void Z_attribute::setHex32(uint32_t _val) { } void Z_attribute::setHex64(uint64_t _val) { char hex[22]; - hex[0] = '0'; // prefix with '0x' - hex[1] = 'x'; - Uint64toHex(_val, &hex[2], 64); + ext_snprintf_P(hex, sizeof(hex), PSTR("0x%_X"), &_val); setStr(hex); } diff --git a/tasmota/xdrv_23_zigbee_2_devices.ino b/tasmota/xdrv_23_zigbee_2_devices.ino index 47247ddd5..6a6b60655 100644 --- a/tasmota/xdrv_23_zigbee_2_devices.ino +++ b/tasmota/xdrv_23_zigbee_2_devices.ino @@ -637,7 +637,7 @@ Z_Data & Z_Data_Set::getByType(Z_Data_Type type, uint8_t ep) { // Byte 3: Power Z_Data & Z_Data_Set::createFromBuffer(const SBuffer & buf, uint32_t start, uint32_t len) { if (len < sizeof(Z_Data)) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Invalid len (<4) %d"), len); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Invalid len (<4) %d"), len); return *(Z_Data*)nullptr; } @@ -651,7 +651,7 @@ Z_Data & Z_Data_Set::createFromBuffer(const SBuffer & buf, uint32_t start, uint3 memcpy(&elt, buf.buf(start), len); } else { memcpy(&elt, buf.buf(start), sizeof(Z_Data)); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "buffer len overflow %d > %d"), len, expected_len); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "buffer len overflow %d > %d"), len, expected_len); } return elt; } @@ -965,6 +965,7 @@ public: Z_Device & devicesAt(size_t i) const; // Remove device from list + void clearDeviceRouterInfo(void); // reset all router flags, done just before ZbMap bool removeDevice(uint16_t shortaddr); // Mark data as 'dirty' and requiring to save in Flash diff --git a/tasmota/xdrv_23_zigbee_2a_devices_impl.ino b/tasmota/xdrv_23_zigbee_2a_devices_impl.ino index 55a98a748..b70a7edda 100644 --- a/tasmota/xdrv_23_zigbee_2a_devices_impl.ino +++ b/tasmota/xdrv_23_zigbee_2a_devices_impl.ino @@ -218,6 +218,15 @@ Z_Device & Z_Devices::updateDevice(uint16_t shortaddr, uint64_t longaddr) { return device_unk; } +// Clear the router flag for each device, called at the beginning of ZbMap +void Z_Devices::clearDeviceRouterInfo(void) { + for (Z_Device & device : zigbee_devices._devices) { + if (device.valid()) { + device.setRouter(false); + } + } +} + // // Clear all endpoints // diff --git a/tasmota/xdrv_23_zigbee_3_hue.ino b/tasmota/xdrv_23_zigbee_3_hue.ino index d71a8c3a9..b8f678d9e 100644 --- a/tasmota/xdrv_23_zigbee_3_hue.ino +++ b/tasmota/xdrv_23_zigbee_3_hue.ino @@ -170,7 +170,7 @@ void ZigbeeHueDimmer(uint16_t shortaddr, uint8_t dimmer) { // CT void ZigbeeHueCT(uint16_t shortaddr, uint16_t ct) { if (ct > 0xFEFF) { ct = 0xFEFF; } - AddLog_P(LOG_LEVEL_INFO, PSTR("ZigbeeHueCT 0x%04X - %d"), shortaddr, ct); + AddLog(LOG_LEVEL_INFO, PSTR("ZigbeeHueCT 0x%04X - %d"), shortaddr, ct); char param[12]; snprintf_P(param, sizeof(param), PSTR("%02X%02X0A00"), ct & 0xFF, ct >> 8); uint8_t colormode = 2; // "ct" diff --git a/tasmota/xdrv_23_zigbee_4_persistence.ino b/tasmota/xdrv_23_zigbee_4_persistence.ino index dc7c385e3..c306cb184 100644 --- a/tasmota/xdrv_23_zigbee_4_persistence.ino +++ b/tasmota/xdrv_23_zigbee_4_persistence.ino @@ -301,7 +301,7 @@ void loadZigbeeDevices(bool dump_only = false) { // first copy SPI buffer into ram uint8_t *spi_buffer = (uint8_t*) malloc(z_spi_len); if (!spi_buffer) { - AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer")); + AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer")); return; } #ifdef USE_UFILESYS @@ -311,8 +311,8 @@ void loadZigbeeDevices(bool dump_only = false) { #endif // ESP32 Z_Flashentry flashdata; memcpy_P(&flashdata, z_dev_start, sizeof(Z_Flashentry)); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Memory %d"), ESP_getFreeHeap()); - // AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Zigbee signature in Flash: %08X - %d"), flashdata.name, flashdata.len); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Memory %d"), ESP_getFreeHeap()); + // AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Zigbee signature in Flash: %08X - %d"), flashdata.name, flashdata.len); // Check the signature if ( ((flashdata.name == ZIGB_NAME1) || (flashdata.name == ZIGB_NAME2)) @@ -322,7 +322,7 @@ void loadZigbeeDevices(bool dump_only = false) { // parse what seems to be a valid entry SBuffer buf(buf_len); buf.addBuffer(z_dev_start + sizeof(Z_Flashentry), buf_len); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee device information in %s (%d bytes)"), PSTR("Flash"), buf_len); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee device information in %s (%d bytes)"), PSTR("Flash"), buf_len); if (dump_only) { size_t buf_len = buf.len(); @@ -336,7 +336,7 @@ void loadZigbeeDevices(bool dump_only = false) { zigbee_devices.clean(); // don't write back to Flash what we just loaded } } else { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No Zigbee device information in %s"), PSTR("Flash")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No Zigbee device information in %s"), PSTR("Flash")); } #ifdef ESP32 free(spi_buffer); @@ -354,14 +354,14 @@ void saveZigbeeDevices(void) { SBuffer buf = hibernateDevices(); size_t buf_len = buf.len(); if (buf_len > 2040) { - AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Buffer too big to fit in Flash (%d bytes)"), buf_len); + AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Buffer too big to fit in Flash (%d bytes)"), buf_len); return; } // first copy SPI buffer into ram uint8_t *spi_buffer = (uint8_t*) malloc(z_spi_len); if (!spi_buffer) { - AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer")); + AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer")); return; } // copy the flash into RAM to make local change, and write back the whole buffer @@ -386,13 +386,13 @@ void saveZigbeeDevices(void) { if (ESP.flashEraseSector(z_spi_start_sector)) { ESP.flashWrite(z_spi_start_sector * SPI_FLASH_SEC_SIZE, (uint32_t*) spi_buffer, SPI_FLASH_SEC_SIZE); } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data store in Flash (0x%08X - %d bytes)"), z_dev_start, buf_len); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data store in Flash (0x%08X - %d bytes)"), z_dev_start, buf_len); #endif // ESP8266 #ifdef ESP32 #ifdef USE_UFILESYS TfsSaveFile(TASM_FILE_ZIGBEE, spi_buffer, z_spi_len); #endif - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data saved in %s (%d bytes)"), PSTR("Flash"), buf_len); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data saved in %s (%d bytes)"), PSTR("Flash"), buf_len); #endif // ESP32 free(spi_buffer); } @@ -407,7 +407,7 @@ void eraseZigbeeDevices(void) { // first copy SPI buffer into ram uint8_t *spi_buffer = (uint8_t*) malloc(z_spi_len); if (!spi_buffer) { - AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer")); + AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Cannot allocate 4KB buffer")); return; } // copy the flash into RAM to make local change, and write back the whole buffer @@ -422,13 +422,13 @@ void eraseZigbeeDevices(void) { } free(spi_buffer); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased in %s"), PSTR("Flash")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased in %s"), PSTR("Flash")); #endif // ESP8266 #ifdef ESP32 #ifdef USE_UFILESYS TfsInitFile(TASM_FILE_ZIGBEE, z_block_len, 0xFF); #endif - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased (%d bytes)"), z_block_len); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased (%d bytes)"), z_block_len); #endif // ESP32 } diff --git a/tasmota/xdrv_23_zigbee_4a_nano_fs.ino b/tasmota/xdrv_23_zigbee_4a_nano_fs.ino index bdc1ab342..007615c1b 100644 --- a/tasmota/xdrv_23_zigbee_4a_nano_fs.ino +++ b/tasmota/xdrv_23_zigbee_4a_nano_fs.ino @@ -363,15 +363,15 @@ void ZFS::initOrFormat(void) { byte map[256]; char hex_char[(256 * 2) + 2]; zigbee.eeprom.readBytes(0x0000, 256, map); - AddLogZ_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 00 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); + AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 00 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); // zigbee.eeprom.readBytes(0x0100, 256, map); - // AddLogZ_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 01 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); + // AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 01 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); zigbee.eeprom.readBytes(0x0200, 256, map); - AddLogZ_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 02 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); + AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 02 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); zigbee.eeprom.readBytes(0x2100, 256, map); - AddLogZ_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 21 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); + AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK 21 %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); // zigbee.eeprom.readBytes(0xFF00, 256, map); - // AddLogZ_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK FF %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); + // AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "BLK FF %s"), ToHex_P(map, sizeof(map), hex_char, sizeof(hex_char))); } #endif diff --git a/tasmota/xdrv_23_zigbee_4b_eeprom.ino b/tasmota/xdrv_23_zigbee_4b_eeprom.ino index 88fa1e391..6acada897 100644 --- a/tasmota/xdrv_23_zigbee_4b_eeprom.ino +++ b/tasmota/xdrv_23_zigbee_4b_eeprom.ino @@ -41,7 +41,7 @@ int32_t hydrateDeviceWideData(class Z_Device & device, const SBuffer & buf, size_t start, size_t len) { size_t segment_len = buf.get8(start); if ((segment_len < 6) || (segment_len > len)) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "invalid device wide data length=%d"), segment_len); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "invalid device wide data length=%d"), segment_len); return -1; } device.last_seen = buf.get32(start+1); @@ -77,13 +77,13 @@ bool hydrateDeviceData(class Z_Device & device, const SBuffer & buf, size_t star int32_t hydrateSingleDevice(const class SBuffer & buf, size_t start, size_t len) { uint8_t segment_len = buf.get8(start); if ((segment_len < 4) || (start + segment_len > len)) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "invalid segment_len=%d"), segment_len); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "invalid segment_len=%d"), segment_len); return -1; } // read shortaddr uint16_t shortaddr = buf.get16(start + 1); if (shortaddr >= 0xFFF0) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "invalid shortaddr=0x%04X"), shortaddr); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "invalid shortaddr=0x%04X"), shortaddr); return -1; } #ifdef Z_EEPROM_DEBUG @@ -118,9 +118,9 @@ bool hydrateDevicesDataFromEEPROM(void) { if (!zigbee.eeprom_ready) { return false; } int32_t file_length = ZFS::getLength(ZIGB_DATA2); if (file_length > 0) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee device data in EEPROM (%d bytes)"), file_length); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee device data in EEPROM (%d bytes)"), file_length); } else { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No Zigbee device data in EEPROM")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No Zigbee device data in EEPROM")); return false; } @@ -222,7 +222,7 @@ void hibernateAllData(void) { } int32_t ret = write_data.close(); #ifdef Z_EEPROM_DEBUG - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "ZbData - %d bytes written to EEPROM"), ret); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "ZbData - %d bytes written to EEPROM"), ret); #endif #endif // USE_ZIGBEE_EZSP } @@ -270,10 +270,10 @@ bool hibernateDevicesInEEPROM(void) { int32_t ret = write_data.close(); if (ret < 0) { - AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Error writing Devices to EEPROM")); + AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Error writing Devices to EEPROM")); return false; } else { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data saved in %s (%d bytes)"), PSTR("EEPROM"), ret); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data saved in %s (%d bytes)"), PSTR("EEPROM"), ret); } return true; } @@ -288,10 +288,10 @@ bool loadZigbeeDevicesFromEEPROM(void) { ZFS::readBytes(ZIGB_NAME2, &num_devices, sizeof(num_devices), 0, sizeof(num_devices)); if ((file_len < 10) || (num_devices == 0x00) || (num_devices == 0xFF)) { // No data - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No Zigbee device information in %s"), PSTR("EEPROM")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "No Zigbee device information in %s"), PSTR("EEPROM")); return false; } - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee device information in %s (%d bytes)"), PSTR("EEPROM"), file_len); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee device information in %s (%d bytes)"), PSTR("EEPROM"), file_len); uint32_t k = 1; // byte index in global buffer for (uint32_t i = 0; (i < num_devices) && (k < file_len); i++) { @@ -301,7 +301,7 @@ bool loadZigbeeDevicesFromEEPROM(void) { buf.setLen(dev_record_len); ret = ZFS::readBytes(ZIGB_NAME2, buf.getBuffer(), dev_record_len, k, dev_record_len); if (ret != dev_record_len) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "File too short when reading EEPROM")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "File too short when reading EEPROM")); return false; } @@ -318,7 +318,7 @@ bool loadZigbeeDevicesFromEEPROM(void) { void ZFS_Erase(void) { if (zigbee.eeprom_present) { ZFS::erase(); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased in %s"), PSTR("EEPROM")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased in %s"), PSTR("EEPROM")); } } diff --git a/tasmota/xdrv_23_zigbee_5_converters.ino b/tasmota/xdrv_23_zigbee_5_converters.ino index 4af809b5c..3380d2fc0 100644 --- a/tasmota/xdrv_23_zigbee_5_converters.ino +++ b/tasmota/xdrv_23_zigbee_5_converters.ino @@ -743,7 +743,7 @@ public: if (Settings.flag3.tuya_serial_mqtt_publish) { MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR)); } else { - AddLogZ_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); + AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); } } @@ -1348,7 +1348,7 @@ void ZCLFrame::computeSyntheticAttributes(Z_attribute_list& attr_list) { brightness = changeUIntScale(light.getDimmer(), 0, 254, 0, 255); // range is 0..255 } } - + const Z_attribute * attr_hue = attr_list.findAttribute(0x0300, 0x0000); const Z_attribute * attr_sat = attr_list.findAttribute(0x0300, 0x0001); const Z_attribute * attr_x = attr_list.findAttribute(0x0300, 0x0003); @@ -1656,7 +1656,7 @@ void ZCLFrame::parseClusterSpecificCommand(Z_attribute_list& attr_list) { Z_Device & device = zigbee_devices.getShortAddr(_srcaddr); if ((device.debounce_endpoint != 0) && (device.debounce_endpoint == _srcendpoint) && (device.debounce_transact == _transact_seq)) { // this is a duplicate, drop the packet - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Discarding duplicate command from 0x%04X, endpoint %d"), _srcaddr, _srcendpoint); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Discarding duplicate command from 0x%04X, endpoint %d"), _srcaddr, _srcendpoint); } else { // reset the duplicate marker, parse the packet normally, and set a timer to reset the marker later (which will discard any existing timer for the same device/endpoint) device.debounce_endpoint = _srcendpoint; diff --git a/tasmota/xdrv_23_zigbee_7_0_statemachine.ino b/tasmota/xdrv_23_zigbee_7_0_statemachine.ino index b2a01b6eb..7c85bc015 100644 --- a/tasmota/xdrv_23_zigbee_7_0_statemachine.ino +++ b/tasmota/xdrv_23_zigbee_7_0_statemachine.ino @@ -932,12 +932,12 @@ void ZigbeeGotoLabel(uint8_t label) { } // no label found, abort - AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Goto label not found, label=%d pc=%d"), label, zigbee.pc); + AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Goto label not found, label=%d pc=%d"), label, zigbee.pc); if (ZIGBEE_LABEL_ABORT != label) { // if not already looking for ZIGBEE_LABEL_ABORT, goto ZIGBEE_LABEL_ABORT ZigbeeGotoLabel(ZIGBEE_LABEL_ABORT); } else { - AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Label Abort (%d) not present, aborting Zigbee"), ZIGBEE_LABEL_ABORT); + AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Label Abort (%d) not present, aborting Zigbee"), ZIGBEE_LABEL_ABORT); zigbee.state_machine = false; zigbee.active = false; } @@ -955,7 +955,7 @@ void ZigbeeStateMachine_Run(void) { // checking if timeout expired if ((zigbee.next_timeout) && (now > zigbee.next_timeout)) { // if next_timeout == 0 then wait forever if (!zigbee.state_no_timeout) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "timeout, goto label %d"), zigbee.on_timeout_goto); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "timeout, goto label %d"), zigbee.on_timeout_goto); ZigbeeGotoLabel(zigbee.on_timeout_goto); } else { zigbee.state_waiting = false; // simply stop waiting @@ -971,7 +971,7 @@ void ZigbeeStateMachine_Run(void) { zigbee.state_no_timeout = false; // reset the no_timeout for next instruction if (zigbee.pc > ARRAY_SIZE(zb_prog)) { - AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Invalid pc: %d, aborting"), zigbee.pc); + AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Invalid pc: %d, aborting"), zigbee.pc); zigbee.pc = -1; } if (zigbee.pc < 0) { @@ -1020,7 +1020,7 @@ void ZigbeeStateMachine_Run(void) { case ZGB_INSTR_STOP: zigbee.state_machine = false; if (cur_d8) { - AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Stopping (%d)"), cur_d8); + AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "Stopping (%d)"), cur_d8); } break; case ZGB_INSTR_CALL: diff --git a/tasmota/xdrv_23_zigbee_7_5_map.ino b/tasmota/xdrv_23_zigbee_7_5_map.ino index c9013b665..f6a50e974 100644 --- a/tasmota/xdrv_23_zigbee_7_5_map.ino +++ b/tasmota/xdrv_23_zigbee_7_5_map.ino @@ -76,7 +76,7 @@ public: edges() {} - void reset(void) { edges.reset(); } + void reset(void) { edges.reset(); zigbee_devices.clearDeviceRouterInfo(); } Z_Mapper_Edge & findEdge(const Z_Mapper_Edge & edge2); bool addEdge(const Z_Mapper_Edge & edge2); diff --git a/tasmota/xdrv_23_zigbee_8_parsers.ino b/tasmota/xdrv_23_zigbee_8_parsers.ino index c85b1a7f0..3c1d3e79b 100644 --- a/tasmota/xdrv_23_zigbee_8_parsers.ino +++ b/tasmota/xdrv_23_zigbee_8_parsers.ino @@ -115,12 +115,10 @@ int32_t EZ_NetworkParameters(int32_t res, class SBuffer &buf) { // localIEEEAddr = long_adr; // localShortAddr = short_adr; - char hex[20]; - Uint64toHex(localIEEEAddr, hex, 64); Response_P(PSTR("{\"" D_JSON_ZIGBEE_STATE "\":{" - "\"Status\":%d,\"IEEEAddr\":\"0x%s\",\"ShortAddr\":\"0x%04X\"" + "\"Status\":%d,\"IEEEAddr\":\"0x%_X\",\"ShortAddr\":\"0x%04X\"" ",\"DeviceType\":%d}}"), - ZIGBEE_STATUS_EZ_INFO, hex, localShortAddr, node_type); + ZIGBEE_STATUS_EZ_INFO, &localIEEEAddr, localShortAddr, node_type); MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE)); @@ -195,7 +193,7 @@ int32_t EZ_MessageSent(int32_t res, const class SBuffer &buf) { uint16_t group_addr = buf.get16(13); if ((EMBER_OUTGOING_MULTICAST == message_type) && (0xFFFD == dst_addr)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Sniffing group 0x%04X"), group_addr); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "Sniffing group 0x%04X"), group_addr); } return -1; // ignore } @@ -229,7 +227,7 @@ void Z_Send_State_or_Map(uint16_t shortaddr, uint8_t index, uint16_t zdo_cmd) { // This callback is registered to send ZbMap(s) to each device one at a time void Z_Map(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint, uint32_t value) { if (BAD_SHORTADDR != shortaddr) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "sending `ZbMap 0x%04X`"), shortaddr); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "sending `ZbMap 0x%04X`"), shortaddr); #ifdef USE_ZIGBEE_ZNP Z_Send_State_or_Map(shortaddr, value, ZDO_MGMT_LQI_REQ); #endif // USE_ZIGBEE_ZNP @@ -237,7 +235,7 @@ void Z_Map(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t end Z_Send_State_or_Map(shortaddr, value, ZDO_Mgmt_Lqi_req); #endif // USE_ZIGBEE_EZSP } else { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "ZbMap done")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "ZbMap done")); zigbee.mapping_in_progress = false; zigbee.mapping_ready = true; } @@ -276,12 +274,10 @@ int32_t Z_EZSPNetworkParameters(int32_t res, class SBuffer &buf) { // localIEEEAddr = long_adr; // localShortAddr = short_adr; - char hex[20]; - Uint64toHex(localIEEEAddr, hex, 64); Response_P(PSTR("{\"" D_JSON_ZIGBEE_STATE "\":{" - "\"Status\":%d,\"IEEEAddr\":\"0x%s\",\"ShortAddr\":\"0x%04X\"" + "\"Status\":%d,\"IEEEAddr\":\"0x%_X\",\"ShortAddr\":\"0x%04X\"" ",\"DeviceType\":%d}}"), - ZIGBEE_STATUS_EZ_INFO, hex, localShortAddr, node_type); + ZIGBEE_STATUS_EZ_INFO, &localIEEEAddr, localShortAddr, node_type); MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEE_STATE)); @@ -313,13 +309,11 @@ int32_t ZNP_ReceiveDeviceInfo(int32_t res, class SBuffer &buf) { localIEEEAddr = long_adr; localShortAddr = short_adr; - char hex[20]; - Uint64toHex(long_adr, hex, 64); Response_P(PSTR("{\"" D_JSON_ZIGBEE_STATE "\":{" - "\"Status\":%d,\"IEEEAddr\":\"0x%s\",\"ShortAddr\":\"0x%04X\"" + "\"Status\":%d,\"IEEEAddr\":\"0x%_X\",\"ShortAddr\":\"0x%04X\"" ",\"DeviceType\":%d,\"DeviceState\":%d" ",\"NumAssocDevices\":%d"), - ZIGBEE_STATUS_CC_INFO, hex, short_adr, device_type, device_state, + ZIGBEE_STATUS_CC_INFO, &long_adr, short_adr, device_type, device_state, device_associated); if (device_associated > 0) { // If there are devices registered in CC2530, print the list @@ -501,12 +495,15 @@ int32_t ZNP_ReceivePermitJoinStatus(int32_t res, const class SBuffer &buf) { if (0xFF == duration) { status_code = ZIGBEE_STATUS_PERMITJOIN_OPEN_XX; message = PSTR("Enable Pairing mode until next boot"); + zigbee.permit_end_time = true; // In ZNP mode, declare permitjoin open } else if (duration > 0) { status_code = ZIGBEE_STATUS_PERMITJOIN_OPEN_60; message = PSTR("Enable Pairing mode for %d seconds"); + zigbee.permit_end_time = true; // In ZNP mode, declare permitjoin open } else { status_code = ZIGBEE_STATUS_PERMITJOIN_CLOSE; message = PSTR("Disable Pairing mode"); + zigbee.permit_end_time = false; // In ZNP mode, declare permitjoin closed } Response_P(PSTR("{\"" D_JSON_ZIGBEE_STATE "\":{" "\"Status\":%d,\"Message\":\""), @@ -769,13 +766,11 @@ int32_t Z_ReceiveIEEEAddr(int32_t res, const class SBuffer &buf) { if (0 == status) { // SUCCESS zigbee_devices.updateDevice(nwkAddr, ieeeAddr); zigbee_devices.deviceWasReached(nwkAddr); - char hex[20]; - Uint64toHex(ieeeAddr, hex, 64); // Ping response const char * friendlyName = zigbee_devices.getFriendlyName(nwkAddr); Response_P(PSTR("{\"" D_JSON_ZIGBEE_PING "\":{\"" D_JSON_ZIGBEE_DEVICE "\":\"0x%04X\"" - ",\"" D_JSON_ZIGBEE_IEEE "\":\"0x%s\""), nwkAddr, hex); + ",\"" D_JSON_ZIGBEE_IEEE "\":\"0x%_X\""), nwkAddr, &ieeeAddr); if (friendlyName) { ResponseAppend_P(PSTR(",\"" D_JSON_ZIGBEE_NAME "\":\"%s\""), friendlyName); } @@ -884,16 +879,22 @@ int32_t Z_ReceiveEndDeviceAnnonce(int32_t res, const class SBuffer &buf) { uint8_t capabilities = buf.get8(10); #endif + // record if we already knew the ieeeAddr for this device + // this will influence the decision whether we do auto-binding or not + const Z_Device & device_before = zigbee_devices.findShortAddr(nwkAddr); + bool ieee_already_known = false; + if (device_before.valid() && (device_before.longaddr != 0) && (device_before.longaddr == ieeeAddr)) { + ieee_already_known = true; + } + zigbee_devices.updateDevice(nwkAddr, ieeeAddr); // device is reachable zigbee_devices.deviceWasReached(nwkAddr); - char hex[20]; - Uint64toHex(ieeeAddr, hex, 64); Response_P(PSTR("{\"" D_JSON_ZIGBEE_STATE "\":{" - "\"Status\":%d,\"IEEEAddr\":\"0x%s\",\"ShortAddr\":\"0x%04X\"" + "\"Status\":%d,\"IEEEAddr\":\"0x%_X\",\"ShortAddr\":\"0x%04X\"" ",\"PowerSource\":%s,\"ReceiveWhenIdle\":%s,\"Security\":%s}}"), - ZIGBEE_STATUS_DEVICE_ANNOUNCE, hex, nwkAddr, + ZIGBEE_STATUS_DEVICE_ANNOUNCE, &ieeeAddr, nwkAddr, (capabilities & 0x04) ? PSTR("true") : PSTR("false"), (capabilities & 0x08) ? PSTR("true") : PSTR("false"), (capabilities & 0x40) ? PSTR("true") : PSTR("false") @@ -903,7 +904,10 @@ int32_t Z_ReceiveEndDeviceAnnonce(int32_t res, const class SBuffer &buf) { Z_Query_Bulb(nwkAddr, wait_ms); MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED)); - Z_SendActiveEpReq(nwkAddr); + // Continue the discovery process and auto-binding only if the device was unknown or if PermitJoin is ongoing + if (!ieee_already_known || zigbee.permit_end_time) { + Z_SendActiveEpReq(nwkAddr); + } return -1; } @@ -920,12 +924,10 @@ int32_t ZNP_ReceiveTCDevInd(int32_t res, const class SBuffer &buf) { // device is reachable zigbee_devices.deviceWasReached(srcAddr); - char hex[20]; - Uint64toHex(ieeeAddr, hex, 64); Response_P(PSTR("{\"" D_JSON_ZIGBEE_STATE "\":{" - "\"Status\":%d,\"IEEEAddr\":\"0x%s\",\"ShortAddr\":\"0x%04X\"" + "\"Status\":%d,\"IEEEAddr\":\"0x%_X\",\"ShortAddr\":\"0x%04X\"" ",\"ParentNetwork\":\"0x%04X\"}}"), - ZIGBEE_STATUS_DEVICE_INDICATION, hex, srcAddr, parentNw + ZIGBEE_STATUS_DEVICE_INDICATION, &ieeeAddr, srcAddr, parentNw ); MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_TELE, PSTR(D_JSON_ZIGBEEZCL_RECEIVED)); @@ -1173,9 +1175,7 @@ int32_t Z_Mgmt_Lqi_Bind_Rsp(int32_t res, const class SBuffer &buf, boolean lqi) if (Z_Addr_Group == addrmode) { // Group address mode ResponseAppend_P(PSTR("\"ToGroup\":%d}"), group); } else if (Z_Addr_IEEEAddress == addrmode) { // IEEE address mode - char hex[20]; - Uint64toHex(dstaddr, hex, 64); - ResponseAppend_P(PSTR("\"ToDevice\":\"0x%s\",\"ToEndpoint\":%d}"), hex, dstep); + ResponseAppend_P(PSTR("\"ToDevice\":\"0x%_X\",\"ToEndpoint\":%d}"), &dstaddr, dstep); } } @@ -1254,9 +1254,7 @@ int32_t EZ_ParentAnnceRsp(int32_t res, const class SBuffer &buf, bool rsp) { if (i > 0) { ResponseAppend_P(PSTR(",")); } - char hex[20]; - Uint64toHex(child_ieee, hex, 64); - ResponseAppend_P(PSTR("\"0x%s\""), hex); + ResponseAppend_P(PSTR("\"0x%_X\""), &child_ieee); } ResponseAppend_P(PSTR("]}}")); @@ -1379,7 +1377,7 @@ void Z_WriteCIEAddress(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, buf.add8(ZEUI64); buf.add64(localIEEEAddr); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Writing CIE address")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Writing CIE address")); ZigbeeZCLSend_Raw(ZigbeeZCLSendMessage({ shortaddr, 0x0000, /* group */ @@ -1403,7 +1401,7 @@ void Z_SendCIEZoneEnrollResponse(uint16_t shortaddr, uint16_t groupaddr, uint16_ uint8_t transacid = zigbee_devices.getNextSeqNumber(shortaddr); uint8_t EnrollRSP[2] = { 0x00 /* Sucess */, Z_B0(value) /* ZoneID */ }; - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Sending Enroll Zone %d"), Z_B0(value)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Sending Enroll Zone %d"), Z_B0(value)); ZigbeeZCLSend_Raw(ZigbeeZCLSendMessage({ shortaddr, 0x0000, /* group */ @@ -1425,7 +1423,7 @@ void Z_SendCIEZoneEnrollResponse(uint16_t shortaddr, uint16_t groupaddr, uint16_ void Z_AutoBind(uint16_t shortaddr, uint16_t groupaddr, uint16_t cluster, uint8_t endpoint, uint32_t value) { uint64_t srcLongAddr = zigbee_devices.getDeviceLongAddr(shortaddr); - AddLogZ_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `ZbBind {\"Device\":\"0x%04X\",\"Endpoint\":%d,\"Cluster\":\"0x%04X\"}`"), + AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `ZbBind {\"Device\":\"0x%04X\",\"Endpoint\":%d,\"Cluster\":\"0x%04X\"}`"), shortaddr, endpoint, cluster); #ifdef USE_ZIGBEE_ZNP SBuffer buf(34); @@ -1535,7 +1533,7 @@ void Z_AutoConfigReportingForCluster(uint16_t shortaddr, uint16_t groupaddr, uin // encode value int32_t res = encodeSingleAttribute(buf, report_change, "", attr_type); if (res < 0) { - AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "internal error, unsupported attribute type")); + AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_ZIGBEE "internal error, unsupported attribute type")); } else { Z_attribute attr; attr.setKeyName(PSTR("ReportableChange"), true); // true because in PMEM @@ -1550,7 +1548,7 @@ void Z_AutoConfigReportingForCluster(uint16_t shortaddr, uint16_t groupaddr, uin ResponseAppend_P(PSTR("}}")); if (buf.len() > 0) { - AddLogZ_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `%s`"), TasmotaGlobal.mqtt_data); + AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "auto-bind `%s`"), TasmotaGlobal.mqtt_data); ZigbeeZCLSend_Raw(ZigbeeZCLSendMessage({ shortaddr, 0x0000, /* group */ @@ -1582,14 +1580,12 @@ int32_t EZ_ReceiveTCJoinHandler(int32_t res, const class SBuffer &buf) { if (EMBER_DEVICE_LEFT != status) { // ignore message if the device is leaving zigbee_devices.updateDevice(srcAddr, ieeeAddr); - char hex[20]; - Uint64toHex(ieeeAddr, hex, 64); Response_P(PSTR("{\"" D_JSON_ZIGBEE_STATE "\":{" - "\"Status\":%d,\"IEEEAddr\":\"0x%s\",\"ShortAddr\":\"0x%04X\"" + "\"Status\":%d,\"IEEEAddr\":\"0x%_X\",\"ShortAddr\":\"0x%04X\"" ",\"ParentNetwork\":\"0x%04X\"" ",\"JoinStatus\":%d,\"Decision\":%d" "}}"), - ZIGBEE_STATUS_DEVICE_INDICATION, hex, srcAddr, parentNw, + ZIGBEE_STATUS_DEVICE_INDICATION, &ieeeAddr, srcAddr, parentNw, status, decision ); @@ -1658,11 +1654,11 @@ void Z_IncomingMessage(class ZCLFrame &zcl_received) { zcl_received.parseClusterSpecificCommand(attr_list); } - AddLogZ_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEEZCL_RAW_RECEIVED ": {\"0x%04X\":{%s}}"), srcaddr, attr_list.toString().c_str()); + AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEEZCL_RAW_RECEIVED ": {\"0x%04X\":{%s}}"), srcaddr, attr_list.toString().c_str()); // discard the message if it was sent by us (broadcast or group loopback) if (srcaddr == localShortAddr) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "loopback message, ignoring")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "loopback message, ignoring")); return; // abort the rest of message management } @@ -2143,7 +2139,7 @@ void ZCLFrame::autoResponder(const uint16_t *attr_list_ids, size_t attr_len) { // we have a non-empty output // log first - AddLogZ_P(LOG_LEVEL_INFO, PSTR("ZIG: Auto-responder: ZbSend {\"Device\":\"0x%04X\"" + AddLog_P(LOG_LEVEL_INFO, PSTR("ZIG: Auto-responder: ZbSend {\"Device\":\"0x%04X\"" ",\"Cluster\":\"0x%04X\"" ",\"Endpoint\":%d" ",\"Response\":%s}" diff --git a/tasmota/xdrv_23_zigbee_9_serial.ino b/tasmota/xdrv_23_zigbee_9_serial.ino index 42f0683b4..19592de94 100644 --- a/tasmota/xdrv_23_zigbee_9_serial.ino +++ b/tasmota/xdrv_23_zigbee_9_serial.ino @@ -101,14 +101,14 @@ void ZigbeeInputLoop(void) { // in this case the first bit (lsb) is missed and Tasmota receives 0xFF instead of 0xFE // We forgive this mistake, and next bytes are automatically resynchronized if (ZIGBEE_SOF_ALT == zigbee_in_byte) { - AddLog_P(LOG_LEVEL_INFO, PSTR("ZbInput forgiven first byte %02X (only for statistics)"), zigbee_in_byte); + AddLog(LOG_LEVEL_INFO, PSTR("ZbInput forgiven first byte %02X (only for statistics)"), zigbee_in_byte); zigbee_in_byte = ZIGBEE_SOF; } } if ((0 == zigbee_buffer->len()) && (ZIGBEE_SOF != zigbee_in_byte)) { // waiting for SOF (Start Of Frame) byte, discard anything else - AddLog_P(LOG_LEVEL_INFO, PSTR("ZbInput discarding byte %02X"), zigbee_in_byte); + AddLog(LOG_LEVEL_INFO, PSTR("ZbInput discarding byte %02X"), zigbee_in_byte); continue; // discard } @@ -156,7 +156,7 @@ void ZigbeeInputLoop(void) { if (Settings.flag3.tuya_serial_mqtt_publish) { MqttPublishPrefixTopicRulesProcess_P(TELE, PSTR(D_RSLT_SENSOR)); } else { - AddLogZ_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); + AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); } // now process the message ZigbeeProcessInput(znp_buffer); @@ -267,7 +267,7 @@ void ZigbeeInputLoop(void) { } ToHex_P((unsigned char*)ezsp_buffer.getBuffer(), ezsp_buffer.len(), hex_char, sizeof(hex_char)); - AddLogZ_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "{\"" D_JSON_ZIGBEE_EZSP_RECEIVED "2\":\"%s\"}"), hex_char); + AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE "{\"" D_JSON_ZIGBEE_EZSP_RECEIVED "2\":\"%s\"}"), hex_char); // now process the message ZigbeeProcessInputRaw(ezsp_buffer); } @@ -357,7 +357,7 @@ void ZigbeeZNPSend(const uint8_t *msg, size_t len) { } // Now send a MQTT message to report the sent message char hex_char[(len * 2) + 2]; - AddLogZ_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEEZNPSENT " %s"), + AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEEZNPSENT " %s"), ToHex_P(msg, len, hex_char, sizeof(hex_char))); } @@ -491,7 +491,7 @@ void ZigbeeEZSPSendRaw(const uint8_t *msg, size_t len, bool send_cancel) { // Now send a MQTT message to report the sent message char hex_char[(len * 2) + 2]; - AddLogZ_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEE_EZSP_SENT_RAW " %s"), + AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_ZIGBEE D_JSON_ZIGBEE_EZSP_SENT_RAW " %s"), ToHex_P(msg, len, hex_char, sizeof(hex_char))); } @@ -500,7 +500,7 @@ void ZigbeeEZSPSendRaw(const uint8_t *msg, size_t len, bool send_cancel) { void ZigbeeEZSPSendCmd(const uint8_t *msg, size_t len) { char hex_char[len*2 + 2]; ToHex_P(msg, len, hex_char, sizeof(hex_char)); - AddLogZ_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "ZbEZSPSend %s"), hex_char); + AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_ZIGBEE "ZbEZSPSend %s"), hex_char); SBuffer cmd(len+3); // prefix with seq number (1 byte) and frame control bytes (2 bytes) @@ -607,7 +607,7 @@ void ZigbeeProcessInputEZSP(class SBuffer &buf) { log_level = LOG_LEVEL_DEBUG; break; } - AddLogZ_P(log_level, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); // TODO move to LOG_LEVEL_DEBUG when stable + AddLog_P(log_level, PSTR(D_LOG_ZIGBEE "%s"), TasmotaGlobal.mqtt_data); // TODO move to LOG_LEVEL_DEBUG when stable } // Pass message to state machine diff --git a/tasmota/xdrv_23_zigbee_9a_upload.ino b/tasmota/xdrv_23_zigbee_9a_upload.ino index d8157c127..79131078a 100644 --- a/tasmota/xdrv_23_zigbee_9a_upload.ino +++ b/tasmota/xdrv_23_zigbee_9a_upload.ino @@ -84,7 +84,7 @@ char ZigbeeUploadFlashRead(void) { // static bool padding = true; // if (padding) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Start padding from %d"), ZbUpload.byte_counter); +// AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Start padding from %d"), ZbUpload.byte_counter); // padding = false; // } @@ -151,7 +151,7 @@ char XModemWaitACK(void) in_char = ZigbeeSerial->read(); // if (in_char != XM_ACK) { -// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd3 0x%02X"), in_char); +// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd3 0x%02X"), in_char); // } if (XM_CAN == in_char) { return XM_CAN; } @@ -266,7 +266,7 @@ bool ZigbeeUploadBootloaderPrompt(void) { if (buf_len) { char hex_char[256]; ToHex_P(serial_buffer, buf_len, hex_char, 256); - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd %s"), hex_char); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd %s"), hex_char); } return ((4 == ZbUpload.byte_counter) && (millis() > XModem.flush_delay)); @@ -279,7 +279,7 @@ bool ZigbeeUploadXmodem(void) { } #ifdef ZIGBEE_BOOTLOADER_SOFTWARE_RESET_FIRST case ZBU_INIT: { // *** Init ESF32 bootloader - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Init bootloader")); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Init bootloader")); ZbUpload.ota_step = ZBU_SOFTWARE_RESET; return false; // Keep Zigbee serial active } @@ -294,7 +294,7 @@ bool ZigbeeUploadXmodem(void) { } case ZBU_SOFTWARE_SEND: { if (millis() > XModem.timeout) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader software reset send timeout")); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader software reset send timeout")); ZbUpload.ota_step = ZBU_HARDWARE_RESET; return true; } @@ -319,17 +319,17 @@ bool ZigbeeUploadXmodem(void) { case ZBU_PROMPT: { // *** Wait for prompt and select option upload ebl if (millis() > XModem.timeout) { if (ZBU_SOFTWARE_RESET == ZbUpload.bootloader) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader software reset timeout")); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader software reset timeout")); ZbUpload.ota_step = ZBU_HARDWARE_RESET; } else { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader hardware reset timeout")); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader hardware reset timeout")); ZbUpload.ota_step = ZBU_ERROR; } return true; } #else // No ZIGBEE_BOOTLOADER_SOFTWARE_RESET_FIRST case ZBU_INIT: { // *** Init ESF32 bootloader - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Init bootloader")); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Init bootloader")); ZigbeeUploadSetBootloader(0); // Reboot MCU EFR32 which returns below text XModem.timeout = millis() + (30 * 1000); // Allow 30 seconds to receive EBL prompt XModem.delay = millis() + (2 * XMODEM_FLUSH_DELAY); @@ -339,7 +339,7 @@ bool ZigbeeUploadXmodem(void) { } case ZBU_PROMPT: { // *** Wait for prompt and select option upload ebl if (millis() > XModem.timeout) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader timeout")); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader timeout")); ZbUpload.ota_step = ZBU_ERROR; return true; } @@ -360,7 +360,7 @@ bool ZigbeeUploadXmodem(void) { // 3. ebl info[cr][lf] // BL > if (ZigbeeUploadBootloaderPrompt()) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Init sync")); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Init sync")); ZigbeeSerial->flush(); ZigbeeSerial->write('1'); // upload ebl if (TasmotaGlobal.sleep > 0) { @@ -374,7 +374,7 @@ bool ZigbeeUploadXmodem(void) { } case ZBU_SYNC: { // *** Handle file upload using XModem - sync if (millis() > XModem.timeout) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: SYNC timeout")); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: SYNC timeout")); ZbUpload.ota_step = ZBU_ERROR; return true; } @@ -385,7 +385,7 @@ bool ZigbeeUploadXmodem(void) { // C char xmodem_sync = ZigbeeSerial->read(); -// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd2 0x%02X"), xmodem_sync); +// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd2 0x%02X"), xmodem_sync); if (('C' == xmodem_sync) || (XM_NAK == xmodem_sync)) { // Determine which checksum algorithm to use @@ -393,7 +393,7 @@ bool ZigbeeUploadXmodem(void) { XModem.packet_no = 1; ZbUpload.byte_counter = 0; ZbUpload.ota_step = ZBU_UPLOAD; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Init packet send")); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Init packet send")); } } break; @@ -401,10 +401,10 @@ bool ZigbeeUploadXmodem(void) { case ZBU_UPLOAD: { // *** Handle file upload using XModem - upload if (ZigbeeUploadAvailable()) { if (ZbUpload.byte_counter && !(ZbUpload.byte_counter % 10240)) { // Show progress every 10kB - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Progress %d kB"), ZbUpload.byte_counter / 1024); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Progress %d kB"), ZbUpload.byte_counter / 1024); } if (!XModemSendPacket(XModem.packet_no)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Packet %d send failed"), XModem.packet_no); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Packet %d send failed"), XModem.packet_no); ZbUpload.ota_step = ZBU_ERROR; return true; } @@ -416,7 +416,7 @@ bool ZigbeeUploadXmodem(void) { ZigbeeSerial->write(XM_EOT); XModem.timeout = millis() + (30 * 1000); // Allow 30 seconds to receive EOT ACK ZbUpload.ota_step = ZBU_EOT; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Transferred %d bytes"), ZbUpload.ota_size); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Transferred %d bytes"), ZbUpload.ota_size); } break; } @@ -427,19 +427,19 @@ bool ZigbeeUploadXmodem(void) { // its XModem state machine waits a sufficient amount of time to allow this checksum process // to occur without timing out on the response just before the EOT is sent. if (millis() > XModem.timeout) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: EOT ACK timeout")); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: EOT ACK timeout")); ZbUpload.ota_step = ZBU_ERROR; return true; } if (ZigbeeSerial->available()) { char xmodem_ack = XModemWaitACK(); if (XM_CAN == xmodem_ack) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Transfer invalid")); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Transfer invalid")); ZbUpload.ota_step = ZBU_ERROR; return true; } else if (XM_ACK == xmodem_ack) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: " D_SUCCESSFUL)); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: " D_SUCCESSFUL)); XModem.timeout = millis() + (30 * 1000); // Allow 30 seconds to receive EBL prompt ZbUpload.byte_counter = 0; ZbUpload.ota_step = ZBU_COMPLETE; @@ -449,7 +449,7 @@ bool ZigbeeUploadXmodem(void) { } case ZBU_COMPLETE: { // *** Wait for Serial upload complete EBL prompt if (millis() > XModem.timeout) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader timeout")); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: Bootloader timeout")); ZbUpload.ota_step = ZBU_ERROR; return true; } else { @@ -467,14 +467,14 @@ bool ZigbeeUploadXmodem(void) { if (ZigbeeUploadBootloaderPrompt()) { ZbUpload.state = ZBU_COMPLETE; ZbUpload.ota_step = ZBU_DONE; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: " D_RESTARTING)); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: " D_RESTARTING)); } } break; } case ZBU_ERROR: ZbUpload.state = ZBU_ERROR; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: " D_FAILED)); + AddLog(LOG_LEVEL_DEBUG, PSTR("XMD: " D_FAILED)); case ZBU_DONE: { // *** Clean up and restart to disable bootloader and use new firmware ZigbeeUploadSetBootloader(1); // Disable bootloader and reset MCU - should happen at restart if (1 == TasmotaGlobal.sleep) { @@ -547,7 +547,7 @@ void HandleZigbeeXfer(void) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPLOAD_TRANSFER)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_UPLOAD_TRANSFER)); WSContentStart_P(PSTR(D_INFORMATION)); WSContentSend_P(HTTP_SCRIPT_XFER_STATE); diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index 673f1ff8d..4455c5b0a 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -67,7 +67,7 @@ void ZigbeeInit(void) // Check if settings in Flash are set if (PinUsed(GPIO_ZIGBEE_RX) && PinUsed(GPIO_ZIGBEE_TX)) { if (0 == Settings.zb_channel) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_RANDOMIZING_ZBCONFIG)); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_RANDOMIZING_ZBCONFIG)); uint64_t mac64 = 0; // stuff mac address into 64 bits WiFi.macAddress((uint8_t*) &mac64); uint32_t esp_id = ESP_getChipId(); @@ -103,7 +103,7 @@ void ZigbeeInit(void) Wire.beginTransmission(USE_ZIGBEE_ZBBRIDGE_EEPROM); uint8_t error = Wire.endTransmission(); if (0 == error) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_EEPROM_FOUND_AT_ADDRESS " 0x%02X"), USE_ZIGBEE_ZBBRIDGE_EEPROM); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE D_ZIGBEE_EEPROM_FOUND_AT_ADDRESS " 0x%02X"), USE_ZIGBEE_ZBBRIDGE_EEPROM); zigbee.eeprom_present = true; } #endif @@ -188,7 +188,7 @@ void zigbeeZCLSendStr(uint16_t shortaddr, uint16_t groupaddr, uint8_t endpoint, endpoint = zigbee_devices.findFirstEndpoint(shortaddr); //AddLog_P(LOG_LEVEL_DEBUG, PSTR("ZbSend: guessing endpoint 0x%02X"), endpoint); } - AddLogZ_P(LOG_LEVEL_DEBUG, PSTR("ZbSend: shortaddr 0x%04X, groupaddr 0x%04X, cluster 0x%04X, endpoint 0x%02X, cmd 0x%02X, data %s"), + AddLog_P(LOG_LEVEL_DEBUG, PSTR("ZbSend: shortaddr 0x%04X, groupaddr 0x%04X, cluster 0x%04X, endpoint 0x%02X, cmd 0x%02X, data %s"), shortaddr, groupaddr, cluster, endpoint, cmd, param); if ((0 == endpoint) && (BAD_SHORTADDR != shortaddr)) { // endpoint null is ok for group address @@ -580,7 +580,7 @@ void ZbSendSend(class JsonParserToken val_cmd, uint16_t device, uint16_t groupad // we have an unsupported command type, just ignore it and fallback to missing command } - AddLogZ_P(LOG_LEVEL_DEBUG, PSTR("ZigbeeZCLSend device: 0x%04X, group: 0x%04X, endpoint:%d, cluster:0x%04X, cmd:0x%02X, send:\"%s\""), + AddLog_P(LOG_LEVEL_DEBUG, PSTR("ZigbeeZCLSend device: 0x%04X, group: 0x%04X, endpoint:%d, cluster:0x%04X, cmd:0x%02X, send:\"%s\""), device, groupaddr, endpoint, cluster, cmd, cmd_s); zigbeeZCLSendStr(device, groupaddr, endpoint, clusterSpecific, manuf, cluster, cmd, cmd_s); ResponseCmndDone(); @@ -1643,25 +1643,18 @@ void CmndZbConfig(void) { } // display the current or new configuration - char hex_ext_panid[20] = "0x"; - Uint64toHex(zb_ext_panid, &hex_ext_panid[2], 64); - char hex_precfgkey_l[20] = "0x"; - Uint64toHex(zb_precfgkey_l, &hex_precfgkey_l[2], 64); - char hex_precfgkey_h[20] = "0x"; - Uint64toHex(zb_precfgkey_h, &hex_precfgkey_h[2], 64); - // {"ZbConfig":{"Channel":11,"PanID":"0x1A63","ExtPanID":"0xCCCCCCCCCCCCCCCC","KeyL":"0x0F0D0B0907050301L","KeyH":"0x0D0C0A0806040200L"}} Response_P(PSTR("{\"" D_PRFX_ZB D_JSON_ZIGBEE_CONFIG "\":{" "\"Channel\":%d" ",\"PanID\":\"0x%04X\"" - ",\"ExtPanID\":\"%s\"" - ",\"KeyL\":\"%s\"" - ",\"KeyH\":\"%s\"" + ",\"ExtPanID\":\"0x%_X\"" + ",\"KeyL\":\"0x%_X\"" + ",\"KeyH\":\"0x%_X\"" ",\"TxRadio\":%d" "}}"), zb_channel, zb_pan_id, - hex_ext_panid, - hex_precfgkey_l, hex_precfgkey_h, + &zb_ext_panid, + &zb_precfgkey_l, &zb_precfgkey_h, zb_txradio_dbm); } diff --git a/tasmota/xdrv_24_buzzer.ino b/tasmota/xdrv_24_buzzer.ino index e6665e21f..868c1d84a 100644 --- a/tasmota/xdrv_24_buzzer.ino +++ b/tasmota/xdrv_24_buzzer.ino @@ -97,7 +97,7 @@ void BuzzerBeep(uint32_t count, uint32_t on, uint32_t off, uint32_t tune, uint32 Buzzer.freq_mode = 0; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("BUZ: %d(%d),%d,%d,0x%08X(0x%08X),%d"), count, Buzzer.count, on, off, tune, Buzzer.tune, Buzzer.freq_mode); + AddLog(LOG_LEVEL_DEBUG, PSTR("BUZ: %d(%d),%d,%d,0x%08X(0x%08X),%d"), count, Buzzer.count, on, off, tune, Buzzer.tune, Buzzer.freq_mode); Buzzer.enable = (Buzzer.count > 0); if (Buzzer.enable) { diff --git a/tasmota/xdrv_26_ariluxrf.ino b/tasmota/xdrv_26_ariluxrf.ino index fca693c8d..0246e6a8f 100644 --- a/tasmota/xdrv_26_ariluxrf.ino +++ b/tasmota/xdrv_26_ariluxrf.ino @@ -98,7 +98,7 @@ void AriluxRfHandler(void) uint16_t stored_hostcode = Settings.rf_code[1][6] << 8 | Settings.rf_code[1][7]; // DEBUG_DRIVER_LOG(PSTR(D_LOG_RFR D_HOST D_CODE " 0x%04X, " D_RECEIVED " 0x%06X"), stored_hostcode, Arilux.rf_received_value); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_RFR D_HOST D_CODE " 0x%04X, " D_RECEIVED " 0x%06X"), stored_hostcode, Arilux.rf_received_value); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_RFR D_HOST D_CODE " 0x%04X, " D_RECEIVED " 0x%06X"), stored_hostcode, Arilux.rf_received_value); if (hostcode == stored_hostcode) { char command[33]; diff --git a/tasmota/xdrv_27_shutter.ino b/tasmota/xdrv_27_shutter.ino index cd54878d7..8ac9f2940 100644 --- a/tasmota/xdrv_27_shutter.ino +++ b/tasmota/xdrv_27_shutter.ino @@ -144,7 +144,7 @@ void ShutterRtc50mS(void) case SHT_COUNTER: if (Shutter[i].accelerator) { - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Accelerator i=%d -> %d"),i, Shutter[i].accelerator); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Accelerator i=%d -> %d"),i, Shutter[i].accelerator); ShutterUpdateVelocity(i); analogWriteFreq(Shutter[i].pwm_velocity); analogWrite(Pin(GPIO_PWM1, i), 50); @@ -164,7 +164,7 @@ int32_t ShutterPercentToRealPosition(int16_t percent, uint32_t index) // check against DIV 0 for (uint32_t j = 0; j < 5; j++) { if (0 == Settings.shuttercoeff[j][index]) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("SHT: RESET/INIT CALIBRATION MATRIX DIV 0")); + AddLog(LOG_LEVEL_ERROR, PSTR("SHT: RESET/INIT CALIBRATION MATRIX DIV 0")); for (uint32_t k = 0; k < 5; k++) { Settings.shuttercoeff[k][index] = SHT_DIV_ROUND(calibrate_pos[k+1] * 1000, calibrate_pos[5]); } @@ -251,7 +251,7 @@ void ShutterInit(void) if (Settings.shutter_mode == SHT_UNDEF) { bool relay_in_interlock = false; - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Mode undef.. calculate...")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Mode undef.. calculate...")); for (uint32_t j = 0; j < MAX_INTERLOCKS * Settings.flag.interlock; j++) { // CMND_INTERLOCK - Enable/disable interlock //AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Interlock state i=%d %d, flag %d, Shuttermask %d, MaskedIL %d"),i, Settings.interlock[i], Settings.flag.interlock,ShutterGlobal.RelayShutterMask, Settings.interlock[i]&ShutterGlobal.RelayShutterMask); @@ -400,7 +400,7 @@ void ShutterDecellerateForStop(uint8_t i) int16_t missing_steps; Shutter[i].accelerator = -(ShutterGlobal.open_velocity_max / (Shutter[i].motordelay>4 ? (Shutter[i].motordelay*11)/10 : 4) ); while (Shutter[i].pwm_velocity > -2*Shutter[i].accelerator ) { - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Velocity %ld, Delta %d"), Shutter[i].pwm_velocity, Shutter[i].accelerator ); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Velocity %ld, Delta %d"), Shutter[i].pwm_velocity, Shutter[i].accelerator ); //Shutter[i].pwm_velocity = tmax(Shutter[i].pwm_velocity-Shutter[i].accelerator , 0); // Control will be done in RTC Ticker. delay(50); @@ -408,19 +408,18 @@ void ShutterDecellerateForStop(uint8_t i) if (ShutterGlobal.position_mode == SHT_COUNTER){ missing_steps = ((Shutter[i].target_position-Shutter[i].start_position)*Shutter[i].direction*ShutterGlobal.open_velocity_max/RESOLUTION/STEPS_PER_SECOND) - RtcSettings.pulse_counter[i]; //prepare for stop PWM - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Remain steps %d, Counter %d, Freq %d"), missing_steps, RtcSettings.pulse_counter[i] ,Shutter[i].pwm_velocity); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Remain steps %d, Counter %d, Freq %d"), missing_steps, RtcSettings.pulse_counter[i] ,Shutter[i].pwm_velocity); Shutter[i].accelerator = 0; Shutter[i].pwm_velocity = Shutter[i].pwm_velocity > 250 ? 250 : Shutter[i].pwm_velocity; analogWriteFreq(Shutter[i].pwm_velocity); analogWrite(Pin(GPIO_PWM1, i), 50); Shutter[i].pwm_velocity = 0; - analogWriteFreq(Shutter[i].pwm_velocity); while (RtcSettings.pulse_counter[i] < (uint32_t)(Shutter[i].target_position-Shutter[i].start_position)*Shutter[i].direction*ShutterGlobal.open_velocity_max/RESOLUTION/STEPS_PER_SECOND) { delay(1); } analogWrite(Pin(GPIO_PWM1, i), 0); // removed with 8.3 because of reset caused by watchog Shutter[i].real_position = ShutterCalculatePosition(i); - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Real %d, Pulsecount %d, Start %d"), Shutter[i].real_position,RtcSettings.pulse_counter[i], Shutter[i].start_position); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Real %d, Pulsecount %d, Start %d"), Shutter[i].real_position,RtcSettings.pulse_counter[i], Shutter[i].start_position); } Shutter[i].direction = 0; @@ -430,7 +429,7 @@ void ShutterDecellerateForStop(uint8_t i) } void ShutterPowerOff(uint8_t i) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Stop Shutter %d. Switchmode %d"), i,Shutter[i].switch_mode); + AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Stop Shutter %d. Switchmode %d"), i,Shutter[i].switch_mode); ShutterDecellerateForStop(i); switch (Shutter[i].switch_mode) { case SHT_SWITCH: @@ -521,14 +520,14 @@ void ShutterAllowPreStartProcedure(uint8_t i) { #ifdef USE_RULES uint32_t uptime_Local=0; - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start. var%d <99>=<%s>, max10s?"),i+i, rules_vars[i]); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start. var%d <99>=<%s>, max10s?"),i+i, rules_vars[i]); TasmotaGlobal.rules_flag.shutter_moving = 1; XdrvRulesProcess(); uptime_Local = TasmotaGlobal.uptime; while (uptime_Local+10 > TasmotaGlobal.uptime && (String)rules_vars[i] == "99") { loop(); } - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start. Done")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Delay Start. Done")); #endif // USE_RULES } @@ -658,7 +657,7 @@ void ShutterRelayChanged(void) switch (powerstate_local) { case 1: ShutterStartInit(i, Shutter[i].lastdirection*-1 , Shutter[i].lastdirection == 1 ? 0 : Shutter[i].open_max); - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d Garage. NewTarget %d"), i, Shutter[i].target_position); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d Garage. NewTarget %d"), i, Shutter[i].target_position); break; default: Shutter[i].target_position = Shutter[i].real_position; @@ -666,7 +665,7 @@ void ShutterRelayChanged(void) } // switch (ShutterGlobal.position_mode) - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d, Target %ld, Powerstatelocal %d"), i+1, Shutter[i].target_position, powerstate_local); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Shtr%d, Target %ld, Powerstatelocal %d"), i+1, Shutter[i].target_position, powerstate_local); } // if (manual_relays_changed) } // for (uint32_t i = 0; i < TasmotaGlobal.shutters_present; i++) } @@ -761,12 +760,12 @@ void ShutterButtonHandler(void) Settings.shutter_button[i], shutter_index, Button.press_counter[i] , min_shutterbutton_press_counter, i); if ((button_index != i) && (Settings.shutter_button[i] & (1<<31)) && ((Settings.shutter_button[i] & 0x03) == shutter_index) && (i != button_index) && (Button.press_counter[i] < min_shutterbutton_press_counter)) { min_shutterbutton_press_counter = Button.press_counter[i]; - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: minShutterButtonPressCounter %d"), min_shutterbutton_press_counter); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: minShutterButtonPressCounter %d"), min_shutterbutton_press_counter); } } if (min_shutterbutton_press_counter == Button.press_counter[button_index]) { // simultaneous shutter button press detected - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Simultanous press detected")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Simultanous press detected")); press_index = Button.press_counter[button_index]; for (uint32_t i = 0; i < MAX_KEYS; i++) if ((Settings.shutter_button[i] & (1<<31)) && ((Settings.shutter_button[i] & 0x03) != shutter_index)) @@ -872,7 +871,7 @@ void ShutterSetPosition(uint32_t device, uint32_t position) void ShutterToggle(bool dir) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Payload toggle: %d, i %d, dir %d"), XdrvMailbox.payload, XdrvMailbox.index, dir); + AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Payload toggle: %d, i %d, dir %d"), XdrvMailbox.payload, XdrvMailbox.index, dir); if ((1 == XdrvMailbox.index) && (XdrvMailbox.payload != -99)) { XdrvMailbox.index = XdrvMailbox.payload; } @@ -896,7 +895,7 @@ void ShutterToggle(bool dir) void CmndShutterOpen(void) { - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Payload open: %d, i %d"), XdrvMailbox.payload, XdrvMailbox.index); + //AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Payload open: %d, i %d"), XdrvMailbox.payload, XdrvMailbox.index); if ((1 == XdrvMailbox.index) && (XdrvMailbox.payload != -99)) { XdrvMailbox.index = XdrvMailbox.payload; } @@ -919,7 +918,7 @@ void CmndShutterStopOpen(void) void CmndShutterClose(void) { - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Payload close: %d, i %d"), XdrvMailbox.payload, XdrvMailbox.index); + //AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Payload close: %d, i %d"), XdrvMailbox.payload, XdrvMailbox.index); if ((1 == XdrvMailbox.index) && (XdrvMailbox.payload != -99)) { XdrvMailbox.index = XdrvMailbox.payload; } @@ -985,7 +984,7 @@ void CmndShutterStop(void) uint32_t i = XdrvMailbox.index -1; if (Shutter[i].direction != 0) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Stop moving %d: dir: %d"), XdrvMailbox.index, Shutter[i].direction); + AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Stop moving %d: dir: %d"), XdrvMailbox.index, Shutter[i].direction); Shutter[i].target_position = Shutter[i].real_position; } if (XdrvMailbox.command) @@ -1017,7 +1016,7 @@ void CmndShutterPosition(void) if (!(Settings.shutter_options[XdrvMailbox.index-1] & 2)) { uint32_t index = XdrvMailbox.index-1; //limit the payload - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Pos. in: payload %s (%d), payload %d, idx %d, src %d"), XdrvMailbox.data , XdrvMailbox.data_len, XdrvMailbox.payload , XdrvMailbox.index, TasmotaGlobal.last_source ); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Pos. in: payload %s (%d), payload %d, idx %d, src %d"), XdrvMailbox.data , XdrvMailbox.data_len, XdrvMailbox.payload , XdrvMailbox.index, TasmotaGlobal.last_source ); // value 0 with data_len > 0 can mean Open // special handling fo UP,DOWN,TOGGLE,STOP command comming with payload -99 @@ -1054,7 +1053,7 @@ void CmndShutterPosition(void) Shutter[index].target_position = ShutterPercentToRealPosition(target_pos_percent, index); //Shutter[i].accelerator[index] = ShutterGlobal.open_velocity_max / ((Shutter[i].motordelay[index] > 0) ? Shutter[i].motordelay[index] : 1); //Shutter[i].target_position[index] = XdrvMailbox.payload < 5 ? Settings.shuttercoeff[2][index] * XdrvMailbox.payload : Settings.shuttercoeff[1][index] * XdrvMailbox.payload + Settings.shuttercoeff[0,index]; - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: lastsource %d:, real %d, target %d, payload %d"), TasmotaGlobal.last_source, Shutter[index].real_position ,Shutter[index].target_position,target_pos_percent); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: lastsource %d:, real %d, target %d, payload %d"), TasmotaGlobal.last_source, Shutter[index].real_position ,Shutter[index].target_position,target_pos_percent); } if ( (target_pos_percent >= 0) && (target_pos_percent <= 100) && abs(Shutter[index].target_position - Shutter[index].real_position ) / Shutter[index].close_velocity > 2) { if (Settings.shutter_options[index] & 4) { @@ -1091,7 +1090,7 @@ void CmndShutterPosition(void) case SHT_TIME_GARAGE: if (!ShutterGlobal.skip_relay_change) { if (new_shutterdirection == Shutter[index].lastdirection) { - AddLog_P(LOG_LEVEL_INFO, PSTR("SHT: Garage not move in this direction: %d"), Shutter[index].switch_mode == SHT_PULSE); + AddLog(LOG_LEVEL_INFO, PSTR("SHT: Garage not move in this direction: %d"), Shutter[index].switch_mode == SHT_PULSE); for (uint8_t k=0 ; k <= (uint8_t)(Shutter[index].switch_mode == SHT_PULSE) ; k++) { ExecuteCommandPowerShutter(Settings.shutter_startrelay[index], 1, SRC_SHUTTER); delay(500); @@ -1401,7 +1400,7 @@ void CmndShutterPwmRange(void) } Settings.shutter_pwmrange[i][XdrvMailbox.index -1] = field; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Init1. pwmmin %d, pwmmax %d"), XdrvMailbox.index , Settings.shutter_pwmrange[0][XdrvMailbox.index -1], Settings.shutter_pwmrange[1][XdrvMailbox.index -1]); + AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shtr%d Init1. pwmmin %d, pwmmax %d"), XdrvMailbox.index , Settings.shutter_pwmrange[0][XdrvMailbox.index -1], Settings.shutter_pwmrange[1][XdrvMailbox.index -1]); ShutterInit(); ResponseCmndIdxChar(XdrvMailbox.data); } else { @@ -1434,7 +1433,7 @@ void CmndShutterCalibration(void) Settings.shutter_set50percent[XdrvMailbox.index -1] = 50; for (i = 0; i < 5; i++) { Settings.shuttercoeff[i][XdrvMailbox.index -1] = SHT_DIV_ROUND((uint32_t)messwerte[i] * 1000, messwerte[4]); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SHT: Shuttercoeff %d, i %d, Value %d, MeasuredValue %d"), i,XdrvMailbox.index -1,Settings.shuttercoeff[i][XdrvMailbox.index -1], messwerte[i]); + AddLog(LOG_LEVEL_DEBUG, PSTR("SHT: Shuttercoeff %d, i %d, Value %d, MeasuredValue %d"), i,XdrvMailbox.index -1,Settings.shuttercoeff[i][XdrvMailbox.index -1], messwerte[i]); } ShutterInit(); ResponseCmndIdxChar(XdrvMailbox.data); @@ -1515,7 +1514,7 @@ bool Xdrv27(uint8_t function) char stemp1[10]; // extract the number of the relay that was switched and save for later in Update Position. ShutterGlobal.RelayCurrentMask = XdrvMailbox.index ^ ShutterGlobal.RelayOldMask; - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Switched relay %d by %s"), ShutterGlobal.RelayCurrentMask,GetTextIndexed(stemp1, sizeof(stemp1), TasmotaGlobal.last_source, kCommandSource)); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Switched relay %d by %s"), ShutterGlobal.RelayCurrentMask,GetTextIndexed(stemp1, sizeof(stemp1), TasmotaGlobal.last_source, kCommandSource)); ShutterRelayChanged(); ShutterGlobal.RelayOldMask = XdrvMailbox.index; break; @@ -1528,10 +1527,10 @@ bool Xdrv27(uint8_t function) } ShutterGlobal.RelayCurrentMask >>= 1; } - //AddLog_P(LOG_LEVEL_ERROR, PSTR("SHT: Skip relay change %d"), i+1); + //AddLog(LOG_LEVEL_ERROR, PSTR("SHT: Skip relay change %d"), i+1); result = true; ShutterGlobal.skip_relay_change = 0; - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Skipping switch off relay %d"), i); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("SHT: Skipping switch off relay %d"), i); ExecuteCommandPowerShutter(i+1, 0, SRC_SHUTTER); } break; diff --git a/tasmota/xdrv_28_pcf8574.ino b/tasmota/xdrv_28_pcf8574.ino index b79f3caa6..231476ba2 100644 --- a/tasmota/xdrv_28_pcf8574.ino +++ b/tasmota/xdrv_28_pcf8574.ino @@ -48,14 +48,14 @@ void Pcf8574SwitchRelay(void) for (uint32_t i = 0; i < TasmotaGlobal.devices_present; i++) { uint8_t relay_state = bitRead(XdrvMailbox.index, i); - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("PCF: Pcf8574.max_devices %d requested pin %d"), Pcf8574.max_devices,Pcf8574.pin[i]); + //AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Pcf8574.max_devices %d requested pin %d"), Pcf8574.max_devices,Pcf8574.pin[i]); if (Pcf8574.max_devices > 0 && Pcf8574.pin[i] < 99) { uint8_t board = Pcf8574.pin[i]>>3; uint8_t oldpinmask = Pcf8574.pin_mask[board]; uint8_t _val = bitRead(TasmotaGlobal.rel_inverted, i) ? !relay_state : relay_state; - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("PCF: Pcf8574SwitchRelay %d on pin %d"), i,state); + //AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Pcf8574SwitchRelay %d on pin %d"), i,state); if (_val) { Pcf8574.pin_mask[board] |= _val << (Pcf8574.pin[i]&0x7); @@ -79,7 +79,7 @@ void Pcf8574Init(void) #ifdef USE_MCP230xx_ADDR if (USE_MCP230xx_ADDR == pcf8574_address) { - AddLog_P(LOG_LEVEL_INFO, PSTR("PCF: Address 0x%02x reserved for MCP320xx skipped"), pcf8574_address); + AddLog(LOG_LEVEL_INFO, PSTR("PCF: Address 0x%02x reserved for MCP320xx skipped"), pcf8574_address); pcf8574_address++; if ((PCF8574_ADDR1 +7) == pcf8574_address) { // Support I2C addresses 0x20 to 0x26 and 0x39 to 0x3F pcf8574_address = PCF8574_ADDR2 +1; @@ -87,7 +87,7 @@ void Pcf8574Init(void) } #endif - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("PCF: Probing addr: 0x%x for PCF8574"), pcf8574_address); + // AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Probing addr: 0x%x for PCF8574"), pcf8574_address); if (I2cSetDevice(pcf8574_address)) { Pcf8574.type = true; @@ -115,7 +115,7 @@ void Pcf8574Init(void) Pcf8574.max_connected_ports = 0; // reset no of devices to avoid duplicate ports on duplicate init. for (uint32_t idx = 0; idx < Pcf8574.max_devices; idx++) { // suport up to 8 boards PCF8574 - AddLog_P(LOG_LEVEL_DEBUG, PSTR("PCF: Device %d config 0x%02x"), idx +1, Settings.pcf8574_config[idx]); + AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Device %d config 0x%02x"), idx +1, Settings.pcf8574_config[idx]); for (uint32_t i = 0; i < 8; i++) { uint8_t _result = Settings.pcf8574_config[idx] >> i &1; @@ -128,7 +128,7 @@ void Pcf8574Init(void) } } } - AddLog_P(LOG_LEVEL_INFO, PSTR("PCF: Total devices %d, PCF8574 output ports %d"), Pcf8574.max_devices, Pcf8574.max_connected_ports); + AddLog(LOG_LEVEL_INFO, PSTR("PCF: Total devices %d, PCF8574 output ports %d"), Pcf8574.max_devices, Pcf8574.max_connected_ports); } } @@ -158,7 +158,7 @@ void HandlePcf8574(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_PCF8574)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_PCF8574)); if (Webserver->hasArg("save")) { Pcf8574SaveSettings(); @@ -193,7 +193,7 @@ void Pcf8574SaveSettings(void) char stemp[7]; char tmp[100]; - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("PCF: Start working on Save arguements: inverted:%d")), Webserver->hasArg("b1"); + //AddLog(LOG_LEVEL_DEBUG, PSTR("PCF: Start working on Save arguements: inverted:%d")), Webserver->hasArg("b1"); Settings.flag3.pcf8574_ports_inverted = Webserver->hasArg("b1"); // SetOption81 - Invert all ports on PCF8574 devices for (byte idx = 0; idx < Pcf8574.max_devices; idx++) { @@ -219,7 +219,7 @@ void Pcf8574SaveSettings(void) } } //Settings.pcf8574_config[0] = (!strlen(webServer->arg("i2cs0").c_str())) ? 0 : atoi(webServer->arg("i2cs0").c_str()); - //AddLog_P(LOG_LEVEL_INFO, PSTR("PCF: I2C Board: %d, Config: %2x")), idx, Settings.pcf8574_config[idx]; + //AddLog(LOG_LEVEL_INFO, PSTR("PCF: I2C Board: %d, Config: %2x")), idx, Settings.pcf8574_config[idx]; } } diff --git a/tasmota/xdrv_29_deepsleep.ino b/tasmota/xdrv_29_deepsleep.ino index 3e28a9d31..45da79cb2 100644 --- a/tasmota/xdrv_29_deepsleep.ino +++ b/tasmota/xdrv_29_deepsleep.ino @@ -68,7 +68,7 @@ void DeepSleepReInit(void) if ((RtcSettings.ultradeepsleep > DEEPSLEEP_MAX_CYCLE) && (RtcSettings.ultradeepsleep < 1700000000)) { // Go back to sleep after 60 minutes if requested deepsleep has not been reached RtcSettings.ultradeepsleep = RtcSettings.ultradeepsleep - DEEPSLEEP_MAX_CYCLE; - AddLog_P(LOG_LEVEL_ERROR, PSTR("DSL: Remain DeepSleep %d"), RtcSettings.ultradeepsleep); + AddLog(LOG_LEVEL_ERROR, PSTR("DSL: Remain DeepSleep %d"), RtcSettings.ultradeepsleep); RtcSettingsSave(); RtcRebootReset(); #ifdef ESP8266 @@ -96,7 +96,7 @@ void DeepSleepPrepare(void) (RtcSettings.deepsleep_slip < 9000) || (RtcSettings.deepsleep_slip > 11000) || (RtcSettings.nextwakeup > (UtcTime() + Settings.deepsleep))) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("DSL: Reset wrong settings wakeup: %ld, slip %ld"), RtcSettings.nextwakeup, RtcSettings.deepsleep_slip ); + AddLog(LOG_LEVEL_ERROR, PSTR("DSL: Reset wrong settings wakeup: %ld, slip %ld"), RtcSettings.nextwakeup, RtcSettings.deepsleep_slip ); RtcSettings.nextwakeup = 0; RtcSettings.deepsleep_slip = 10000; } @@ -137,7 +137,7 @@ void DeepSleepPrepare(void) void DeepSleepStart(void) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Sleeping")); // Won't show in GUI + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Sleeping")); // Won't show in GUI WifiShutdown(); RtcSettings.ultradeepsleep = RtcSettings.nextwakeup - UtcTime(); diff --git a/tasmota/xdrv_30_exs_dimmer.ino b/tasmota/xdrv_30_exs_dimmer.ino index b704d616d..ffab61d5d 100644 --- a/tasmota/xdrv_30_exs_dimmer.ino +++ b/tasmota/xdrv_30_exs_dimmer.ino @@ -124,7 +124,7 @@ void ExsSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0) char rc; #ifdef EXS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: Tx Packet:")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: Tx Packet:")); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)data, len); #endif @@ -145,7 +145,7 @@ void ExsSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0) { // timeout #ifdef EXS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ESX: serial send timeout")); + AddLog(LOG_LEVEL_DEBUG, PSTR("ESX: serial send timeout")); #endif continue; } @@ -215,9 +215,9 @@ void ExsSetBri(uint8_t device, uint8_t bri) void ExsSyncState(uint8_t device) { #ifdef EXS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("EXS: Channel %d Power Want %d, Is %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR("EXS: Channel %d Power Want %d, Is %d"), device, bitRead(Exs.power, device), Exs.dimmer.channel[device].dimm); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("EXS: Set Channel %d Brightness Want %d, Is %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR("EXS: Set Channel %d Brightness Want %d, Is %d"), device, Exs.dimm[device], Exs.dimmer.channel[device].bright_tbl); #endif @@ -236,7 +236,7 @@ void ExsSyncState(uint8_t device) bool ExsSyncState() { #ifdef EXS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("EXS: Serial %p, Cmd %d"), ExsSerial, Exs.cmd_status); + AddLog(LOG_LEVEL_DEBUG, PSTR("EXS: Serial %p, Cmd %d"), ExsSerial, Exs.cmd_status); #endif if (!ExsSerial || Exs.cmd_status != 0) @@ -363,7 +363,7 @@ bool ExsModuleSelected(void) bool ExsSetChannels(void) { #ifdef EXS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: SetChannels:")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: SetChannels:")); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)XdrvMailbox.data, XdrvMailbox.data_len); #endif @@ -374,7 +374,7 @@ bool ExsSetChannels(void) bool ExsSetPower(void) { - AddLog_P(LOG_LEVEL_INFO, PSTR("EXS: Set Power, Device %d, Power 0x%02x"), + AddLog(LOG_LEVEL_INFO, PSTR("EXS: Set Power, Device %d, Power 0x%02x"), TasmotaGlobal.active_device, XdrvMailbox.index); Exs.power = XdrvMailbox.index; @@ -386,7 +386,7 @@ void EsxMcuStart(void) int retries = 3; #ifdef EXS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("EXS: Request MCU configuration, PIN %d to Low"), Pin(GPIO_EXS_ENABLE)); + AddLog(LOG_LEVEL_DEBUG, PSTR("EXS: Request MCU configuration, PIN %d to Low"), Pin(GPIO_EXS_ENABLE)); #endif pinMode(Pin(GPIO_EXS_ENABLE), OUTPUT); @@ -404,7 +404,7 @@ void EsxMcuStart(void) void ExsInit(void) { #ifdef EXS_DEBUG - AddLog_P(LOG_LEVEL_INFO, PSTR("EXS: Starting Tx %d Rx %d"), Pin(GPIO_TXD), Pin(GPIO_RXD)); + AddLog(LOG_LEVEL_INFO, PSTR("EXS: Starting Tx %d Rx %d"), Pin(GPIO_TXD), Pin(GPIO_RXD)); #endif Exs.buffer = (uint8_t *)malloc(EXS_BUFFER_SIZE); @@ -432,7 +432,7 @@ void ExsSerialInput(void) yield(); uint8_t serial_in_byte = ExsSerial->read(); - AddLog_P(LOG_LEVEL_INFO, PSTR("EXS: Serial In Byte 0x%02x"), serial_in_byte); + AddLog(LOG_LEVEL_INFO, PSTR("EXS: Serial In Byte 0x%02x"), serial_in_byte); if (Exs.cmd_status == 0 && serial_in_byte == 0x7B) @@ -456,7 +456,7 @@ void ExsSerialInput(void) Exs.cmd_status = 0; #ifdef EXS_DEBUG - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: CRC: 0x%02x, RX Packet:"), crc); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("EXS: CRC: 0x%02x, RX Packet:"), crc); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)Exs.buffer, Exs.byte_counter); #endif diff --git a/tasmota/xdrv_31_tasmota_client.ino b/tasmota/xdrv_31_tasmota_client.ino index bf4426b61..54082d827 100644 --- a/tasmota/xdrv_31_tasmota_client.ino +++ b/tasmota/xdrv_31_tasmota_client.ino @@ -238,14 +238,14 @@ uint8_t TasmotaClient_receiveData(char* buffer, int size) { } if (255 == index) { index = 0; } -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TCL: ReceiveData")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("TCL: ReceiveData")); // AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t*)buffer, index); return index; } uint8_t TasmotaClient_sendBytes(uint8_t* bytes, int count) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TCL: SendBytes")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("TCL: SendBytes")); // AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t*)&bytes, count); TasmotaClient_Serial->write(bytes, count); @@ -298,7 +298,7 @@ uint32_t TasmotaClient_Flash(uint8_t* data, size_t size) { } if (timeout > 50) { return 1; } // Error: Bootloader could not be found - AddLog_P(LOG_LEVEL_INFO, PSTR("TCL: Found bootloader")); + AddLog(LOG_LEVEL_INFO, PSTR("TCL: Found bootloader")); uint8_t ProgParams[] = {0x86, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00}; if (!TasmotaClient_execParam(CMND_STK_SET_DEVICE, ProgParams, sizeof(ProgParams))) { @@ -368,7 +368,7 @@ uint32_t TasmotaClient_Flash(uint8_t* data, size_t size) { } else if (0x0A != flash_buffer[ca]) { if (!isalnum(flash_buffer[ca])) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: Size %d, Processed %d"), size, processed); +// AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: Size %d, Processed %d"), size, processed); error = 7; // Error: Invalid data break; } @@ -408,7 +408,7 @@ void TasmotaClient_Init(void) { pinMode(Pin(GPIO_TASMOTACLIENT_RST), OUTPUT); TClient.SerialEnabled = true; TasmotaClient_Reset(); - AddLog_P(LOG_LEVEL_INFO, PSTR("TCL: Enabled")); + AddLog(LOG_LEVEL_INFO, PSTR("TCL: Enabled")); } } } @@ -421,10 +421,10 @@ void TasmotaClient_Init(void) { memcpy(&TClientSettings, &buffer, sizeof(TClientSettings)); if (TASMOTA_CLIENT_LIB_VERSION == TClientSettings.features_version) { TClient.type = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("TCL: Version %u"), TClientSettings.features_version); + AddLog(LOG_LEVEL_INFO, PSTR("TCL: Version %u"), TClientSettings.features_version); } else { if ((!TClient.unsupported) && (TClientSettings.features_version > 0)) { - AddLog_P(LOG_LEVEL_INFO, PSTR("TCL: Version %u not supported!"), TClientSettings.features_version); + AddLog(LOG_LEVEL_INFO, PSTR("TCL: Version %u not supported!"), TClientSettings.features_version); TClient.unsupported = true; } } @@ -456,7 +456,7 @@ void TasmotaClient_sendCmnd(uint8_t cmnd, uint8_t param) { memcpy(&buffer[1], &TClientCommand, sizeof(TClientCommand)); buffer[sizeof(TClientCommand)+1] = CMND_END; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TCL: SendCmnd")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("TCL: SendCmnd")); // AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t*)&buffer, sizeof(buffer)); for (uint32_t ca = 0; ca < sizeof(buffer); ca++) { diff --git a/tasmota/xdrv_33_nrf24l01.ino b/tasmota/xdrv_33_nrf24l01.ino index e992c398b..dfe690de2 100644 --- a/tasmota/xdrv_33_nrf24l01.ino +++ b/tasmota/xdrv_33_nrf24l01.ino @@ -67,10 +67,10 @@ void NRF24Detect(void) { if (PinUsed(GPIO_NRF24_CS) && PinUsed(GPIO_NRF24_DC) && TasmotaGlobal.spi_enabled) { if (NRF24initRadio()) { NRF24.chipType = 32; // SPACE - AddLog_P(LOG_LEVEL_INFO, PSTR("NRF: Model 24L01 initialized")); + AddLog(LOG_LEVEL_INFO, PSTR("NRF: Model 24L01 initialized")); if (NRF24radio.isPVariant()) { NRF24.chipType = 43; // + - AddLog_P(LOG_LEVEL_INFO, PSTR("NRF: Model 24L01+ detected")); + AddLog(LOG_LEVEL_INFO, PSTR("NRF: Model 24L01+ detected")); } } } diff --git a/tasmota/xdrv_35_pwm_dimmer.ino b/tasmota/xdrv_35_pwm_dimmer.ino index 3bca88477..0abd2206b 100644 --- a/tasmota/xdrv_35_pwm_dimmer.ino +++ b/tasmota/xdrv_35_pwm_dimmer.ino @@ -254,6 +254,12 @@ void PWMDimmerHandleDevGroupItem(void) #endif // USE_PWM_DIMMER_REMOTE SendLocalDeviceGroupMessage(DGR_MSGTYP_UPDATE, DGR_ITEM_BRI_POWER_ON, Settings.bri_power_on, DGR_ITEM_BRI_PRESET_LOW, Settings.bri_preset_low, DGR_ITEM_BRI_PRESET_HIGH, Settings.bri_preset_high); +#ifdef USE_PWM_DIMMER_REMOTE + else + SendDeviceGroupMessage(device_group_index, DGR_MSGTYP_UPDATE, DGR_ITEM_POWER, remote_pwm_dimmer->power_on, + DGR_ITEM_BRI_POWER_ON, remote_pwm_dimmer->bri_power_on, DGR_ITEM_BRI_PRESET_LOW, remote_pwm_dimmer->bri_preset_low, + DGR_ITEM_BRI_PRESET_HIGH, remote_pwm_dimmer->bri_preset_high); +#endif // USE_PWM_DIMMER_REMOTE break; } } @@ -614,7 +620,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed) char topic[TOPSZ]; sprintf_P(TasmotaGlobal.mqtt_data, PSTR("Trigger%u"), mqtt_trigger); #ifdef USE_PWM_DIMMER_REMOTE - if (active_remote_pwm_dimmer) { + if (Settings.flag4.multiple_device_groups) { snprintf_P(topic, sizeof(topic), PSTR("cmnd/%s/EVENT"), device_groups[power_button_index].group_name); MqttPublish(topic); } diff --git a/tasmota/xdrv_36_keeloq.ino b/tasmota/xdrv_36_keeloq.ino index 4a0f33a83..0703190ca 100644 --- a/tasmota/xdrv_36_keeloq.ino +++ b/tasmota/xdrv_36_keeloq.ino @@ -97,7 +97,7 @@ void GenerateDeviceCryptKey() jaroliftDevice.device_key_msb = k.decrypt(jaroliftDevice.serial | 0x60000000L); jaroliftDevice.device_key_lsb = k.decrypt(jaroliftDevice.serial | 0x20000000L); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("generated device keys: %08x %08x"), jaroliftDevice.device_key_msb, jaroliftDevice.device_key_lsb); + AddLog(LOG_LEVEL_DEBUG, PSTR("generated device keys: %08x %08x"), jaroliftDevice.device_key_msb, jaroliftDevice.device_key_lsb); } void CmdSendButton(void) @@ -114,7 +114,7 @@ void CmdSendButton(void) DEBUG_DRIVER_LOG(LOG_LEVEL_DEBUG_MORE, PSTR("lsb: %08x"), jaroliftDevice.device_key_lsb); DEBUG_DRIVER_LOG(LOG_LEVEL_DEBUG_MORE, PSTR("serial: %08x"), jaroliftDevice.serial); DEBUG_DRIVER_LOG(LOG_LEVEL_DEBUG_MORE, PSTR("disc: %08x"), jaroliftDevice.disc); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("KLQ: count: %08x"), jaroliftDevice.count); + AddLog(LOG_LEVEL_DEBUG, PSTR("KLQ: count: %08x"), jaroliftDevice.count); CreateKeeloqPacket(); jaroliftDevice.count++; @@ -236,8 +236,8 @@ void CreateKeeloqPacket() jaroliftDevice.enc = k.encrypt(result); jaroliftDevice.pack |= jaroliftDevice.enc; - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("pack high: %08x"), jaroliftDevice.pack>>32); - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("pack low: %08x"), jaroliftDevice.pack); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("pack high: %08x"), jaroliftDevice.pack>>32); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("pack low: %08x"), jaroliftDevice.pack); } void KeeloqInit() @@ -248,7 +248,7 @@ void KeeloqInit() DEBUG_DRIVER_LOG(LOG_LEVEL_DEBUG_MORE, PSTR("cc1101.init()")); delay(100); cc1101.init(); - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("CC1101 done.")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("CC1101 done.")); cc1101.setSyncWord(SYNC_WORD, false); cc1101.setCarrierFreq(CFREQ_433); cc1101.disableAddressCheck(); @@ -272,7 +272,7 @@ bool Xdrv36(uint8_t function) switch (function) { case FUNC_COMMAND: - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("calling command")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("calling command")); result = DecodeCommand(kJaroliftCommands, jaroliftCommand); break; case FUNC_INIT: diff --git a/tasmota/xdrv_37_sonoff_d1.ino b/tasmota/xdrv_37_sonoff_d1.ino index 5abefd452..435bd28e5 100644 --- a/tasmota/xdrv_37_sonoff_d1.ino +++ b/tasmota/xdrv_37_sonoff_d1.ino @@ -50,7 +50,7 @@ void SonoffD1Received(void) if (action != SnfD1.power) { SnfD1.power = action; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SD1: Remote power (%d, %d)"), SnfD1.power, SnfD1.dimmer); +// AddLog(LOG_LEVEL_DEBUG, PSTR("SD1: Remote power (%d, %d)"), SnfD1.power, SnfD1.dimmer); ExecuteCommandPower(1, action, SRC_SWITCH); } @@ -59,7 +59,7 @@ void SonoffD1Received(void) if (dimmer != SnfD1.dimmer) { SnfD1.dimmer = dimmer; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SD1: Remote dimmer (%d, %d)"), SnfD1.power, SnfD1.dimmer); +// AddLog(LOG_LEVEL_DEBUG, PSTR("SD1: Remote dimmer (%d, %d)"), SnfD1.power, SnfD1.dimmer); char scmnd[20]; snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), SnfD1.dimmer); @@ -137,7 +137,7 @@ bool SonoffD1SendPower(void) if (action != SnfD1.power) { SnfD1.power = action; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SD1: Tasmota power (%d, %d)"), SnfD1.power, SnfD1.dimmer); +// AddLog(LOG_LEVEL_DEBUG, PSTR("SD1: Tasmota power (%d, %d)"), SnfD1.power, SnfD1.dimmer); SonoffD1Send(); } @@ -152,7 +152,7 @@ bool SonoffD1SendDimmer(void) if (dimmer != SnfD1.dimmer) { SnfD1.dimmer = dimmer; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SD1: Tasmota dimmer (%d, %d)"), SnfD1.power, SnfD1.dimmer); +// AddLog(LOG_LEVEL_DEBUG, PSTR("SD1: Tasmota dimmer (%d, %d)"), SnfD1.power, SnfD1.dimmer); SonoffD1Send(); } diff --git a/tasmota/xdrv_39_thermostat.ino b/tasmota/xdrv_39_thermostat.ino index 455e45f13..2078fd829 100644 --- a/tasmota/xdrv_39_thermostat.ino +++ b/tasmota/xdrv_39_thermostat.ino @@ -1272,58 +1272,58 @@ void ThermostatVirtualSwitchCtrState(uint8_t ctr_output) void ThermostatDebug(uint8_t ctr_output) { char result_chr[FLOATSZ]; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("")); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("------ Thermostat Start ------")); + AddLog(LOG_LEVEL_DEBUG, PSTR("")); + AddLog(LOG_LEVEL_DEBUG, PSTR("------ Thermostat Start ------")); dtostrfd(Thermostat[ctr_output].status.counter_seconds, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.counter_seconds: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.counter_seconds: %s"), result_chr); dtostrfd(Thermostat[ctr_output].status.thermostat_mode, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.thermostat_mode: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.thermostat_mode: %s"), result_chr); dtostrfd(Thermostat[ctr_output].diag.state_emergency, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].diag.state_emergency: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].diag.state_emergency: %s"), result_chr); dtostrfd(Thermostat[ctr_output].diag.output_inconsist_ctr, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].diag.output_inconsist_ctr: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].diag.output_inconsist_ctr: %s"), result_chr); dtostrfd(Thermostat[ctr_output].status.controller_mode, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.controller_mode: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.controller_mode: %s"), result_chr); dtostrfd(Thermostat[ctr_output].status.command_output, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.command_output: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.command_output: %s"), result_chr); dtostrfd(Thermostat[ctr_output].status.status_output, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.status_output: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.status_output: %s"), result_chr); dtostrfd(Thermostat[ctr_output].status.status_input, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.status_input: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.status_input: %s"), result_chr); dtostrfd(Thermostat[ctr_output].status.phase_hybrid_ctr, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.phase_hybrid_ctr: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.phase_hybrid_ctr: %s"), result_chr); dtostrfd(Thermostat[ctr_output].status.sensor_alive, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.sensor_alive: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.sensor_alive: %s"), result_chr); dtostrfd(Thermostat[ctr_output].status.status_cycle_active, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.status_cycle_active: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].status.status_cycle_active: %s"), result_chr); dtostrfd(Thermostat[ctr_output].temp_pi_error, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_pi_error: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_pi_error: %s"), result_chr); dtostrfd(Thermostat[ctr_output].temp_pi_accum_error, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_pi_accum_error: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_pi_accum_error: %s"), result_chr); dtostrfd(Thermostat[ctr_output].time_proportional_pi, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_proportional_pi: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_proportional_pi: %s"), result_chr); dtostrfd(Thermostat[ctr_output].time_integral_pi, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_integral_pi: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_integral_pi: %s"), result_chr); dtostrfd(Thermostat[ctr_output].time_total_pi, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_total_pi: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_total_pi: %s"), result_chr); dtostrfd(Thermostat[ctr_output].temp_measured_gradient, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_measured_gradient: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_measured_gradient: %s"), result_chr); dtostrfd(Thermostat[ctr_output].time_rampup_deadtime, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_rampup_deadtime: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_rampup_deadtime: %s"), result_chr); dtostrfd(Thermostat[ctr_output].temp_rampup_meas_gradient, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_rampup_meas_gradient: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_rampup_meas_gradient: %s"), result_chr); dtostrfd(Thermostat[ctr_output].time_ctr_changepoint, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_ctr_changepoint: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_ctr_changepoint: %s"), result_chr); dtostrfd(Thermostat[ctr_output].temp_rampup_output_off, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_rampup_output_off: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].temp_rampup_output_off: %s"), result_chr); dtostrfd(Thermostat[ctr_output].time_ctr_checkpoint, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_ctr_checkpoint: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("Thermostat[ctr_output].time_ctr_checkpoint: %s"), result_chr); dtostrfd(TasmotaGlobal.uptime, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("uptime: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("uptime: %s"), result_chr); dtostrfd(TasmotaGlobal.power, 0, result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("power: %s"), result_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("------ Thermostat End ------")); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("")); + AddLog(LOG_LEVEL_DEBUG, PSTR("power: %s"), result_chr); + AddLog(LOG_LEVEL_DEBUG, PSTR("------ Thermostat End ------")); + AddLog(LOG_LEVEL_DEBUG, PSTR("")); } #endif // DEBUG_THERMOSTAT diff --git a/tasmota/xdrv_40_telegram.ino b/tasmota/xdrv_40_telegram.ino index 0ceefa3a7..3e4cc6f0a 100644 --- a/tasmota/xdrv_40_telegram.ino +++ b/tasmota/xdrv_40_telegram.ino @@ -99,7 +99,7 @@ bool TelegramInit(void) { Telegram.next_update_id = 0; // Code of last read Message Telegram.message[0].text = ""; - AddLog_P(LOG_LEVEL_INFO, PSTR("TGM: Started")); + AddLog(LOG_LEVEL_INFO, PSTR("TGM: Started")); } init_done = true; } @@ -115,7 +115,7 @@ String TelegramConnectToTelegram(String command) { uint32_t tls_connect_time = millis(); if (telegramClient->connect("api.telegram.org", 443)) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TGM: Connected in %d ms, max ThunkStack used %d"), millis() - tls_connect_time, telegramClient->getMaxThunkStackUse()); +// AddLog(LOG_LEVEL_DEBUG, PSTR("TGM: Connected in %d ms, max ThunkStack used %d"), millis() - tls_connect_time, telegramClient->getMaxThunkStackUse()); telegramClient->println("GET /"+command); @@ -144,7 +144,7 @@ String TelegramConnectToTelegram(String command) { } void TelegramGetUpdates(uint32_t offset) { - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: getUpdates")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: getUpdates")); if (!TelegramInit()) { return; } @@ -241,15 +241,15 @@ void TelegramGetUpdates(uint32_t offset) { AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Parsed update_id %d, chat_id %d, text \"%s\""), Telegram.message[i].update_id, Telegram.message[i].chat_id, Telegram.message[i].text.c_str()); } } else { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TGM: No new messages")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("TGM: No new messages")); } } else { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TGM: Failed to update")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("TGM: Failed to update")); } } bool TelegramSendMessage(int32_t chat_id, String text) { - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: sendMessage")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: sendMessage")); if (!TelegramInit()) { return false; } @@ -262,7 +262,7 @@ bool TelegramSendMessage(int32_t chat_id, String text) { // AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: Response %s"), response.c_str()); if (response.startsWith("{\"ok\":true")) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("TGM: Message sent")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("TGM: Message sent")); sent = true; } } @@ -272,7 +272,7 @@ bool TelegramSendMessage(int32_t chat_id, String text) { /* void TelegramSendGetMe(void) { - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: getMe")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("TGM: getMe")); if (!TelegramInit()) { return; } diff --git a/tasmota/xdrv_41_tcp_bridge.ino b/tasmota/xdrv_41_tcp_bridge.ino index 7533e7d6d..9cc0b7942 100644 --- a/tasmota/xdrv_41_tcp_bridge.ino +++ b/tasmota/xdrv_41_tcp_bridge.ino @@ -127,7 +127,7 @@ void TCPLoop(void) void TCPInit(void) { if (PinUsed(GPIO_TCP_RX) && PinUsed(GPIO_TCP_TX)) { tcp_buf = (uint8_t*) malloc(TCP_BRIDGE_BUF_SIZE); - if (!tcp_buf) { AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_TCP "could not allocate buffer")); return; } + if (!tcp_buf) { AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_TCP "could not allocate buffer")); return; } if (!Settings.tcp_baudrate) { Settings.tcp_baudrate = 115200 / 1200; } TCPSerial = new TasmotaSerial(Pin(GPIO_TCP_RX), Pin(GPIO_TCP_TX), TasmotaGlobal.seriallog_level ? 1 : 2, 0, TCP_BRIDGE_BUF_SIZE); // set a receive buffer of 256 bytes @@ -151,7 +151,7 @@ void CmndTCPStart(void) { int32_t tcp_port = XdrvMailbox.payload; if (server_tcp) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_TCP "Stopping TCP server")); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TCP "Stopping TCP server")); server_tcp->stop(); delete server_tcp; server_tcp = nullptr; @@ -162,7 +162,7 @@ void CmndTCPStart(void) { } } if (tcp_port > 0) { - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_TCP "Starting TCP server on port %d"), tcp_port); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_TCP "Starting TCP server on port %d"), tcp_port); server_tcp = new WiFiServer(tcp_port); server_tcp->begin(); // start TCP server server_tcp->setNoDelay(true); diff --git a/tasmota/xdrv_42_i2s_audio.ino b/tasmota/xdrv_42_i2s_audio.ino index db19cf369..359308cba 100644 --- a/tasmota/xdrv_42_i2s_audio.ino +++ b/tasmota/xdrv_42_i2s_audio.ino @@ -379,7 +379,7 @@ uint32_t i2s_record(char *path, uint32_t secs) { if (data_offset >= mic_size-DATA_SIZE) break; delay(0); } - //AddLog_P(LOG_LEVEL_INFO, PSTR("rectime: %d ms"), millis()-stime); + //AddLog(LOG_LEVEL_INFO, PSTR("rectime: %d ms"), millis()-stime); SpeakerMic(MODE_SPK); // save to path SaveWav(path, mic_buff, mic_size); @@ -457,7 +457,7 @@ void MDCallback(void *cbData, const char *type, bool isUnicode, const char *str) if (strstr_P(type, PSTR("Title"))) { strncpy(wr_title, str, sizeof(wr_title)); wr_title[sizeof(wr_title)-1] = 0; - //AddLog_P(LOG_LEVEL_INFO,PSTR("WR-Title: %s"),wr_title); + //AddLog(LOG_LEVEL_INFO,PSTR("WR-Title: %s"),wr_title); } else { // Who knows what to do? Not me! } diff --git a/tasmota/xdrv_43_mlx90640.ino b/tasmota/xdrv_43_mlx90640.ino index 53cbcfe07..ea2b60f43 100644 --- a/tasmota/xdrv_43_mlx90640.ino +++ b/tasmota/xdrv_43_mlx90640.ino @@ -413,7 +413,7 @@ void MLX90640HandleWebGuiResponse(void){ WebGetArg("ul", tmp, sizeof(tmp)); // update line if (strlen(tmp)) { uint8_t _line = atoi(tmp); - // AddLog_P(LOG_LEVEL_DEBUG, "MLX90640: send line %u", _line); + // AddLog(LOG_LEVEL_DEBUG, "MLX90640: send line %u", _line); float _buf[65]; if(_line==0){_buf[0]=1000+MLX90640.Ta;} //ambient temperature modulation hack else{_buf[0]=(float)_line;} @@ -431,9 +431,9 @@ void MLX90640HandleWebGuiResponse(void){ uint32_t _poiNum = (_poi-(_poi%10000))/10000; MLX90640.pois[_poiNum*2] = (_poi%10000)/100; MLX90640.pois[(_poiNum*2)+1] = _poi%100; - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("RAW: %u, POI-%u: x: %u, y: %u"),_poi,_poiNum,MLX90640.pois[_poiNum],MLX90640.pois[_poiNum+1]); + // AddLog(LOG_LEVEL_DEBUG, PSTR("RAW: %u, POI-%u: x: %u, y: %u"),_poi,_poiNum,MLX90640.pois[_poiNum],MLX90640.pois[_poiNum+1]); for(int i = 0;i23) MLX90640.pois[_idx+1]=23; } - AddLog_P(LOG_LEVEL_INFO, PSTR("POI-%u = x:%u,y:%u"),XdrvMailbox.index,MLX90640.pois[_idx],MLX90640.pois[_idx+1]); + AddLog(LOG_LEVEL_INFO, PSTR("POI-%u = x:%u,y:%u"),XdrvMailbox.index,MLX90640.pois[_idx],MLX90640.pois[_idx+1]); Response_P(S_JSON_MLX90640_COMMAND_NVALUE, command, XdrvMailbox.payload); break; default: @@ -494,10 +494,10 @@ void MLX90640init() if(!MLX90640.dumpedEE){ status = MLX90640_DumpEE(MLX90640_ADDRESS, MLX90640.Frame); if (status != 0){ - AddLog_P(LOG_LEVEL_INFO, PSTR("Failed to load system parameters")); + AddLog(LOG_LEVEL_INFO, PSTR("Failed to load system parameters")); } else { - AddLog_P(LOG_LEVEL_INFO, PSTR("MLX90640: started")); + AddLog(LOG_LEVEL_INFO, PSTR("MLX90640: started")); MLX90640.type = true; } MLX90640.params = new paramsMLX90640; @@ -514,11 +514,11 @@ void MLX90640every100msec(){ if(!MLX90640.extractedParams){ static uint32_t _chunk = 0; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: will read chunk: %u"), _chunk); + AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: will read chunk: %u"), _chunk); _time = millis(); status = MLX90640_ExtractParameters(MLX90640.Frame, MLX90640.params, _chunk); if (status == 0){ - AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: parameter received after: %u msec, status: %u"), TimePassedSince(_time), status); + AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: parameter received after: %u msec, status: %u"), TimePassedSince(_time), status); } if (_chunk == 5) MLX90640.extractedParams = true; _chunk++; @@ -529,12 +529,12 @@ void MLX90640every100msec(){ case 0: if(MLX90640_SynchFrame(MLX90640_ADDRESS)!=0){ _job=-1; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: frame not ready")); + AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: frame not ready")); break; } // _time = millis(); status = MLX90640_GetFrameData(MLX90640_ADDRESS, MLX90640.Frame); - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: got frame 0 in %u msecs, status: %i"), TimePassedSince(_time), status); + // AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: got frame 0 in %u msecs, status: %i"), TimePassedSince(_time), status); break; case 1: MLX90640.Ta = MLX90640_GetTa(MLX90640.Frame, MLX90640.params); @@ -542,7 +542,7 @@ void MLX90640every100msec(){ case 2: // _time = millis(); MLX90640_CalculateTo(MLX90640.Frame, MLX90640.params, 0.95f, MLX90640.Ta - 8, MLX90640.To, 0); - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: calculated temperatures in %u msecs"), TimePassedSince(_time)); + // AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: calculated temperatures in %u msecs"), TimePassedSince(_time)); break; case 5: if(MLX90640_SynchFrame(MLX90640_ADDRESS)!=0){ @@ -551,12 +551,12 @@ void MLX90640every100msec(){ } // _time = millis(); status = MLX90640_GetFrameData(MLX90640_ADDRESS, MLX90640.Frame); - // // AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: got frame 1 in %u msecs, status: %i"), TimePassedSince(_time), status); + // // AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: got frame 1 in %u msecs, status: %i"), TimePassedSince(_time), status); break; case 7: // _time = millis(); MLX90640_CalculateTo(MLX90640.Frame, MLX90640.params, 0.95f, MLX90640.Ta - 8, MLX90640.To, 1); - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("MLX90640: calculated temperatures in %u msecs"), TimePassedSince(_time)); + // AddLog(LOG_LEVEL_DEBUG, PSTR("MLX90640: calculated temperatures in %u msecs"), TimePassedSince(_time)); break; default: break; @@ -580,8 +580,8 @@ void MLX90640Show(uint8_t json) char obj_tstr[FLOATSZ]; dtostrfd(MLX90640.To[MLX90640.pois[i*2]+(MLX90640.pois[(i*2)+1]*32)], Settings.flag2.temperature_resolution, obj_tstr); ResponseAppend_P(PSTR(",%s"),obj_tstr); - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("Array pos: %u"),MLX90640.pois[i*2]+(MLX90640.pois[(i*2)+1]*32)); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("POI-%u: x: %u, y: %u"),i+1,MLX90640.pois[i*2],MLX90640.pois[(i*2)+1]); + // AddLog(LOG_LEVEL_DEBUG, PSTR("Array pos: %u"),MLX90640.pois[i*2]+(MLX90640.pois[(i*2)+1]*32)); + AddLog(LOG_LEVEL_DEBUG, PSTR("POI-%u: x: %u, y: %u"),i+1,MLX90640.pois[i*2],MLX90640.pois[(i*2)+1]); } ResponseAppend_P(PSTR("]}")); } diff --git a/tasmota/xdrv_44_miel_hvac.ino b/tasmota/xdrv_44_miel_hvac.ino index 680d9d72f..189b00d1a 100644 --- a/tasmota/xdrv_44_miel_hvac.ino +++ b/tasmota/xdrv_44_miel_hvac.ino @@ -366,7 +366,7 @@ miel_hvac_parse(struct miel_hvac_softc *sc, uint8_t byte) case MIEL_HVAC_P_MIDDLE1: if (byte != MIEL_HVAC_H_MIDDLE1) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME ": parse state MIDDLE1 expected %02x got %02x" ", restarting"), MIEL_HVAC_H_MIDDLE1, byte); return (MIEL_HVAC_P_START); @@ -377,7 +377,7 @@ miel_hvac_parse(struct miel_hvac_softc *sc, uint8_t byte) case MIEL_HVAC_P_MIDDLE2: if (byte != MIEL_HVAC_H_MIDDLE2) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME ": parse state MIDDLE2 expected %02x got %02x" ", restarting"), MIEL_HVAC_H_MIDDLE2, byte); return (MIEL_HVAC_P_START); @@ -388,7 +388,7 @@ miel_hvac_parse(struct miel_hvac_softc *sc, uint8_t byte) case MIEL_HVAC_P_LEN: if (byte == 0) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME ": skipping 0 byte message type 0x%02x"), p->p_type); return (MIEL_HVAC_P_SKIP_CKSUM); @@ -403,14 +403,14 @@ miel_hvac_parse(struct miel_hvac_softc *sc, uint8_t byte) case MIEL_HVAC_H_TYPE_UPDATED: break; default: - AddLog_P(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME ": skipping unknown message type 0x%02x"), p->p_type); return (MIEL_HVAC_P_SKIP); } if (byte > sizeof(p->p_data)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME ": skipping %u data bytes of message type 0x%02x"), p->p_len, p->p_type); return (MIEL_HVAC_P_SKIP); @@ -427,7 +427,7 @@ miel_hvac_parse(struct miel_hvac_softc *sc, uint8_t byte) case MIEL_HVAC_P_CKSUM: if (miel_hvac_cksum_fini(p->p_sum) != byte) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME ": checksum failed, restarting")); return (MIEL_HVAC_P_START); } @@ -845,7 +845,7 @@ static void miel_hvac_input_connected(struct miel_hvac_softc *sc, const void *buf, size_t len) { - AddLog_P(LOG_LEVEL_INFO, + AddLog(LOG_LEVEL_INFO, PSTR(MIEL_HVAC_LOGNAME ": connected to Mitsubishi Electric HVAC")); sc->sc_connected = 1; } @@ -973,7 +973,7 @@ miel_hvac_input_data(struct miel_hvac_softc *sc, miel_hvac_log_bytes(sc, "data", buf, len); if (len < sizeof(*d)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME + AddLog(LOG_LEVEL_DEBUG, PSTR(MIEL_HVAC_LOGNAME ": short data response (%zu < %zu)"), len, sizeof(*d)); return; } @@ -1021,7 +1021,7 @@ miel_hvac_pre_init(void) sc = (struct miel_hvac_softc *)malloc(sizeof(*sc)); if (sc == NULL) { - AddLog_P(LOG_LEVEL_ERROR, + AddLog(LOG_LEVEL_ERROR, PSTR(MIEL_HVAC_LOGNAME ": unable to allocate state")); return; } @@ -1033,7 +1033,7 @@ miel_hvac_pre_init(void) Pin(GPIO_MIEL_HVAC_TX), 2); if (!sc->sc_serial->begin(baudrate, 2)) { - AddLog_P(LOG_LEVEL_ERROR, + AddLog(LOG_LEVEL_ERROR, PSTR(MIEL_HVAC_LOGNAME ": unable to begin serial " "(baudrate %d)"), baudrate); goto del; diff --git a/tasmota/xdrv_45_shelly_dimmer.ino b/tasmota/xdrv_45_shelly_dimmer.ino index 0b44cde96..8e6e00e5c 100644 --- a/tasmota/xdrv_45_shelly_dimmer.ino +++ b/tasmota/xdrv_45_shelly_dimmer.ino @@ -111,7 +111,7 @@ struct SHD void ShdResetToDFUMode() { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Request co-processor reset in dfu mode")); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Request co-processor reset in dfu mode")); #endif // SHELLY_DIMMER_DEBUG pinMode(Pin(GPIO_SHELLY_DIMMER_RST_INV), OUTPUT); @@ -133,7 +133,7 @@ void ShdResetToDFUMode() bool ShdUpdateFirmware(uint8_t* data, uint32_t size) { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Update firmware")); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Update firmware")); #endif // SHELLY_DIMMER_DEBUG bool ret = true; @@ -148,7 +148,7 @@ bool ShdUpdateFirmware(uint8_t* data, uint32_t size) stm32_err_t s_err; #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "STM32 erase memory")); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "STM32 erase memory")); #endif // SHELLY_DIMMER_DEBUG stm32_erase_memory(stm, 0, STM32_MASS_ERASE); @@ -190,7 +190,7 @@ bool ShdPresent(void) { uint32_t ShdFlash(uint8_t* data, size_t size) { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Updating firmware v%u.%u with %u bytes"), Shd.dimmer.version_major, Shd.dimmer.version_minor, size); + AddLog(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Updating firmware v%u.%u with %u bytes"), Shd.dimmer.version_major, Shd.dimmer.version_minor, size); #endif // SHELLY_DIMMER_DEBUG Serial.end(); @@ -244,7 +244,7 @@ int check_byte() if (chksm != chksm_calc) { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Checksum: %x calculated: %x"), chksm, chksm_calc); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Checksum: %x calculated: %x"), chksm, chksm_calc); #endif // SHELLY_DIMMER_DEBUG return 0; } @@ -267,7 +267,7 @@ bool ShdSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0) int retries = 3; #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Tx Packet:")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Tx Packet:")); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t*)data, len); #endif // SHELLY_DIMMER_DEBUG @@ -287,7 +287,7 @@ bool ShdSerialSend(const uint8_t data[] = nullptr, uint16_t len = 0) } // timeout - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Serial send timeout")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Serial send timeout")); } return false; } @@ -426,9 +426,9 @@ void ShdSendCalibration(uint16_t brightness, uint16_t func, uint16_t fade_rate) bool ShdSyncState() { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Serial %p"), ShdSerial); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set Brightness Want %d, Is %d"), Shd.req_brightness, Shd.dimmer.brightness); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set Fade Want %d, Is %d"), Settings.light_speed, Shd.dimmer.fade_rate); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Serial %p"), ShdSerial); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set Brightness Want %d, Is %d"), Shd.req_brightness, Shd.dimmer.brightness); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set Fade Want %d, Is %d"), Settings.light_speed, Shd.dimmer.fade_rate); #endif // SHELLY_DIMMER_DEBUG if (!ShdSerial) @@ -456,7 +456,7 @@ bool ShdSyncState() void ShdDebugState() { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "MCU v%d.%d, Brightness:%d(%d%%), Power:%d, Fade:%d"), + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "MCU v%d.%d, Brightness:%d(%d%%), Power:%d, Fade:%d"), Shd.dimmer.version_major, Shd.dimmer.version_minor, Shd.dimmer.brightness, changeUIntScale(Shd.dimmer.brightness, 0, 1000, 0, 100), @@ -538,7 +538,7 @@ bool ShdPacketProcess(void) { float kWhused = (float)Energy.active_power[0] * (Rtc.utc_time - Shd.last_power_check) / 36; #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Adding %i mWh to todays usage from %lu to %lu"), (int)(kWhused * 10), Shd.last_power_check, Rtc.utc_time); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Adding %i mWh to todays usage from %lu to %lu"), (int)(kWhused * 10), Shd.last_power_check, Rtc.utc_time); #endif // USE_ENERGY_SENSOR Energy.kWhtoday += kWhused; EnergyUpdateToday(); @@ -547,7 +547,7 @@ bool ShdPacketProcess(void) #endif // USE_ENERGY_SENSOR #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "ShdPacketProcess: Brightness:%d Power:%lu Voltage:%lu Current:%lu Fade:%d"), brightness, wattage_raw, voltage_raw, current_raw, fade_rate); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "ShdPacketProcess: Brightness:%d Power:%lu Voltage:%lu Current:%lu Fade:%d"), brightness, wattage_raw, voltage_raw, current_raw, fade_rate); #endif // SHELLY_DIMMER_DEBUG Shd.dimmer.brightness = brightness; Shd.dimmer.power = wattage_raw; @@ -557,7 +557,7 @@ bool ShdPacketProcess(void) case SHD_VERSION_CMD: { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "ShdPacketProcess: Version: %u.%u"), Shd.buffer[pos + 1], Shd.buffer[pos]); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "ShdPacketProcess: Version: %u.%u"), Shd.buffer[pos + 1], Shd.buffer[pos]); #endif // SHELLY_DIMMER_DEBUG Shd.dimmer.version_minor = Shd.buffer[pos]; Shd.dimmer.version_major = Shd.buffer[pos + 1]; @@ -581,7 +581,7 @@ bool ShdPacketProcess(void) void ShdResetToAppMode() { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Request co-processor reset in app mode")); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Request co-processor reset in app mode")); #endif // SHELLY_DIMMER_DEBUG pinMode(Pin(GPIO_SHELLY_DIMMER_RST_INV), OUTPUT); @@ -603,7 +603,7 @@ void ShdResetToAppMode() void ShdPoll(void) { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Poll")); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Poll")); #endif // SHELLY_DIMMER_DEBUG if (!ShdSerial) @@ -616,7 +616,7 @@ void ShdPoll(void) bool ShdSendVersion(void) { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Sending version command")); + AddLog(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Sending version command")); #endif // SHELLY_DIMMER_DEBUG return ShdSendCmd(SHD_VERSION_CMD, 0, 0); } @@ -632,7 +632,7 @@ void ShdGetSettings(void) if (strstr(SettingsText(SET_SHD_PARAM), ",") != nullptr) { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Loading params: %s"), SettingsText(SET_SHD_PARAM)); + AddLog(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Loading params: %s"), SettingsText(SET_SHD_PARAM)); #endif // SHELLY_DIMMER_DEBUG // Shd.req_brightness = atoi(subStr(parameters, SettingsText(SET_SHD_PARAM), ",", 1)); Shd.leading_edge = atoi(subStr(parameters, SettingsText(SET_SHD_PARAM), ",", 2)); @@ -653,7 +653,7 @@ void ShdSaveSettings(void) void ShdInit(void) { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Shelly Dimmer Driver Starting Tx %d Rx %d"), Pin(GPIO_TXD), Pin(GPIO_RXD)); + AddLog(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Shelly Dimmer Driver Starting Tx %d Rx %d"), Pin(GPIO_TXD), Pin(GPIO_RXD)); #endif // SHELLY_DIMMER_DEBUG Shd.buffer = (uint8_t *)malloc(SHD_BUFFER_SIZE); @@ -669,7 +669,7 @@ void ShdInit(void) ShdResetToAppMode(); bool got_version = ShdSendVersion(); - AddLog_P(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Shelly Dimmer Co-processor Version v%u.%u"), Shd.dimmer.version_major, Shd.dimmer.version_minor); + AddLog(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Shelly Dimmer Co-processor Version v%u.%u"), Shd.dimmer.version_major, Shd.dimmer.version_minor); ShdGetSettings(); ShdSaveSettings(); @@ -694,7 +694,7 @@ bool ShdSerialInput(void) // finished #ifdef SHELLY_DIMMER_DEBUG Shd.byte_counter++; - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Rx Packet:")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "Rx Packet:")); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, Shd.buffer, Shd.byte_counter); #endif // SHELLY_DIMMER_DEBUG Shd.byte_counter = 0; @@ -707,7 +707,7 @@ bool ShdSerialInput(void) { // wrong data #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Byte %i of received data frame is invalid. Rx Packet:"), Shd.byte_counter); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Byte %i of received data frame is invalid. Rx Packet:"), Shd.byte_counter); Shd.byte_counter++; AddLogBuffer(LOG_LEVEL_DEBUG_MORE, Shd.buffer, Shd.byte_counter); #endif // SHELLY_DIMMER_DEBUG @@ -739,7 +739,7 @@ bool ShdModuleSelected(void) { bool ShdSetChannels(void) { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "SetChannels:")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(SHD_LOGNAME "SetChannels:")); AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t *)XdrvMailbox.data, XdrvMailbox.data_len); #endif // SHELLY_DIMMER_DEBUG @@ -757,7 +757,7 @@ bool ShdSetChannels(void) bool ShdSetPower(void) { #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Set Power, Power 0x%02x"), XdrvMailbox.index); + AddLog(LOG_LEVEL_INFO, PSTR(SHD_LOGNAME "Set Power, Power 0x%02x"), XdrvMailbox.index); #endif // SHELLY_DIMMER_DEBUG Shd.req_on = (bool)XdrvMailbox.index; @@ -784,9 +784,9 @@ void CmndShdLeadingEdge(void) Settings.shd_leading_edge = XdrvMailbox.payload; #ifdef SHELLY_DIMMER_DEBUG if (Shd.leading_edge == 1) - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set to trailing edge")); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set to trailing edge")); else - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set to leading edge")); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set to leading edge")); #endif // SHELLY_DIMMER_DEBUG ShdSendSettings(); } @@ -801,7 +801,7 @@ void CmndShdWarmupBrightness(void) Shd.warmup_brightness = XdrvMailbox.payload * 10; Settings.shd_warmup_brightness = XdrvMailbox.payload; #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set warmup brightness to %d%%"), XdrvMailbox.payload); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set warmup brightness to %d%%"), XdrvMailbox.payload); #endif // SHELLY_DIMMER_DEBUG ShdSendSettings(); } @@ -816,7 +816,7 @@ void CmndShdWarmupTime(void) Shd.warmup_time = XdrvMailbox.payload; Settings.shd_warmup_time = XdrvMailbox.payload; #ifdef SHELLY_DIMMER_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set warmup time to %dms"), XdrvMailbox.payload); + AddLog(LOG_LEVEL_DEBUG, PSTR(SHD_LOGNAME "Set warmup time to %dms"), XdrvMailbox.payload); #endif // SHELLY_DIMMER_DEBUG ShdSendSettings(); } diff --git a/tasmota/xdrv_46_ccloader.ino b/tasmota/xdrv_46_ccloader.ino index 3675ca676..3b2afc84b 100644 --- a/tasmota/xdrv_46_ccloader.ino +++ b/tasmota/xdrv_46_ccloader.ino @@ -533,7 +533,7 @@ void CCLProgrammerInit(void) bool CCLoaderinit() { CCLProgrammerInit(); - AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: programmer init")); + AddLog(LOG_LEVEL_INFO,PSTR("CCL: programmer init")); CCL.init = true; return true; } @@ -564,17 +564,17 @@ void CCLoaderLoop() { switch(step) { case 0: CCLdebug_init(); - AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: debug init")); + AddLog(LOG_LEVEL_INFO,PSTR("CCL: debug init")); step++; break; case 1: CCLread_chip_id(); if((CCL.chip.ID!=0)) { - AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: found chip with ID: %x, Rev: %x -> %s"), CCL.chip.ID, CCL.chip.rev, CCLChipName(CCL.chip.ID).c_str()); + AddLog(LOG_LEVEL_INFO,PSTR("CCL: found chip with ID: %x, Rev: %x -> %s"), CCL.chip.ID, CCL.chip.rev, CCLChipName(CCL.chip.ID).c_str()); step++; } else { - AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: no chip found")); + AddLog(LOG_LEVEL_INFO,PSTR("CCL: no chip found")); return; } break; @@ -587,7 +587,7 @@ bool CLLFlashFirmware(uint8_t* data, uint32_t size) bool ret = true; unsigned char debug_config = 0; unsigned char Verify = 0; - AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: .bin file downloaded with size: %u blocks"), size/512); + AddLog(LOG_LEVEL_INFO,PSTR("CCL: .bin file downloaded with size: %u blocks"), size/512); if (CCL.chip.ID!=0) { CCLRunDUP(); @@ -608,7 +608,7 @@ bool CLLFlashFirmware(uint8_t* data, uint32_t size) unsigned char rxBuf[512]; uint32_t block = 0; unsigned int addr = 0x0000; - AddLog_P(LOG_LEVEL_INFO,PSTR("CCL: will flash ....")); + AddLog(LOG_LEVEL_INFO,PSTR("CCL: will flash ....")); AddLogBuffer(LOG_LEVEL_DEBUG,data,16); // quick check to compare with a hex editor while((block*512)= FTC532_DEBOUNCE) { #endif // FTC532_DEBOUNCE > 1 #ifdef DEBUG_FTC532 - AddLog_P(LOG_LEVEL_DEBUG, PSTR("FTC: SAM=%04X KEY=%X OLD=%X INV=%u NOI=%u FRM=%u OK=%u TIME=%lu Pin=%u"), + AddLog(LOG_LEVEL_DEBUG, PSTR("FTC: SAM=%04X KEY=%X OLD=%X INV=%u NOI=%u FRM=%u OK=%u TIME=%lu Pin=%u"), Ftc532.sample, Ftc532.keys, Ftc532.old_keys, Ftc532.e_inv, Ftc532.e_noise, Ftc532.e_frame, Ftc532.valid, Ftc532.rxtime, Pin(GPIO_FTC532)); #endif // DEBUG_FTC532 @@ -197,7 +197,7 @@ void ftc532_update(void) { // Usually called every 50 m #ifdef DEBUG_FTC532 else { ++Ftc532.e_inv; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("FTC: ILL SAM=%04X"), Ftc532.sample); + AddLog(LOG_LEVEL_DEBUG, PSTR("FTC: ILL SAM=%04X"), Ftc532.sample); } #endif // DEBUG_FTC532 } diff --git a/tasmota/xdrv_48_timeprop.ino b/tasmota/xdrv_48_timeprop.ino index 5589868de..e2a699832 100644 --- a/tasmota/xdrv_48_timeprop.ino +++ b/tasmota/xdrv_48_timeprop.ino @@ -136,7 +136,7 @@ void TimepropSetPower(int index, float power) { } void TimepropInit(void) { - // AddLog_P(LOG_LEVEL_INFO, PSTR("TPR: Timeprop Init")); + // AddLog(LOG_LEVEL_INFO, PSTR("TPR: Timeprop Init")); int cycleTimes[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_CYCLETIMES}; int deadTimes[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_DEADTIMES}; int opInverts[TIMEPROP_NUM_OUTPUTS] = {TIMEPROP_OPINVERTS}; @@ -184,29 +184,26 @@ bool TimepropCommand() bool serviced = true; uint8_t ua_prefix_len = strlen(D_CMND_TIMEPROP); // to detect prefix of command /* - snprintf_P(log_data, sizeof(log_data), "Command called: " - "index: %d data_len: %d payload: %d topic: %s data: %s\n", + AddLog_P(LOG_LEVEL_INFO, PSTR("Command called: " + "index: %d data_len: %d payload: %d topic: %s data: %s"), XdrvMailbox.index, XdrvMailbox.data_len, XdrvMailbox.payload, (XdrvMailbox.payload >= 0 ? XdrvMailbox.topic : ""), (XdrvMailbox.data_len >= 0 ? XdrvMailbox.data : "")); - - AddLog(LOG_LEVEL_INFO); */ if (0 == strncasecmp_P(XdrvMailbox.topic, PSTR(D_CMND_TIMEPROP), ua_prefix_len)) { // command starts with timeprop_ int command_code = GetCommandCode(command, sizeof(command), XdrvMailbox.topic + ua_prefix_len, kTimepropCommands); if (CMND_TIMEPROP_SETPOWER == command_code) { /* - snprintf_P(log_data, sizeof(log_data), "Timeprop command timeprop_setpower: " - "index: %d data_len: %d payload: %d topic: %s data: %s", + AddLog_P(LOG_LEVEL_INFO, PSTR("Timeprop command timeprop_setpower: " + "index: %d data_len: %d payload: %d topic: %s data: %s"), XdrvMailbox.index, XdrvMailbox.data_len, XdrvMailbox.payload, (XdrvMailbox.payload >= 0 ? XdrvMailbox.topic : ""), (XdrvMailbox.data_len >= 0 ? XdrvMailbox.data : "")); - AddLog(LOG_LEVEL_INFO); */ if (XdrvMailbox.index >=0 && XdrvMailbox.index < TIMEPROP_NUM_OUTPUTS) { timeprops[XdrvMailbox.index].setPower( atof(XdrvMailbox.data), Tprop.current_time_secs ); diff --git a/tasmota/xdrv_49_pid.ino b/tasmota/xdrv_49_pid.ino index 15097106b..5ba61b004 100644 --- a/tasmota/xdrv_49_pid.ino +++ b/tasmota/xdrv_49_pid.ino @@ -246,7 +246,7 @@ void PIDShowSensor() { Pid.run_pid_now = true; } } else { - AddLog_P(LOG_LEVEL_ERROR, PSTR("PID: No local temperature sensor found")); + AddLog(LOG_LEVEL_ERROR, PSTR("PID: No local temperature sensor found")); } } diff --git a/tasmota/xdrv_50_filesystem.ino b/tasmota/xdrv_50_filesystem.ino index d2729bd7c..f42dd2ff6 100644 --- a/tasmota/xdrv_50_filesystem.ino +++ b/tasmota/xdrv_50_filesystem.ino @@ -131,7 +131,7 @@ void UfsInitOnce(void) { void UfsInit(void) { UfsInitOnce(); if (ufs_type) { - AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: FlashFS mounted with %d kB free"), UfsInfo(1, 0)); + AddLog(LOG_LEVEL_INFO, PSTR("UFS: FlashFS mounted with %d kB free"), UfsInfo(1, 0)); } } @@ -165,10 +165,10 @@ void UfsCheckSDCardInit(void) { // make sd card the global filesystem #ifdef ESP8266 // on esp8266 sdcard info takes several seconds !!!, so we ommit it here - AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: SDCard mounted")); + AddLog(LOG_LEVEL_INFO, PSTR("UFS: SDCard mounted")); #endif // ESP8266 #ifdef ESP32 - AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: SDCard mounted with %d kB free"), UfsInfo(1, 0)); + AddLog(LOG_LEVEL_INFO, PSTR("UFS: SDCard mounted with %d kB free"), UfsInfo(1, 0)); #endif // ESP32 } } @@ -276,7 +276,7 @@ bool TfsFileExists(const char *fname){ bool yes = ffsp->exists(fname); if (!yes) { - AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: File not found")); + AddLog(LOG_LEVEL_INFO, PSTR("TFS: File not found")); } return yes; } @@ -286,7 +286,7 @@ bool TfsSaveFile(const char *fname, const uint8_t *buf, uint32_t len) { File file = ffsp->open(fname, "w"); if (!file) { - AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Save failed")); + AddLog(LOG_LEVEL_INFO, PSTR("TFS: Save failed")); return false; } @@ -300,7 +300,7 @@ bool TfsInitFile(const char *fname, uint32_t len, uint8_t init_value) { File file = ffsp->open(fname, "w"); if (!file) { - AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Erase failed")); + AddLog(LOG_LEVEL_INFO, PSTR("TFS: Erase failed")); return false; } @@ -317,7 +317,7 @@ bool TfsLoadFile(const char *fname, uint8_t *buf, uint32_t len) { File file = ffsp->open(fname, "r"); if (!file) { - AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: File not found")); + AddLog(LOG_LEVEL_INFO, PSTR("TFS: File not found")); return false; } @@ -330,7 +330,7 @@ bool TfsDeleteFile(const char *fname) { if (!ffs_type) { return false; } if (!ffsp->remove(fname)) { - AddLog_P(LOG_LEVEL_INFO, PSTR("TFS: Delete failed")); + AddLog(LOG_LEVEL_INFO, PSTR("TFS: Delete failed")); return false; } return true; @@ -446,7 +446,7 @@ const char UFS_FORM_SDC_HREFdel[] PROGMEM = void UfsDirectory(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_MANAGE_FILE_SYSTEM)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_MANAGE_FILE_SYSTEM)); uint8_t depth = 0; @@ -597,13 +597,13 @@ uint8_t UfsDownloadFile(char *file) { File download_file; if (!dfsp->exists(file)) { - AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: File not found")); + AddLog(LOG_LEVEL_INFO, PSTR("UFS: File not found")); return 0; } download_file = dfsp->open(file, UFS_FILE_READ); if (!download_file) { - AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: Could not open file")); + AddLog(LOG_LEVEL_INFO, PSTR("UFS: Could not open file")); return 0; } @@ -659,7 +659,7 @@ uint8_t UfsDownloadFile(char *file) { download_file.close(); if (download_busy == true) { - AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: Download is busy")); + AddLog(LOG_LEVEL_INFO, PSTR("UFS: Download is busy")); return 0; } diff --git a/tasmota/xdrv_51_bs814a2.ino b/tasmota/xdrv_51_bs814a2.ino index 1a10eab9a..aa1abc4bb 100644 --- a/tasmota/xdrv_51_bs814a2.ino +++ b/tasmota/xdrv_51_bs814a2.ino @@ -34,7 +34,7 @@ THE PROTOCOL [tm]: ================== see Holtek-Semicon BS814A-2 datasheet for details - + ********************* * About this driver * ********************* @@ -100,7 +100,7 @@ void bs814_read(void) { // Poll touch keys uint8_t checksum = 0; uint8_t bitp; bool bitval; - + // generate clock signal & sample frame for (bitp = 0; bitp < 2 * BS814_KEYS_MAX; ++bitp) { digitalWrite(Pin(GPIO_BS814_CLK), LOW); @@ -123,8 +123,8 @@ void bs814_read(void) { // Poll touch keys // validate frame if (BS814_KEYS_MAX - checksum != ((frame >> 4) & 0x7)) { // checksum error #ifdef DEBUG_BS814_DRIVER - ++Bs814.e_cksum; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CKS=%02X CFR=%02X"), checksum, (frame >> 4) & 0x7); + ++Bs814.e_cksum; + AddLog(LOG_LEVEL_DEBUG, PSTR("CKS=%02X CFR=%02X"), checksum, (frame >> 4) & 0x7); #endif // DEBUG_BS814_DRIVER return; } @@ -144,7 +144,7 @@ void bs814_update(void) { // Usually called every 50 ms bs814_read(); if ((Bs814.keys & 0xF) != (Bs814.keys >> 4)) { #ifdef DEBUG_BS814_DRIVER - AddLog_P(LOG_LEVEL_DEBUG, PSTR("BS814: KEY=%0X OLD=%0X LVL=%u CKS=%u STP=%u OK=%u CLK=%u DAT=%u"), + AddLog(LOG_LEVEL_DEBUG, PSTR("BS814: KEY=%0X OLD=%0X LVL=%u CKS=%u STP=%u OK=%u CLK=%u DAT=%u"), Bs814.keys & 0xF, Bs814.keys >> 4, Bs814.e_level, Bs814.e_cksum, Bs814.e_stp, Bs814.valid, Pin(GPIO_BS814_CLK), Pin(GPIO_BS814_DAT)); #endif // DEBUG_BS814_DRIVER diff --git a/tasmota/xdrv_52_BLE_ESP32.ino b/tasmota/xdrv_52_BLE_ESP32.ino index cfd176a8d..e542ba427 100644 --- a/tasmota/xdrv_52_BLE_ESP32.ino +++ b/tasmota/xdrv_52_BLE_ESP32.ino @@ -599,7 +599,7 @@ int addSeenDevice(const uint8_t *mac, uint8_t addrtype, const char *name, int8_t int total = seenDevices.size(); if (total < MAX_BLE_DEVICES_LOGGED){ #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: New seendev slot %d"), total); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: New seendev slot %d"), total); #endif BLE_ESP32::BLE_simple_device_t* dev = new BLE_ESP32::BLE_simple_device_t; freeDevices.push_back(dev); @@ -667,10 +667,10 @@ int deleteSeenDevices(int ageS = 0){ dump(addr, 20, dev->mac, 6); const char *alias = getAlias(dev->mac); if (!filter){ - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Delete device %s(%s) by age lastseen %u + maxage %u < now %u."), + AddLog(LOG_LEVEL_INFO,PSTR("BLE: Delete device %s(%s) by age lastseen %u + maxage %u < now %u."), addr, alias, lastseenS, ageS, nowS); } else { - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Delete device %s(%s) by addrtype filter %d > %d."), + AddLog(LOG_LEVEL_INFO,PSTR("BLE: Delete device %s(%s) by addrtype filter %d > %d."), addr, alias, dev->addrtype, BLEAddressFilter); } #endif @@ -682,7 +682,7 @@ int deleteSeenDevices(int ageS = 0){ } if (res){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Deleted %d devices"), res); + AddLog(LOG_LEVEL_INFO,PSTR("BLE: Deleted %d devices"), res); #endif } return res; @@ -820,7 +820,7 @@ int getSeenDevicesToJson(char *dest, int maxlen){ } // deliberate test of SafeAddLog_P from main thread... - //AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: getSeen %d"), seenDevices.size()); + //AddLog(LOG_LEVEL_INFO,PSTR("BLE: getSeen %d"), seenDevices.size()); int len; @@ -1184,17 +1184,17 @@ void postAdvertismentDetails(){ class BLESensorCallback : public NimBLEClientCallbacks { void onConnect(NimBLEClient* pClient) { #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: onConnect %s"), ((std::string)pClient->getPeerAddress()).c_str()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: onConnect %s"), ((std::string)pClient->getPeerAddress()).c_str()); #endif } void onDisconnect(NimBLEClient* pClient) { #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: onDisconnect %s"), ((std::string)pClient->getPeerAddress()).c_str()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: onDisconnect %s"), ((std::string)pClient->getPeerAddress()).c_str()); #endif } bool onConnParamsUpdateRequest(NimBLEClient* pClient, const ble_gap_upd_params* params) { #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: onConnParamsUpdateRequest %s"), ((std::string)pClient->getPeerAddress()).c_str()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: onConnParamsUpdateRequest %s"), ((std::string)pClient->getPeerAddress()).c_str()); #endif // if(params->itvl_min < 24) { /** 1.25ms units */ @@ -1315,7 +1315,7 @@ class BLEAdvCallbacks: public NimBLEAdvertisedDeviceCallbacks { } } catch(const std::exception& e){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: exception in advertismentCallbacks")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: exception in advertismentCallbacks")); #endif } } @@ -1334,18 +1334,18 @@ static BLESensorCallback BLESensorCB; static void BLEscanEndedCB(NimBLEScanResults results){ #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Scan ended")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Scan ended")); #endif for (int i = 0; i < scancompleteCallbacks.size(); i++){ try { SCANCOMPLETE_CALLBACK *pFn = scancompleteCallbacks[i]; int callbackres = pFn(results); #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: scancompleteCallbacks %d %d"), i, callbackres); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: scancompleteCallbacks %d %d"), i, callbackres); #endif } catch(const std::exception& e){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: exception in operationsCallbacks")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: exception in operationsCallbacks")); #endif } } @@ -1367,21 +1367,21 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui if (!pRemoteCharacteristic){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Notify: no remote char!!??")); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Notify: no remote char!!??")); #endif return; } #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Notified length: %u"),length); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Notified length: %u"),length); #endif // find the operation this is associated with NimBLERemoteService *pSvc = pRemoteCharacteristic->getRemoteService(); if (!pSvc){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Notify: no remote service found")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Notify: no remote service found")); #endif return; } @@ -1389,7 +1389,7 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui pRClient = pSvc->getClient(); if (!pRClient){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Notify: no remote client!!??")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Notify: no remote client!!??")); #endif return; } @@ -1404,7 +1404,7 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui generic_sensor_t *op = currentOperations[i]; if (!op){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Notify: null op in currentOperations!!??")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Notify: null op in currentOperations!!??")); #endif } else { if (devaddr == op->addr){ @@ -1420,7 +1420,7 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui if (!thisop){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: no op for notify")); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: no op for notify")); #endif return; } @@ -1452,21 +1452,21 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui void registerForAdvertismentCallbacks(const char *tag, BLE_ESP32::ADVERTISMENT_CALLBACK* pFn){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: registerForAdvertismentCallbacks %s:%x"), tag, (uint32_t) pFn); + AddLog(LOG_LEVEL_INFO,PSTR("BLE: registerForAdvertismentCallbacks %s:%x"), tag, (uint32_t) pFn); #endif advertismentCallbacks.push_back(pFn); } void registerForOpCallbacks(const char *tag, BLE_ESP32::OPCOMPLETE_CALLBACK* pFn){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: registerForOpCallbacks %s:%x"), tag, (uint32_t) pFn); + AddLog(LOG_LEVEL_INFO,PSTR("BLE: registerForOpCallbacks %s:%x"), tag, (uint32_t) pFn); #endif operationsCallbacks.push_back(pFn); } void registerForScanCallbacks(const char *tag, BLE_ESP32::SCANCOMPLETE_CALLBACK* pFn){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: registerForScnCallbacks %s:%x"), tag, (uint32_t) pFn); + AddLog(LOG_LEVEL_INFO,PSTR("BLE: registerForScnCallbacks %s:%x"), tag, (uint32_t) pFn); #endif scancompleteCallbacks.push_back(pFn); } @@ -1490,7 +1490,7 @@ static void BLEInit(void) { TasmotaGlobal.wifi_stay_asleep = true; if (WiFi.getSleep() == false) { - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Put WiFi modem in sleep mode"),"BLE"); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Put WiFi modem in sleep mode"),"BLE"); WiFi.setSleep(true); // Sleep } @@ -1524,7 +1524,7 @@ static void BLEOperationTask(void *pvParameters); static void BLEStartOperationTask(){ if (BLERunning == false){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: %s: Start operations"),D_CMND_BLE); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: %s: Start operations"),D_CMND_BLE); #endif BLERunning = true; @@ -1547,25 +1547,25 @@ static void BLEStartOperationTask(){ static void BLETaskStopStartNimBLE(NimBLEClient **ppClient, bool start = true){ if (*ppClient){ - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Task:Stopping NimBLE")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Task:Stopping NimBLE")); (*ppClient)->setClientCallbacks(nullptr, false); try { if ((*ppClient)->isConnected()){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: disconnecting connected client")); + AddLog(LOG_LEVEL_INFO,PSTR("BLE: disconnecting connected client")); #endif (*ppClient)->disconnect(); } NimBLEDevice::deleteClient((*ppClient)); (*ppClient) = nullptr; #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: deleted client")); + AddLog(LOG_LEVEL_INFO,PSTR("BLE: deleted client")); #endif } catch(const std::exception& e){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Stopping NimBLE:exception in delete client")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Stopping NimBLE:exception in delete client")); #endif } @@ -1582,7 +1582,7 @@ static void BLETaskStopStartNimBLE(NimBLEClient **ppClient, bool start = true){ BLERunningScan = 0; if (start){ - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: BLETask:Starting NimBLE")); + AddLog(LOG_LEVEL_INFO,PSTR("BLE: BLETask:Starting NimBLE")); NimBLEDevice::init("BLE_ESP32"); *ppClient = NimBLEDevice::createClient(); @@ -1623,7 +1623,7 @@ int BLETaskStartScan(int time){ } #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: Startscan")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: Startscan")); #endif //vTaskDelay(500/ portTICK_PERIOD_MS); ble32Scan->setActiveScan(BLEScanActiveMode ? 1: 0); @@ -1652,7 +1652,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe *pCurrentOperation = nextOperation(&queuedOperations); if (*pCurrentOperation){ #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: new currentOperation")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: new currentOperation")); #endif BLEOpCount++; generic_sensor_t* temp = *pCurrentOperation; @@ -1673,7 +1673,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe diff = diff/1000; if (diff > 20000){ // 20s #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: notify timeout")); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: notify timeout")); #endif (*pCurrentOperation)->state = GEN_STATE_FAILED_NOTIFYTIMEOUT; (*pCurrentOperation)->notifytimer = 0; @@ -1690,7 +1690,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe (*pCurrentOperation)->state = GEN_STATE_NOTIFIED; // just stay here until this is removed by the main thread #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: notify operation complete")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: notify operation complete")); #endif BLE_ESP32::BLETaskRunTaskDoneOperation(pCurrentOperation, ppClient); pClient = *ppClient; @@ -1701,7 +1701,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe case GEN_STATE_NOTIFIED: // - may have completed DURING our read/write to get here // just stay here until this is removed by the main thread #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: operation complete")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: operation complete")); #endif BLE_ESP32::BLETaskRunTaskDoneOperation(pCurrentOperation, ppClient); pClient = *ppClient; @@ -1721,7 +1721,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe if ((*pCurrentOperation)->state <= GEN_STATE_FAILED){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: BLETask: op failed %d"), (*pCurrentOperation)->state); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: BLETask: op failed %d"), (*pCurrentOperation)->state); #endif BLE_ESP32::BLETaskRunTaskDoneOperation(pCurrentOperation, ppClient); pClient = *ppClient; @@ -1735,7 +1735,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe if (pClient->isConnected()){ // don't do anything if we are still connected #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: still connected")); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: still connected")); #endif return; } @@ -1755,7 +1755,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe op->state = GEN_STATE_STARTED; #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: attempt connect %s"), ((std::string)op->addr).c_str()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: attempt connect %s"), ((std::string)op->addr).c_str()); #endif if (!op->serviceUUID.bitSize()){ @@ -1766,7 +1766,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe if (pClient->connect(op->addr, true)) { #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: connected %s -> getservice"), ((std::string)op->addr).c_str()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: connected %s -> getservice"), ((std::string)op->addr).c_str()); #endif NimBLERemoteService *pService = pClient->getService(op->serviceUUID); int waitNotify = false; @@ -1775,7 +1775,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe if (pService != nullptr) { #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: got service")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: got service")); #endif // pre-set to fail if no operations requested //newstate = GEN_STATE_FAILED_NOREADWRITE; @@ -1792,13 +1792,13 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe pService->getCharacteristic(op->notificationCharacteristicUUID); if (pNCharacteristic != nullptr) { #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: got notify characteristic")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: got notify characteristic")); #endif op->notifylen = 0; if(pNCharacteristic->canNotify()) { if(pNCharacteristic->subscribe(true, BLE_ESP32::BLEGenNotifyCB)) { #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for notify")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for notify")); #endif uint64_t now = esp_timer_get_time(); op->notifytimer = now; @@ -1808,7 +1808,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe waitNotify = true; } else { #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for notify")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for notify")); #endif newstate = GEN_STATE_FAILED_NOTIFY; } @@ -1816,7 +1816,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe if(pNCharacteristic->canIndicate()) { if(pNCharacteristic->subscribe(false, BLE_ESP32::BLEGenNotifyCB)) { #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for indicate")); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for indicate")); #endif notifystate = GEN_STATE_WAITINDICATE; uint64_t now = esp_timer_get_time(); @@ -1824,21 +1824,21 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe waitNotify = true; } else { #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for indicate")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for indicate")); #endif newstate = GEN_STATE_FAILED_INDICATE; } } else { newstate = GEN_STATE_FAILED_CANTNOTIFYORINDICATE; #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: characteristic can't notify")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: characteristic can't notify")); #endif } } } else { newstate = GEN_STATE_FAILED_NONOTIFYCHAR; #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: notify characteristic not found")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: notify characteristic not found")); #endif } @@ -1855,7 +1855,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe pCharacteristic = pService->getCharacteristic(op->characteristicUUID); if (pCharacteristic != nullptr) { #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: got read/write characteristic")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: got read/write characteristic")); #endif newstate = GEN_STATE_FAILED_NOREADWRITE; // overwritten on failure @@ -1875,12 +1875,12 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe if (op->readmodifywritecallback){ READ_CALLBACK *pFn = (READ_CALLBACK *)op->readmodifywritecallback; #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: read characteristic with readmodifywritecallback")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: read characteristic with readmodifywritecallback")); #endif pFn(op); } else { #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: read characteristic")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: read characteristic")); #endif } @@ -1896,12 +1896,12 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe if (!pCharacteristic->writeValue(op->dataToWrite, op->writelen, true)){ newstate = GEN_STATE_FAILED_WRITE; #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: characteristic write fail")); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: characteristic write fail")); #endif } else { if (!waitNotify) newstate = GEN_STATE_WRITEDONE; #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: write characteristic")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: write characteristic")); #endif } } else { @@ -1913,7 +1913,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe } else { newstate = GEN_STATE_FAILED_NO_RW_CHAR; #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: r/w characteristic not found")); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: r/w characteristic not found")); #endif } } @@ -1934,7 +1934,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe newstate = GEN_STATE_FAILED_NOSERVICE; // failed to get a service #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: failed - svc not on device?")); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: failed - svc not on device?")); #endif } @@ -1946,14 +1946,14 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe switch (rc){ case (0x0200+BLE_ERR_CONN_LIMIT ): #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Hit connection limit? - restarting NimBLE")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Hit connection limit? - restarting NimBLE")); #endif BLERestartNimBLE = 1; BLERestartBLEReason = BLE_RESTART_BLE_REASON_CONN_LIMIT; break; case (0x0200+BLE_ERR_ACL_CONN_EXISTS): #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Connection exists? - restarting NimBLE")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Connection exists? - restarting NimBLE")); #endif BLERestartNimBLE = 1; BLERestartBLEReason = BLE_RESTART_BLE_REASON_CONN_EXISTS; @@ -1963,7 +1963,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe // failed to connect #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: failed to connect to device %d"), rc); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: failed to connect to device %d"), rc); #endif } op->state = newstate; @@ -1979,7 +1979,7 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE try { if ((*ppClient)->isConnected()){ #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: runTaskDoneOperation: disconnecting connected client")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: runTaskDoneOperation: disconnecting connected client")); #endif (*ppClient)->disconnect(); // wait for 1/2 second after disconnect @@ -1990,7 +1990,7 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE //(*ppClient)->disconnect(); // we will stall here forever!!! - as testing #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d"), waits); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d"), waits); #endif vTaskDelay(500/ portTICK_PERIOD_MS); } @@ -1999,11 +1999,11 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE int conn_id = (*ppClient)->getConnId(); ble_gap_conn_broken(conn_id, -1); #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d - kill connection"), waits); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d - kill connection"), waits); #endif } if (waits == 60){ - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: >60s waiting -> BLE Failed, restart Tasmota %d"), waits); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: >60s waiting -> BLE Failed, restart Tasmota %d"), waits); BLEStop = 1; BLEStopAt = esp_timer_get_time(); @@ -2015,7 +2015,7 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE } } catch(const std::exception& e){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: runTaskDoneOperation: exception in disconnect")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: runTaskDoneOperation: exception in disconnect")); #endif } @@ -2035,7 +2035,7 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE // by adding it to this list, this will cause it to be sent to MQTT #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: runTaskDoneOperation: add to completedOperations")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: runTaskDoneOperation: add to completedOperations")); #endif addOperation(&completedOperations, op); return; @@ -2096,7 +2096,7 @@ static void BLEOperationTask(void *pvParameters){ BLERestartNimBLE = 0; BLERestartTasmota = 10; BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_RESTARTING_BLE_TIMEOUT; - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: BLETask: Restart NimBLE - restart Tasmota in 10 if not complt")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: BLETask: Restart NimBLE - restart Tasmota in 10 if not complt")); BLE_ESP32::BLETaskStopStartNimBLE(&pClient); BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_UNKNOWN; BLERestartTasmota = 0; @@ -2110,7 +2110,7 @@ static void BLEOperationTask(void *pvParameters){ vTaskDelay(100/ portTICK_PERIOD_MS); #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLEOperationTask: Left task")); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLEOperationTask: Left task")); #endif deleteSeenDevices(); @@ -2159,7 +2159,7 @@ static void BLEEverySecond(bool restart){ BLEMasterEnable = Settings.flag5.mi32_enable; } } - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: MasterEnable->%d"), BLEMasterEnable); + AddLog(LOG_LEVEL_INFO,PSTR("BLE: MasterEnable->%d"), BLEMasterEnable); } @@ -2192,11 +2192,11 @@ static void BLEEverySecond(bool restart){ if (!BLERestartTasmotaReason) BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_UNKNOWN; snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"reboot\":\"%s\"}"), BLERestartTasmotaReason); MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain); - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting Tasmota in %d seconds because %s"), BLERestartTasmota, BLERestartTasmotaReason); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting Tasmota in %d seconds because %s"), BLERestartTasmota, BLERestartTasmotaReason); } if (!BLERestartTasmota){ - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting Tasmota because %s"), BLERestartTasmotaReason); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting Tasmota because %s"), BLERestartTasmotaReason); // just a normal restart TasmotaGlobal.restart_flag = 1; } @@ -2205,7 +2205,7 @@ static void BLEEverySecond(bool restart){ if (BLERestartBLEReason){ // just use the ptr as the trigger to send MQTT snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"blerestart\":\"%s\"}"), BLERestartBLEReason); MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain); - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting BLE Stack because %s"), BLERestartBLEReason); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting BLE Stack because %s"), BLERestartBLEReason); BLERestartBLEReason = nullptr; } @@ -2250,9 +2250,9 @@ int addOperation(std::deque *ops, generic_sensor_t** op){ } } if (res){ - //AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: added operation")); + //AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: added operation")); } else { - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: op - no room")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: op - no room")); } return res; } @@ -2260,7 +2260,7 @@ int addOperation(std::deque *ops, generic_sensor_t** op){ int newOperation(BLE_ESP32::generic_sensor_t** op){ if (!op) { - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: op inv in newOperation")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: op inv in newOperation")); return 0; } @@ -2299,7 +2299,7 @@ int freeOperation(BLE_ESP32::generic_sensor_t** op){ int extQueueOperation(BLE_ESP32::generic_sensor_t** op){ if (!op || !(*op)) { - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: op invalid")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: op invalid")); return 0; } (*op)->state = GEN_STATE_START; // trigger request later @@ -2307,7 +2307,7 @@ int extQueueOperation(BLE_ESP32::generic_sensor_t** op){ int res = addOperation(&queuedOperations, op); if (!res){ - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: extQueueOperation: op added id %d failed"), (lastopid-1)); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: extQueueOperation: op added id %d failed"), (lastopid-1)); } return res; } @@ -2427,7 +2427,7 @@ static int StartBLE(void) { BLE_ESP32::BLEStartOperationTask(); return 1; } - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: StartBLE - wait as BLEStop==1")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: StartBLE - wait as BLEStop==1")); return 0; } @@ -2436,16 +2436,16 @@ static int StopBLE(void){ if (BLERunning){ if (BLEStop != 1){ BLEStop = 1; - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: StopBLE - BLEStop->1")); + AddLog(LOG_LEVEL_INFO,PSTR("BLE: StopBLE - BLEStop->1")); BLEStopAt = esp_timer_get_time(); // give a little time for it to stop. vTaskDelay(1000/ portTICK_PERIOD_MS); return 1; } - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: StopBLE - wait as BLEStop==1")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: StopBLE - wait as BLEStop==1")); return 0; } else { - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: StopBLE - was not running")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: StopBLE - was not running")); return 1; } } @@ -2686,7 +2686,7 @@ void CmndBLEDetails(void){ void CmndBLEAlias(void){ #ifdef BLE_ESP32_ALIASES int op = XdrvMailbox.index; - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Alias %d %s"), op, XdrvMailbox.data); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Alias %d %s"), op, XdrvMailbox.data); int res = -1; switch(op){ @@ -2705,7 +2705,7 @@ void CmndBLEAlias(void){ char *mac = p; int len = fromHex(addr, p, sizeof(addr)); if (len != 6){ - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Alias invalid mac %s"), p); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Alias invalid mac %s"), p); ResponseCmndChar("invalidmac"); return; } @@ -2726,7 +2726,7 @@ void CmndBLEAlias(void){ return; } - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Add Alias mac %s = name %s"), mac, p); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Add Alias mac %s = name %s"), mac, p); if (addAlias( addr, name )){ added++; } @@ -2734,7 +2734,7 @@ void CmndBLEAlias(void){ } while (p); if (added){ - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Added %d Aliases"), added); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Added %d Aliases"), added); BLEAliasListResp(); } else { BLEAliasListResp(); @@ -2742,7 +2742,7 @@ void CmndBLEAlias(void){ return; } break; case 2:{ // clear - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Alias clearing %d"), aliases.size()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: Alias clearing %d"), aliases.size()); for (int i = aliases.size()-1; i >= 0; i--){ BLE_ESP32::ble_alias_t *alias = aliases[i]; aliases.pop_back(); @@ -2773,14 +2773,14 @@ void CmndBLEName(void) { if (addrres){ if (addrres == 2){ - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: addr used alias: %s"), p); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: addr used alias: %s"), p); } //#ifdef EQ3_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: cmd addr: %s -> %s"), p, addr.toString().c_str()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: cmd addr: %s -> %s"), p, addr.toString().c_str()); //#endif } else { - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: addr invalid: %s"), p); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: addr invalid: %s"), p); ResponseCmndIdxChar(PSTR("invalidaddr")); return; } @@ -2789,11 +2789,11 @@ void CmndBLEName(void) { // ALWAYS use this function to create a new one. int res = BLE_ESP32::newOperation(&op); if (!res){ - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Can't get a newOperation")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Can't get a newOperation")); ResponseCmndChar(PSTR("FAIL")); return; } else { - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: got a newOperation from BLE")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: got a newOperation from BLE")); } op->addr = addr; @@ -2804,29 +2804,29 @@ void CmndBLEName(void) { char *name = strtok(nullptr, " "); bool write = false; if (name && *name){ - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: write name %s"), name); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: write name %s"), name); op->writelen = strlen(name); memcpy(op->dataToWrite, name, op->writelen); write = true; } else { - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: read name")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: read name")); op->readlen = 1; } res = BLE_ESP32::extQueueOperation(&op); - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: queue res %d"), res); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: queue res %d"), res); if (!res){ // if it fails to add to the queue, do please delete it BLE_ESP32::freeOperation(&op); - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failed to queue new operation - deleted")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Failed to queue new operation - deleted")); ResponseCmndChar(PSTR("QUEUEFAIL")); return; } if (write){ - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: will write name")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: will write name")); } else { - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: will read name")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: will read name")); } ResponseCmndDone(); return; @@ -2856,7 +2856,7 @@ void CmndBLEOperation(void){ int op = XdrvMailbox.index; - //AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: op %d"), op); + //AddLog(LOG_LEVEL_INFO,PSTR("BLE: op %d"), op); int res = -1; @@ -2864,7 +2864,7 @@ void CmndBLEOperation(void){ switch(op) { case 0: #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: preview")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: preview")); #endif BLEPostMQTTTrigger = 1; break; @@ -2875,7 +2875,7 @@ void CmndBLEOperation(void){ int opres = BLE_ESP32::newOperation(&prepOperation); if (!opres){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Could not create new operation")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Could not create new operation")); #endif ResponseCmndChar("FailCreate"); return; @@ -2933,14 +2933,14 @@ void CmndBLEOperation(void){ // this means you could retry with another BLEOp10. // it WOULD be deleted if you sent another BELOP1 #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Could not queue new operation")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Could not queue new operation")); #endif ResponseCmndChar("FailQueue"); return; } else { // NOTE: prepOperation has been set to null if we queued sucessfully. #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Operations queued:%d"), queuedOperations.size()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: Operations queued:%d"), queuedOperations.size()); #endif char temp[40]; sprintf(temp, "{\"opid\":%d,\"u\":%d}", lastopid-1, u); @@ -2969,13 +2969,13 @@ void CmndBLEOperation(void){ // this means you could retry with another BLEOp10. // it WOULD be deleted if you sent another BELOP1 #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Could not queue new operation")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Could not queue new operation")); #endif ResponseCmndChar("FailQueue"); } else { // NOTE: prepOperation has been set to null if we queued sucessfully. #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Operations queued:%d"), queuedOperations.size()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: Operations queued:%d"), queuedOperations.size()); #endif char temp[40]; sprintf(temp, "{\"opid\":%d,\"u\":%d}", lastopid-1, u); @@ -3026,20 +3026,20 @@ static void BLEPostMQTT(bool onlycompleted) { if (prepOperation || completedOperations.size() || queuedOperations.size() || currentOperations.size()){ #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: some to show")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: some to show")); #endif if (prepOperation && !onlycompleted){ std::string out = BLETriggerResponse(prepOperation); snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str()); MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain); #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: prep sent %s"), out.c_str()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: prep sent %s"), out.c_str()); #endif } if (queuedOperations.size() && !onlycompleted){ #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: queued %d"), queuedOperations.size()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: queued %d"), queuedOperations.size()); #endif for (int i = 0; i < queuedOperations.size(); i++){ TasAutoMutex localmutex(&BLEOperationsRecursiveMutex, "BLEPost1"); @@ -3053,7 +3053,7 @@ static void BLEPostMQTT(bool onlycompleted) { snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str()); MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain); #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: queued %d sent %s"), i, out.c_str()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: queued %d sent %s"), i, out.c_str()); #endif //break; } @@ -3062,7 +3062,7 @@ static void BLEPostMQTT(bool onlycompleted) { if (currentOperations.size() && !onlycompleted){ #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: current %d"), currentOperations.size()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: current %d"), currentOperations.size()); #endif for (int i = 0; i < currentOperations.size(); i++){ TasAutoMutex localmutex(&BLEOperationsRecursiveMutex, "BLEPost2"); @@ -3075,7 +3075,7 @@ static void BLEPostMQTT(bool onlycompleted) { snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str()); MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain); #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: curr %d sent %s"), i, out.c_str()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: curr %d sent %s"), i, out.c_str()); #endif //break; } @@ -3084,7 +3084,7 @@ static void BLEPostMQTT(bool onlycompleted) { if (completedOperations.size()){ #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: completed %d"), completedOperations.size()); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: completed %d"), completedOperations.size()); #endif do { generic_sensor_t *toSend = nextOperation(&completedOperations); @@ -3092,7 +3092,7 @@ static void BLEPostMQTT(bool onlycompleted) { break; // break from while loop } else { #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: completedOperation removed")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: completedOperation removed")); #endif std::string out = BLETriggerResponse(toSend); snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str()); @@ -3121,11 +3121,11 @@ static void mainThreadBLETimeouts() { if (BLEStop == 1){ if (BLEStopAt + 30L*1000L*1000L < now){ // if asked to stop > 30s ago... - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Stop Timeout - restart Tasmota")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Stop Timeout - restart Tasmota")); BLERestartTasmota = 2; BLEStopAt = now; } - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Awaiting BLEStop")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Awaiting BLEStop")); return; } @@ -3135,7 +3135,7 @@ static void mainThreadBLETimeouts() { if (BLEScanLastAdvertismentAt + adTimeout < now){ BLEScanLastAdvertismentAt = now; // initialise the time of the last advertisment BLERestartNimBLE = 1; - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: scan stall? no adverts > 120s, restart BLE")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: scan stall? no adverts > 120s, restart BLE")); BLERestartBLEReason = BLE_RESTART_BLE_REASON_ADVERT_BLE_TIMEOUT; } @@ -3146,7 +3146,7 @@ static void mainThreadBLETimeouts() { if (BLELastLoopTime + bleLoopTimeout < now){ BLELastLoopTime = now; // initialise the time of the last advertisment BLERestartTasmota = 10; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask stall > 120s, restart Tasmota in 10s")); + AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask stall > 120s, restart Tasmota in 10s")); BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_BLE_LOOP_STALLED; } } @@ -3154,7 +3154,7 @@ static void mainThreadBLETimeouts() { static void mainThreadOpCallbacks() { if (completedOperations.size()){ - //AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: completed %d"), completedOperations.size()); + //AddLog(LOG_LEVEL_INFO,PSTR("BLE: completed %d"), completedOperations.size()); TasAutoMutex localmutex(&BLEOperationsRecursiveMutex, "BLEMainCB"); // find this operation in currentOperations, and remove it. @@ -3169,11 +3169,11 @@ static void mainThreadOpCallbacks() { OPCOMPLETE_CALLBACK *pFn = (OPCOMPLETE_CALLBACK *)(op->completecallback); callbackres = pFn(op); #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: op->completecallback %d"), callbackres); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: op->completecallback %d"), callbackres); #endif } catch(const std::exception& e){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: exception in op->completecallback")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: exception in op->completecallback")); #endif } } @@ -3184,14 +3184,14 @@ static void mainThreadOpCallbacks() { OPCOMPLETE_CALLBACK *pFn = operationsCallbacks[i]; callbackres = pFn(op); #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: operationsCallbacks %d %d"), i, callbackres); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: operationsCallbacks %d %d"), i, callbackres); #endif if (callbackres){ break; // this callback ate the op. } } catch(const std::exception& e){ #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: exception in operationsCallbacks")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: exception in operationsCallbacks")); #endif } } @@ -3200,7 +3200,7 @@ static void mainThreadOpCallbacks() { // if some callback told us not to send on MQTT, then remove from completed and delete the data if (callbackres){ #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: callbackres true -> delete op")); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("BLE: callbackres true -> delete op")); #endif completedOperations.erase(completedOperations.begin() + i); delete op; @@ -3214,7 +3214,7 @@ static void BLEShow(bool json) { if (json){ #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: show json %d"),json); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO,PSTR("BLE: show json %d"),json); #endif uint32_t totalCount = BLEAdvertisment.totalCount; uint32_t deviceCount = seenDevices.size(); @@ -3372,30 +3372,30 @@ void HandleBleConfiguration(void) { #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: HandleBleConfiguration")); + AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: HandleBleConfiguration")); #endif if (!HttpCheckPriviledgedAccess()) { #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: !HttpCheckPriviledgedAccess()")); + AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: !HttpCheckPriviledgedAccess()")); #endif return; } #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_BLE)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_BLE)); #endif char tmp[20]; WebGetArg("en", tmp, sizeof(tmp)); #ifdef BLE_ESP32_DEBUG - if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: arg en is %s"), tmp); + if (BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: arg en is %s"), tmp); #endif if (Webserver->hasArg("save")) { #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: SETTINGS SAVE")); + AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: SETTINGS SAVE")); #endif Settings.flag5.mi32_enable = Webserver->hasArg("e0"); // BLEScanActiveMode = (Webserver->hasArg("e1")?1:0); // @@ -3405,7 +3405,7 @@ void HandleBleConfiguration(void) return; } #ifdef BLE_ESP32_DEBUG - AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: !SAVE")); + AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: !SAVE")); #endif char str[TOPSZ]; @@ -3460,7 +3460,7 @@ void HandleBleConfiguration(void) \*********************************************************************************************/ int ExtStopBLE(){ - AddLog_P(LOG_LEVEL_INFO, PSTR("BLE: Stopping if active")); + AddLog(LOG_LEVEL_INFO, PSTR("BLE: Stopping if active")); BLE_ESP32::BLEMode = BLE_ESP32::BLEModeDisabled; BLE_ESP32::StopBLE(); return 0; @@ -3548,13 +3548,13 @@ int myAdvertCallback(BLE_ESP32::ble_advertisment_t *pStruct) { // this one is used to demonstrate processing ALL operations int myOpCallback(BLE_ESP32::generic_sensor_t *pStruct){ - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: myOpCallback")); + AddLog(LOG_LEVEL_INFO,PSTR("BLE: myOpCallback")); return 0; // return true to block MQTT broadcast } // this one is used to demonstrate processing of ONE specific operation int myOpCallback2(BLE_ESP32::generic_sensor_t *pStruct){ - AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: myOpCallback2")); + AddLog(LOG_LEVEL_INFO,PSTR("BLE: myOpCallback2")); return 1; // return true to block MQTT broadcast } #endif @@ -3577,7 +3577,7 @@ void sendExample(){ BLE_ESP32::generic_sensor_t *op = nullptr; int res = BLE_ESP32::newOperation(&op); if (!res){ - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Could not create new operation")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Could not create new operation")); return; } strncpy(op->MAC, "001A22092EE0", sizeof(op->MAC)); @@ -3592,7 +3592,7 @@ void sendExample(){ if (!res){ // if it fails to add to the queue, do please delete it BLE_ESP32::freeOperation(&op); - AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failed to queue new operation - deleted")); + AddLog(LOG_LEVEL_ERROR,PSTR("BLE: Failed to queue new operation - deleted")); return; } diff --git a/tasmota/xdrv_81_webcam.ino b/tasmota/xdrv_81_webcam.ino index f3d44710e..0844b1ba9 100755 --- a/tasmota/xdrv_81_webcam.ino +++ b/tasmota/xdrv_81_webcam.ino @@ -174,7 +174,7 @@ uint32_t WcSetup(int32_t fsiz) { if (Wc.up) { esp_camera_deinit(); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Deinit")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Deinit")); //return Wc.up; } Wc.up = 0; @@ -207,7 +207,7 @@ uint32_t WcSetup(int32_t fsiz) { config.pin_pwdn = (PinUsed(GPIO_WEBCAM_PWDN)) ? Pin(GPIO_WEBCAM_PWDN) : -1; // PWDN_GPIO_NUM; config.pin_reset = (PinUsed(GPIO_WEBCAM_RESET)) ? Pin(GPIO_WEBCAM_RESET) : -1; // RESET_GPIO_NUM; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: User template")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: User template")); } else { // defaults to AI THINKER config.pin_d0 = Y2_GPIO_NUM; @@ -226,7 +226,7 @@ uint32_t WcSetup(int32_t fsiz) { config.pin_sscb_scl = SIOC_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Default template")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Default template")); } //ESP.getPsramSize() @@ -241,15 +241,15 @@ uint32_t WcSetup(int32_t fsiz) { config.frame_size = FRAMESIZE_UXGA; config.jpeg_quality = 10; config.fb_count = 2; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: PSRAM found")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: PSRAM found")); } else { config.frame_size = FRAMESIZE_VGA; config.jpeg_quality = 12; config.fb_count = 1; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: PSRAM not found")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: PSRAM not found")); } -// AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: heap check 1: %d"),ESP_getFreeHeap()); +// AddLog(LOG_LEVEL_INFO, PSTR("CAM: heap check 1: %d"),ESP_getFreeHeap()); // stupid workaround camera diver eats up static ram should prefer PSRAM // so we steal static ram to force driver to alloc PSRAM @@ -260,11 +260,11 @@ uint32_t WcSetup(int32_t fsiz) { if (x) { free(x); } if (err != ESP_OK) { - AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: Init failed with error 0x%x"), err); + AddLog(LOG_LEVEL_INFO, PSTR("CAM: Init failed with error 0x%x"), err); return 0; } -// AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: heap check 2: %d"),ESP_getFreeHeap()); +// AddLog(LOG_LEVEL_INFO, PSTR("CAM: heap check 2: %d"),ESP_getFreeHeap()); sensor_t * wc_s = esp_camera_sensor_get(); @@ -279,7 +279,7 @@ uint32_t WcSetup(int32_t fsiz) { camera_fb_t *wc_fb = esp_camera_fb_get(); if (!wc_fb) { - AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: Init failed to get the frame on time")); + AddLog(LOG_LEVEL_INFO, PSTR("CAM: Init failed to get the frame on time")); return 0; } Wc.width = wc_fb->width; @@ -290,7 +290,7 @@ uint32_t WcSetup(int32_t fsiz) { fd_init(); #endif - AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: Initialized")); + AddLog(LOG_LEVEL_INFO, PSTR("CAM: Initialized")); Wc.up = 1; if (psram) { Wc.up = 2; } @@ -513,7 +513,7 @@ uint32_t WcDetectFace(void) { image_matrix = dl_matrix3du_alloc(1, fb->width, fb->height, 3); if (!image_matrix) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: dl_matrix3du_alloc failed")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: dl_matrix3du_alloc failed")); esp_camera_fb_return(fb); return ESP_FAIL; } @@ -527,7 +527,7 @@ uint32_t WcDetectFace(void) { esp_camera_fb_return(fb); if (!s){ dl_matrix3du_free(image_matrix); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: to rgb888 failed")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: to rgb888 failed")); return ESP_FAIL; } @@ -594,7 +594,7 @@ uint32_t WcGetFrame(int32_t bnum) { wc_fb = esp_camera_fb_get(); if (!wc_fb) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Can't get frame")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Can't get frame")); return 0; } if (!bnum) { @@ -625,7 +625,7 @@ pcopy: memcpy(Wc.picstore[bnum].buff, _jpg_buf, _jpg_buf_len); Wc.picstore[bnum].len = _jpg_buf_len; } else { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Can't allocate picstore")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Can't allocate picstore")); Wc.picstore[bnum].len = 0; } if (wc_fb) { esp_camera_fb_return(wc_fb); } @@ -669,20 +669,20 @@ void HandleImage(void) { } else { bnum--; if (!Wc.picstore[bnum].len) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: No image #: %d"), bnum); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: No image #: %d"), bnum); return; } client.write((char *)Wc.picstore[bnum].buff, Wc.picstore[bnum].len); } client.stop(); - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("CAM: Sending image #: %d"), bnum+1); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("CAM: Sending image #: %d"), bnum+1); } void HandleImageBasic(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP "Capture image")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP "Capture image")); if (Settings.webcam_config.stream) { if (!Wc.CamServer) { @@ -693,7 +693,7 @@ void HandleImageBasic(void) { camera_fb_t *wc_fb; wc_fb = esp_camera_fb_get(); // Acquire frame if (!wc_fb) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Frame buffer could not be acquired")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Frame buffer could not be acquired")); return; } @@ -720,16 +720,16 @@ void HandleImageBasic(void) { esp_camera_fb_return(wc_fb); // Free frame buffer - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("CAM: Image sent")); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("CAM: Image sent")); } void HandleWebcamMjpeg(void) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Handle camserver")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Handle camserver")); // if (!Wc.stream_active) { // always restart stream Wc.stream_active = 1; Wc.client = Wc.CamServer->client(); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Create client")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Create client")); // } } @@ -743,13 +743,13 @@ void HandleWebcamMjpegTask(void) { bool jpeg_converted = false; if (!Wc.client.connected()) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Client fail")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Client fail")); Wc.stream_active = 0; } if (1 == Wc.stream_active) { Wc.client.flush(); Wc.client.setTimeout(3); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Start stream")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Start stream")); Wc.client.print("HTTP/1.1 200 OK\r\n" "Content-Type: multipart/x-mixed-replace;boundary=" BOUNDARY "\r\n" "\r\n"); @@ -758,7 +758,7 @@ void HandleWebcamMjpegTask(void) { if (2 == Wc.stream_active) { wc_fb = esp_camera_fb_get(); if (!wc_fb) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Frame fail")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Frame fail")); Wc.stream_active = 0; } } @@ -766,7 +766,7 @@ void HandleWebcamMjpegTask(void) { if (wc_fb->format != PIXFORMAT_JPEG) { jpeg_converted = frame2jpg(wc_fb, 80, &_jpg_buf, &_jpg_buf_len); if (!jpeg_converted){ - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: JPEG compression failed")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: JPEG compression failed")); _jpg_buf_len = wc_fb->len; _jpg_buf = wc_fb->buf; } @@ -783,7 +783,7 @@ void HandleWebcamMjpegTask(void) { if (tlen!=_jpg_buf_len) { esp_camera_fb_return(wc_fb); Wc.stream_active=0; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Send fail")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Send fail")); }*/ Wc.client.print("\r\n--" BOUNDARY "\r\n"); @@ -800,10 +800,10 @@ void HandleWebcamMjpegTask(void) { if (jpeg_converted) { free(_jpg_buf); } esp_camera_fb_return(wc_fb); - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: send frame")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: send frame")); } if (0 == Wc.stream_active) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Stream exit")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Stream exit")); Wc.client.flush(); Wc.client.stop(); } @@ -813,7 +813,7 @@ void HandleWebcamRoot(void) { //CamServer->redirect("http://" + String(ip) + ":81/cam.mjpeg"); Wc.CamServer->sendHeader("Location", WiFi.localIP().toString() + ":81/cam.mjpeg"); Wc.CamServer->send(302, "", ""); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Root called")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Root called")); } /*********************************************************************************************/ @@ -830,7 +830,7 @@ uint32_t WcSetStreamserver(uint32_t flag) { Wc.CamServer->on("/cam.mjpeg", HandleWebcamMjpeg); Wc.CamServer->on("/cam.jpg", HandleWebcamMjpeg); Wc.CamServer->on("/stream", HandleWebcamMjpeg); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Stream init")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Stream init")); Wc.CamServer->begin(); } } else { @@ -838,7 +838,7 @@ uint32_t WcSetStreamserver(uint32_t flag) { Wc.CamServer->stop(); delete Wc.CamServer; Wc.CamServer = NULL; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CAM: Stream exit")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CAM: Stream exit")); } } return 0; @@ -868,7 +868,7 @@ void WcLoop(void) { Wc.rtspp = new WiFiServer(8554); Wc.rtspp->begin(); Wc.rtsp_start = 1; - AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: RTSP init")); + AddLog(LOG_LEVEL_INFO, PSTR("CAM: RTSP init")); Wc.rtsp_lastframe_time = millis(); } @@ -881,7 +881,7 @@ void WcLoop(void) { if ((now-Wc.rtsp_lastframe_time) > RTSP_FRAME_TIME) { Wc.rtsp_session->broadcastCurrentFrame(now); Wc.rtsp_lastframe_time = now; - // AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: RTSP session frame")); + // AddLog(LOG_LEVEL_INFO, PSTR("CAM: RTSP session frame")); } if (Wc.rtsp_session->m_stopped) { @@ -889,7 +889,7 @@ void WcLoop(void) { delete Wc.rtsp_streamer; Wc.rtsp_session = NULL; Wc.rtsp_streamer = NULL; - AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: RTSP stopped")); + AddLog(LOG_LEVEL_INFO, PSTR("CAM: RTSP stopped")); } } else { @@ -897,7 +897,7 @@ void WcLoop(void) { if (Wc.rtsp_client) { Wc.rtsp_streamer = new OV2640Streamer(&Wc.rtsp_client, Wc.cam); // our streamer for UDP/TCP based RTP transport Wc.rtsp_session = new CRtspSession(&Wc.rtsp_client, Wc.rtsp_streamer); // our threads RTSP session and state - AddLog_P(LOG_LEVEL_INFO, PSTR("CAM: RTSP stream created")); + AddLog(LOG_LEVEL_INFO, PSTR("CAM: RTSP stream created")); } } } diff --git a/tasmota/xdrv_82_ethernet.ino b/tasmota/xdrv_82_ethernet.ino index d169b3e2e..abb6922ad 100644 --- a/tasmota/xdrv_82_ethernet.ino +++ b/tasmota/xdrv_82_ethernet.ino @@ -85,15 +85,15 @@ char eth_hostname[sizeof(TasmotaGlobal.hostname)]; void EthernetEvent(WiFiEvent_t event) { switch (event) { case SYSTEM_EVENT_ETH_START: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ETH: " D_ATTEMPTING_CONNECTION)); + AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: " D_ATTEMPTING_CONNECTION)); ETH.setHostname(eth_hostname); break; case SYSTEM_EVENT_ETH_CONNECTED: - AddLog_P(LOG_LEVEL_INFO, PSTR("ETH: " D_CONNECTED " at %dMbps%s"), + AddLog(LOG_LEVEL_INFO, PSTR("ETH: " D_CONNECTED " at %dMbps%s"), ETH.linkSpeed(), (ETH.fullDuplex()) ? " Full Duplex" : ""); break; case SYSTEM_EVENT_ETH_GOT_IP: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ETH: Mac %s, IPAddress %s, Hostname %s"), + AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: Mac %s, IPAddress %s, Hostname %s"), ETH.macAddress().c_str(), ETH.localIP().toString().c_str(), eth_hostname); Settings.ipv4_address[1] = (uint32_t)ETH.gatewayIP(); Settings.ipv4_address[2] = (uint32_t)ETH.subnetMask(); @@ -101,11 +101,11 @@ void EthernetEvent(WiFiEvent_t event) { TasmotaGlobal.global_state.eth_down = 0; break; case SYSTEM_EVENT_ETH_DISCONNECTED: - AddLog_P(LOG_LEVEL_INFO, PSTR("ETH: Disconnected")); + AddLog(LOG_LEVEL_INFO, PSTR("ETH: Disconnected")); TasmotaGlobal.global_state.eth_down = 1; break; case SYSTEM_EVENT_ETH_STOP: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ETH: Stopped")); + AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: Stopped")); TasmotaGlobal.global_state.eth_down = 1; break; default: @@ -116,7 +116,7 @@ void EthernetEvent(WiFiEvent_t event) { void EthernetInit(void) { if (!Settings.flag4.network_ethernet) { return; } if (!PinUsed(GPIO_ETH_PHY_MDC) && !PinUsed(GPIO_ETH_PHY_MDIO)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ETH: No ETH MDC and/or ETH MDIO GPIO defined")); + AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: No ETH MDC and/or ETH MDIO GPIO defined")); return; } @@ -130,7 +130,7 @@ void EthernetInit(void) { int eth_mdc = Pin(GPIO_ETH_PHY_MDC); int eth_mdio = Pin(GPIO_ETH_PHY_MDIO); if (!ETH.begin(Settings.eth_address, eth_power, eth_mdc, eth_mdio, (eth_phy_type_t)Settings.eth_type, (eth_clock_mode_t)Settings.eth_clk_mode)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ETH: Bad PHY type or init error")); + AddLog(LOG_LEVEL_DEBUG, PSTR("ETH: Bad PHY type or init error")); }; } diff --git a/tasmota/xdrv_83_esp32watch.ino b/tasmota/xdrv_83_esp32watch.ino index ef564813e..e452e1b74 100644 --- a/tasmota/xdrv_83_esp32watch.ino +++ b/tasmota/xdrv_83_esp32watch.ino @@ -378,11 +378,11 @@ uint8_t data; if (ttgo_globs.bma->isDoubleClick()) { ttgo_globs.bma_double_click = true; - //AddLog_P(LOG_LEVEL_INFO, PSTR("double click")); + //AddLog(LOG_LEVEL_INFO, PSTR("double click")); } if (ttgo_globs.bma->isAnyNoMotion()) { ttgo_globs.bma_click = true; - //AddLog_P(LOG_LEVEL_INFO, PSTR("click")); + //AddLog(LOG_LEVEL_INFO, PSTR("click")); } //! setp counter @@ -408,7 +408,7 @@ uint8_t data; } if (ttgo_globs.ttgo_power->isPEKShortPressIRQ()) { ttgo_globs.bma_button = true; - //AddLog_P(LOG_LEVEL_INFO, PSTR("button press")); + //AddLog(LOG_LEVEL_INFO, PSTR("button press")); } ttgo_globs.ttgo_power->clearIRQ(); break; diff --git a/tasmota/xdrv_84_core2.ino b/tasmota/xdrv_84_core2.ino index 86a576596..da3e202e9 100644 --- a/tasmota/xdrv_84_core2.ino +++ b/tasmota/xdrv_84_core2.ino @@ -34,7 +34,6 @@ rtc better sync #include #include #include -#include #include #define XDRV_84 84 @@ -97,7 +96,7 @@ void CORE2_Init(void) { BreakTime(Rtc.utc_time, tmpTime); Rtc.daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year); Rtc.standard_time = RuleToTime(Settings.tflag[0], RtcTime.year); - AddLog_P(LOG_LEVEL_INFO, PSTR("Set time from BM8563 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), + AddLog(LOG_LEVEL_INFO, PSTR("Set time from BM8563 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str()); if (Rtc.local_time < START_VALID_TIME) { // 2016-01-01 TasmotaGlobal.rules_flag.time_init = 1; @@ -277,8 +276,8 @@ void GetRtc(void) { RtcTime.day_of_month = RTCdate.Date; RtcTime.year = RTCdate.Year; - AddLog_P(LOG_LEVEL_INFO, PSTR("RTC: %02d:%02d:%02d"), RTCtime.Hours, RTCtime.Minutes, RTCtime.Seconds); - AddLog_P(LOG_LEVEL_INFO, PSTR("RTC: %02d.%02d.%04d"), RTCdate.Date, RTCdate.Month, RTCdate.Year); + AddLog(LOG_LEVEL_INFO, PSTR("RTC: %02d:%02d:%02d"), RTCtime.Hours, RTCtime.Minutes, RTCtime.Seconds); + AddLog(LOG_LEVEL_INFO, PSTR("RTC: %02d.%02d.%04d"), RTCdate.Date, RTCdate.Month, RTCdate.Year); } @@ -322,7 +321,7 @@ void CORE2_EverySecond(void) { if (Rtc.utc_time > START_VALID_TIME && core2_globs.tset==false && abs(Rtc.utc_time - Get_utc()) > 3) { Set_utc(Rtc.utc_time); - AddLog_P(LOG_LEVEL_INFO, PSTR("Write Time TO BM8563 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), + AddLog(LOG_LEVEL_INFO, PSTR("Write Time TO BM8563 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str()); core2_globs.tset = true; } diff --git a/tasmota/xdrv_99_debug.ino b/tasmota/xdrv_99_debug.ino index d7b786781..f99815d36 100644 --- a/tasmota/xdrv_99_debug.ino +++ b/tasmota/xdrv_99_debug.ino @@ -174,11 +174,11 @@ void CpuLoadLoop(void) #if defined(F_CPU) && (F_CPU == 160000000L) int CPU_load = 100 - ( (CPU_loops*(1 + 30*TasmotaGlobal.sleep)) / (CPU_load_check *800) ); CPU_loops = CPU_loops / CPU_load_check; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(160MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(160MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops); #else int CPU_load = 100 - ( (CPU_loops*(1 + 30*TasmotaGlobal.sleep)) / (CPU_load_check *400) ); CPU_loops = CPU_loops / CPU_load_check; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(80MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(80MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops); #endif CPU_last_millis = CPU_last_loop_time; CPU_loops = 0; @@ -202,7 +202,7 @@ void DebugFreeMem(void) { register uint32_t *sp asm("a1"); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_pcont->stack), XdrvMailbox.data); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_pcont->stack), XdrvMailbox.data); } #endif // ESP8266 @@ -212,7 +212,7 @@ void DebugFreeMem(void) { register uint8_t *sp asm("a1"); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), sp - pxTaskGetStackStart(NULL), XdrvMailbox.data); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), sp - pxTaskGetStackStart(NULL), XdrvMailbox.data); } #endif // ESP8266 - ESP32 @@ -246,7 +246,7 @@ void DebugRtcDump(char* parms) uint16_t srow = strtol(parms, &p, 16) / CFG_COLS; uint16_t mrow = strtol(p, &p, 10); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow); +// AddLog(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow); if (0 == mrow) { // Default only 8 lines mrow = 8; @@ -298,7 +298,7 @@ void DebugDump(uint32_t start, uint32_t size) { uint32_t srow = 0; uint32_t mrow = maxrow; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow); +// AddLog(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow); if (0 == mrow) { // Default only 8 lines mrow = 8; @@ -349,7 +349,7 @@ void DebugCfgDump(char* parms) uint16_t srow = strtol(parms, &p, 16) / CFG_COLS; uint16_t mrow = strtol(p, &p, 10); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow); +// AddLog(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow); if (0 == mrow) { // Default only 8 lines mrow = 8; @@ -428,7 +428,7 @@ void DebugCfgPoke(char* parms) uint32_t ndata32 = (buffer[address +3] << 24) + (buffer[address +2] << 16) + (buffer[address +1] << 8) + buffer[address]; - AddLog_P(LOG_LEVEL_INFO, PSTR("%03X: 0x%0LX (%lu) poked to 0x%0LX (%lu)"), address, data32, data32, ndata32, ndata32); + AddLog(LOG_LEVEL_INFO, PSTR("%03X: 0x%0LX (%lu) poked to 0x%0LX (%lu)"), address, data32, data32, ndata32, ndata32); } void SetFlashMode(uint8_t mode) @@ -574,7 +574,7 @@ void CmndFlashDump(void) // FlashDump 0xFC000 10 const uint32_t flash_start = 0x40200000; // Start address flash const uint8_t bytes_per_cols = 0x20; - const uint32_t max = (FLASH_EEPROM_START + 5) * SPI_FLASH_SEC_SIZE; // 0x100000 for 1M flash, 0x400000 for 4M flash + const uint32_t max = (EEPROM_LOCATION + 5) * SPI_FLASH_SEC_SIZE; // 0x100000 for 1M flash, 0x400000 for 4M flash uint32_t start = flash_start; uint32_t rows = 8; @@ -594,7 +594,7 @@ void CmndFlashDump(void) for (uint32_t pos = start; pos < end; pos += bytes_per_cols) { uint32_t* values = (uint32_t*)(pos); - AddLog_P(LOG_LEVEL_INFO, PSTR("%06X: %08X %08X %08X %08X %08X %08X %08X %08X"), pos - flash_start, + AddLog(LOG_LEVEL_INFO, PSTR("%06X: %08X %08X %08X %08X %08X %08X %08X %08X"), pos - flash_start, DebugSwap32(values[0]), DebugSwap32(values[1]), DebugSwap32(values[2]), DebugSwap32(values[3]), DebugSwap32(values[4]), DebugSwap32(values[5]), DebugSwap32(values[6]), DebugSwap32(values[7])); } @@ -626,7 +626,7 @@ void CmndI2cWrite(void) Wire.write(buffer[i]); } int result = Wire.endTransmission(); - AddLog_P(LOG_LEVEL_INFO, PSTR("I2C: Result %d"), result); + AddLog(LOG_LEVEL_INFO, PSTR("I2C: Result %d"), result); } } ResponseCmndDone(); diff --git a/tasmota/xdsp_01_lcd.ino b/tasmota/xdsp_01_lcd.ino index 3db1c48e3..8f3a9a779 100644 --- a/tasmota/xdsp_01_lcd.ino +++ b/tasmota/xdsp_01_lcd.ino @@ -147,7 +147,7 @@ bool LcdPrintLog(void) strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols); DisplayFillScreen(last_row); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); lcd->setCursor(0, last_row); lcd->print(disp_screen_buffer[last_row]); diff --git a/tasmota/xdsp_02_ssd1306.ino b/tasmota/xdsp_02_ssd1306.ino index d9184b790..a3e9bb8f5 100644 --- a/tasmota/xdsp_02_ssd1306.ino +++ b/tasmota/xdsp_02_ssd1306.ino @@ -124,7 +124,7 @@ void Ssd1306PrintLog(void) strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols); DisplayFillScreen(last_row); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); renderer->println(disp_screen_buffer[last_row]); renderer->Updateframe(); diff --git a/tasmota/xdsp_03_matrix.ino b/tasmota/xdsp_03_matrix.ino index e82c0586b..3b0155a8f 100644 --- a/tasmota/xdsp_03_matrix.ino +++ b/tasmota/xdsp_03_matrix.ino @@ -95,7 +95,7 @@ void MatrixScrollLeft(char* txt, int loop) // Horiz. position of text -- starts off right edge mtx_x = 8 * mtx_matrices; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), txt); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), txt); disp_refresh = Settings.display_refresh; case 2: @@ -265,7 +265,7 @@ void MatrixPrintLog(uint8_t direction) i++; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), mtx_buffer); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), mtx_buffer); mtx_done = 1; } diff --git a/tasmota/xdsp_04_ili9341.ino b/tasmota/xdsp_04_ili9341.ino index 088f545d5..e6b38ca7d 100644 --- a/tasmota/xdsp_04_ili9341.ino +++ b/tasmota/xdsp_04_ili9341.ino @@ -118,7 +118,7 @@ void Ili9341InitDriver(void) { Ili9341InitMode(); tft_init_done = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: ILI9341")); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: ILI9341")); } } @@ -195,7 +195,7 @@ void Ili9341PrintLog(void) { DisplayFillScreen(last_row); tft->print(disp_screen_buffer[last_row]); } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt); } } } diff --git a/tasmota/xdsp_05_epaper_29.ino b/tasmota/xdsp_05_epaper_29.ino index d9c35435f..4c670e00b 100644 --- a/tasmota/xdsp_05_epaper_29.ino +++ b/tasmota/xdsp_05_epaper_29.ino @@ -92,7 +92,7 @@ void EpdInitDriver29(void) { #endif epd_init_done = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: E-Paper 2.9")); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: E-Paper 2.9")); } } @@ -134,7 +134,7 @@ void EpdPrintLog29(void) renderer->DrawStringAt(0, epd_scroll, disp_screen_buffer[last_row], COLORED, 0); // EpdDisplayFrame(); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt); } } } diff --git a/tasmota/xdsp_06_epaper_42.ino b/tasmota/xdsp_06_epaper_42.ino index d5783668d..1b9f7b1c5 100644 --- a/tasmota/xdsp_06_epaper_42.ino +++ b/tasmota/xdsp_06_epaper_42.ino @@ -96,7 +96,7 @@ void EpdInitDriver42() { #endif epd42_init_done = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: E-Paper 4.2")); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: E-Paper 4.2")); } } diff --git a/tasmota/xdsp_07_sh1106.ino b/tasmota/xdsp_07_sh1106.ino index ea09a958c..3ca925932 100644 --- a/tasmota/xdsp_07_sh1106.ino +++ b/tasmota/xdsp_07_sh1106.ino @@ -119,7 +119,7 @@ void SH1106PrintLog(void) strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols); DisplayFillScreen(last_row); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); renderer->println(disp_screen_buffer[last_row]); renderer->Updateframe(); diff --git a/tasmota/xdsp_08_ILI9488.ino b/tasmota/xdsp_08_ILI9488.ino index 513150af7..bb423097c 100644 --- a/tasmota/xdsp_08_ILI9488.ino +++ b/tasmota/xdsp_08_ILI9488.ino @@ -95,7 +95,7 @@ void ILI9488_InitDriver(void) { #endif ili9488_init_done = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: ILI9488")); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: ILI9488")); } } diff --git a/tasmota/xdsp_09_SSD1351.ino b/tasmota/xdsp_09_SSD1351.ino index f3ad53b29..0a1957e3a 100644 --- a/tasmota/xdsp_09_SSD1351.ino +++ b/tasmota/xdsp_09_SSD1351.ino @@ -84,7 +84,7 @@ void SSD1351_InitDriver() { color_type = COLOR_COLOR; ssd1351_init_done = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: SSD1351")); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: SSD1351")); } } @@ -110,7 +110,7 @@ void SSD1351PrintLog(void) { strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols); DisplayFillScreen(last_row); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); renderer->println(disp_screen_buffer[last_row]); renderer->Updateframe(); diff --git a/tasmota/xdsp_10_RA8876.ino b/tasmota/xdsp_10_RA8876.ino index a56f3ebf4..877a088d0 100644 --- a/tasmota/xdsp_10_RA8876.ino +++ b/tasmota/xdsp_10_RA8876.ino @@ -82,7 +82,7 @@ void RA8876_InitDriver(void) { #endif ra8876_init_done = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: RA8876")); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: RA8876")); } } diff --git a/tasmota/xdsp_12_ST7789.ino b/tasmota/xdsp_12_ST7789.ino index be3a40da9..9b285418f 100644 --- a/tasmota/xdsp_12_ST7789.ino +++ b/tasmota/xdsp_12_ST7789.ino @@ -136,7 +136,7 @@ void ST7789_InitDriver(void) { #endif // ESP32 st7789_init_done = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: ST7789")); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: ST7789")); } } @@ -190,7 +190,7 @@ bool Xdsp12(uint8_t function) { bool result = false; -//AddLog_P(LOG_LEVEL_INFO, PSTR("touch %d - %d"), FT5206_found, function); +//AddLog(LOG_LEVEL_INFO, PSTR("touch %d - %d"), FT5206_found, function); if (FUNC_DISPLAY_INIT_DRIVER == function) { ST7789_InitDriver(); diff --git a/tasmota/xdsp_13_ILI9341-2.ino b/tasmota/xdsp_13_ILI9341-2.ino index cb0e4616e..785dfc51f 100644 --- a/tasmota/xdsp_13_ILI9341-2.ino +++ b/tasmota/xdsp_13_ILI9341-2.ino @@ -205,7 +205,7 @@ void ILI9341_2_PrintLog(bool withDateTime) { strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols); DisplayFillScreen(last_row); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); renderer->println(disp_screen_buffer[last_row]); renderer->Updateframe(); diff --git a/tasmota/xdsp_14_SSD1331.ino b/tasmota/xdsp_14_SSD1331.ino index a7e48eae8..4d297cab8 100644 --- a/tasmota/xdsp_14_SSD1331.ino +++ b/tasmota/xdsp_14_SSD1331.ino @@ -93,7 +93,7 @@ void SSD1331_InitDriver() { color_type = COLOR_COLOR; ssd1331_init_done = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: SSD1331")); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: SSD1331")); } } @@ -128,7 +128,7 @@ void SSD1331PrintLog(bool withDateTime) { strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols); DisplayFillScreen(last_row); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); renderer->println(disp_screen_buffer[last_row]); renderer->Updateframe(); diff --git a/tasmota/xlgt_02_my92x1.ino b/tasmota/xlgt_02_my92x1.ino index 412cfd771..fe8ca1270 100644 --- a/tasmota/xlgt_02_my92x1.ino +++ b/tasmota/xlgt_02_my92x1.ino @@ -138,7 +138,7 @@ void My92x1ModuleSelected(void) LightMy92x1Init(); TasmotaGlobal.light_driver = XLGT_02; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: MY29x1 Found")); + AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: MY29x1 Found")); } } diff --git a/tasmota/xlgt_03_sm16716.ino b/tasmota/xlgt_03_sm16716.ino index 129f64e1a..66c714075 100644 --- a/tasmota/xlgt_03_sm16716.ino +++ b/tasmota/xlgt_03_sm16716.ino @@ -123,7 +123,7 @@ bool Sm16716SetChannels(void) // handle any PWM pins, skipping the first 3 values for sm16716 for (uint32_t i = 3; i < Light.subtype; i++) { if (PinUsed(GPIO_PWM1, i-3)) { - //AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d 10 bits %d, Pwm%d %d"), i, cur_col[i], i+1, curcol); + //AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d 10 bits %d, Pwm%d %d"), i, cur_col[i], i+1, curcol); analogWrite(Pin(GPIO_PWM1, i-3), bitRead(TasmotaGlobal.pwm_inverted, i-3) ? Settings.pwm_range - cur_col_10bits[i] : cur_col_10bits[i]); } } @@ -177,7 +177,7 @@ void Sm16716ModuleSelected(void) LightPwmOffset(LST_RGB); // Handle any PWM pins, skipping the first 3 color values for sm16716 TasmotaGlobal.light_type += LST_RGB; // Add RGB to be controlled by sm16716 TasmotaGlobal.light_driver = XLGT_03; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DBG: SM16716 Found")); + AddLog(LOG_LEVEL_DEBUG, PSTR("DBG: SM16716 Found")); } } diff --git a/tasmota/xlgt_04_sm2135.ino b/tasmota/xlgt_04_sm2135.ino index 8affdc528..a43336265 100644 --- a/tasmota/xlgt_04_sm2135.ino +++ b/tasmota/xlgt_04_sm2135.ino @@ -210,7 +210,7 @@ void Sm2135ModuleSelected(void) TasmotaGlobal.light_type = LT_RGBWC; TasmotaGlobal.light_driver = XLGT_04; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: SM2135 %s Found"), (SM2135_WCBGR == (Sm2135.model &1)) ? PSTR("BGR") : PSTR("GRB")); + AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: SM2135 %s Found"), (SM2135_WCBGR == (Sm2135.model &1)) ? PSTR("BGR") : PSTR("GRB")); } } diff --git a/tasmota/xlgt_05_sonoff_l1.ino b/tasmota/xlgt_05_sonoff_l1.ino index 227d8f1c9..368e1673d 100644 --- a/tasmota/xlgt_05_sonoff_l1.ino +++ b/tasmota/xlgt_05_sonoff_l1.ino @@ -70,7 +70,7 @@ void SnfL1SendDelayed(void) { void SnfL1Send(void) { #ifdef SONOFF_L1_DEBUG1 - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), Snfl1.buffer); + AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), Snfl1.buffer); #endif Serial.print(Snfl1.buffer); Serial.write(0x1B); @@ -87,7 +87,7 @@ void SnfL1SerialSendOk(void) void SnfL1Send(const char *buffer) { #ifdef SONOFF_L1_DEBUG1 - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), buffer); + AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Send %s"), buffer); #endif Serial.print(buffer); Serial.write(0x1B); @@ -119,7 +119,7 @@ bool SnfL1SerialInput(void) // AT+UPDATE="sequence":"34906","switch":"on","light_type":1,"colorR":0,"colorG":16,"colorB":0,"bright":6,"mode":1 // AT+UPDATE="switch":"on","light_type":1,"colorR":255,"colorG":0,"colorB":0,"bright":6,"mode":1,"speed":100,"sensitive":10 #ifdef SONOFF_L1_DEBUG1 - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd %s"), TasmotaGlobal.serial_in_buffer); + AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd %s"), TasmotaGlobal.serial_in_buffer); #endif if (!strncmp(TasmotaGlobal.serial_in_buffer +3, "RESULT", 6)) { #ifdef SONOFF_L1_ALLOW_REMOTE_INTERRUPT @@ -147,7 +147,7 @@ bool SnfL1SerialInput(void) if (!strncmp(token2, "\"sequence\"", 10)) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd sequence %s"), token3); +// AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd sequence %s"), token3); token = nullptr; } @@ -155,7 +155,7 @@ bool SnfL1SerialInput(void) else if (!strncmp(token2, "\"switch\"", 8)) { switch_state = !strncmp(token3, "\"on\"", 4) ? true : false; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd switch %d (%d)"), switch_state, Light.power); +// AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd switch %d (%d)"), switch_state, Light.power); is_power_change = (switch_state != Light.power); } @@ -178,7 +178,7 @@ bool SnfL1SerialInput(void) bool all_color_channels_updated = color_updated[0] && color_updated[1] && color_updated[2]; if (all_color_channels_updated) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd color R%d G%d B%d (R%d G%d B%d)"), +// AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd color R%d G%d B%d (R%d G%d B%d)"), // Snfl1.color[0], Snfl1.color[1], Snfl1.color[2], // Settings.light_color[0], Settings.light_color[1], Settings.light_color[2]); @@ -190,7 +190,7 @@ bool SnfL1SerialInput(void) else if (!strncmp(token2, "\"bright\"", 8)) { uint8_t dimmer = atoi(token3); -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd dimmer %d (%d)"), dimmer, Settings.light_dimmer); +// AddLog(LOG_LEVEL_DEBUG, PSTR("SL1: Rcvd dimmer %d (%d)"), dimmer, Settings.light_dimmer); is_brightness_change = (Light.power && (dimmer > 0) && (dimmer != Settings.light_dimmer)); snprintf_P(cmnd_dimmer, sizeof(cmnd_dimmer), PSTR(D_CMND_DIMMER " %d"), dimmer); @@ -311,7 +311,7 @@ bool SnfL1ModuleSelected(void) TasmotaGlobal.light_type = LT_RGB; TasmotaGlobal.light_driver = XLGT_05; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: Sonoff L1 Found")); + AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Sonoff L1 Found")); return true; } } diff --git a/tasmota/xlgt_06_electriq_moodl.ino b/tasmota/xlgt_06_electriq_moodl.ino index 3cb07a7e6..f6bef1ff5 100644 --- a/tasmota/xlgt_06_electriq_moodl.ino +++ b/tasmota/xlgt_06_electriq_moodl.ino @@ -74,7 +74,7 @@ void ElectriqMoodLModuleSelected(void) SetSerial(9600, TS_SERIAL_8N1); TasmotaGlobal.light_type = LT_RGBW; TasmotaGlobal.light_driver = XLGT_06; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("LGT: ElectriQ Mood Lamp Found")); + AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: ElectriQ Mood Lamp Found")); } } diff --git a/tasmota/xnrg_01_hlw8012.ino b/tasmota/xnrg_01_hlw8012.ino index a174699a0..ff6b40bf5 100644 --- a/tasmota/xnrg_01_hlw8012.ino +++ b/tasmota/xnrg_01_hlw8012.ino @@ -164,7 +164,7 @@ void HlwEvery200ms(void) } } uint32_t median = Hlw.debug[(Hlw.cf1_pulse_counter +1) / 2]; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NRG: power %d, ui %d, cnt %d, smpl%s, sum %d, mean %d, median %d"), + AddLog(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); #endif diff --git a/tasmota/xnrg_02_cse7766.ino b/tasmota/xnrg_02_cse7766.ino index e70b0addb..24c7fcc09 100644 --- a/tasmota/xnrg_02_cse7766.ino +++ b/tasmota/xnrg_02_cse7766.ino @@ -68,7 +68,7 @@ void CseReceived(void) { uint8_t header = Cse.rx_buffer[0]; if ((header & 0xFC) == 0xFC) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CSE: Abnormal hardware")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CSE: Abnormal hardware")); return; } @@ -165,7 +165,7 @@ void CseSerialInput(void) { Cse.byte_counter--; } while ((Cse.byte_counter > 2) && (0x5A != Cse.rx_buffer[1])); if (0x5A != Cse.rx_buffer[1]) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CSE: " D_CHECKSUM_FAILURE)); + AddLog(LOG_LEVEL_DEBUG, PSTR("CSE: " D_CHECKSUM_FAILURE)); Cse.received = false; Cse.byte_counter = 0; } @@ -208,7 +208,7 @@ void CseEverySecond(void) { Energy.kWhtoday_delta += delta; } else { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("CSE: Overload")); + AddLog(LOG_LEVEL_DEBUG, PSTR("CSE: Overload")); Cse.cf_pulses_last_time = CSE_PULSES_NOT_INITIALIZED; } EnergyUpdateToday(); diff --git a/tasmota/xnrg_03_pzem004t.ino b/tasmota/xnrg_03_pzem004t.ino index 39a382a41..692621cfc 100644 --- a/tasmota/xnrg_03_pzem004t.ino +++ b/tasmota/xnrg_03_pzem004t.ino @@ -138,15 +138,15 @@ bool PzemRecieve(uint8_t resp, float *data) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, len); if (len != sizeof(PZEMCommand)) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem comms timeout")); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem comms timeout")); return false; } if (buffer[6] != PzemCrc(buffer)) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem crc error")); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem crc error")); return false; } if (buffer[0] != resp) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem bad response")); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Pzem bad response")); return false; } @@ -208,7 +208,7 @@ void PzemEvery250ms(void) Pzem.read_state = 1; } -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("PZM: Retry %d"), 5 - Pzem.send_retry); +// AddLog(LOG_LEVEL_DEBUG, PSTR("PZM: Retry %d"), 5 - Pzem.send_retry); } } @@ -220,7 +220,7 @@ void PzemEvery250ms(void) Pzem.phase--; } -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("PZM: Probing address %d, Max phases %d"), Pzem.phase +1, Energy.phase_count); +// AddLog(LOG_LEVEL_DEBUG, PSTR("PZM: Probing address %d, Max phases %d"), Pzem.phase +1, Energy.phase_count); } if (Pzem.address) { diff --git a/tasmota/xnrg_04_mcp39f501.ino b/tasmota/xnrg_04_mcp39f501.ino index bfe7c48fd..ce6f2e455 100644 --- a/tasmota/xnrg_04_mcp39f501.ino +++ b/tasmota/xnrg_04_mcp39f501.ino @@ -484,15 +484,15 @@ void McpSerialInput(void) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, (uint8_t*)mcp_buffer, mcp_byte_counter); if (MCP_BUFFER_SIZE == mcp_byte_counter) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("MCP: Overflow")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("MCP: Overflow")); } else if (1 == mcp_byte_counter) { if (MCP_ERROR_CRC == mcp_buffer[0]) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("MCP: Send " D_CHECKSUM_FAILURE)); +// AddLog(LOG_LEVEL_DEBUG, PSTR("MCP: Send " D_CHECKSUM_FAILURE)); mcp_timeout = 0; } else if (MCP_ERROR_NAK == mcp_buffer[0]) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("MCP: NAck")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("MCP: NAck")); mcp_timeout = 0; } } @@ -500,7 +500,7 @@ void McpSerialInput(void) if (mcp_byte_counter == mcp_buffer[1]) { if (McpChecksum((uint8_t *)mcp_buffer) != mcp_buffer[mcp_byte_counter -1]) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("MCP: " D_CHECKSUM_FAILURE)); + AddLog(LOG_LEVEL_DEBUG, PSTR("MCP: " D_CHECKSUM_FAILURE)); } else { if (5 == mcp_buffer[1]) { McpAddressReceive(); } if (25 == mcp_buffer[1]) { McpParseData(); } diff --git a/tasmota/xnrg_05_pzem_ac.ino b/tasmota/xnrg_05_pzem_ac.ino index 2c79ae2f6..2c386d104 100644 --- a/tasmota/xnrg_05_pzem_ac.ino +++ b/tasmota/xnrg_05_pzem_ac.ino @@ -63,7 +63,7 @@ void PzemAcEverySecond(void) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, PzemAcModbus->ReceiveCount()); if (error) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("PAC: PzemAc %d error %d"), PZEM_AC_DEVICE_ADDRESS + PzemAc.phase, error); + AddLog(LOG_LEVEL_DEBUG, PSTR("PAC: PzemAc %d error %d"), PZEM_AC_DEVICE_ADDRESS + PzemAc.phase, error); } else { Energy.data_valid[PzemAc.phase] = 0; if (10 == registers) { diff --git a/tasmota/xnrg_06_pzem_dc.ino b/tasmota/xnrg_06_pzem_dc.ino index 8e5b13c54..5d9a11c69 100644 --- a/tasmota/xnrg_06_pzem_dc.ino +++ b/tasmota/xnrg_06_pzem_dc.ino @@ -62,7 +62,7 @@ void PzemDcEverySecond(void) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, PzemDcModbus->ReceiveCount()); if (error) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("PDC: PzemDc %d error %d"), PZEM_DC_DEVICE_ADDRESS + PzemDc.channel, error); + AddLog(LOG_LEVEL_DEBUG, PSTR("PDC: PzemDc %d error %d"), PZEM_DC_DEVICE_ADDRESS + PzemDc.channel, error); } else { Energy.data_valid[PzemDc.channel] = 0; if (8 == registers) { diff --git a/tasmota/xnrg_07_ade7953.ino b/tasmota/xnrg_07_ade7953.ino index a9c8acc5f..f058223bf 100644 --- a/tasmota/xnrg_07_ade7953.ino +++ b/tasmota/xnrg_07_ade7953.ino @@ -131,7 +131,7 @@ void Ade7953GetData(void) reg[i >> 2][i &3] = value; } } - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("ADE: %d, %d, [%d, %d, %d, %d], [%d, %d, %d, %d]"), + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ADE: %d, %d, [%d, %d, %d, %d], [%d, %d, %d, %d]"), Ade7953.voltage_rms, Ade7953.period, reg[0][0], reg[0][1], reg[0][2], reg[0][3], reg[1][0], reg[1][1], reg[1][2], reg[1][3]); @@ -154,7 +154,7 @@ void Ade7953GetData(void) uint32_t current_rms_sum = Ade7953.current_rms[0] + Ade7953.current_rms[1]; uint32_t active_power_sum = Ade7953.active_power[0] + Ade7953.active_power[1]; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ADE: U %d, C %d, I %d + %d = %d, P %d + %d = %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR("ADE: U %d, C %d, I %d + %d = %d, P %d + %d = %d"), Ade7953.voltage_rms, Ade7953.period, Ade7953.current_rms[0], Ade7953.current_rms[1], current_rms_sum, Ade7953.active_power[0], Ade7953.active_power[1], active_power_sum); diff --git a/tasmota/xnrg_08_sdm120.ino b/tasmota/xnrg_08_sdm120.ino index 5ba6242f6..c532deafc 100644 --- a/tasmota/xnrg_08_sdm120.ino +++ b/tasmota/xnrg_08_sdm120.ino @@ -83,7 +83,7 @@ void SDM120Every250ms(void) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Sdm120Modbus->ReceiveCount()); if (error) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SDM: SDM120 error %d"), error); + AddLog(LOG_LEVEL_DEBUG, PSTR("SDM: SDM120 error %d"), error); } else { Energy.data_valid[0] = 0; diff --git a/tasmota/xnrg_09_dds2382.ino b/tasmota/xnrg_09_dds2382.ino index 25ae5cf35..02a1d7673 100644 --- a/tasmota/xnrg_09_dds2382.ino +++ b/tasmota/xnrg_09_dds2382.ino @@ -50,7 +50,7 @@ void Dds2382EverySecond(void) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Dds2382Modbus->ReceiveCount()); if (error) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "DDS2382 response error %d"), error); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "DDS2382 response error %d"), error); } else { Energy.data_valid[0] = 0; diff --git a/tasmota/xnrg_10_sdm630.ino b/tasmota/xnrg_10_sdm630.ino index 7dcf478e4..46c14ffc4 100644 --- a/tasmota/xnrg_10_sdm630.ino +++ b/tasmota/xnrg_10_sdm630.ino @@ -86,7 +86,7 @@ void SDM630Every250ms(void) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Sdm630Modbus->ReceiveCount()); if (error) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SDM: SDM630 error %d"), error); + AddLog(LOG_LEVEL_DEBUG, PSTR("SDM: SDM630 error %d"), error); } else { Energy.data_valid[0] = 0; Energy.data_valid[1] = 0; diff --git a/tasmota/xnrg_11_ddsu666.ino b/tasmota/xnrg_11_ddsu666.ino index dc52cff5a..6b2d8dfb9 100644 --- a/tasmota/xnrg_11_ddsu666.ino +++ b/tasmota/xnrg_11_ddsu666.ino @@ -67,7 +67,7 @@ void DDSU666Every250ms(void) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Ddsu666Modbus->ReceiveCount()); if (error) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SDM: Ddsu666 error %d"), error); + AddLog(LOG_LEVEL_DEBUG, PSTR("SDM: Ddsu666 error %d"), error); } else { Energy.data_valid[0] = 0; diff --git a/tasmota/xnrg_12_solaxX1.ino b/tasmota/xnrg_12_solaxX1.ino index 04d873deb..c6af1f770 100644 --- a/tasmota/xnrg_12_solaxX1.ino +++ b/tasmota/xnrg_12_solaxX1.ino @@ -1,529 +1,506 @@ -/* - xnrg_12_solaxX1.ino - Solax X1 inverter RS485 support for Tasmota - - Copyright (C) 2021 Pablo Zerón - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifdef USE_ENERGY_SENSOR -#ifdef USE_SOLAX_X1 -/*********************************************************************************************\ - * Solax X1 Inverter -\*********************************************************************************************/ - -#define XNRG_12 12 - -#ifndef SOLAXX1_SPEED -#define SOLAXX1_SPEED 9600 // default solax rs485 speed -#endif - -#define INVERTER_ADDRESS 0x0A - -#define D_SOLAX_X1 "SolaxX1" - -#include - -enum solaxX1_Error -{ - solaxX1_ERR_NO_ERROR, - solaxX1_ERR_CRC_ERROR -}; - -union { - uint32_t ErrMessage; - struct { - //BYTE0 - uint8_t TzProtectFault:1;//0 - uint8_t MainsLostFault:1;//1 - uint8_t GridVoltFault:1;//2 - uint8_t GridFreqFault:1;//3 - uint8_t PLLLostFault:1;//4 - uint8_t BusVoltFault:1;//5 - uint8_t ErrBit06:1;//6 - uint8_t OciFault:1;//7 - //BYTE1 - uint8_t Dci_OCP_Fault:1;//8 - uint8_t ResidualCurrentFault:1;//9 - uint8_t PvVoltFault:1;//10 - uint8_t Ac10Mins_Voltage_Fault:1;//11 - uint8_t IsolationFault:1;//12 - uint8_t TemperatureOverFault:1;//13 - uint8_t FanFault:1;//14 - uint8_t ErrBit15:1;//15 - //BYTE2 - uint8_t SpiCommsFault:1;//16 - uint8_t SciCommsFault:1;//17 - uint8_t ErrBit18:1;//18 - uint8_t InputConfigFault:1;//19 - uint8_t EepromFault:1;//20 - uint8_t RelayFault:1;//21 - uint8_t SampleConsistenceFault:1;//22 - uint8_t ResidualCurrent_DeviceFault:1;//23 - //BYTE3 - uint8_t ErrBit24:1;//24 - uint8_t ErrBit25:1;//25 - uint8_t ErrBit26:1;//26 - uint8_t ErrBit27:1;//27 - uint8_t ErrBit28:1;//28 - uint8_t DCI_DeviceFault:1;//29 - uint8_t OtherDeviceFault:1;//30 - uint8_t ErrBit31:1;//31 - }; -} ErrCode; - -const char kSolaxMode[] PROGMEM = D_WAITING "|" D_CHECKING "|" D_WORKING "|" D_FAILURE; - -const char kSolaxError[] PROGMEM = - D_SOLAX_ERROR_0 "|" D_SOLAX_ERROR_1 "|" D_SOLAX_ERROR_2 "|" D_SOLAX_ERROR_3 "|" D_SOLAX_ERROR_4 "|" D_SOLAX_ERROR_5 "|" - D_SOLAX_ERROR_6 "|" D_SOLAX_ERROR_7 "|" D_SOLAX_ERROR_8; - -/*********************************************************************************************/ - -TasmotaSerial *solaxX1Serial; - -uint8_t solaxX1_Init = 1; - -struct SOLAXX1 { - float temperature = 0; - float energy_today = 0; - float dc1_voltage = 0; - float dc2_voltage = 0; - float dc1_current = 0; - float dc2_current = 0; - float energy_total = 0; - float runtime_total = 0; - float dc1_power = 0; - float dc2_power = 0; - - uint8_t status = 0; - uint32_t errorCode = 0; -} solaxX1; - -union { - uint8_t status; - struct { - uint8_t freeBit7:1; // Bit7 - uint8_t freeBit6:1; // Bit6 - uint8_t freeBit5:1; // Bit5 - uint8_t queryOffline:1; // Bit4 - uint8_t queryOfflineSend:1; // Bit3 - uint8_t hasAddress:1; // Bit2 - uint8_t inverterAddressSend:1; // Bit1 - uint8_t inverterSnReceived:1; // Bit0 - }; -} protocolStatus; - -uint8_t header[2] = {0xAA, 0x55}; -uint8_t source[2] = {0x00, 0x00}; -uint8_t destination[2] = {0x00, 0x00}; -uint8_t controlCode[1] = {0x00}; -uint8_t functionCode[1] = {0x00}; -uint8_t dataLength[1] = {0x00}; -uint8_t data[16] = {0}; - -uint8_t message[30]; - -/*********************************************************************************************/ - -bool solaxX1_RS485ReceiveReady(void) -{ - return (solaxX1Serial->available() > 1); -} - -void solaxX1_RS485Send(uint16_t msgLen) -{ - memcpy(message, header, 2); - memcpy(message + 2, source, 2); - memcpy(message + 4, destination, 2); - memcpy(message + 6, controlCode, 1); - memcpy(message + 7, functionCode, 1); - memcpy(message + 8, dataLength, 1); - memcpy(message + 9, data, sizeof(data)); - uint16_t crc = solaxX1_calculateCRC(message, msgLen); // calculate out crc bytes - - while (solaxX1Serial->available() > 0) - { // read serial if any old data is available - solaxX1Serial->read(); - } - - solaxX1Serial->flush(); - solaxX1Serial->write(message, msgLen); - solaxX1Serial->write(highByte(crc)); - solaxX1Serial->write(lowByte(crc)); - AddLogBuffer(LOG_LEVEL_DEBUG_MORE, message, msgLen); -} - -uint8_t solaxX1_RS485Receive(uint8_t *value) -{ - uint8_t len = 0; - - while (solaxX1Serial->available() > 0) - { - value[len++] = (uint8_t)solaxX1Serial->read(); - } - - AddLogBuffer(LOG_LEVEL_DEBUG_MORE, value, len); - - uint16_t crc = solaxX1_calculateCRC(value, len - 2); // calculate out crc bytes - - if (value[len - 1] == lowByte(crc) && value[len - 2] == highByte(crc)) - { // check calc crc with received crc - return solaxX1_ERR_NO_ERROR; - } - else - { - return solaxX1_ERR_CRC_ERROR; - } -} - -uint16_t solaxX1_calculateCRC(uint8_t *bExternTxPackage, uint8_t bLen) -{ - uint8_t i; - uint16_t wChkSum; - wChkSum = 0; - - for (i = 0; i < bLen; i++) - { - wChkSum = wChkSum + bExternTxPackage[i]; - } - return wChkSum; -} - -void solaxX1_SendInverterAddress(void) -{ - source[0] = 0x00; - destination[0] = 0x00; - destination[1] = 0x00; - controlCode[0] = 0x10; - functionCode[0] = 0x01; - dataLength[0] = 0x0F; - data[14] = INVERTER_ADDRESS; // Inverter Address, It must be unique in case of more inverters in the same rs485 net. - solaxX1_RS485Send(24); -} - -void solaxX1_QueryLiveData(void) -{ - source[0] = 0x01; - destination[0] = 0x00; - destination[1] = INVERTER_ADDRESS; - controlCode[0] = 0x11; - functionCode[0] = 0x02; - dataLength[0] = 0x00; - solaxX1_RS485Send(9); -} - -uint8_t solaxX1_ParseErrorCode(uint32_t code){ - ErrCode.ErrMessage = code; - - if (code == 0) return 0; - if (ErrCode.MainsLostFault) return 1; - if (ErrCode.GridVoltFault) return 2; - if (ErrCode.GridFreqFault) return 3; - if (ErrCode.PvVoltFault) return 4; - if (ErrCode.IsolationFault) return 5; - if (ErrCode.TemperatureOverFault) return 6; - if (ErrCode.FanFault) return 7; - if (ErrCode.OtherDeviceFault) return 8; - return 0; -} - -/*********************************************************************************************/ - -uint8_t solaxX1_send_retry = 0; -uint8_t solaxX1_nodata_count = 0; - -void solaxX1250MSecond(void) // Every Second -{ - uint8_t value[61] = {0}; - bool data_ready = solaxX1_RS485ReceiveReady(); - - if (protocolStatus.hasAddress && (data_ready || solaxX1_send_retry == 0)) - { - if (data_ready) - { - uint8_t error = solaxX1_RS485Receive(value); - if (error) - { - DEBUG_SENSOR_LOG(PSTR("SX1: Data response CRC error")); - } - else - { - solaxX1_nodata_count = 0; - solaxX1_send_retry = 12; - Energy.data_valid[0] = 0; - - solaxX1.temperature = (float)((value[9] << 8) | value[10]); // Temperature - solaxX1.energy_today = (float)((value[11] << 8) | value[12]) * 0.1f; // Energy Today - solaxX1.dc1_voltage = (float)((value[13] << 8) | value[14]) * 0.1f; // PV1 Voltage - solaxX1.dc2_voltage = (float)((value[15] << 8) | value[16]) * 0.1f; // PV2 Voltage - solaxX1.dc1_current = (float)((value[17] << 8) | value[18]) * 0.1f; // PV1 Current - solaxX1.dc2_current = (float)((value[19] << 8) | value[20]) * 0.1f; // PV2 Current - Energy.current[0] = (float)((value[21] << 8) | value[22]) * 0.1f; // AC Current - Energy.voltage[0] = (float)((value[23] << 8) | value[24]) * 0.1f; // AC Voltage - Energy.frequency[0] = (float)((value[25] << 8) | value[26]) * 0.01f; // AC Frequency - Energy.active_power[0] = (float)((value[27] << 8) | value[28]); // AC Power - //temporal = (float)((value[29] << 8) | value[30]) * 0.1f; // Not Used - solaxX1.energy_total = (float)((value[31] << 8) | (value[32] << 8) | (value[33] << 8) | value[34]) * 0.1f; // Energy Total - solaxX1.runtime_total = (float)((value[35] << 8) | (value[36] << 8) | (value[37] << 8) | value[38]); // Work Time Total - solaxX1.status = (uint8_t)((value[39] << 8) | value[40]); // Work mode - //temporal = (float)((value[41] << 8) | value[42]); // Grid voltage fault value 0.1V - //temporal = (float)((value[43] << 8) | value[44]); // Gird frequency fault value 0.01Hz - //temporal = (float)((value[45] << 8) | value[46]); // Dc injection fault value 1mA - //temporal = (float)((value[47] << 8) | value[48]); // Temperature fault value - //temporal = (float)((value[49] << 8) | value[50]); // Pv1 voltage fault value 0.1V - //temporal = (float)((value[51] << 8) | value[52]); // Pv2 voltage fault value 0.1V - //temporal = (float)((value[53] << 8) | value[54]); // GFC fault value - solaxX1.errorCode = (uint32_t)((value[58] << 8) | (value[57] << 8) | (value[56] << 8) | value[55]); // Error Code - - solaxX1.dc1_power = solaxX1.dc1_voltage * solaxX1.dc1_current; - solaxX1.dc2_power = solaxX1.dc2_voltage * solaxX1.dc2_current; - - solaxX1_QueryLiveData(); - EnergyUpdateTotal(solaxX1.energy_total, true); // 484.708 kWh - } - } // End data Ready - - if (0 == solaxX1_send_retry && 255 != solaxX1_nodata_count) { - solaxX1_send_retry = 12; - solaxX1_QueryLiveData(); - } - - // While the inverter has not stable ambient light, will send an address adquired but go offline again, - // so no data will be received when the query is send, then we start the countdown to set the inverter as offline again. - if (255 == solaxX1_nodata_count) { - solaxX1_nodata_count = 0; - solaxX1_send_retry = 12; - } - } // end hasAddress && (data_ready || solaxX1_send_retry == 0) - else - { - if ((solaxX1_nodata_count % 4) == 0) { DEBUG_SENSOR_LOG(PSTR("SX1: No Data count: %d"), solaxX1_nodata_count); } - if (solaxX1_nodata_count < 10 * 4) // max. seconds without data - { - solaxX1_nodata_count++; - } - else if (255 != solaxX1_nodata_count) - { - // no data from RS485, reset values to 0 and set inverter as offline - solaxX1_nodata_count = 255; - solaxX1_send_retry = 12; - protocolStatus.status = 0b00001000; // queryOffline - Energy.data_valid[0] = ENERGY_WATCHDOG; - - solaxX1.temperature = solaxX1.dc1_voltage = solaxX1.dc2_voltage = solaxX1.dc1_current = solaxX1.dc2_current = solaxX1.dc1_power = 0; - solaxX1.dc2_power = solaxX1.status = Energy.current[0] = Energy.voltage[0] = Energy.frequency[0] = Energy.active_power[0] = 0; - //solaxX1.energy_today = solaxX1.energy_total = solaxX1.runtime_total = 0; - } - } - - if (!protocolStatus.hasAddress && (data_ready || solaxX1_send_retry == 0)) - { - if (data_ready) - { - // check address confirmation from inverter - if (protocolStatus.inverterAddressSend) - { - uint8_t error = solaxX1_RS485Receive(value); - if (error) - { - DEBUG_SENSOR_LOG(PSTR("SX1: Address confirmation response CRC error")); - } - else - { - if (value[6] == 0x10 && value[7] == 0x81 && value[9] == 0x06) - { - DEBUG_SENSOR_LOG(PSTR("SX1: Set hasAddress")); - protocolStatus.status = 0b00100000; // hasAddress - } - } - } - - // Check inverter serial number and send the set address request - if (protocolStatus.queryOfflineSend) - { - uint8_t error = solaxX1_RS485Receive(value); - if (error) - { - DEBUG_SENSOR_LOG(PSTR("SX1: Query Offline response CRC error")); - } - else - { - // Serial number from query response - if (value[6] == 0x10 && value[7] == 0x80 && protocolStatus.inverterSnReceived == false) - { - for (uint8_t i = 9; i <= 22; i++) - { - data[i - 9] = value[i]; - } - solaxX1_SendInverterAddress(); - protocolStatus.status = 0b1100000; // inverterSnReceived and inverterAddressSend - DEBUG_SENSOR_LOG(PSTR("SX1: Set inverterSnReceived and inverterAddressSend")); - } - } - } - } // End data ready - - if (solaxX1_send_retry == 0) - { - if (protocolStatus.queryOfflineSend) - { - protocolStatus.status = 0b00001000; // queryOffline - DEBUG_SENSOR_LOG(PSTR("SX1: Set Query Offline")); - } - solaxX1_send_retry = 12; - } - - // request to the inverter the serial number if offline - if (protocolStatus.queryOffline) - { - // We sent the message to query inverters in offline status - source[0] = 0x01; - destination[1] = 0x00; - controlCode[0] = 0x10; - functionCode[0] = 0x00; - dataLength[0] = 0x00; - solaxX1_RS485Send(9); - protocolStatus.status = 0b00010000; // queryOfflineSend - DEBUG_SENSOR_LOG(PSTR("SX1: Query Offline Send")); - } - } // end !hasAddress && (data_ready || solaxX1_send_retry == 0) - - if (!data_ready) - solaxX1_send_retry--; -} - -void solaxX1SnsInit(void) -{ - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SX1: Solax X1 Inverter Init")); - DEBUG_SENSOR_LOG(PSTR("SX1: RX pin: %d, TX pin: %d"), Pin(GPIO_SOLAXX1_RX), Pin(GPIO_SOLAXX1_TX)); - protocolStatus.status = 0b00100000; // hasAddress - - solaxX1Serial = new TasmotaSerial(Pin(GPIO_SOLAXX1_RX), Pin(GPIO_SOLAXX1_TX), 1); - if (solaxX1Serial->begin(SOLAXX1_SPEED)) { - if (solaxX1Serial->hardwareSerial()) { ClaimSerial(); } - } else { - TasmotaGlobal.energy_driver = ENERGY_NONE; - } -} - -void solaxX1DrvInit(void) -{ - if (PinUsed(GPIO_SOLAXX1_RX) && PinUsed(GPIO_SOLAXX1_TX)) { - TasmotaGlobal.energy_driver = XNRG_12; - } -} - -#ifdef USE_WEBSERVER -const char HTTP_SNS_solaxX1_DATA1[] PROGMEM = - "{s}" D_SOLAX_X1 " " D_SOLAR_POWER "{m}%s " D_UNIT_WATT "{e}" - "{s}" D_SOLAX_X1 " " D_PV1_VOLTAGE "{m}%s " D_UNIT_VOLT "{e}" - "{s}" D_SOLAX_X1 " " D_PV1_CURRENT "{m}%s " D_UNIT_AMPERE "{e}" - "{s}" D_SOLAX_X1 " " D_PV1_POWER "{m}%s " D_UNIT_WATT "{e}"; -#ifdef SOLAXX1_PV2 -const char HTTP_SNS_solaxX1_DATA2[] PROGMEM = - "{s}" D_SOLAX_X1 " " D_PV2_VOLTAGE "{m}%s " D_UNIT_VOLT "{e}" - "{s}" D_SOLAX_X1 " " D_PV2_CURRENT "{m}%s " D_UNIT_AMPERE "{e}" - "{s}" D_SOLAX_X1 " " D_PV2_POWER "{m}%s " D_UNIT_WATT "{e}"; -#endif -const char HTTP_SNS_solaxX1_DATA3[] PROGMEM = - "{s}" D_SOLAX_X1 " " D_UPTIME "{m}%s " D_UNIT_HOUR "{e}" - "{s}" D_SOLAX_X1 " " D_STATUS "{m}%s" - "{s}" D_SOLAX_X1 " " D_ERROR "{m}%s"; -#endif // USE_WEBSERVER - -void solaxX1Show(bool json) -{ - char solar_power[33]; - dtostrfd(solaxX1.dc1_power + solaxX1.dc2_power, Settings.flag2.wattage_resolution, solar_power); - char pv1_voltage[33]; - dtostrfd(solaxX1.dc1_voltage, Settings.flag2.voltage_resolution, pv1_voltage); - char pv1_current[33]; - dtostrfd(solaxX1.dc1_current, Settings.flag2.current_resolution, pv1_current); - char pv1_power[33]; - dtostrfd(solaxX1.dc1_power, Settings.flag2.wattage_resolution, pv1_power); -#ifdef SOLAXX1_PV2 - char pv2_voltage[33]; - dtostrfd(solaxX1.dc2_voltage, Settings.flag2.voltage_resolution, pv2_voltage); - char pv2_current[33]; - dtostrfd(solaxX1.dc2_current, Settings.flag2.current_resolution, pv2_current); - char pv2_power[33]; - dtostrfd(solaxX1.dc2_power, Settings.flag2.wattage_resolution, pv2_power); -#endif - char temperature[33]; - dtostrfd(solaxX1.temperature, Settings.flag2.temperature_resolution, temperature); - char runtime[33]; - dtostrfd(solaxX1.runtime_total, 0, runtime); - char status[33]; - GetTextIndexed(status, sizeof(status), solaxX1.status, kSolaxMode); - - if (json) - { - ResponseAppend_P(PSTR(",\"" D_JSON_SOLAR_POWER "\":%s,\"" D_JSON_PV1_VOLTAGE "\":%s,\"" D_JSON_PV1_CURRENT "\":%s,\"" D_JSON_PV1_POWER "\":%s"), - solar_power, pv1_voltage, pv1_current, pv1_power); -#ifdef SOLAXX1_PV2 - ResponseAppend_P(PSTR(",\"" D_JSON_PV2_VOLTAGE "\":%s,\"" D_JSON_PV2_CURRENT "\":%s,\"" D_JSON_PV2_POWER "\":%s"), - pv2_voltage, pv2_current, pv2_power); -#endif - ResponseAppend_P(PSTR(",\"" D_JSON_TEMPERATURE "\":%s,\"" D_JSON_RUNTIME "\":%s,\"" D_JSON_STATUS "\":\"%s\",\"" D_JSON_ERROR "\":%d"), - temperature, runtime, status, solaxX1.errorCode); - -#ifdef USE_WEBSERVER - } - else - { - WSContentSend_PD(HTTP_SNS_solaxX1_DATA1, solar_power, pv1_voltage, pv1_current, pv1_power); -#ifdef SOLAXX1_PV2 - WSContentSend_PD(HTTP_SNS_solaxX1_DATA2, pv2_voltage, pv2_current, pv2_power); -#endif - WSContentSend_PD(HTTP_SNS_TEMP, D_SOLAX_X1, temperature, TempUnit()); - char errorCodeString[33]; - WSContentSend_PD(HTTP_SNS_solaxX1_DATA3, runtime, status, - GetTextIndexed(errorCodeString, sizeof(errorCodeString), solaxX1_ParseErrorCode(solaxX1.errorCode), kSolaxError)); -#endif // USE_WEBSERVER - } -} - -/*********************************************************************************************\ - * Interface -\*********************************************************************************************/ - -bool Xnrg12(uint8_t function) -{ - bool result = false; - - switch (function) { - case FUNC_EVERY_250_MSECOND: - solaxX1250MSecond(); - break; - case FUNC_JSON_APPEND: - solaxX1Show(1); - break; -#ifdef USE_WEBSERVER - case FUNC_WEB_SENSOR: - solaxX1Show(0); - break; -#endif // USE_WEBSERVER - case FUNC_INIT: - solaxX1SnsInit(); - break; - case FUNC_PRE_INIT: - solaxX1DrvInit(); - break; - } - return result; -} - -#endif // USE_SOLAX_X1_NRG +/* + xnrg_12_solaxX1.ino - Solax X1 inverter RS485 support for Tasmota + + Copyright (C) 2021 Pablo Zerón + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef USE_ENERGY_SENSOR +#ifdef USE_SOLAX_X1 +/*********************************************************************************************\ + * Solax X1 Inverter +\*********************************************************************************************/ + +#define XNRG_12 12 + +#ifndef SOLAXX1_SPEED +#define SOLAXX1_SPEED 9600 // default solax rs485 speed +#endif + +#define INVERTER_ADDRESS 0x0A + +#define D_SOLAX_X1 "SolaxX1" + +#include + +enum solaxX1_Error +{ + solaxX1_ERR_NO_ERROR, + solaxX1_ERR_CRC_ERROR +}; + +union { + uint32_t ErrMessage; + struct { + //BYTE0 + uint8_t TzProtectFault:1;//0 + uint8_t MainsLostFault:1;//1 + uint8_t GridVoltFault:1;//2 + uint8_t GridFreqFault:1;//3 + uint8_t PLLLostFault:1;//4 + uint8_t BusVoltFault:1;//5 + uint8_t ErrBit06:1;//6 + uint8_t OciFault:1;//7 + //BYTE1 + uint8_t Dci_OCP_Fault:1;//8 + uint8_t ResidualCurrentFault:1;//9 + uint8_t PvVoltFault:1;//10 + uint8_t Ac10Mins_Voltage_Fault:1;//11 + uint8_t IsolationFault:1;//12 + uint8_t TemperatureOverFault:1;//13 + uint8_t FanFault:1;//14 + uint8_t ErrBit15:1;//15 + //BYTE2 + uint8_t SpiCommsFault:1;//16 + uint8_t SciCommsFault:1;//17 + uint8_t ErrBit18:1;//18 + uint8_t InputConfigFault:1;//19 + uint8_t EepromFault:1;//20 + uint8_t RelayFault:1;//21 + uint8_t SampleConsistenceFault:1;//22 + uint8_t ResidualCurrent_DeviceFault:1;//23 + //BYTE3 + uint8_t ErrBit24:1;//24 + uint8_t ErrBit25:1;//25 + uint8_t ErrBit26:1;//26 + uint8_t ErrBit27:1;//27 + uint8_t ErrBit28:1;//28 + uint8_t DCI_DeviceFault:1;//29 + uint8_t OtherDeviceFault:1;//30 + uint8_t ErrBit31:1;//31 + }; +} ErrCode; + +const char kSolaxMode[] PROGMEM = D_WAITING "|" D_CHECKING "|" D_WORKING "|" D_FAILURE; + +const char kSolaxError[] PROGMEM = + D_SOLAX_ERROR_0 "|" D_SOLAX_ERROR_1 "|" D_SOLAX_ERROR_2 "|" D_SOLAX_ERROR_3 "|" D_SOLAX_ERROR_4 "|" D_SOLAX_ERROR_5 "|" + D_SOLAX_ERROR_6 "|" D_SOLAX_ERROR_7 "|" D_SOLAX_ERROR_8; + +/*********************************************************************************************/ + +TasmotaSerial *solaxX1Serial; + +struct SOLAXX1 { + float temperature = 0; + float energy_today = 0; + float dc1_voltage = 0; + float dc2_voltage = 0; + float dc1_current = 0; + float dc2_current = 0; + uint32_t energy_total = 0; + uint32_t runtime_total = 0; + float dc1_power = 0; + float dc2_power = 0; + + uint8_t status = 0; + uint32_t errorCode = 0; +} solaxX1; + +union { + uint8_t status; + struct { + uint8_t freeBit7:1; // Bit7 + uint8_t freeBit6:1; // Bit6 + uint8_t freeBit5:1; // Bit5 + uint8_t queryOffline:1; // Bit4 + uint8_t queryOfflineSend:1; // Bit3 + uint8_t hasAddress:1; // Bit2 + uint8_t inverterAddressSend:1; // Bit1 + uint8_t inverterSnReceived:1; // Bit0 + }; +} protocolStatus; + +uint8_t header[2] = {0xAA, 0x55}; +uint8_t source[2] = {0x00, 0x00}; +uint8_t destination[2] = {0x00, 0x00}; +uint8_t controlCode[1] = {0x00}; +uint8_t functionCode[1] = {0x00}; +uint8_t dataLength[1] = {0x00}; +uint8_t data[16] = {0}; + +uint8_t message[30]; + +/*********************************************************************************************/ + +bool solaxX1_RS485ReceiveReady(void) +{ + return (solaxX1Serial->available() > 1); +} + +void solaxX1_RS485Send(uint16_t msgLen) +{ + memcpy(message, header, 2); + memcpy(message + 2, source, 2); + memcpy(message + 4, destination, 2); + memcpy(message + 6, controlCode, 1); + memcpy(message + 7, functionCode, 1); + memcpy(message + 8, dataLength, 1); + memcpy(message + 9, data, sizeof(data)); + uint16_t crc = solaxX1_calculateCRC(message, msgLen); // calculate out crc bytes + + while (solaxX1Serial->available() > 0) + { // read serial if any old data is available + solaxX1Serial->read(); + } + + solaxX1Serial->flush(); + solaxX1Serial->write(message, msgLen); + solaxX1Serial->write(highByte(crc)); + solaxX1Serial->write(lowByte(crc)); + AddLogBuffer(LOG_LEVEL_DEBUG_MORE, message, msgLen); +} + +uint8_t solaxX1_RS485Receive(uint8_t *value) +{ + uint8_t len = 0; + + while (solaxX1Serial->available() > 0) + { + value[len++] = (uint8_t)solaxX1Serial->read(); + } + + AddLogBuffer(LOG_LEVEL_DEBUG_MORE, value, len); + + uint16_t crc = solaxX1_calculateCRC(value, len - 2); // calculate out crc bytes + + if (value[len - 1] == lowByte(crc) && value[len - 2] == highByte(crc)) + { // check calc crc with received crc + return solaxX1_ERR_NO_ERROR; + } + else + { + return solaxX1_ERR_CRC_ERROR; + } +} + +uint16_t solaxX1_calculateCRC(uint8_t *bExternTxPackage, uint8_t bLen) +{ + uint8_t i; + uint16_t wChkSum; + wChkSum = 0; + + for (i = 0; i < bLen; i++) + { + wChkSum = wChkSum + bExternTxPackage[i]; + } + return wChkSum; +} + +void solaxX1_SendInverterAddress(void) +{ + source[0] = 0x00; + destination[0] = 0x00; + destination[1] = 0x00; + controlCode[0] = 0x10; + functionCode[0] = 0x01; + dataLength[0] = 0x0F; + data[14] = INVERTER_ADDRESS; // Inverter Address, It must be unique in case of more inverters in the same rs485 net. + solaxX1_RS485Send(24); +} + +void solaxX1_QueryLiveData(void) +{ + source[0] = 0x01; + destination[0] = 0x00; + destination[1] = INVERTER_ADDRESS; + controlCode[0] = 0x11; + functionCode[0] = 0x02; + dataLength[0] = 0x00; + solaxX1_RS485Send(9); +} + +uint8_t solaxX1_ParseErrorCode(uint32_t code){ + ErrCode.ErrMessage = code; + + if (code == 0) return 0; + if (ErrCode.MainsLostFault) return 1; + if (ErrCode.GridVoltFault) return 2; + if (ErrCode.GridFreqFault) return 3; + if (ErrCode.PvVoltFault) return 4; + if (ErrCode.IsolationFault) return 5; + if (ErrCode.TemperatureOverFault) return 6; + if (ErrCode.FanFault) return 7; + if (ErrCode.OtherDeviceFault) return 8; + return 0; +} + +/*********************************************************************************************/ + +uint8_t solaxX1_send_retry = 20; +uint8_t solaxX1_queryData_count = 0; + +void solaxX1250MSecond(void) // Every 250 milliseconds +{ + uint8_t value[61] = {0}; + bool data_ready = solaxX1_RS485ReceiveReady(); + + if (data_ready) + { + if (protocolStatus.hasAddress) + { + uint8_t error = solaxX1_RS485Receive(value); + if (error) + { + DEBUG_SENSOR_LOG(PSTR("SX1: Data response CRC error")); + } + else + { + solaxX1_send_retry = 20; + Energy.data_valid[0] = 0; + + solaxX1.temperature = (float)((value[9] << 8) | value[10]); // Temperature + solaxX1.energy_today = (float)((value[11] << 8) | value[12]) * 0.1f; // Energy Today + solaxX1.dc1_voltage = (float)((value[13] << 8) | value[14]) * 0.1f; // PV1 Voltage + solaxX1.dc2_voltage = (float)((value[15] << 8) | value[16]) * 0.1f; // PV2 Voltage + solaxX1.dc1_current = (float)((value[17] << 8) | value[18]) * 0.1f; // PV1 Current + solaxX1.dc2_current = (float)((value[19] << 8) | value[20]) * 0.1f; // PV2 Current + Energy.current[0] = (float)((value[21] << 8) | value[22]) * 0.1f; // AC Current + Energy.voltage[0] = (float)((value[23] << 8) | value[24]) * 0.1f; // AC Voltage + Energy.frequency[0] = (float)((value[25] << 8) | value[26]) * 0.01f; // AC Frequency + Energy.active_power[0] = (float)((value[27] << 8) | value[28]); // AC Power + //temporal = (float)((value[29] << 8) | value[30]) * 0.1f; // Not Used + solaxX1.energy_total = ((value[31] << 24) | (value[32] << 16) | (value[33] << 8) | value[34]); // Energy Total + solaxX1.runtime_total = ((value[35] << 24) | (value[36] << 16) | (value[37] << 8) | value[38]); // Work Time Total + solaxX1.status = (uint8_t)((value[39] << 8) | value[40]); // Work mode + //temporal = (float)((value[41] << 8) | value[42]); // Grid voltage fault value 0.1V + //temporal = (float)((value[43] << 8) | value[44]); // Gird frequency fault value 0.01Hz + //temporal = (float)((value[45] << 8) | value[46]); // Dc injection fault value 1mA + //temporal = (float)((value[47] << 8) | value[48]); // Temperature fault value + //temporal = (float)((value[49] << 8) | value[50]); // Pv1 voltage fault value 0.1V + //temporal = (float)((value[51] << 8) | value[52]); // Pv2 voltage fault value 0.1V + //temporal = (float)((value[53] << 8) | value[54]); // GFC fault value + solaxX1.errorCode = ((value[58] << 24) | (value[57] << 16) | (value[56] << 8) | value[55]); // Error Code + + solaxX1.dc1_power = solaxX1.dc1_voltage * solaxX1.dc1_current; + solaxX1.dc2_power = solaxX1.dc2_voltage * solaxX1.dc2_current; + + EnergyUpdateTotal((float)solaxX1.energy_total * 0.1f, true); // 484.708 kWh + } + } else { // end hasAddress + // check address confirmation from inverter + if (protocolStatus.inverterAddressSend) + { + uint8_t error = solaxX1_RS485Receive(value); + if (error) + { + DEBUG_SENSOR_LOG(PSTR("SX1: Address confirmation response CRC error")); + } + else + { + if (value[6] == 0x10 && value[7] == 0x81 && value[9] == 0x06) + { + DEBUG_SENSOR_LOG(PSTR("SX1: Set hasAddress")); + protocolStatus.status = 0b00100000; // hasAddress + } + } + } + + // Check inverter serial number and send the set address request + if (protocolStatus.queryOfflineSend) + { + uint8_t error = solaxX1_RS485Receive(value); + if (error) + { + DEBUG_SENSOR_LOG(PSTR("SX1: Query Offline response CRC error")); + } + else + { + // Serial number from query response + if (value[6] == 0x10 && value[7] == 0x80 && protocolStatus.inverterSnReceived == false) + { + for (uint8_t i = 9; i <= 22; i++) + { + data[i - 9] = value[i]; + } + solaxX1_SendInverterAddress(); + protocolStatus.status = 0b1100000; // inverterSnReceived and inverterAddressSend + DEBUG_SENSOR_LOG(PSTR("SX1: Set inverterSnReceived and inverterAddressSend")); + } + } + } + } + } + + if (protocolStatus.hasAddress) { + if (solaxX1_queryData_count <= 0) { + solaxX1_queryData_count = 5; + DEBUG_SENSOR_LOG(PSTR("SX1: Send Retry count: %d"), solaxX1_send_retry); + solaxX1_QueryLiveData(); + } + solaxX1_queryData_count--; + } + + // request to the inverter the serial number if offline + if (protocolStatus.queryOffline) + { + // We sent the message to query inverters in offline status + source[0] = 0x01; + destination[1] = 0x00; + controlCode[0] = 0x10; + functionCode[0] = 0x00; + dataLength[0] = 0x00; + solaxX1_RS485Send(9); + protocolStatus.status = 0b00010000; // queryOfflineSend + solaxX1_send_retry = 20; + DEBUG_SENSOR_LOG(PSTR("SX1: Query Offline Send")); + } + + if (solaxX1_send_retry == 0) { + if (protocolStatus.hasAddress) { + protocolStatus.status = 0b00001000; // queryOffline + Energy.data_valid[0] = ENERGY_WATCHDOG; + + solaxX1.temperature = solaxX1.dc1_voltage = solaxX1.dc2_voltage = solaxX1.dc1_current = solaxX1.dc2_current = solaxX1.dc1_power = 0; + solaxX1.dc2_power = solaxX1.status = Energy.current[0] = Energy.voltage[0] = Energy.frequency[0] = Energy.active_power[0] = 0; + //solaxX1.energy_today = solaxX1.energy_total = solaxX1.runtime_total = 0; + } else { + if (protocolStatus.queryOfflineSend) { + protocolStatus.status = 0b00001000; // queryOffline + DEBUG_SENSOR_LOG(PSTR("SX1: Set Query Offline")); + } + solaxX1_send_retry = 20; + } + } + + if (!data_ready && solaxX1_send_retry > 0) { solaxX1_send_retry--; } +} + +void solaxX1SnsInit(void) +{ + AddLog(LOG_LEVEL_DEBUG, PSTR("SX1: Solax X1 Inverter Init")); + DEBUG_SENSOR_LOG(PSTR("SX1: RX pin: %d, TX pin: %d"), Pin(GPIO_SOLAXX1_RX), Pin(GPIO_SOLAXX1_TX)); + protocolStatus.status = 0b00100000; // hasAddress + + solaxX1Serial = new TasmotaSerial(Pin(GPIO_SOLAXX1_RX), Pin(GPIO_SOLAXX1_TX), 1); + if (solaxX1Serial->begin(SOLAXX1_SPEED)) { + if (solaxX1Serial->hardwareSerial()) { ClaimSerial(); } + } else { + TasmotaGlobal.energy_driver = ENERGY_NONE; + } +} + +void solaxX1DrvInit(void) +{ + if (PinUsed(GPIO_SOLAXX1_RX) && PinUsed(GPIO_SOLAXX1_TX)) { + TasmotaGlobal.energy_driver = XNRG_12; + } +} + +#ifdef USE_WEBSERVER +const char HTTP_SNS_solaxX1_DATA1[] PROGMEM = + "{s}" D_SOLAX_X1 " " D_SOLAR_POWER "{m}%s " D_UNIT_WATT "{e}" + "{s}" D_SOLAX_X1 " " D_PV1_VOLTAGE "{m}%s " D_UNIT_VOLT "{e}" + "{s}" D_SOLAX_X1 " " D_PV1_CURRENT "{m}%s " D_UNIT_AMPERE "{e}" + "{s}" D_SOLAX_X1 " " D_PV1_POWER "{m}%s " D_UNIT_WATT "{e}"; +#ifdef SOLAXX1_PV2 +const char HTTP_SNS_solaxX1_DATA2[] PROGMEM = + "{s}" D_SOLAX_X1 " " D_PV2_VOLTAGE "{m}%s " D_UNIT_VOLT "{e}" + "{s}" D_SOLAX_X1 " " D_PV2_CURRENT "{m}%s " D_UNIT_AMPERE "{e}" + "{s}" D_SOLAX_X1 " " D_PV2_POWER "{m}%s " D_UNIT_WATT "{e}"; +#endif +const char HTTP_SNS_solaxX1_DATA3[] PROGMEM = + "{s}" D_SOLAX_X1 " " D_UPTIME "{m}%s " D_UNIT_HOUR "{e}" + "{s}" D_SOLAX_X1 " " D_STATUS "{m}%s" + "{s}" D_SOLAX_X1 " " D_ERROR "{m}%s"; +#endif // USE_WEBSERVER + +void solaxX1Show(bool json) +{ + char solar_power[33]; + dtostrfd(solaxX1.dc1_power + solaxX1.dc2_power, Settings.flag2.wattage_resolution, solar_power); + char pv1_voltage[33]; + dtostrfd(solaxX1.dc1_voltage, Settings.flag2.voltage_resolution, pv1_voltage); + char pv1_current[33]; + dtostrfd(solaxX1.dc1_current, Settings.flag2.current_resolution, pv1_current); + char pv1_power[33]; + dtostrfd(solaxX1.dc1_power, Settings.flag2.wattage_resolution, pv1_power); +#ifdef SOLAXX1_PV2 + char pv2_voltage[33]; + dtostrfd(solaxX1.dc2_voltage, Settings.flag2.voltage_resolution, pv2_voltage); + char pv2_current[33]; + dtostrfd(solaxX1.dc2_current, Settings.flag2.current_resolution, pv2_current); + char pv2_power[33]; + dtostrfd(solaxX1.dc2_power, Settings.flag2.wattage_resolution, pv2_power); +#endif + char temperature[33]; + dtostrfd(solaxX1.temperature, Settings.flag2.temperature_resolution, temperature); + char runtime[33]; + dtostrfd(solaxX1.runtime_total, 0, runtime); + char status[33]; + GetTextIndexed(status, sizeof(status), solaxX1.status, kSolaxMode); + + if (json) + { + ResponseAppend_P(PSTR(",\"" D_JSON_SOLAR_POWER "\":%s,\"" D_JSON_PV1_VOLTAGE "\":%s,\"" D_JSON_PV1_CURRENT "\":%s,\"" D_JSON_PV1_POWER "\":%s"), + solar_power, pv1_voltage, pv1_current, pv1_power); +#ifdef SOLAXX1_PV2 + ResponseAppend_P(PSTR(",\"" D_JSON_PV2_VOLTAGE "\":%s,\"" D_JSON_PV2_CURRENT "\":%s,\"" D_JSON_PV2_POWER "\":%s"), + pv2_voltage, pv2_current, pv2_power); +#endif + ResponseAppend_P(PSTR(",\"" D_JSON_TEMPERATURE "\":%s,\"" D_JSON_RUNTIME "\":%s,\"" D_JSON_STATUS "\":\"%s\",\"" D_JSON_ERROR "\":%d"), + temperature, runtime, status, solaxX1.errorCode); + +#ifdef USE_DOMOTICZ + // Avoid bad temperature report at beginning of the day (spikes of 1200 celsius degrees) + if (0 == TasmotaGlobal.tele_period && solaxX1.temperature < 100) { DomoticzSensor(DZ_TEMP, temperature); } +#endif // USE_DOMOTICZ + +#ifdef USE_WEBSERVER + } else { + WSContentSend_PD(HTTP_SNS_solaxX1_DATA1, solar_power, pv1_voltage, pv1_current, pv1_power); +#ifdef SOLAXX1_PV2 + WSContentSend_PD(HTTP_SNS_solaxX1_DATA2, pv2_voltage, pv2_current, pv2_power); +#endif + WSContentSend_PD(HTTP_SNS_TEMP, D_SOLAX_X1, temperature, TempUnit()); + char errorCodeString[33]; + WSContentSend_PD(HTTP_SNS_solaxX1_DATA3, runtime, status, + GetTextIndexed(errorCodeString, sizeof(errorCodeString), solaxX1_ParseErrorCode(solaxX1.errorCode), kSolaxError)); +#endif // USE_WEBSERVER + } +} + +/*********************************************************************************************\ + * Interface +\*********************************************************************************************/ + +bool Xnrg12(uint8_t function) +{ + bool result = false; + + switch (function) { + case FUNC_EVERY_250_MSECOND: + solaxX1250MSecond(); + break; + case FUNC_JSON_APPEND: + solaxX1Show(1); + break; +#ifdef USE_WEBSERVER + case FUNC_WEB_SENSOR: + solaxX1Show(0); + break; +#endif // USE_WEBSERVER + case FUNC_INIT: + solaxX1SnsInit(); + break; + case FUNC_PRE_INIT: + solaxX1DrvInit(); + break; + } + return result; +} + +#endif // USE_SOLAX_X1_NRG #endif // USE_ENERGY_SENSOR \ No newline at end of file diff --git a/tasmota/xnrg_13_fif_le01mr.ino b/tasmota/xnrg_13_fif_le01mr.ino index 8678e0a6c..727f6530a 100644 --- a/tasmota/xnrg_13_fif_le01mr.ino +++ b/tasmota/xnrg_13_fif_le01mr.ino @@ -123,7 +123,7 @@ void FifLEEvery250ms(void) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, FifLEModbus->ReceiveCount()); if (error) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("FiF-LE: LE01MR Modbus error %d"), error); + AddLog(LOG_LEVEL_DEBUG, PSTR("FiF-LE: LE01MR Modbus error %d"), error); } else { Energy.data_valid[0] = 0; diff --git a/tasmota/xnrg_14_bl0940.ino b/tasmota/xnrg_14_bl0940.ino index 3237c485d..20df87f1a 100644 --- a/tasmota/xnrg_14_bl0940.ino +++ b/tasmota/xnrg_14_bl0940.ino @@ -86,7 +86,7 @@ void Bl0940Received(void) { if ((Bl0940.rx_buffer[0] != BL0940_PACKET_HEADER) || // Bad header (Bl0940.tps1 && ((tps1 < (Bl0940.tps1 -10)) || (tps1 > (Bl0940.tps1 +10)))) // Invalid temperature change ) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("BL9: Invalid data")); + AddLog(LOG_LEVEL_DEBUG, PSTR("BL9: Invalid data")); return; } @@ -101,7 +101,7 @@ void Bl0940Received(void) { int32_t cf_cnt = Bl0940.rx_buffer[24] << 24 | Bl0940.rx_buffer[23] << 16 | Bl0940.rx_buffer[22] << 8; // CF_CNT signed Bl0940.cf_pulses = abs(cf_cnt) >> 8; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("BL9: U %d, I %d, P %d, C %d, T %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR("BL9: U %d, I %d, P %d, C %d, T %d"), Bl0940.voltage, Bl0940.current, Bl0940.power, Bl0940.cf_pulses, Bl0940.tps1); if (Energy.power_on) { // Powered on @@ -149,7 +149,7 @@ void Bl0940SerialInput(void) { Bl0940.byte_counter--; } while ((Bl0940.byte_counter > 1) && (BL0940_PACKET_HEADER != Bl0940.rx_buffer[0])); if (BL0940_PACKET_HEADER != Bl0940.rx_buffer[0]) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("BL9: " D_CHECKSUM_FAILURE)); + AddLog(LOG_LEVEL_DEBUG, PSTR("BL9: " D_CHECKSUM_FAILURE)); Bl0940.received = false; Bl0940.byte_counter = 0; } @@ -191,7 +191,7 @@ void Bl0940EverySecond(void) { Bl0940.cf_pulses_last_time = Bl0940.cf_pulses; Energy.kWhtoday_delta += delta; } else { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("BL9: Overload")); + AddLog(LOG_LEVEL_DEBUG, PSTR("BL9: Overload")); Bl0940.cf_pulses_last_time = BL0940_PULSES_NOT_INITIALIZED; } EnergyUpdateToday(); @@ -200,7 +200,7 @@ void Bl0940EverySecond(void) { } -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("BL9: Poll")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("BL9: Poll")); Bl0940Serial->flush(); Bl0940Serial->write(BL0940_READ_COMMAND); diff --git a/tasmota/xnrg_15_teleinfo.ino b/tasmota/xnrg_15_teleinfo.ino index e2dfe6195..7b5c52a43 100755 --- a/tasmota/xnrg_15_teleinfo.ino +++ b/tasmota/xnrg_15_teleinfo.ino @@ -158,7 +158,7 @@ void ADPSCallback(uint8_t phase) // Publish adding ADCO serial number into the topic MqttPublishPrefixTopic_P(RESULT_OR_TELE, serialNumber, false); - AddLog_P(LOG_LEVEL_INFO, PSTR("ADPS on phase %d"), phase); + AddLog(LOG_LEVEL_INFO, PSTR("ADPS on phase %d"), phase); } /* ====================================================================== @@ -187,7 +187,7 @@ void DataCallback(struct _ValueList * me, uint8_t flags) if (flags & TINFO_FLAGS_ADDED) { c = '#'; } if (flags & TINFO_FLAGS_UPDATED) { c = '*'; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: [%d]%c %s=%s"), ilabel, c , me->name, me->value); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: [%d]%c %s=%s"), ilabel, c , me->name, me->value); if (ilabelvalue, tarif); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Tarif changed, now '%s' (%d)"), me->value, tarif); } // Current tariff (standard is in clear text in value) else if (ilabel == LABEL_LTARF) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Tarif name changed, now '%s'"), me->value); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Tarif name changed, now '%s'"), me->value); } // Current tariff (standard index is is in clear text in value) else if (ilabel == LABEL_NTARF) { tarif = atoi(me->value); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Tarif index changed, now '%d'"), tarif); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Tarif index changed, now '%d'"), tarif); } @@ -223,21 +223,21 @@ void DataCallback(struct _ValueList * me, uint8_t flags) { Energy.voltage_available = true; Energy.voltage[0] = (float) atoi(me->value); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Voltage %s, now %d"), me->value, (int) Energy.voltage[0]); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Voltage %s, now %d"), me->value, (int) Energy.voltage[0]); } // Current I else if (ilabel == LABEL_IINST || ilabel == LABEL_IRMS1) { Energy.current[0] = (float) atoi(me->value); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Current %s, now %d"), me->value, (int) Energy.current[0]); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Current %s, now %d"), me->value, (int) Energy.current[0]); } // Power P else if (ilabel == LABEL_PAPP || ilabel == LABEL_SINSTS) { Energy.active_power[0] = (float) atoi(me->value);; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Power %s, now %d"), me->value, (int) Energy.active_power[0]); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Power %s, now %d"), me->value, (int) Energy.active_power[0]); } // Wh indexes (legacy) @@ -251,7 +251,7 @@ void DataCallback(struct _ValueList * me, uint8_t flags) // Base, un seul index if (ilabel == LABEL_BASE) { total = atoi(me->value); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Base:%u"), total); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Base:%u"), total); // Heures creuses/pleines calculer total } else { // Heures creuses get heures pleines @@ -269,7 +269,7 @@ void DataCallback(struct _ValueList * me, uint8_t flags) } } total = hc + hp; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: HC:%u HP:%u Total:%u"), hc, hp, total); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: HC:%u HP:%u Total:%u"), hc, hp, total); } if (!Settings.flag4.teleinfo_rawdata) { @@ -284,17 +284,17 @@ void DataCallback(struct _ValueList * me, uint8_t flags) if (!Settings.flag4.teleinfo_rawdata) { EnergyUpdateTotal(total/1000.0f, true); } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Total:%uWh"), total); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Total:%uWh"), total); } // Wh indexes (standard) else if ( ilabel == LABEL_EASF01) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: HC:%u"), atoi(me->value)); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: HC:%u"), atoi(me->value)); } else if ( ilabel == LABEL_EASF02) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: HP:%u"), atoi(me->value)); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: HP:%u"), atoi(me->value)); } // Contract subscribed (legacy) @@ -308,26 +308,26 @@ void DataCallback(struct _ValueList * me, uint8_t flags) break; } } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Contract changed, now '%s' (%d)"), me->value, contrat); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Contract changed, now '%s' (%d)"), me->value, contrat); } // Contract subscribed (standard is in clear text in value) else if (ilabel == LABEL_NGTF) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: Contract changed, now '%s'"), me->value); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: Contract changed, now '%s'"), me->value); } // Contract subscribed (Power) else if (ilabel == LABEL_ISOUSC || ilabel == LABEL_PREF) { isousc = atoi( me->value); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: ISousc set to %d"), isousc); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: ISousc set to %d"), isousc); } // Serial Number of device else if (ilabel == LABEL_ADCO || ilabel == LABEL_ADSC) { strcpy(serialNumber, me->value); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: %s set to %s"), me->name, serialNumber); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: %s set to %s"), me->name, serialNumber); } } @@ -447,20 +447,20 @@ void TInfoInit(void) tinfo_mode = TINFO_MODE_HISTORIQUE; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("TIC: inferface speed %d bps"),baudrate); + AddLog(LOG_LEVEL_DEBUG, PSTR("TIC: inferface speed %d bps"),baudrate); if (PinUsed(GPIO_TELEINFO_RX)) { uint8_t rx_pin = Pin(GPIO_TELEINFO_RX); - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: RX on GPIO%d"), rx_pin); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: RX on GPIO%d"), rx_pin); // Enable Teleinfo pin used, control it if (PinUsed(GPIO_TELEINFO_ENABLE)) { uint8_t en_pin = Pin(GPIO_TELEINFO_ENABLE); pinMode(en_pin, OUTPUT); digitalWrite(en_pin, HIGH); - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: Enable with GPIO%d"), en_pin); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: Enable with GPIO%d"), en_pin); } else { - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: always enabled")); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: always enabled")); } #ifdef ESP8266 @@ -488,13 +488,13 @@ void TInfoInit(void) //SetSerialConfig(TS_SERIAL_7E1); //TInfoSerial->setTimeout(TINFO_READ_TIMEOUT); - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: using hardware serial")); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: using hardware serial")); } else { - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: using software serial")); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: using software serial")); } #endif // ESP8266 #ifdef ESP32 - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: using ESP32 hardware serial")); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: using ESP32 hardware serial")); #endif // ESP32 // Init teleinfo tinfo.init(tinfo_mode); @@ -504,7 +504,7 @@ void TInfoInit(void) tinfo.attachNewFrame(NewFrameCallback); tinfo_found = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: Ready")); + AddLog(LOG_LEVEL_INFO, PSTR("TIC: Ready")); } } } diff --git a/tasmota/xnrg_16_iem3000.ino b/tasmota/xnrg_16_iem3000.ino index c5ad359fe..459b45a08 100644 --- a/tasmota/xnrg_16_iem3000.ino +++ b/tasmota/xnrg_16_iem3000.ino @@ -76,7 +76,7 @@ void IEM3000Every250ms(void) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, Iem3000Modbus->ReceiveCount()); if (error) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SDM: Iem3000 error %d"), error); + AddLog(LOG_LEVEL_DEBUG, PSTR("SDM: Iem3000 error %d"), error); } else { Energy.data_valid[0] = 0; diff --git a/tasmota/xnrg_17_ornowe517.ino b/tasmota/xnrg_17_ornowe517.ino index d77114002..9dccd8b94 100644 --- a/tasmota/xnrg_17_ornowe517.ino +++ b/tasmota/xnrg_17_ornowe517.ino @@ -82,7 +82,7 @@ void WE517Every250ms(void) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, We517Modbus->ReceiveCount()); if (error) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ORNO: WE517 error %d"), error); + AddLog(LOG_LEVEL_DEBUG, PSTR("ORNO: WE517 error %d"), error); } else { Energy.data_valid[0] = 0; Energy.data_valid[1] = 0; @@ -188,7 +188,7 @@ void We517SnsInit(void) uint8_t result = We517Modbus->Begin(WE517_SPEED); if (result) { if (2 == result) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("ORNO: WE517 HW serial init 8E1 at %d baud"), WE517_SPEED); + AddLog(LOG_LEVEL_DEBUG, PSTR("ORNO: WE517 HW serial init 8E1 at %d baud"), WE517_SPEED); Serial.begin(WE517_SPEED, SERIAL_8E1); ClaimSerial(); } diff --git a/tasmota/xsns_01_counter.ino b/tasmota/xsns_01_counter.ino index 77d630851..ef3b13e4c 100644 --- a/tasmota/xsns_01_counter.ino +++ b/tasmota/xsns_01_counter.ino @@ -264,7 +264,7 @@ void SyncACDimmer(void) #ifdef ESP32 analogWrite(Pin(GPIO_PWM1, i), 5); #endif // ESP32 - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("CNT: [%d] dimm_time_CCs %d, current_cycle_CC: %d, timelag %lu, lastcc %lu, currentSteps %d, curr %d"), i, ac_zero_cross_dimmer.dimm_timeClockCycles,ac_zero_cross_dimmer.current_cycle_ClockCycles , timelag_ClockCycles, ac_zero_cross_dimmer.currentCycleCount, ac_zero_cross_dimmer.currentSteps, Light.fade_cur_10[i]); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("CNT: [%d] dimm_time_CCs %d, current_cycle_CC: %d, timelag %lu, lastcc %lu, currentSteps %d, curr %d"), i, ac_zero_cross_dimmer.dimm_timeClockCycles,ac_zero_cross_dimmer.current_cycle_ClockCycles , timelag_ClockCycles, ac_zero_cross_dimmer.currentCycleCount, ac_zero_cross_dimmer.currentSteps, Light.fade_cur_10[i]); } } } diff --git a/tasmota/xsns_02_analog.ino b/tasmota/xsns_02_analog.ino index 239f461c5..c0db2c1e5 100644 --- a/tasmota/xsns_02_analog.ino +++ b/tasmota/xsns_02_analog.ino @@ -105,10 +105,10 @@ #define ANALOG_PH_CALSOLUTION_LOW_PH 4.0 #define ANALOG_PH_CALSOLUTION_LOW_ANALOG_VALUE 282 // Default values for calibration solution with higher PH -#define ANALOG_PH_CALSOLUTION_HIGH_PH 9.18 +#define ANALOG_PH_CALSOLUTION_HIGH_PH 9.18 #define ANALOG_PH_CALSOLUTION_HIGH_ANALOG_VALUE 435 -// Multiplier used to store pH with 2 decimal places in a non decimal datatype +// Multiplier used to store pH with 2 decimal places in a non decimal datatype #define ANALOG_PH_DECIMAL_MULTIPLIER 100.0 struct { @@ -343,14 +343,14 @@ float AdcGetPh(uint32_t idx) { float m = (y2 - y1) / (x2 - x1); float ph = m * (adc - x1) + y1; - - + + char phLow_chr[6]; char phHigh_chr[6]; dtostrfd(y1, 2, phLow_chr); dtostrfd(y2, 2, phHigh_chr); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Analog pH read. ADC-RAW: %d, cal-low(pH=ADC): %s=%d, cal-high(pH=ADC): %s=%d"), adc, phLow_chr, x1, phHigh_chr,x2); - + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Analog pH read. ADC-RAW: %d, cal-low(pH=ADC): %s=%d, cal-high(pH=ADC): %s=%d"), adc, phLow_chr, x1, phHigh_chr,x2); + return ph; } @@ -560,7 +560,7 @@ void AdcShow(bool json) { char ph_chr[6]; dtostrfd(ph, 2, ph_chr); - + if (json) { AdcShowContinuation(&jsonflg); ResponseAppend_P(PSTR("\"pH%d\":%s"), idx + offset, ph_chr); @@ -618,13 +618,13 @@ void CmndAdcParam(void) { char *phHigh_chr = subStr(sub_string, XdrvMailbox.data, ",", 4); float phLow = CharToFloat(phLow_chr); float phHigh = CharToFloat(phHigh_chr); - + Adc[idx].param1 = phLow * ANALOG_PH_DECIMAL_MULTIPLIER; Adc[idx].param2 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 3), nullptr, 10); Adc[idx].param3 = phHigh * ANALOG_PH_DECIMAL_MULTIPLIER; Adc[idx].param4 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 5), nullptr, 10); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Analog pH probe calibrated. cal-low(pH=ADC): %s=%d, cal-high(pH=ADC): %s=%d"), phLow_chr, Adc[idx].param2, phHigh_chr, Adc[idx].param4); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Analog pH probe calibrated. cal-low(pH=ADC): %s=%d, cal-high(pH=ADC): %s=%d"), phLow_chr, Adc[idx].param2, phHigh_chr, Adc[idx].param4); } if (ADC_CT_POWER == XdrvMailbox.payload) { diff --git a/tasmota/xsns_04_snfsc.ino b/tasmota/xsns_04_snfsc.ino index 38f693c30..545c39e7a 100644 --- a/tasmota/xsns_04_snfsc.ino +++ b/tasmota/xsns_04_snfsc.ino @@ -62,7 +62,7 @@ void SonoffScSend(const char *data) { Serial.write(data); Serial.write('\x1B'); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_SERIAL D_TRANSMIT " %s"), data); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_SERIAL D_TRANSMIT " %s"), data); } void SonoffScInit(void) @@ -78,7 +78,7 @@ void SonoffScSerialInput(char *rcvstat) char *str; uint16_t value[5] = { 0 }; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_SERIAL D_RECEIVED " %s"), rcvstat); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_SERIAL D_RECEIVED " %s"), rcvstat); if (!strncasecmp_P(rcvstat, PSTR("AT+UPDATE="), 10)) { int8_t i = -1; diff --git a/tasmota/xsns_05_ds18x20.ino b/tasmota/xsns_05_ds18x20.ino index eafe668de..876d328be 100644 --- a/tasmota/xsns_05_ds18x20.ino +++ b/tasmota/xsns_05_ds18x20.ino @@ -344,7 +344,7 @@ void Ds18x20Init(void) } } } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSORS_FOUND " %d"), ds18x20_sensors); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSORS_FOUND " %d"), ds18x20_sensors); } void Ds18x20Convert(void) @@ -429,7 +429,7 @@ bool Ds18x20Read(uint8_t sensor) } } } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSOR_CRC_ERROR)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSOR_CRC_ERROR)); return false; } diff --git a/tasmota/xsns_05_ds18x20_esp32.ino b/tasmota/xsns_05_ds18x20_esp32.ino index ec0226c9b..8e2b20504 100644 --- a/tasmota/xsns_05_ds18x20_esp32.ino +++ b/tasmota/xsns_05_ds18x20_esp32.ino @@ -58,7 +58,7 @@ void Ds18x20Init(void) { ds = new OneWire(Pin(GPIO_DSB)); Ds18x20Search(); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSORS_FOUND " %d"), ds18x20_sensors); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSORS_FOUND " %d"), ds18x20_sensors); } void Ds18x20Search(void) { @@ -144,7 +144,7 @@ bool Ds18x20Read(uint8_t sensor, float &t) } } } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSOR_CRC_ERROR)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSOR_CRC_ERROR)); return false; } diff --git a/tasmota/xsns_06_dht.ino b/tasmota/xsns_06_dht.ino index 3ae2ecc9d..c9eec0955 100644 --- a/tasmota/xsns_06_dht.ino +++ b/tasmota/xsns_06_dht.ino @@ -52,7 +52,7 @@ bool DhtWaitState(uint32_t sensor, uint32_t level) unsigned long timeout = micros() + 100; while (digitalRead(Dht[sensor].pin) != level) { if (TimeReachedUsec(timeout)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT D_TIMEOUT_WAITING_FOR " %s " D_PULSE), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT D_TIMEOUT_WAITING_FOR " %s " D_PULSE), (level) ? D_START_SIGNAL_HIGH : D_START_SIGNAL_LOW); return false; } @@ -149,7 +149,7 @@ bool DhtRead(uint32_t sensor) uint8_t checksum = (dht_data[0] + dht_data[1] + dht_data[2] + dht_data[3]) & 0xFF; if (dht_data[4] != checksum) { char hex_char[15]; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT D_CHECKSUM_FAILURE " %s =? %02X"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT D_CHECKSUM_FAILURE " %s =? %02X"), ToHex_P(dht_data, 5, hex_char, sizeof(hex_char), ' '), checksum); return false; } @@ -171,7 +171,7 @@ bool DhtRead(uint32_t sensor) break; } if (isnan(temperature) || isnan(humidity)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT "Invalid NAN reading")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT "Invalid NAN reading")); return false; } @@ -220,7 +220,7 @@ void DhtInit(void) snprintf_P(Dht[i].stype, sizeof(Dht[i].stype), PSTR("%s%c%02d"), Dht[i].stype, IndexSeparator(), Dht[i].pin); } } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT "(v5) " D_SENSORS_FOUND " %d"), dht_sensors); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT "(v5) " D_SENSORS_FOUND " %d"), dht_sensors); } else { dht_active = false; } diff --git a/tasmota/xsns_07_sht1x.ino b/tasmota/xsns_07_sht1x.ino index ed7bf3a1c..7d3bc06e7 100644 --- a/tasmota/xsns_07_sht1x.ino +++ b/tasmota/xsns_07_sht1x.ino @@ -86,7 +86,7 @@ bool ShtSendCommand(const uint8_t cmd) } if (ackerror) { // sht_type = 0; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_SHT1 D_SENSOR_DID_NOT_ACK_COMMAND)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_SHT1 D_SENSOR_DID_NOT_ACK_COMMAND)); } return (!ackerror); } @@ -100,7 +100,7 @@ bool ShtAwaitResult(void) } delay(20); } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_SHT1 D_SENSOR_BUSY)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_SHT1 D_SENSOR_BUSY)); // sht_type = 0; return false; } @@ -163,7 +163,7 @@ void ShtDetect(void) sht_scl_pin = Pin(GPIO_I2C_SCL); if (ShtRead()) { sht_type = 1; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_I2C D_SHT1X_FOUND)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_I2C D_SHT1X_FOUND)); } else { Wire.begin(sht_sda_pin, sht_scl_pin); sht_type = 0; diff --git a/tasmota/xsns_11_veml6070.ino b/tasmota/xsns_11_veml6070.ino index d49b229d1..83f889b09 100644 --- a/tasmota/xsns_11_veml6070.ino +++ b/tasmota/xsns_11_veml6070.ino @@ -155,11 +155,11 @@ void Veml6070UvTableInit(void) uv_risk_map[i] = ( (USE_VEML6070_RSET / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1); } else { uv_risk_map[i] = ( (VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 resistor error %d"), USE_VEML6070_RSET); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 resistor error %d"), USE_VEML6070_RSET); } #else uv_risk_map[i] = ( (VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 resistor default used %d"), VEML6070_RSET_DEFAULT); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 resistor default used %d"), VEML6070_RSET_DEFAULT); #endif } } @@ -187,7 +187,7 @@ void Veml6070ModeCmd(bool mode_cmd) uint8_t status = Wire.endTransmission(); // action on status if (!status) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 mode_cmd")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 mode_cmd")); } } @@ -231,7 +231,7 @@ double Veml6070UvRiskLevel(uint16_t uv_level) // 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); return ( risk = 99 ); - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 out of range %d"), risk); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 out of range %d"), risk); } } diff --git a/tasmota/xsns_12_ads1115.ino b/tasmota/xsns_12_ads1115.ino index 6afb1b028..2fb7d259e 100644 --- a/tasmota/xsns_12_ads1115.ino +++ b/tasmota/xsns_12_ads1115.ino @@ -245,14 +245,14 @@ void Ads1115Show(bool json) int16_t values[4]; for (uint32_t t = 0; t < sizeof(Ads1115.addresses); t++) { - //AddLog_P(LOG_LEVEL_INFO, "Logging ADS1115 %02x", Ads1115.addresses[t]); + //AddLog(LOG_LEVEL_INFO, "Logging ADS1115 %02x", Ads1115.addresses[t]); if (Ads1115.found[t]) { uint8_t old_address = Ads1115.address; Ads1115.address = Ads1115.addresses[t]; for (uint32_t i = 0; i < 4; i++) { values[i] = Ads1115GetConversion(i); - //AddLog_P(LOG_LEVEL_INFO, "Logging ADS1115 %02x (%i) = %i", Ads1115.address, i, values[i] ); + //AddLog(LOG_LEVEL_INFO, "Logging ADS1115 %02x (%i) = %i", Ads1115.address, i, values[i] ); } Ads1115.address = old_address; diff --git a/tasmota/xsns_15_mhz19.ino b/tasmota/xsns_15_mhz19.ino index a2afb267f..bfde603a1 100644 --- a/tasmota/xsns_15_mhz19.ino +++ b/tasmota/xsns_15_mhz19.ino @@ -74,7 +74,7 @@ const char kMhzModels[] PROGMEM = "|B"; const char ABC_ENABLED[] = "ABC is Enabled"; const char ABC_DISABLED[] = "ABC is Disabled"; -enum MhzCommands { MHZ_CMND_READPPM, MHZ_CMND_ABCENABLE, MHZ_CMND_ABCDISABLE, MHZ_CMND_ZEROPOINT, MHZ_CMND_RESET, MHZ_CMND_RANGE_1000, MHZ_CMND_RANGE_2000, MHZ_CMND_RANGE_3000, MHZ_CMND_RANGE_5000, MHZ_CMND_RANGE_10000 }; +enum MhzCommands { MHZ_CMND_READPPM, MHZ_CMND_ABCENABLE, MHZ_CMND_ABCDISABLE, MHZ_CMND_ZEROPOINT, MHZ_CMND_RESET, MHZ_CMND_RANGE_1000, MHZ_CMND_RANGE_2000, MHZ_CMND_RANGE_3000, MHZ_CMND_RANGE_5000 }; const uint8_t kMhzCommands[][4] PROGMEM = { // 2 3 6 7 {0x86,0x00,0x00,0x00}, // mhz_cmnd_read_ppm @@ -85,8 +85,7 @@ const uint8_t kMhzCommands[][4] PROGMEM = { {0x99,0x00,0x03,0xE8}, // mhz_cmnd_set_range_1000 {0x99,0x00,0x07,0xD0}, // mhz_cmnd_set_range_2000 {0x99,0x00,0x0B,0xB8}, // mhz_cmnd_set_range_3000 - {0x99,0x00,0x13,0x88}, // mhz_cmnd_set_range_5000 - {0x99,0x00,0x27,0x10}}; // mhz_cmnd_set_range_10000 + {0x99,0x00,0x13,0x88}}; // mhz_cmnd_set_range_5000 uint8_t mhz_type = 1; uint16_t mhz_last_ppm = 0; @@ -136,7 +135,7 @@ bool MhzCheckAndApplyFilter(uint16_t ppm, uint8_t s) if (1 == s) { return false; // S==1 => "A" version sensor bootup, do not use values. } - if (mhz_last_ppm < 400 || mhz_last_ppm > 10000) { + if (mhz_last_ppm < 400 || mhz_last_ppm > 5000) { // Prevent unrealistic values during start-up with filtering enabled. // Just assume the entered value is correct. mhz_last_ppm = ppm; @@ -201,17 +200,17 @@ void MhzEverySecond(void) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, mhz_response, counter); if (counter < 9) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "MH-Z19 comms timeout")); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "MH-Z19 comms timeout")); return; } uint8_t crc = MhzCalculateChecksum(mhz_response); if (mhz_response[8] != crc) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "MH-Z19 crc error")); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "MH-Z19 crc error")); return; } if (0xFF != mhz_response[0] || 0x86 != mhz_response[1]) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "MH-Z19 bad response")); +// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "MH-Z19 bad response")); return; } @@ -270,7 +269,6 @@ void MhzEverySecond(void) #define D_JSON_RANGE_2000 "2000 ppm range" #define D_JSON_RANGE_3000 "3000 ppm range" #define D_JSON_RANGE_5000 "5000 ppm range" -#define D_JSON_RANGE_10000 "10000 ppm range" bool MhzCommandSensor(void) { @@ -311,10 +309,6 @@ bool MhzCommandSensor(void) MhzSendCmd(MHZ_CMND_RANGE_5000); Response_P(S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, D_JSON_RANGE_5000); break; - case 10000: - MhzSendCmd(MHZ_CMND_RANGE_10000); - Response_P(S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, D_JSON_RANGE_10000); - break; default: if (!Settings.SensorBits1.mhz19b_abc_disable) { Response_P(S_JSON_SENSOR_INDEX_SVALUE, XSNS_15, ABC_ENABLED); diff --git a/tasmota/xsns_17_senseair.ino b/tasmota/xsns_17_senseair.ino index 8d705648b..ea6ba683b 100644 --- a/tasmota/xsns_17_senseair.ino +++ b/tasmota/xsns_17_senseair.ino @@ -70,16 +70,16 @@ void Senseair250ms(void) // Every 250 mSec if (data_ready) { uint8_t error = SenseairModbus->Receive16BitRegister(&value); if (error) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir response error %d"), error); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir response error %d"), error); } else { switch(senseair_read_state) { case 0: // 0x1A (26) READ_TYPE_LOW - S8: fe 04 02 01 77 ec 92 senseair_type = 2; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir type id low %04X"), value); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir type id low %04X"), value); break; case 1: // 0x00 (0) READ_ERRORLOG - fe 04 02 00 00 ad 24 if (value) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir error %04X"), value); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir error %04X"), value); } break; case 2: // 0x03 (3) READ_CO2 - fe 04 02 06 2c af 59 @@ -97,11 +97,11 @@ void Senseair250ms(void) // Every 250 mSec case 5: // 0x1C (28) READ_RELAY_STATE - S8: fe 04 02 01 54 ad 4b - firmware version { bool relay_state = value >> 8 & 1; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir relay state %d"), relay_state); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir relay state %d"), relay_state); break; } case 6: // 0x0A (10) READ_TEMP_ADJUSTMENT - S8: fe 84 02 f2 f1 - Illegal Data Address - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir temp adjustment %d"), value); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir temp adjustment %d"), value); break; } } diff --git a/tasmota/xsns_18_pms5003.ino b/tasmota/xsns_18_pms5003.ino index 1126aeb95..d689c5a41 100644 --- a/tasmota/xsns_18_pms5003.ino +++ b/tasmota/xsns_18_pms5003.ino @@ -145,7 +145,7 @@ bool PmsReadData(void) #else if (sum != buffer_u16[14]) { #endif // PMS_MODEL_PMS3003 - AddLog_P(LOG_LEVEL_DEBUG, PSTR("PMS: " D_CHECKSUM_FAILURE)); + AddLog(LOG_LEVEL_DEBUG, PSTR("PMS: " D_CHECKSUM_FAILURE)); return false; } diff --git a/tasmota/xsns_20_novasds.ino b/tasmota/xsns_20_novasds.ino index 8263f8a65..6f036c743 100644 --- a/tasmota/xsns_20_novasds.ino +++ b/tasmota/xsns_20_novasds.ino @@ -82,7 +82,7 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor } // char hex_char[60]; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SDS: Send %s"), ToHex_P((unsigned char*)novasds_cmnd, 19, hex_char, sizeof(hex_char), ' ')); +// AddLog(LOG_LEVEL_DEBUG, PSTR("SDS: Send %s"), ToHex_P((unsigned char*)novasds_cmnd, 19, hex_char, sizeof(hex_char), ' ')); // send cmnd NovaSdsSerial->write(novasds_cmnd, sizeof(novasds_cmnd)); @@ -115,7 +115,7 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor // checksum & tail check if ((0xAB != recbuf[9] ) || (recbuf[8] != ((recbuf[2] + recbuf[3] + recbuf[4] + recbuf[5] + recbuf[6] + recbuf[7]) & 0xFF))) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SDS: " D_CHECKSUM_FAILURE)); + AddLog(LOG_LEVEL_DEBUG, PSTR("SDS: " D_CHECKSUM_FAILURE)); return false; } diff --git a/tasmota/xsns_21_sgp30.ino b/tasmota/xsns_21_sgp30.ino index 11059d5d4..73b6e2d78 100644 --- a/tasmota/xsns_21_sgp30.ino +++ b/tasmota/xsns_21_sgp30.ino @@ -47,7 +47,7 @@ void sgp30_Init(void) if (sgp.begin()) { sgp30_type = true; -// AddLog_P(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, PSTR("SGP: Serialnumber 0x%04X-0x%04X-0x%04X"), sgp.serialnumber[0], sgp.serialnumber[1], sgp.serialnumber[2]); I2cSetActiveFound(SGP30_ADDRESS, "SGP30"); } } @@ -97,7 +97,7 @@ void Sgp30Update(void) // Perform every second to ensure proper operation of th uint16_t eCO2_base; if (!sgp.getIAQBaseline(&eCO2_base, &TVOC_base)) return; // Failed to get baseline readings -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("SGP: Baseline values eCO2 0x%04X, TVOC 0x%04X"), eCO2_base, TVOC_base); +// AddLog(LOG_LEVEL_DEBUG, PSTR("SGP: Baseline values eCO2 0x%04X, TVOC 0x%04X"), eCO2_base, TVOC_base); } } diff --git a/tasmota/xsns_22_sr04.ino b/tasmota/xsns_22_sr04.ino index 3a075e1e1..f2659f294 100644 --- a/tasmota/xsns_22_sr04.ino +++ b/tasmota/xsns_22_sr04.ino @@ -71,7 +71,7 @@ uint8_t Sr04TModeDetect(void) } } - AddLog_P(LOG_LEVEL_INFO,PSTR("SR04: Mode %d"), sr04_type); + AddLog(LOG_LEVEL_INFO,PSTR("SR04: Mode %d"), sr04_type); return sr04_type; } @@ -123,7 +123,7 @@ uint16_t Sr04TMode2Distance(void) //check crc sum if (crc != sonar_serial->read()) { - AddLog_P(LOG_LEVEL_ERROR,PSTR("SR04: Reading CRC error.")); + AddLog(LOG_LEVEL_ERROR,PSTR("SR04: Reading CRC error.")); return NO_ECHO; } //DEBUG_SENSOR_LOG(PSTR("SR04: Distance: %d"), distance); @@ -156,7 +156,7 @@ void Sr04TReading(void) { } #ifdef USE_WEBSERVER -const char HTTP_SNS_DISTANCE[] PROGMEM = +const char HTTP_SNS_DISTANCE_CM[] PROGMEM = "{s}SR04 " D_DISTANCE "{m}%s" D_UNIT_CENTIMETER "{e}"; // {s} = , {m} = , {e} = #endif // USE_WEBSERVER @@ -176,7 +176,7 @@ void Sr04Show(bool json) #endif // USE_DOMOTICZ #ifdef USE_WEBSERVER } else { - WSContentSend_PD(HTTP_SNS_DISTANCE, distance_chr); + WSContentSend_PD(HTTP_SNS_DISTANCE_CM, distance_chr); #endif // USE_WEBSERVER } } diff --git a/tasmota/xsns_27_apds9960.ino b/tasmota/xsns_27_apds9960.ino index 2489329ac..2138015fd 100644 --- a/tasmota/xsns_27_apds9960.ino +++ b/tasmota/xsns_27_apds9960.ino @@ -1437,7 +1437,7 @@ int16_t readGesture(void) { 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 APDS9960_overload = true; // we report this as "long"-gesture - AddLog_P(LOG_LEVEL_DEBUG, PSTR("Sensor overload")); + AddLog(LOG_LEVEL_DEBUG, PSTR("Sensor overload")); } gesture_loop_counter += 1; @@ -1453,7 +1453,7 @@ int16_t readGesture(void) { fifo_level = I2cRead8(APDS9960_I2C_ADDR, APDS9960_GFLVL); #ifdef USE_DEBUG_DRIVER - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DRV: FIFO Level : %d"), fifo_level); + AddLog(LOG_LEVEL_DEBUG, PSTR("DRV: FIFO Level : %d"), fifo_level); #endif // USE_DEBUG_DRIVER /* If there's stuff in the FIFO, read it into our data block */ @@ -1471,7 +1471,7 @@ int16_t readGesture(void) { for ( i = 0; i < bytes_read; i++ ) { ptr += sprintf(ptr, "%02X", fifo_data[i]); } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DRV: FIFO Dump : %s"), output); + AddLog(LOG_LEVEL_DEBUG, PSTR("DRV: FIFO Dump : %s"), output); #endif // USE_DEBUG_DRIVER /* If at least 1 set of data, sort the data into U/D/L/R */ @@ -1745,27 +1745,27 @@ void handleGesture(void) { if (isGestureAvailable()) { switch (readGesture()) { case DIR_UP: - AddLog_P(LOG_LEVEL_DEBUG, GESTURE_UP); + AddLog(LOG_LEVEL_DEBUG, GESTURE_UP); snprintf_P(currentGesture, sizeof(currentGesture), GESTURE_UP); break; case DIR_DOWN: - AddLog_P(LOG_LEVEL_DEBUG, GESTURE_DOWN); + AddLog(LOG_LEVEL_DEBUG, GESTURE_DOWN); snprintf_P(currentGesture, sizeof(currentGesture), GESTURE_DOWN); break; case DIR_LEFT: - AddLog_P(LOG_LEVEL_DEBUG, GESTURE_LEFT); + AddLog(LOG_LEVEL_DEBUG, GESTURE_LEFT); snprintf_P(currentGesture, sizeof(currentGesture), GESTURE_LEFT); break; case DIR_RIGHT: - AddLog_P(LOG_LEVEL_DEBUG, GESTURE_RIGHT); + AddLog(LOG_LEVEL_DEBUG, GESTURE_RIGHT); snprintf_P(currentGesture, sizeof(currentGesture), GESTURE_RIGHT); break; default: if (APDS9960_overload) { - AddLog_P(LOG_LEVEL_DEBUG, GESTURE_LONG); + AddLog(LOG_LEVEL_DEBUG, GESTURE_LONG); snprintf_P(currentGesture, sizeof(currentGesture), GESTURE_LONG); } else { - AddLog_P(LOG_LEVEL_DEBUG, GESTURE_NONE); + AddLog(LOG_LEVEL_DEBUG, GESTURE_NONE); snprintf_P(currentGesture, sizeof(currentGesture), GESTURE_NONE); } break; @@ -1812,7 +1812,7 @@ void APDS9960_detect(void) { #ifdef USE_DEBUG_DRIVER // Debug new chip - AddLog_P(LOG_LEVEL_DEBUG, PSTR("DRV: %s Chip %X"), APDS9960_TAG, APDS9960_type); + AddLog(LOG_LEVEL_DEBUG, PSTR("DRV: %s Chip %X"), APDS9960_TAG, APDS9960_type); #endif // USE_DEBUG_DRIVER if (APDS9960_type == APDS9960_CHIPID_1 || APDS9960_type == APDS9960_CHIPID_2 || APDS9960_type == APDS9960_CHIPID_3) { diff --git a/tasmota/xsns_29_mcp230xx.ino b/tasmota/xsns_29_mcp230xx.ino index 56427278d..d973f1b77 100644 --- a/tasmota/xsns_29_mcp230xx.ino +++ b/tasmota/xsns_29_mcp230xx.ino @@ -514,7 +514,7 @@ bool MCP230xx_Command(void) if (Settings.mcp230xx_config[pin].int_count_en) { Settings.mcp230xx_config[pin].int_count_en=0; MCP230xx_CheckForIntCounter(); - AddLog_P(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled INTCNT for pin D%i"),pin); + AddLog(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled INTCNT for pin D%i"),pin); } Response_P(MCP230XX_INTCFG_RESPONSE,"DEF",pin,Settings.mcp230xx_config[pin].int_report_defer); // "{\"MCP230xx_INT%s\":{\"D_%i\":%i}}"; return serviced; @@ -552,14 +552,14 @@ bool MCP230xx_Command(void) Settings.mcp230xx_config[pin].int_count_en=intcnt; if (Settings.mcp230xx_config[pin].int_report_defer) { Settings.mcp230xx_config[pin].int_report_defer=0; - AddLog_P(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled INTDEF for pin D%i"),pin); + AddLog(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled INTDEF for pin D%i"),pin); } if (Settings.mcp230xx_config[pin].int_report_mode < 3) { Settings.mcp230xx_config[pin].int_report_mode=3; - AddLog_P(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled immediate interrupt/telemetry reporting for pin D%i"),pin); + AddLog(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled immediate interrupt/telemetry reporting for pin D%i"),pin); } if ((Settings.mcp230xx_config[pin].int_count_en) && (!Settings.mcp230xx_int_timer)) { - AddLog_P(LOG_LEVEL_INFO, PSTR("*** WARNING *** - INTCNT enabled for pin D%i but global INTTIMER is disabled!"),pin); + AddLog(LOG_LEVEL_INFO, PSTR("*** WARNING *** - INTCNT enabled for pin D%i but global INTTIMER is disabled!"),pin); } MCP230xx_CheckForIntCounter(); // update register on whether or not we should be counting interrupts Response_P(MCP230XX_INTCFG_RESPONSE,"CNT",pin,Settings.mcp230xx_config[pin].int_count_en); // "{\"MCP230xx_INT%s\":{\"D_%i\":%i}}"; @@ -803,7 +803,7 @@ void MCP230xx_SwitchRelay() { uint8_t pin = mcp230xx_outpinmapping[i - (TasmotaGlobal.devices_present - mcp230xx_oldoutpincount)]; uint8_t pincmd = Settings.mcp230xx_config[pin].pinmode - 5; uint8_t relay_state = bitRead(XdrvMailbox.index, i); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("MCP: relay %d pin_no %d state %d"), i,pin, relay_state); + AddLog(LOG_LEVEL_DEBUG, PSTR("MCP: relay %d pin_no %d state %d"), i,pin, relay_state); switch (relay_state) { case 1: MCP230xx_SetOutPin(pin,abs(pincmd-1)); diff --git a/tasmota/xsns_30_mpr121.ino b/tasmota/xsns_30_mpr121.ino index 9053f39bd..8523c5bdd 100644 --- a/tasmota/xsns_30_mpr121.ino +++ b/tasmota/xsns_30_mpr121.ino @@ -293,7 +293,7 @@ void Mpr121Init(struct mpr121 *pS, bool initial) // Check if sensor is running pS->running[i] = (0x00 != I2cRead8(pS->i2c_addr[i], MPR121_ECR_REG)); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_I2C "MPR121%c: %sRunning"), pS->id[i], (pS->running[i]) ? "" : "NOT"); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_I2C "MPR121%c: %sRunning"), pS->id[i], (pS->running[i]) ? "" : "NOT"); } else { @@ -305,7 +305,7 @@ void Mpr121Init(struct mpr121 *pS, bool initial) // Display no sensor found message if (!(pS->connected[0] || pS->connected[1] || pS->connected[2] || pS->connected[3])) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_I2C "MPR121: No sensors found")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_I2C "MPR121: No sensors found")); } } // void Mpr121Init(struct mpr121 *s) @@ -334,7 +334,7 @@ void Mpr121Show(struct mpr121 *pS, uint8_t function) // Read data if (!I2cValidRead16LE(&pS->current[i], pS->i2c_addr[i], MPR121_ELEX_REG)) { - AddLog_P(LOG_LEVEL_ERROR, PSTR(D_LOG_I2C "MPR121%c: ERROR: Cannot read data!"), pS->id[i]); + AddLog(LOG_LEVEL_ERROR, PSTR(D_LOG_I2C "MPR121%c: ERROR: Cannot read data!"), pS->id[i]); Mpr121Init(pS, false); return; } @@ -343,7 +343,7 @@ void Mpr121Show(struct mpr121 *pS, uint8_t function) // Clear OVCF bit I2cWrite8(pS->i2c_addr[i], MPR121_ELEX_REG, 0x00); - AddLog_P(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]); + AddLog(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]); Mpr121Init(pS, false); return; } diff --git a/tasmota/xsns_33_ds3231.ino b/tasmota/xsns_33_ds3231.ino index 92254268c..a667d3ad1 100644 --- a/tasmota/xsns_33_ds3231.ino +++ b/tasmota/xsns_33_ds3231.ino @@ -142,7 +142,7 @@ void DS3231EverySecond(void) RtcTime.year = tmpTime.year + 1970; Rtc.daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year); Rtc.standard_time = RuleToTime(Settings.tflag[0], RtcTime.year); - AddLog_P(LOG_LEVEL_INFO, PSTR("Set time from DS3231 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), + AddLog(LOG_LEVEL_INFO, PSTR("Set time from DS3231 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str()); if (Rtc.local_time < START_VALID_TIME) { // 2016-01-01 TasmotaGlobal.rules_flag.time_init = 1; @@ -151,7 +151,7 @@ void DS3231EverySecond(void) } } else if (!ds3231WriteStatus && Rtc.utc_time > START_VALID_TIME && abs(Rtc.utc_time - ReadFromDS3231()) > 60) {//if time is valid and is drift from RTC in more that 60 second - AddLog_P(LOG_LEVEL_INFO, PSTR("Write Time TO DS3231 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), + AddLog(LOG_LEVEL_INFO, PSTR("Write Time TO DS3231 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), GetDateAndTime(DT_UTC).c_str(), GetDateAndTime(DT_DST).c_str(), GetDateAndTime(DT_STD).c_str()); SetDS3231Time (Rtc.utc_time); //update the DS3231 time ds3231WriteStatus = true; diff --git a/tasmota/xsns_34_hx711.ino b/tasmota/xsns_34_hx711.ino index 7dc9da3d7..aeb54f542 100644 --- a/tasmota/xsns_34_hx711.ino +++ b/tasmota/xsns_34_hx711.ino @@ -490,7 +490,7 @@ void HandleHxAction(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_HX711)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_HX711)); if (Webserver->hasArg("save")) { HxSaveSettings(); @@ -549,7 +549,7 @@ void HxLogUpdates(void) char weigth_item_chr[33]; dtostrfd((float)Settings.weight_item / 10000, 4, weigth_item_chr); - AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_JSON_WEIGHT_REF " %s, " D_JSON_WEIGHT_ITEM " %s"), weigth_ref_chr, weigth_item_chr); + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_JSON_WEIGHT_REF " %s, " D_JSON_WEIGHT_ITEM " %s"), weigth_ref_chr, weigth_item_chr); } #endif // USE_HX711_GUI diff --git a/tasmota/xsns_36_mgc3130.ino b/tasmota/xsns_36_mgc3130.ino index c68714419..584b214d2 100644 --- a/tasmota/xsns_36_mgc3130.ino +++ b/tasmota/xsns_36_mgc3130.ino @@ -247,31 +247,31 @@ void MGC3130_handleGesture(){ } switch(MGC_data.out.gestureInfo.gestureCode){ case MGC3130_GESTURE_GARBAGE: - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("NONE")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("NONE")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("NONE")); break; case MGC3130_FLICK_WEST_EAST: - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_WE"), edge); + //AddLog(LOG_LEVEL_DEBUG, PSTR("%sFL_WE"), edge); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_WE"), edge); break; case MGC3130_FLICK_EAST_WEST: - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_EW"), edge); + //AddLog(LOG_LEVEL_DEBUG, PSTR("%sFL_EW"), edge); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_EW"), edge); break; case MGC3130_FLICK_SOUTH_NORTH: - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_SN"), edge); + //AddLog(LOG_LEVEL_DEBUG, PSTR("%sFL_SN"), edge); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_SN"), edge); break; case MGC3130_FLICK_NORTH_SOUTH: - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_NS"), edge); + //AddLog(LOG_LEVEL_DEBUG, PSTR("%sFL_NS"), edge); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_NS"), edge); break; case MGC3130_CIRCLE_CLOCKWISE: - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("CW")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("CW")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("CW")); break; case MGC3130_CIRCLE_CCLOCKWISE: - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("CCW")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("CCW")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("CCW")); break; } @@ -280,101 +280,101 @@ void MGC3130_handleGesture(){ bool MGC3130_handleTouch(){ bool success = false; // if we find a touch of higher order, we are done if (MGC_data.out.touchInfo.doubleTapCentre && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_CENTRE")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("DTAP_CENTRE")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_C")); MGC3130_touchTimeout = 5; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.doubleTapEast && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_EAST")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("DTAP_EAST")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_E")); MGC3130_touchTimeout = 5; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.doubleTapNorth && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_NORTH")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("DTAP_NORTH")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_N")); MGC3130_touchTimeout = 5; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.doubleTapWest && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_WEST")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("DTAP_WEST")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_W")); MGC3130_touchTimeout = 5; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.doubleTapSouth && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_SOUTH")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("DTAP_SOUTH")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_S")); MGC3130_touchTimeout = 5; success = true; MGC3130_touchCounter = 1; } if (MGC_data.out.touchInfo.tapCentre && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_CENTRE")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("TAP_CENTRE")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_C")); MGC3130_touchTimeout = 2; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.tapEast && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_EAST")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("TAP_EAST")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_E")); MGC3130_touchTimeout = 2; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.tapNorth && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_NORTH")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("TAP_NORTH")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_N")); MGC3130_touchTimeout = 2; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.tapWest && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_WEST")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("TAP_WEST")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_W")); MGC3130_touchTimeout = 2; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.tapSouth && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_SOUTH")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("TAP_SOUTH")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_S")); MGC3130_touchTimeout = 2; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.touchCentre && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_CENTRE")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("TOUCH_CENTRE")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_C")); success = true; MGC3130_touchCounter++; // This will reset to 0 after touching for approx. 1h and 50 minutes ;) } else if (MGC_data.out.touchInfo.touchEast && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_EAST")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("TOUCH_EAST")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_E")); success = true; MGC3130_touchCounter++; } else if (MGC_data.out.touchInfo.touchNorth && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_NORTH")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("TOUCH_NORTH")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_N")); success = true; MGC3130_touchCounter++; } else if (MGC_data.out.touchInfo.touchWest && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_WEST")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("TOUCH_WEST")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_W")); success = true; MGC3130_touchCounter++; } else if (MGC_data.out.touchInfo.touchSouth && !success){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_SOUTH")); + //AddLog(LOG_LEVEL_DEBUG, PSTR("TOUCH_SOUTH")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_S")); success = true; MGC3130_touchCounter++; @@ -396,7 +396,7 @@ void MGC3130_handleAirWheel(){ } void MGC3130_handleSystemStatus(){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("MGC3130: system_status: response to ID:%02x, error code: %04x"),MGC_data.status.id, MGC_data.status.error); + AddLog(LOG_LEVEL_DEBUG,PSTR("MGC3130: system_status: response to ID:%02x, error code: %04x"),MGC_data.status.id, MGC_data.status.error); } bool MGC3130_receiveMessage(){ @@ -414,7 +414,7 @@ bool MGC3130_receiveMessage(){ loaderVersion[1] = MGC_data.fw.loaderVersion[0]; loaderVersion[0] = MGC_data.fw.loaderVersion[1]; loaderPlatform = MGC_data.fw.loaderPlatform; - AddLog_P(LOG_LEVEL_INFO,PSTR("MGC3130: GestIC:%s"),MGC_data.fw.fwVersion); + AddLog(LOG_LEVEL_INFO,PSTR("MGC3130: GestIC:%s"),MGC_data.fw.fwVersion); break; } MGC_data.out.id = 0; @@ -443,7 +443,7 @@ bool MGC3130_readData() uint8_t _mismatch = MGC_data.out.counter - _lastCounter; if(_mismatch != 1){ if(i>4 && MGC_data.out.id != MGC3130_FW_VERSION){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("MGC3130: missed a packet, mismatch: %u"), _mismatch - 1); + AddLog(LOG_LEVEL_DEBUG,PSTR("MGC3130: missed a packet, mismatch: %u"), _mismatch - 1); AddLogBuffer(LOG_LEVEL_DEBUG,MGC_data.buffer,i); } } diff --git a/tasmota/xsns_37_rfsensor.ino b/tasmota/xsns_37_rfsensor.ino index aee5f6641..66dcf17d4 100644 --- a/tasmota/xsns_37_rfsensor.ino +++ b/tasmota/xsns_37_rfsensor.ino @@ -619,7 +619,7 @@ void RfSnsInit(void) void RfSnsAnalyzeRawSignal(void) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("RFS: Pulses %d"), (int)rfsns_raw_signal->Number); + AddLog(LOG_LEVEL_DEBUG, PSTR("RFS: Pulses %d"), (int)rfsns_raw_signal->Number); #ifdef USE_THEO_V2 RfSnsAnalyzeTheov2(); diff --git a/tasmota/xsns_38_az7798.ino b/tasmota/xsns_38_az7798.ino index b063dc166..1aed89816 100644 --- a/tasmota/xsns_38_az7798.ino +++ b/tasmota/xsns_38_az7798.ino @@ -166,14 +166,14 @@ void AzEverySecond(void) AddLogBuffer(LOG_LEVEL_DEBUG_MORE, az_response, counter); if (!az_received) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 comms timeout")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 comms timeout")); return; } i = 0; while((az_response[i] != 'T') && (i < counter)) {i++;} // find the start of response if(az_response[i] != 'T') { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find start of response")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find start of response")); return; } i++; // advance to start of temperature value @@ -183,7 +183,7 @@ void AzEverySecond(void) response_substr[j++] = az_response[i++]; } if((az_response[i] != 'C') && (az_response[i] != 'F')){ - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find end of temperature")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find end of temperature")); return; } response_substr[j] = 0; // add null terminator @@ -195,12 +195,12 @@ void AzEverySecond(void) } i++; // advance to first delimiter if(az_response[i] != ':') { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error first delimiter")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error first delimiter")); return; } i++; // advance to start of CO2 if(az_response[i] != 'C') { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error start of CO2")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error start of CO2")); return; } i++; // advance to start of CO2 value @@ -210,7 +210,7 @@ void AzEverySecond(void) response_substr[j++] = az_response[i++]; } if(az_response[i] != 'p') { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find end of CO2")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find end of CO2")); return; } response_substr[j] = 0; // add null terminator @@ -220,12 +220,12 @@ void AzEverySecond(void) #endif // USE_LIGHT i += 3; // advance to second delimiter if(az_response[i] != ':') { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error second delimiter")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error second delimiter")); return; } i++; // advance to start of humidity if(az_response[i] != 'H') { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error start of humidity")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 error start of humidity")); return; } i++; // advance to start of humidity value @@ -235,7 +235,7 @@ void AzEverySecond(void) response_substr[j++] = az_response[i++]; } if(az_response[i] != '%') { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find end of humidity")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 failed to find end of humidity")); return; } response_substr[j] = 0; // add null terminator @@ -256,7 +256,7 @@ void AzEverySecond(void) } } while(((millis() - start) < AZ_READ_TIMEOUT)); az_clock_update = AZ_CLOCK_UPDATE_INTERVAL; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 clock updated")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "AZ7798 clock updated")); } else { az_clock_update--; } diff --git a/tasmota/xsns_40_pn532.ino b/tasmota/xsns_40_pn532.ino index 4e9bbdcc4..4f03f185d 100644 --- a/tasmota/xsns_40_pn532.ino +++ b/tasmota/xsns_40_pn532.ino @@ -80,7 +80,7 @@ void PN532_Init(void) { ToHex_P((unsigned char*)empty_uid, sizeof(empty_uid), Pn532.uids, sizeof(Pn532.uids)); PN532_setPassiveActivationRetries(0xFF); PN532_SAMConfig(); - AddLog_P(LOG_LEVEL_INFO,"NFC: PN532 NFC Reader detected v%u.%u",(ver>>16) & 0xFF, (ver>>8) & 0xFF); + AddLog(LOG_LEVEL_INFO,"NFC: PN532 NFC Reader detected v%u.%u",(ver>>16) & 0xFF, (ver>>8) & 0xFF); Pn532.present = true; } } @@ -429,7 +429,7 @@ void PN532_ScanForTag(void) { } if (mifareclassic_WriteDataBlock(1, card_data)) { erase_success = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Erase success")); + AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Erase success")); memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string } } @@ -438,7 +438,7 @@ void PN532_ScanForTag(void) { memcpy(&card_data,&Pn532.newdata,sizeof(card_data)); if (mifareclassic_WriteDataBlock(1, card_data)) { set_success = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data write successful")); + AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data write successful")); memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string } #else @@ -453,11 +453,11 @@ void PN532_ScanForTag(void) { card_data[Pn532.newdata_len] = '\0'; // Enforce null termination if (mifareclassic_WriteDataBlock(1, card_data)) { set_success = true; - AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data write successful")); + AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data write successful")); memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string } } else { - AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data must be alphanumeric")); + AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data must be alphanumeric")); } #endif // USE_PN532_DATA_RAW } @@ -468,12 +468,12 @@ void PN532_ScanForTag(void) { switch (Pn532.function) { case 0x01: if (!erase_success) { - AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Erase fail - exiting erase mode")); + AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Erase fail - exiting erase mode")); } break; case 0x02: if (!set_success) { - AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Write failed - exiting set mode")); + AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Write failed - exiting set mode")); } default: break; @@ -509,7 +509,7 @@ bool PN532_Command(void) { UpperCase(XdrvMailbox.data,XdrvMailbox.data); if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"E")) { Pn532.function = 1; // Block 1 of next card/tag will be reset to 0x00... - AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be erased")); + AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be erased")); ResponseTime_P(PSTR(",\"PN532\":{\"COMMAND\":\"E\"}}")); return serviced; } @@ -525,7 +525,7 @@ bool PN532_Command(void) { memcpy(&Pn532.newdata,&sub_string_tmp,Pn532.newdata_len); Pn532.newdata[Pn532.newdata_len] = 0x00; // Null terminate the string Pn532.function = 2; - AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be set to '%s'"), Pn532.newdata); + AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be set to '%s'"), Pn532.newdata); ResponseTime_P(PSTR(",\"PN532\":{\"COMMAND\":\"S\"}}")); return serviced; } diff --git a/tasmota/xsns_41_max44009.ino b/tasmota/xsns_41_max44009.ino index 7eccb043e..7eaf1322d 100644 --- a/tasmota/xsns_41_max44009.ino +++ b/tasmota/xsns_41_max44009.ino @@ -75,7 +75,7 @@ void Max4409Detect(void) if ((I2cValidRead8(&buffer1, max44009_address, REG_LOWER_THRESHOLD)) && (I2cValidRead8(&buffer2, max44009_address, REG_THRESHOLD_TIMER))) { - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("MAX44009 %x: %x, %x"), max44009_address, (int)buffer1, (int)buffer2); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("MAX44009 %x: %x, %x"), max44009_address, (int)buffer1, (int)buffer2); if ((0x00 == buffer1) && (0xFF == buffer2)) { diff --git a/tasmota/xsns_42_scd30.ino b/tasmota/xsns_42_scd30.ino index 458e046aa..671b29903 100644 --- a/tasmota/xsns_42_scd30.ino +++ b/tasmota/xsns_42_scd30.ino @@ -93,7 +93,7 @@ void Scd30Detect(void) I2cSetActiveFound(SCD30_ADDRESS, "SCD30"); scd30Found = true; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SCD: FW v%d.%d"), major, minor); + AddLog(LOG_LEVEL_DEBUG, PSTR("SCD: FW v%d.%d"), major, minor); } // gets data from the sensor every 3 seconds or so to give the sensor time to gather new data diff --git a/tasmota/xsns_43_hre.ino b/tasmota/xsns_43_hre.ino index 68299b066..98e52b0ab 100644 --- a/tasmota/xsns_43_hre.ino +++ b/tasmota/xsns_43_hre.ino @@ -142,7 +142,7 @@ void hreEvery50ms(void) sync_run = 0; sync_counter = 0; hre_state = hre_syncing; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_syncing")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_syncing")); break; case hre_syncing: @@ -165,19 +165,19 @@ void hreEvery50ms(void) if (sync_counter > 1000) { hre_state = hre_sleep; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE D_ERROR)); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE D_ERROR)); } break; // Start reading the data block case hre_read: - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "sync_run:%d, sync_counter:%d"), sync_run, sync_counter); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "sync_run:%d, sync_counter:%d"), sync_run, sync_counter); read_counter = 0; parity_errors = 0; curr_start = TasmotaGlobal.uptime; memset(buff, 0, sizeof(buff)); hre_state = hre_reading; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_reading")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_reading")); // So this is intended to fall through to the hre_reading section. // it seems that if there is much of a delay between getting the sync // bits and starting the read, the HRE won't output the message we @@ -190,7 +190,7 @@ void hreEvery50ms(void) if (read_counter == 46) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "pe:%d, re:%d, buff:%s"), + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "pe:%d, re:%d, buff:%s"), parity_errors, hre_read_errors, buff); if (parity_errors == 0) { @@ -218,7 +218,7 @@ void hreEvery50ms(void) case hre_sleep: hre_usage_time = curr_start; hre_state = hre_sleeping; - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_sleeping")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_sleeping")); case hre_sleeping: // If there isn't some delay between readings, rate calculations diff --git a/tasmota/xsns_44_sps30.ino b/tasmota/xsns_44_sps30.ino index 9dd73dbcf..831b0bdba 100644 --- a/tasmota/xsns_44_sps30.ino +++ b/tasmota/xsns_44_sps30.ino @@ -143,7 +143,7 @@ void SPS30_Detect(void) uint8_t dcode[32]; sps30_get_data(SPS_CMD_GET_SERIAL,dcode,sizeof(dcode)); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("sps30 found with serial: %s"),dcode); + AddLog(LOG_LEVEL_DEBUG, PSTR("sps30 found with serial: %s"),dcode); sps30_cmd(SPS_CMD_START_MEASUREMENT); sps30_running = 1; sps30_ready = 1; diff --git a/tasmota/xsns_45_vl53l0x.ino b/tasmota/xsns_45_vl53l0x.ino index 54c49534c..1d377bd6d 100644 --- a/tasmota/xsns_45_vl53l0x.ino +++ b/tasmota/xsns_45_vl53l0x.ino @@ -25,8 +25,11 @@ * I2C Addres: 0x29 \*********************************************************************************************/ -#define XSNS_45 45 -#define XI2C_31 31 // See I2CDEVICES.md +#define XSNS_45 45 +#define XI2C_31 31 // See I2CDEVICES.md + +#define USE_VL_MEDIAN +#define USE_VL_MEDIAN_SIZE 5 // Odd number of samples median detection #include #include "VL53L0X.h" @@ -44,7 +47,6 @@ struct { void Vl53l0Detect(void) { if (!I2cSetDevice(0x29)) { return; } - if (!sensor.init()) { return; } I2cSetActiveFound(sensor.getAddress(), "VL53L0X"); @@ -61,15 +63,7 @@ void Vl53l0Detect(void) { Vl53l0x.index = 0; } -#ifdef USE_WEBSERVER -const char HTTP_SNS_VL53L0X[] PROGMEM = - "{s}VL53L0X " D_DISTANCE "{m}%d" D_UNIT_MILLIMETER "{e}"; // {s} = , {m} = , {e} = -#endif // USE_WEBSERVER - -#define USE_VL_MEDIAN - void Vl53l0Every_250MSecond(void) { - // every 200 ms uint16_t dist = sensor.readRangeContinuousMillimeters(); if ((0 == dist) || (dist > 2000)) { dist = 9999; @@ -79,18 +73,18 @@ void Vl53l0Every_250MSecond(void) { // store in ring buffer Vl53l0x.buffer[Vl53l0x.index] = dist; Vl53l0x.index++; - if (Vl53l0x.index >= 5) { + if (Vl53l0x.index >= USE_VL_MEDIAN_SIZE) { Vl53l0x.index = 0; } // sort list and take median - uint16_t tbuff[5]; + uint16_t tbuff[USE_VL_MEDIAN_SIZE]; memmove(tbuff, Vl53l0x.buffer, sizeof(tbuff)); uint16_t tmp; uint8_t flag; - for (uint32_t ocnt = 0; ocnt < 5; ocnt++) { + for (uint32_t ocnt = 0; ocnt < USE_VL_MEDIAN_SIZE; ocnt++) { flag = 0; - for (uint32_t count = 0; count < 4; count++) { + for (uint32_t count = 0; count < USE_VL_MEDIAN_SIZE -1; count++) { if (tbuff[count] > tbuff[count +1]) { tmp = tbuff[count]; tbuff[count] = tbuff[count +1]; @@ -100,7 +94,7 @@ void Vl53l0Every_250MSecond(void) { } if (!flag) { break; } } - Vl53l0x.distance = tbuff[2]; + Vl53l0x.distance = tbuff[(USE_VL_MEDIAN_SIZE -1) / 2]; #else Vl53l0x.distance = dist; #endif @@ -125,7 +119,7 @@ void Vl53l0Show(boolean json) { #endif // USE_DOMOTICZ #ifdef USE_WEBSERVER } else { - WSContentSend_PD(HTTP_SNS_VL53L0X, Vl53l0x.distance); + WSContentSend_PD(HTTP_SNS_DISTANCE, PSTR("VL53L0X"), Vl53l0x.distance); #endif } } @@ -134,8 +128,7 @@ void Vl53l0Show(boolean json) { * Interface \*********************************************************************************************/ -bool Xsns45(byte function) -{ +bool Xsns45(byte function) { if (!I2cEnabled(XI2C_31)) { return false; } bool result = false; diff --git a/tasmota/xsns_47_max31865.ino b/tasmota/xsns_47_max31865.ino index 83bef5e9a..388da057f 100644 --- a/tasmota/xsns_47_max31865.ino +++ b/tasmota/xsns_47_max31865.ino @@ -79,7 +79,7 @@ void MAX31865_GetResult(void) { rtd = max31865[i].readRTD(); MAX31865_Result[i].Rtd = rtd; MAX31865_Result[i].PtdResistance = max31865[i].rtd_to_resistance(rtd, MAX31865_REF_RES); - MAX31865_Result[i].PtdTemp = max31865[i].rtd_to_temperature(rtd, MAX31865_PTD_RES, MAX31865_REF_RES) + MAX31865_PTD_BIAS; + MAX31865_Result[i].PtdTemp = ConvertTemp(max31865[i].rtd_to_temperature(rtd, MAX31865_PTD_RES, MAX31865_REF_RES) + MAX31865_PTD_BIAS); } } } diff --git a/tasmota/xsns_48_chirp.ino b/tasmota/xsns_48_chirp.ino index 1e92d6c79..bb887cf85 100644 --- a/tasmota/xsns_48_chirp.ino +++ b/tasmota/xsns_48_chirp.ino @@ -216,13 +216,13 @@ bool ChirpSet(uint8_t addr) { chirp_timeout_count = 10; chirp_next_job = 0; if(chirp_sensor[chirp_current].version == 255){ // this should be Chirp! and it seems to need a power cycle (or RESET to GND) - AddLog_P(LOG_LEVEL_INFO, PSTR("CHIRP: wrote new address %u, please power off device"), addr); + AddLog(LOG_LEVEL_INFO, PSTR("CHIRP: wrote new address %u, please power off device"), addr); chirp_sensor[chirp_current].version == 0; // make it "invisible" } return true; } } - AddLog_P(LOG_LEVEL_INFO, PSTR("CHIRP: address %u incorrect and not used"), addr); + AddLog(LOG_LEVEL_INFO, PSTR("CHIRP: address %u incorrect and not used"), addr); return false; } @@ -241,13 +241,13 @@ bool ChirpScan() I2cSetActiveFound(address, "CHIRP"); if (chirp_found_sensors 0); } @@ -387,7 +387,7 @@ void ChirpEvery100MSecond(void) DEBUG_SENSOR_LOG(PSTR("CHIRP: timeout 1/10 sec: %u, tele: %u"), chirp_timeout_count, Settings.tele_period); } else{ - AddLog_P(LOG_LEVEL_INFO, PSTR("CHIRP: TELEPERIOD must be > 16 seconds !")); + AddLog(LOG_LEVEL_INFO, PSTR("CHIRP: TELEPERIOD must be > 16 seconds !")); // we could overwrite it to i.e. 20 seconds here } chirp_next_job = 1; // back to step 1 diff --git a/tasmota/xsns_50_paj7620.ino b/tasmota/xsns_50_paj7620.ino index 174febc7d..9df5d152e 100644 --- a/tasmota/xsns_50_paj7620.ino +++ b/tasmota/xsns_50_paj7620.ino @@ -317,7 +317,7 @@ void PAJ7620Detect(void) uint8_t PAJ7620_ver = I2cRead8(PAJ7620_ADDR,2); if (0x7620 == PAJ7620_id) { // this device ID makes sense ;) I2cSetActiveFound(PAJ7620_ADDR, PAJ7620_name); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("PAJ: ID: 0x%x and VER: %u"), PAJ7620_id, PAJ7620_ver); + AddLog(LOG_LEVEL_DEBUG, PSTR("PAJ: ID: 0x%x and VER: %u"), PAJ7620_id, PAJ7620_ver); PAJ7620_next_job = 1; // now init } else { diff --git a/tasmota/xsns_52_ibeacon.ino b/tasmota/xsns_52_ibeacon.ino index c31f64850..188ed2941 100755 --- a/tasmota/xsns_52_ibeacon.ino +++ b/tasmota/xsns_52_ibeacon.ino @@ -192,7 +192,7 @@ class ESP32BLEScanCallback : public BLEAdvertisedDeviceCallbacks uint8_t PWR = oBeacon.getSignalPower(); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: MAC: %s Major: %d Minor: %d UUID: %s Power: %d RSSI: %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: MAC: %s Major: %d Minor: %d UUID: %s Power: %d RSSI: %d"), "BLE", advertisedDevice->getAddress().toString().c_str(), Major, Minor, @@ -240,7 +240,7 @@ void ESP32StartScanTask(){ 0, /* Priority of the task */ NULL, /* Task handle. */ 0); /* Core where the task should run */ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Start scanning"),"BLE"); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Start scanning"),"BLE"); } void ESP32scanEndedCB(NimBLEScanResults results); @@ -258,25 +258,25 @@ void ESP32ScanTask(void *pvParameters){ for (;;) { vTaskDelay(10000/ portTICK_PERIOD_MS); ESP32BLEScan->clearResults(); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Clear scanning results"),"BLE"); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Clear scanning results"),"BLE"); } } void ESP32scanEndedCB(NimBLEScanResults results) { ESP32BLE.mode.runningScan = 0; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Stop scanning"),"BLE"); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Stop scanning"),"BLE"); } void ESP32StopScanTask() { ESP32BLEScan->stop(); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: Pausing scanner task"),"BLE"); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: Pausing scanner task"),"BLE"); } void ESP32ResumeScanTask() { ESP32BLE.mode.runningScan = 1; ESP32BLEScan->start(0, ESP32scanEndedCB, false); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: Resumed scanner task"),"BLE"); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: Resumed scanner task"),"BLE"); } void ESP32Init() { @@ -285,11 +285,11 @@ void ESP32Init() { TasmotaGlobal.wifi_stay_asleep = true; if (WiFi.getSleep() == false) { - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Put WiFi modem in sleep mode"),"BLE"); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Put WiFi modem in sleep mode"),"BLE"); WiFi.setSleep(true); // Sleep } - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Initializing Bluetooth..."),"BLE"); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Initializing Bluetooth..."),"BLE"); if (!ESP32BLE.mode.init) { NimBLEDevice::init(""); @@ -344,12 +344,12 @@ void esp32_every_second(void) { if (TasmotaGlobal.ota_state_flag) { if (ESP32BLE.mode.runningScan) { - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Upgrade procedure started"),"BLE"); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Upgrade procedure started"),"BLE"); ESP32StopScanTask(); } } else { if (!ESP32BLE.mode.runningScan) { - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Resuming scan"),"BLE"); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Resuming scan"),"BLE"); ESP32ResumeScanTask(); } } @@ -409,7 +409,7 @@ void hm17_sendcmd(uint8_t cmd) { hm17_sbclr(); hm17_cmd=cmd; #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("hm17cmd %d"),cmd); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("hm17cmd %d"),cmd); #endif switch (cmd) { case HM17_TEST: @@ -522,7 +522,7 @@ void hm17_decode(void) { case HM17_TEST: if (!strncmp(hm17_sbuffer,"OK",2)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("AT OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("AT OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -532,7 +532,7 @@ void hm17_decode(void) { case HM17_ROLE: if (!strncmp(hm17_sbuffer,"OK+Set:1",8)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("ROLE OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("ROLE OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -541,7 +541,7 @@ void hm17_decode(void) { case HM17_IMME: if (!strncmp(hm17_sbuffer,"OK+Set:1",8)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("IMME OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("IMME OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -550,7 +550,7 @@ void hm17_decode(void) { case HM17_IBEA: if (!strncmp(hm17_sbuffer,"OK+Set:1",8)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("IBEA OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("IBEA OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -559,7 +559,7 @@ void hm17_decode(void) { case HM17_SCAN: if (!strncmp(hm17_sbuffer,"OK+Set:5",8)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("SCAN OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("SCAN OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -568,7 +568,7 @@ void hm17_decode(void) { case HM17_RESET: if (!strncmp(hm17_sbuffer,"OK+RESET",8)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("RESET OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("RESET OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -577,7 +577,7 @@ void hm17_decode(void) { case HM17_RENEW: if (!strncmp(hm17_sbuffer,"OK+RENEW",8)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("RENEW OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("RENEW OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -587,7 +587,7 @@ void hm17_decode(void) { if (!strncmp(hm17_sbuffer,"OK+CONNA",8)) { hm17_sbclr(); #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONNA OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONNA OK")); #endif hm17_connecting=2; break; @@ -595,21 +595,21 @@ void hm17_decode(void) { if (!strncmp(hm17_sbuffer,"OK+CONNE",8)) { hm17_sbclr(); #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONNE ERROR")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONNE ERROR")); #endif break; } if (!strncmp(hm17_sbuffer,"OK+CONNF",8)) { hm17_sbclr(); #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONNF ERROR")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONNF ERROR")); #endif break; } if (hm17_connecting==2 && !strncmp(hm17_sbuffer,"OK+CONN",7)) { hm17_sbclr(); #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONN OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONN OK")); #endif hm17_connecting=3; hm17_sendcmd(HM17_TEST); @@ -624,7 +624,7 @@ void hm17_decode(void) { hm17_sbclr(); hm17_result=1; #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("DISCS OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("DISCS OK")); #endif break; } @@ -632,7 +632,7 @@ void hm17_decode(void) { hm17_sbclr(); hm17_result=1; #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("DISIS OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("DISIS OK")); #endif break; } @@ -640,7 +640,7 @@ void hm17_decode(void) { hm17_sbclr(); hm17_result=HM17_SUCESS; #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("DISCE OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("DISCE OK")); #endif hm17_scanning=0; break; @@ -650,8 +650,8 @@ void hm17_decode(void) { hm17_result=HM17_SUCESS; #ifdef IBEACON_DEBUG if (hm17_debug) { - AddLog_P(LOG_LEVEL_INFO, PSTR("NAME OK")); - AddLog_P(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]); + AddLog(LOG_LEVEL_INFO, PSTR("NAME OK")); + AddLog(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]); } #endif hm17_sbclr(); @@ -668,8 +668,8 @@ void hm17_decode(void) { hm17_result=HM17_SUCESS; #ifdef IBEACON_DEBUG if (hm17_debug) { - AddLog_P(LOG_LEVEL_INFO, PSTR("DIS0 OK")); - AddLog_P(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]); + AddLog(LOG_LEVEL_INFO, PSTR("DIS0 OK")); + AddLog(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]); } #endif hm17_sbclr(); @@ -683,9 +683,9 @@ hm17_v110: if (hm17_sindex==78) { #ifdef IBEACON_DEBUG if (hm17_debug) { - AddLog_P(LOG_LEVEL_INFO, PSTR("DISC: OK")); + AddLog(LOG_LEVEL_INFO, PSTR("DISC: OK")); //OK+DISC:4C 000C0E:003 A9144081A8 3B16849611 862EC1005: 0B1CE7485D :4DB4E940F C0E:-078 - AddLog_P(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]); + AddLog(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]); } #endif memcpy(ib.FACID,&hm17_sbuffer[8],8); @@ -704,7 +704,7 @@ hm17_v110: } } else { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR(">->%s"),&hm17_sbuffer[8]); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR(">->%s"),&hm17_sbuffer[8]); #endif } break; @@ -746,7 +746,7 @@ uint32_t difftime=millis()-hm17_lastms; if (hm17_cmd==99) { if (hm17_sindex>=HM17_BSIZ-2 || (hm17_sindex && (difftime>100))) { - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),hm17_sbuffer); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),hm17_sbuffer); hm17_sbclr(); } } diff --git a/tasmota/xsns_52_ibeacon_BLE_ESP32.ino b/tasmota/xsns_52_ibeacon_BLE_ESP32.ino index 687bf05cf..f869e6a20 100644 --- a/tasmota/xsns_52_ibeacon_BLE_ESP32.ino +++ b/tasmota/xsns_52_ibeacon_BLE_ESP32.ino @@ -46,7 +46,7 @@ char ib_mac[14]; - + struct { union { struct { @@ -167,8 +167,8 @@ int advertismentCallback(BLE_ESP32::ble_advertisment_t *pStruct) if (manufacturerDataLen){ const uint8_t *manufacturerData = (const uint8_t *)data.data(); DumpHex(manufacturerData, 2, ib.FACID); - if (manufacturerDataLen == 25 && - manufacturerData[0] == 0x4C && + if (manufacturerDataLen == 25 && + manufacturerData[0] == 0x4C && manufacturerData[1] == 0x00) { BLEBeacon oBeacon = BLEBeacon(); @@ -191,7 +191,7 @@ int advertismentCallback(BLE_ESP32::ble_advertisment_t *pStruct) // if we added it if (ibeacon_add(&ib) == 1){ - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: MAC: %s Major: %d Minor: %d UUID: %s Power: %d RSSI: %d"), + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: MAC: %s Major: %d Minor: %d UUID: %s Power: %d RSSI: %d"), "iBeacon", advertisedDevice->getAddress().toString().c_str(), Major, Minor, @@ -277,11 +277,11 @@ void esp32_every_second(void) { // if device not present at all. if (!ageS){ - //AddLog_P(LOG_LEVEL_INFO, PSTR("iBeacon no device %s %02x%02x%02x%02x%02x%02x"),tmp, mac[0],mac[1], mac[2],mac[3], mac[4],mac[5]); + //AddLog(LOG_LEVEL_INFO, PSTR("iBeacon no device %s %02x%02x%02x%02x%02x%02x"),tmp, mac[0],mac[1], mac[2],mac[3], mac[4],mac[5]); ibeacons[cnt].FLAGS=0; ibeacon_mqtt(ibeacons[cnt].MAC,"0000",ibeacons[cnt].UID,ibeacons[cnt].MAJOR,ibeacons[cnt].MINOR,ibeacons[cnt].NAME); } else { - //AddLog_P(LOG_LEVEL_INFO, PSTR("iBeacon device %s %02x%02x%02x%02x%02x%02x"),tmp, mac[0],mac[1], mac[2],mac[3], mac[4],mac[5]); + //AddLog(LOG_LEVEL_INFO, PSTR("iBeacon device %s %02x%02x%02x%02x%02x%02x"),tmp, mac[0],mac[1], mac[2],mac[3], mac[4],mac[5]); } //ibeacons[cnt].TIME++; ibeacons[cnt].REPTIME++; // counter used to send mqtt for a dev regularly @@ -332,7 +332,7 @@ void hm17_sendcmd(uint8_t cmd) { hm17_sbclr(); hm17_cmd=cmd; #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("hm17cmd %d"),cmd); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("hm17cmd %d"),cmd); #endif switch (cmd) { case HM17_TEST: @@ -383,7 +383,7 @@ uint32_t ibeacon_add(struct IBEACON *ib) { return 0; } - // don't bother protecting this. + // don't bother protecting this. //TasAutoMutex localmutex(&beaconmutex, "iBeacAdd"); // keyfob starts with ffff, ibeacon has valid facid @@ -448,7 +448,7 @@ void hm17_decode(void) { case HM17_TEST: if (!strncmp(hm17_sbuffer,"OK",2)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("AT OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("AT OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -458,7 +458,7 @@ void hm17_decode(void) { case HM17_ROLE: if (!strncmp(hm17_sbuffer,"OK+Set:1",8)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("ROLE OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("ROLE OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -467,7 +467,7 @@ void hm17_decode(void) { case HM17_IMME: if (!strncmp(hm17_sbuffer,"OK+Set:1",8)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("IMME OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("IMME OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -476,7 +476,7 @@ void hm17_decode(void) { case HM17_IBEA: if (!strncmp(hm17_sbuffer,"OK+Set:1",8)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("IBEA OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("IBEA OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -485,7 +485,7 @@ void hm17_decode(void) { case HM17_SCAN: if (!strncmp(hm17_sbuffer,"OK+Set:5",8)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("SCAN OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("SCAN OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -494,7 +494,7 @@ void hm17_decode(void) { case HM17_RESET: if (!strncmp(hm17_sbuffer,"OK+RESET",8)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("RESET OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("RESET OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -503,7 +503,7 @@ void hm17_decode(void) { case HM17_RENEW: if (!strncmp(hm17_sbuffer,"OK+RENEW",8)) { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("RENEW OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("RENEW OK")); #endif hm17_sbclr(); hm17_result=HM17_SUCESS; @@ -513,7 +513,7 @@ void hm17_decode(void) { if (!strncmp(hm17_sbuffer,"OK+CONNA",8)) { hm17_sbclr(); #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONNA OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONNA OK")); #endif hm17_connecting=2; break; @@ -521,21 +521,21 @@ void hm17_decode(void) { if (!strncmp(hm17_sbuffer,"OK+CONNE",8)) { hm17_sbclr(); #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONNE ERROR")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONNE ERROR")); #endif break; } if (!strncmp(hm17_sbuffer,"OK+CONNF",8)) { hm17_sbclr(); #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONNF ERROR")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONNF ERROR")); #endif break; } if (hm17_connecting==2 && !strncmp(hm17_sbuffer,"OK+CONN",7)) { hm17_sbclr(); #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("CONN OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("CONN OK")); #endif hm17_connecting=3; hm17_sendcmd(HM17_TEST); @@ -550,7 +550,7 @@ void hm17_decode(void) { hm17_sbclr(); hm17_result=1; #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("DISCS OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("DISCS OK")); #endif break; } @@ -558,7 +558,7 @@ void hm17_decode(void) { hm17_sbclr(); hm17_result=1; #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("DISIS OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("DISIS OK")); #endif break; } @@ -566,7 +566,7 @@ void hm17_decode(void) { hm17_sbclr(); hm17_result=HM17_SUCESS; #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR("DISCE OK")); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR("DISCE OK")); #endif hm17_scanning=0; break; @@ -576,8 +576,8 @@ void hm17_decode(void) { hm17_result=HM17_SUCESS; #ifdef IBEACON_DEBUG if (hm17_debug) { - AddLog_P(LOG_LEVEL_INFO, PSTR("NAME OK")); - AddLog_P(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]); + AddLog(LOG_LEVEL_INFO, PSTR("NAME OK")); + AddLog(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]); } #endif hm17_sbclr(); @@ -594,8 +594,8 @@ void hm17_decode(void) { hm17_result=HM17_SUCESS; #ifdef IBEACON_DEBUG if (hm17_debug) { - AddLog_P(LOG_LEVEL_INFO, PSTR("DIS0 OK")); - AddLog_P(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]); + AddLog(LOG_LEVEL_INFO, PSTR("DIS0 OK")); + AddLog(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]); } #endif hm17_sbclr(); @@ -609,9 +609,9 @@ hm17_v110: if (hm17_sindex==78) { #ifdef IBEACON_DEBUG if (hm17_debug) { - AddLog_P(LOG_LEVEL_INFO, PSTR("DISC: OK")); + AddLog(LOG_LEVEL_INFO, PSTR("DISC: OK")); //OK+DISC:4C 000C0E:003 A9144081A8 3B16849611 862EC1005: 0B1CE7485D :4DB4E940F C0E:-078 - AddLog_P(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]); + AddLog(LOG_LEVEL_INFO, PSTR(">>%s"),&hm17_sbuffer[8]); } #endif memcpy(ib.FACID,&hm17_sbuffer[8],8); @@ -630,7 +630,7 @@ hm17_v110: } } else { #ifdef IBEACON_DEBUG - if (hm17_debug) AddLog_P(LOG_LEVEL_INFO, PSTR(">->%s"),&hm17_sbuffer[8]); + if (hm17_debug) AddLog(LOG_LEVEL_INFO, PSTR(">->%s"),&hm17_sbuffer[8]); #endif } break; @@ -672,7 +672,7 @@ void IBEACON_loop() { if (hm17_cmd==99) { if (hm17_sindex>=HM17_BSIZ-2 || (hm17_sindex && (difftime>100))) { - AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),hm17_sbuffer); + AddLog(LOG_LEVEL_INFO, PSTR("%s"),hm17_sbuffer); hm17_sbclr(); } } @@ -731,7 +731,7 @@ void IBEACON_Show(void) { } // add a break line after us, if we showed anything. if (total) WSContentSend_PD(HTTP_IBEACON_HL); - + } #endif // USE_WEBSERVER diff --git a/tasmota/xsns_53_sml.ino b/tasmota/xsns_53_sml.ino index 7792de29b..dca878b29 100755 --- a/tasmota/xsns_53_sml.ino +++ b/tasmota/xsns_53_sml.ino @@ -1258,7 +1258,7 @@ void sml_shift_in(uint32_t meters,uint32_t shard) { SML_Decode(meters); } else { // crc error - //AddLog_P(LOG_LEVEL_INFO, PSTR("ebus crc error")); + //AddLog(LOG_LEVEL_INFO, PSTR("ebus crc error")); } } meter_spos[meters]=0; @@ -1539,16 +1539,16 @@ void SML_Decode(uint8_t index) { #ifdef ED300L g_mindex=mindex; #endif - if (*mp=='#') { + if (*mp == '#') { // get string value mp++; - if (meter_desc_p[mindex].type=='o') { - for (uint8_t p=0;pconfig = config; // Full scale current in tenths of an amp - //AddLog_P( LOG_LEVEL_NONE, "Full Scale I in tenths of an amp: %u", Settings.ina226_i_fs[i]); + //AddLog( LOG_LEVEL_NONE, "Full Scale I in tenths of an amp: %u", Settings.ina226_i_fs[i]); p->i_lsb = (((float) Settings.ina226_i_fs[i])/10.0f)/32768.0f; //_debug_fval("i_lsb: %s", p->i_lsb, 7); // Get shunt resistor value in micro ohms uint32_t r_shunt_uohms = _expand_r_shunt(Settings.ina226_r_shunt[i]); - //AddLog_P( LOG_LEVEL_NONE, "Shunt R in micro-ohms: %u", r_shunt_uohms); + //AddLog( LOG_LEVEL_NONE, "Shunt R in micro-ohms: %u", r_shunt_uohms); p->calibrationValue = ((uint16_t) (0.00512/(p->i_lsb * r_shunt_uohms/1000000.0f))); // Device present p->present = true; - //AddLog_P( LOG_LEVEL_NONE, "INA226 Device %d calibration value: %04X", i, p->calibrationValue); + //AddLog( LOG_LEVEL_NONE, "INA226 Device %d calibration value: %04X", i, p->calibrationValue); Ina226SetCalibration(i); @@ -336,11 +336,11 @@ float Ina226ReadPower_w(uint8_t device) void Ina226Read(uint8_t device) { - //AddLog_P( LOG_LEVEL_NONE, "Ina226Read"); + //AddLog( LOG_LEVEL_NONE, "Ina226Read"); voltages[device] = Ina226ReadBus_v(device); currents[device] = Ina226ReadShunt_i(device); powers[device] = Ina226ReadPower_w(device); - //AddLog_P( LOG_LEVEL_NONE, "INA226 Device %d", device ); + //AddLog( LOG_LEVEL_NONE, "INA226 Device %d", device ); //_debug_fval("Voltage", voltages[device]); //_debug_fval("Current", currents[device]); //_debug_fval("Power", powers[device]); @@ -352,7 +352,7 @@ void Ina226Read(uint8_t device) void Ina226EverySecond() { - //AddLog_P( LOG_LEVEL_NONE, "Ina226EverySecond"); + //AddLog( LOG_LEVEL_NONE, "Ina226EverySecond"); for (uint8_t device = 0; device < INA226_MAX_ADDRESSES; device++){ // If there are Ina226s, and the device was present, and the device still is present, read its registers if (Ina226sFound && Ina226Info[device].present && Ina226TestPresence(device)){ @@ -363,7 +363,7 @@ void Ina226EverySecond() // If device was present, note that it dropped off here //if(Ina226Info[device].present){ //reinit_count[device]++; - //AddLog_P( LOG_LEVEL_DEBUG, "INA226 Device %d dropped off, count: %d", device, reinit_count[device]); + //AddLog( LOG_LEVEL_DEBUG, "INA226 Device %d dropped off, count: %d", device, reinit_count[device]); //} // Device no longer present Ina226Info[device].present = false; @@ -384,8 +384,8 @@ bool Ina226CommandSensor() uint8_t i, param_count, device, p1 = XdrvMailbox.payload; uint32_t r_shunt_uohms; uint16_t compact_r_shunt_uohms; - //AddLog_P( LOG_LEVEL_NONE, "Command received: %d", XdrvMailbox.payload); - //AddLog_P( LOG_LEVEL_NONE, "Command data received: %s", XdrvMailbox.data); + //AddLog( LOG_LEVEL_NONE, "Command received: %d", XdrvMailbox.payload); + //AddLog( LOG_LEVEL_NONE, "Command data received: %s", XdrvMailbox.data); // Make a copy of the data and add another terminator @@ -401,7 +401,7 @@ bool Ina226CommandSensor() if (param_str[i] == ' ' || param_str[i] == ',' || param_str[i] == 0){ param_str[i] = 0; params[param_count] = cp; - //AddLog_P( LOG_LEVEL_NONE, "INA226 Command parameter: %d, value: %s", param_count, params[param_count]); + //AddLog( LOG_LEVEL_NONE, "INA226 Command parameter: %d, value: %s", param_count, params[param_count]); param_count++; cp = param_str + i + 1; } @@ -437,7 +437,7 @@ bool Ina226CommandSensor() r_shunt_uohms = (uint32_t) ((CharToFloat(params[1])) * 1000000.0f); - //AddLog_P( LOG_LEVEL_NONE, "r_shunt_uohms: %d", r_shunt_uohms); + //AddLog( LOG_LEVEL_NONE, "r_shunt_uohms: %d", r_shunt_uohms); if (r_shunt_uohms > 32767){ uint32_t r_shunt_mohms = r_shunt_uohms/1000UL; Settings.ina226_r_shunt[device] = (uint16_t) (r_shunt_mohms | 0x8000); @@ -445,13 +445,13 @@ bool Ina226CommandSensor() else Settings.ina226_r_shunt[device] = (uint16_t) r_shunt_uohms; - //AddLog_P( LOG_LEVEL_NONE, "r_shunt_compacted: %04X", Settings.ina226_r_shunt[device]); + //AddLog( LOG_LEVEL_NONE, "r_shunt_compacted: %04X", Settings.ina226_r_shunt[device]); show_config = true; break; case 2: // Set full scale current in tenths of amps from user input in Amps Settings.ina226_i_fs[device] = (uint16_t) ((CharToFloat(params[1])) * 10.0f); - //AddLog_P( LOG_LEVEL_NONE, "i_fs: %d", Settings.ina226_i_fs[device]); + //AddLog( LOG_LEVEL_NONE, "i_fs: %d", Settings.ina226_i_fs[device]); show_config = true; break; diff --git a/tasmota/xsns_59_ds1624.ino b/tasmota/xsns_59_ds1624.ino index ccc079f4c..90633724b 100644 --- a/tasmota/xsns_59_ds1624.ino +++ b/tasmota/xsns_59_ds1624.ino @@ -69,7 +69,7 @@ void DS1624_Restart(uint8_t config, uint32_t idx) { config &= ~(DS1621_CFG_DONE|DS1621_CFG_1SHOT); I2cWrite8(addr, DS1624_CONF_REGISTER, config); // 1shot off delay(10); // by spec after writing - AddLog_P(LOG_LEVEL_ERROR, "%s addr %x is reset, reconfig: %x", ds1624_sns[idx].name, addr, config); + AddLog(LOG_LEVEL_ERROR, "%s addr %x is reset, reconfig: %x", ds1624_sns[idx].name, addr, config); } I2cValidRead(addr, DS1624_START_REGISTER, 1); } @@ -94,7 +94,7 @@ void DS1624_HotPlugUp(uint32_t idx) ds1624_sns[idx].errcnt = 0; ds1624_sns[idx].misscnt = 0; DS1624_Restart(config,idx); - AddLog_P(LOG_LEVEL_INFO, "Hot Plug %s addr %x config: %x", ds1624_sns[idx].name, addr, config); + AddLog(LOG_LEVEL_INFO, "Hot Plug %s addr %x config: %x", ds1624_sns[idx].name, addr, config); } } @@ -104,7 +104,7 @@ void DS1624_HotPlugDown(int idx) if (!I2cActive(addr)) { return; } I2cResetActive(addr); ds1624_sns[idx].valid = false; - AddLog_P(LOG_LEVEL_INFO, "Hot UnPlug %s", ds1624_sns[idx].name); + AddLog(LOG_LEVEL_INFO, "Hot UnPlug %s", ds1624_sns[idx].name); } bool DS1624GetTemp(float *value, int idx) @@ -114,13 +114,13 @@ bool DS1624GetTemp(float *value, int idx) uint8_t config; if (!I2cValidRead8(&config, addr, DS1624_CONF_REGISTER)) { ds1624_sns[idx].misscnt++; - AddLog_P(LOG_LEVEL_INFO, "%s device missing (errors: %i)", ds1624_sns[idx].name, ds1624_sns[idx].misscnt); + AddLog(LOG_LEVEL_INFO, "%s device missing (errors: %i)", ds1624_sns[idx].name, ds1624_sns[idx].misscnt); return false; } ds1624_sns[idx].misscnt=0; if (config & (DS1621_CFG_1SHOT|DS1621_CFG_DONE)) { ds1624_sns[idx].errcnt++; - AddLog_P(LOG_LEVEL_INFO, "%s config error, restart... (errors: %i)", ds1624_sns[idx].name, ds1624_sns[idx].errcnt); + AddLog(LOG_LEVEL_INFO, "%s config error, restart... (errors: %i)", ds1624_sns[idx].name, ds1624_sns[idx].errcnt); DS1624_Restart(config, idx); return false; } diff --git a/tasmota/xsns_60_GPS.ino b/tasmota/xsns_60_GPS.ino index 10e02efc2..56c6f4f10 100644 --- a/tasmota/xsns_60_GPS.ino +++ b/tasmota/xsns_60_GPS.ino @@ -573,17 +573,17 @@ void UBXSelectMode(uint16_t mode) break; case 4: Flog->startRecording(true); - AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: start recording - appending")); + AddLog(LOG_LEVEL_INFO, PSTR("UBX: start recording - appending")); break; case 5: Flog->startRecording(false); - AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: start recording - new log")); + AddLog(LOG_LEVEL_INFO, PSTR("UBX: start recording - new log")); break; case 6: if(Flog->recording == true){ Flog->stopRecording(); } - AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: stop recording")); + AddLog(LOG_LEVEL_INFO, PSTR("UBX: stop recording")); break; #endif //USE_FLOG case 7: @@ -689,7 +689,7 @@ void UBXHandleTIME() gpsTime.second = UBX.Message.navTime.sec; UBX.rec_buffer.values.time = MakeTime(gpsTime); if (UBX.mode.forceUTCupdate || Rtc.user_time_entry == false){ - AddLog_P(LOG_LEVEL_INFO, PSTR("UBX: UTC-Time is valid, set system time")); + AddLog(LOG_LEVEL_INFO, PSTR("UBX: UTC-Time is valid, set system time")); Rtc.utc_time = UBX.rec_buffer.values.time; } Rtc.user_time_entry = true; @@ -702,7 +702,7 @@ void UBXHandleOther(void) if (UBX.state.non_empty_loops>6) { // we expect only 4-5 non-empty loops in a row, could change with other sensor speed (Hz) if(UBX.mode.runningVPort) return; UBXinitCFG(); // this should only happen with lots of NMEA-messages, but it is only a guess!! - AddLog_P(LOG_LEVEL_ERROR, PSTR("UBX: possible device-reset, will re-init")); + AddLog(LOG_LEVEL_ERROR, PSTR("UBX: possible device-reset, will re-init")); UBXSerial->flush(); UBX.state.non_empty_loops = 0; } diff --git a/tasmota/xsns_61_MI_NRF24.ino b/tasmota/xsns_61_MI_NRF24.ino index 8dff44920..01dc309be 100644 --- a/tasmota/xsns_61_MI_NRF24.ino +++ b/tasmota/xsns_61_MI_NRF24.ino @@ -419,7 +419,7 @@ void MINRFinit(void) { MINRF.option.minimalSummary = 0; MINRF.option.directBridgeMode = 0; - AddLog_P(LOG_LEVEL_INFO, PSTR("NRF: Started")); + AddLog(LOG_LEVEL_INFO, PSTR("NRF: Started")); } } @@ -452,7 +452,7 @@ bool MINRFinitBLE(uint8_t _mode) MINRFchangePacketModeTo(_mode); return true; } - // AddLog_P(LOG_LEVEL_INFO,PSTR("MINRF chip NOT !!!! connected")); + // AddLog(LOG_LEVEL_INFO,PSTR("MINRF chip NOT !!!! connected")); return false; } @@ -495,7 +495,7 @@ bool MINRFreceivePacket(void) MINRFswapbuf((uint8_t*)&MINRF.buffer, sizeof(MINRF.buffer) ); // MINRF_LOG_BUFFER(); - // AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: _lsfrlist: %x, chan: %u, mode: %u"),_lsfrlist[MINRF.currentChan],MINRF.currentChan, MINRF.packetMode); + // AddLog(LOG_LEVEL_INFO,PSTR("NRF: _lsfrlist: %x, chan: %u, mode: %u"),_lsfrlist[MINRF.currentChan],MINRF.currentChan, MINRF.packetMode); switch (MINRF.packetMode) { case 0: case NLIGHT: case MJYD2S: MINRFwhiten((uint8_t *)&MINRF.buffer, sizeof(MINRF.buffer), MINRF.channel[MINRF.currentChan] | 0x40); // "BEACON" mode, "NLIGHT" mode, "MJYD2S" mode @@ -603,7 +603,7 @@ void MINRFhandleScan(void){ MINRFscanResult.erase(std::remove_if(MINRFscanResult.begin(), MINRFscanResult.end(), [&i](scan_entry_t e) { - if(e.showedUp>2) AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: Beacon %02u: %02X%02X%02X%02X%02X%02X Cid: %04X Svc: %04X UUID: %04X"),i,e.MAC[0],e.MAC[1],e.MAC[2],e.MAC[3],e.MAC[4],e.MAC[5],e.cid,e.svc,e.uuid); + if(e.showedUp>2) AddLog(LOG_LEVEL_INFO,PSTR("NRF: Beacon %02u: %02X%02X%02X%02X%02X%02X Cid: %04X Svc: %04X UUID: %04X"),i,e.MAC[0],e.MAC[1],e.MAC[2],e.MAC[3],e.MAC[4],e.MAC[5],e.cid,e.svc,e.uuid); i++; return ((e.showedUp < 3)); }), @@ -616,7 +616,7 @@ void MINRFhandleScan(void){ for(uint32_t i=0; i30) break; uint32_t ADtype = _buf[i+1]; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Size: %u AD: %x i:%u"), size, ADtype,i); + // AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Size: %u AD: %x i:%u"), size, ADtype,i); if (size+i>32+offset) size=32-i+offset-2; if (size>30) break; char _stemp[(size*2)]; uint32_t backupSize; switch(ADtype){ case 0x01: - AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Flags: %02x"), _buf[i+2]); + AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Flags: %02x"), _buf[i+2]); break; case 0x02: case 0x03: entry->uuid = _buf[i+3]*256 + _buf[i+2]; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: UUID: %04x"), entry->uuid); + AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: UUID: %04x"), entry->uuid); success = true; break; case 0x08: case 0x09: backupSize = _buf[i+size+1]; _buf[i+size+1] = 0; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Name: %s"), (char*)&_buf[i+2]); + AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Name: %s"), (char*)&_buf[i+2]); success = true; _buf[i+size+1] = backupSize; break; case 0x0a: - AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: TxPow: %02u"), _buf[i+2]); + AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: TxPow: %02u"), _buf[i+2]); break; case 0xff: entry->cid = _buf[i+3]*256 + _buf[i+2]; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Cid: %04x"), entry->cid); + AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Cid: %04x"), entry->cid); ToHex_P((unsigned char*)&_buf+i+4,size-3,_stemp,(size*2)); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s"),_stemp); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s"),_stemp); success = true; break; case 0x16: entry->svc = _buf[i+3]*256 + _buf[i+2]; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Svc: %04x"), entry->svc); + AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Svc: %04x"), entry->svc); ToHex_P((unsigned char*)&_buf+i+4,size-3,_stemp,(size*2)); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s"),_stemp); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s"),_stemp); success = true; break; default: ToHex_P((unsigned char*)&_buf+i+2,size-1,_stemp,(size*2)); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s"),_stemp); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s"),_stemp); } i+=size; } @@ -732,7 +732,7 @@ void MINRFbeaconCounter(void) { /* char stemp[20]; snprintf_P(stemp, sizeof(stemp),PSTR("{%s:{\"Beacon\": %u}}"),D_CMND_NRF, MINRF.beacon.time); - AddLog_P(LOG_LEVEL_DEBUG, stemp); + AddLog(LOG_LEVEL_DEBUG, stemp); RulesProcessEvent(stemp); */ Response_P(PSTR("{%s:{\"Beacon\":%u}}"), D_CMND_NRF, MINRF.beacon.time); @@ -761,9 +761,9 @@ void MINRFcomputeBeaconPDU(uint8_t (&_MAC)[6], uint32_t (&PDU)[3], uint32_t offs #ifdef USE_MI_DECRYPTION int MINRFdecryptPacket(char *_buf){ encPacket_t *packet = (encPacket_t*)_buf; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("to decrypt: %02x %02x %02x %02x %02x %02x %02x %02x"),(uint8_t)_buf[0],(uint8_t)_buf[1],(uint8_t)_buf[2],(uint8_t)_buf[3],(uint8_t)_buf[4],(uint8_t)_buf[5],(uint8_t)_buf[6],(uint8_t)_buf[7]); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR(" : %02x %02x %02x %02x %02x %02x %02x %02x"),(uint8_t)_buf[8],(uint8_t)_buf[9],(uint8_t)_buf[10],(uint8_t)_buf[11],(uint8_t)_buf[12],(uint8_t)_buf[13],(uint8_t)_buf[14],(uint8_t)_buf[15]); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR(" : %02x %02x %02x %02x %02x "),(uint8_t)_buf[16],(uint8_t)_buf[17],(uint8_t)_buf[18],(uint8_t)_buf[19],(uint8_t)_buf[20]); + // AddLog(LOG_LEVEL_DEBUG,PSTR("to decrypt: %02x %02x %02x %02x %02x %02x %02x %02x"),(uint8_t)_buf[0],(uint8_t)_buf[1],(uint8_t)_buf[2],(uint8_t)_buf[3],(uint8_t)_buf[4],(uint8_t)_buf[5],(uint8_t)_buf[6],(uint8_t)_buf[7]); + // AddLog(LOG_LEVEL_DEBUG,PSTR(" : %02x %02x %02x %02x %02x %02x %02x %02x"),(uint8_t)_buf[8],(uint8_t)_buf[9],(uint8_t)_buf[10],(uint8_t)_buf[11],(uint8_t)_buf[12],(uint8_t)_buf[13],(uint8_t)_buf[14],(uint8_t)_buf[15]); + // AddLog(LOG_LEVEL_DEBUG,PSTR(" : %02x %02x %02x %02x %02x "),(uint8_t)_buf[16],(uint8_t)_buf[17],(uint8_t)_buf[18],(uint8_t)_buf[19],(uint8_t)_buf[20]); int ret = 0; unsigned char output[16] = {0}; @@ -781,13 +781,13 @@ int MINRFdecryptPacket(char *_buf){ uint8_t _bindkey[16] = {0x0}; for(uint32_t i=0; iMAC,MIBLEbindKeys[i].MAC,sizeof(packet->MAC))==0){ - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("have key")); + // AddLog(LOG_LEVEL_DEBUG,PSTR("have key")); memcpy(_bindkey,MIBLEbindKeys[i].key,sizeof(_bindkey)); break; } // else{ - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("MAC in packet: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("MAC in vector: %02x %02x %02x %02x %02x %02x"), MIBLEbindKeys[i].MAC[0], MIBLEbindKeys[i].MAC[1], MIBLEbindKeys[i].MAC[2], MIBLEbindKeys[i].MAC[3], MIBLEbindKeys[i].MAC[4], MIBLEbindKeys[i].MAC[5]); + // AddLog(LOG_LEVEL_DEBUG,PSTR("MAC in packet: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]); + // AddLog(LOG_LEVEL_DEBUG,PSTR("MAC in vector: %02x %02x %02x %02x %02x %02x"), MIBLEbindKeys[i].MAC[0], MIBLEbindKeys[i].MAC[1], MIBLEbindKeys[i].MAC[2], MIBLEbindKeys[i].MAC[3], MIBLEbindKeys[i].MAC[4], MIBLEbindKeys[i].MAC[5]); // } } @@ -804,7 +804,7 @@ int MINRFdecryptPacket(char *_buf){ br_ccm_run(&ctx, 0, output, sizeof(packet->payload.cipher)); ret = br_ccm_check_tag(&ctx, packet->payload.tag); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: Err:%i, Decrypted : %02x %02x %02x %02x %02x "), ret, output[0],output[1],output[2],output[3],output[4]); + AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: Err:%i, Decrypted : %02x %02x %02x %02x %02x "), ret, output[0],output[1],output[2],output[3],output[4]); memcpy((uint8_t*)(packet->payload.cipher)+1,output,sizeof(packet->payload.cipher)); return ret; } @@ -823,22 +823,22 @@ int MINRFdecryptMJYD2SPacket(char *_buf, uint8_t _light, char* _output){ memcpy((uint8_t*)&nonce+6,(uint8_t*)&packet->PID,2); nonce[8] = packet->frameCnt; memcpy((uint8_t*)&nonce+9,(uint8_t*)&packet->padding[0] + packet->payloadSize + 5, 3); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("nonce: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"), nonce[0], nonce[1], nonce[2], nonce[3], nonce[4], nonce[5], nonce[6], nonce[7], nonce[8], nonce[9], nonce[10], nonce[11]); + // AddLog(LOG_LEVEL_DEBUG,PSTR("nonce: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"), nonce[0], nonce[1], nonce[2], nonce[3], nonce[4], nonce[5], nonce[6], nonce[7], nonce[8], nonce[9], nonce[10], nonce[11]); uint8_t _bindkey[16]; for(uint32_t i=0; iMAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("MAC in vector: %02x %02x %02x %02x %02x %02x"), MIBLEbindKeys[i].MAC[0], MIBLEbindKeys[i].MAC[1], MIBLEbindKeys[i].MAC[2], MIBLEbindKeys[i].MAC[3], MIBLEbindKeys[i].MAC[4], MIBLEbindKeys[i].MAC[5]); + // AddLog(LOG_LEVEL_DEBUG,PSTR("MAC in packet: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]); + // AddLog(LOG_LEVEL_DEBUG,PSTR("MAC in vector: %02x %02x %02x %02x %02x %02x"), MIBLEbindKeys[i].MAC[0], MIBLEbindKeys[i].MAC[1], MIBLEbindKeys[i].MAC[2], MIBLEbindKeys[i].MAC[3], MIBLEbindKeys[i].MAC[4], MIBLEbindKeys[i].MAC[5]); // } } - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("size %u"),packet->payloadSize); + // AddLog(LOG_LEVEL_DEBUG,PSTR("size %u"),packet->payloadSize); uint32_t _size; int32_t _offset; uint32_t _tagSize; @@ -862,9 +862,9 @@ int MINRFdecryptMJYD2SPacket(char *_buf, uint8_t _light, char* _output){ return 0; break; } - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("size %u , offset %u"),_size,_offset); + // AddLog(LOG_LEVEL_DEBUG,PSTR("size %u , offset %u"),_size,_offset); memcpy(_output,(uint8_t*)&packet->padding[0] + packet->payloadSize - _offset, _size); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("BEARSSL: Output : %02x %02x %02x %02x %02x %02x %02x"), _output[0], _output[1],_output[2],_output[3],_output[4],_output[5],_output[6]); + // AddLog(LOG_LEVEL_DEBUG,PSTR("BEARSSL: Output : %02x %02x %02x %02x %02x %02x %02x"), _output[0], _output[1],_output[2],_output[3],_output[4],_output[5],_output[6]); br_aes_small_ctrcbc_keys keyCtx; br_aes_small_ctrcbc_init(&keyCtx, _bindkey, sizeof(_bindkey)); @@ -875,7 +875,7 @@ int MINRFdecryptMJYD2SPacket(char *_buf, uint8_t _light, char* _output){ br_ccm_aad_inject(&ctx, authData, sizeof(authData)); br_ccm_flip(&ctx); br_ccm_run(&ctx, 0, _output, _size); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("BEARSSL: Err:%i, Decrypted : %02x %02x %02x %02x %02x %02x %02x"), ret, _output[0], _output[1],_output[2],_output[3],_output[4],_output[5],_output[6]); + // AddLog(LOG_LEVEL_DEBUG,PSTR("BEARSSL: Err:%i, Decrypted : %02x %02x %02x %02x %02x %02x %02x"), ret, _output[0], _output[1],_output[2],_output[3],_output[4],_output[5],_output[6]); br_ccm_get_tag(&ctx, tag); ret = memcmp(tag,(uint8_t*)&packet->padding[0] + packet->payloadSize + 8, _tagSize); @@ -1124,7 +1124,7 @@ uint32_t MINRFgetSensorSlot(uint8_t (&_MAC)[6], uint16_t _type){ break; } MIBLEsensors.push_back(_newSensor); - AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: new %s at slot: %u"),kMINRFDeviceType[_type-1], MIBLEsensors.size()-1); + AddLog(LOG_LEVEL_INFO,PSTR("NRF: new %s at slot: %u"),kMINRFDeviceType[_type-1], MIBLEsensors.size()-1); return (MIBLEsensors.size()-1); }; @@ -1203,7 +1203,7 @@ void MINRFhandleMiBeaconPacket(void){ switch(MINRF.buffer.miBeacon.type){ case 0x1: if(MINRF.buffer.miBeacon.counter==_sensorVec->lastCnt) break; - // AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: YEE-RC button: %u Long: %u"), MINRF.buffer.miBeacon.Btn.num, MINRF.buffer.miBeacon.Btn.longPress); + // AddLog(LOG_LEVEL_INFO,PSTR("NRF: YEE-RC button: %u Long: %u"), MINRF.buffer.miBeacon.Btn.num, MINRF.buffer.miBeacon.Btn.longPress); _sensorVec->lastCnt=MINRF.buffer.miBeacon.counter; _sensorVec->Btn=MINRF.buffer.miBeacon.Btn.num + (MINRF.buffer.miBeacon.Btn.longPress/2)*6; _sensorVec->eventType.Btn = 1; @@ -1323,10 +1323,10 @@ void MINRFhandleNlightPacket(void){ // no MiBeacon uint32_t offset = 6; uint8_t _buf[32+offset]; MINRFrecalcBuffer((uint8_t*)&_buf,offset); - // AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"),_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6],_buf[7],_buf[8],_buf[9],_buf[10],_buf[11],_buf[12],_buf[13],_buf[14],_buf[15],_buf[16],_buf[17],_buf[18]); + // AddLog(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"),_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6],_buf[7],_buf[8],_buf[9],_buf[10],_buf[11],_buf[12],_buf[13],_buf[14],_buf[15],_buf[16],_buf[17],_buf[18]); uint32_t _frame_PID = _buf[15]<<24 | _buf[16]<<16 | _buf[17]<<8 | _buf[18]; if(_frame_PID!=0x4030dd03) return; // invalid packet - // AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT:%x"),_frame_PID); + // AddLog(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT:%x"),_frame_PID); uint32_t _idx = MINRF.activeLight-1; if((millis() - MIBLElights[_idx].lastTime)<1500) return; if(_buf[19]!=MIBLElights[_idx].lastCnt){ @@ -1334,7 +1334,7 @@ void MINRFhandleNlightPacket(void){ // no MiBeacon MIBLElights[_idx].events++; MIBLElights[_idx].shallSendMQTT = 1; MIBLElights[_idx].lastTime = millis(); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: NLIGHT %u: events: %u, Cnt:%u"), _idx,MIBLElights[_idx].events, MIBLElights[_idx].lastCnt); + AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: NLIGHT %u: events: %u, Cnt:%u"), _idx,MIBLElights[_idx].events, MIBLElights[_idx].lastCnt); } } @@ -1344,20 +1344,20 @@ void MINRFhandleMJYD2SPacket(void){ // no MiBeacon MINRFrecalcBuffer((uint8_t*)&_buf,offset); mjysd02_Packet_t *_packet = (mjysd02_Packet_t*)&_buf; if(_packet->PID!=0x07f6) return; // invalid packet - // AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: MJYD2S: %02u %04x %04x %04x %02x"),_packet->payloadSize,_packet->UUID,_packet->frameCtrl,_packet->PID,_packet->frameCnt); - // AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: PAYLOAD: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"),_packet->data[0],_packet->data[1],_packet->data[2],_packet->data[3],_packet->data[4],_packet->data[5],_packet->data[6],_packet->data[7],_packet->data[8],_packet->data[9],_packet->data[10],_packet->data[11],_packet->data[12],_packet->data[13],_packet->data[14],_packet->data[15],_packet->data[16],_packet->data[17]); + // AddLog(LOG_LEVEL_INFO,PSTR("NRF: MJYD2S: %02u %04x %04x %04x %02x"),_packet->payloadSize,_packet->UUID,_packet->frameCtrl,_packet->PID,_packet->frameCnt); + // AddLog(LOG_LEVEL_INFO,PSTR("NRF: PAYLOAD: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"),_packet->data[0],_packet->data[1],_packet->data[2],_packet->data[3],_packet->data[4],_packet->data[5],_packet->data[6],_packet->data[7],_packet->data[8],_packet->data[9],_packet->data[10],_packet->data[11],_packet->data[12],_packet->data[13],_packet->data[14],_packet->data[15],_packet->data[16],_packet->data[17]); uint32_t _idx = MINRF.activeLight-1; switch(_packet->frameCtrl){ case 0x5910: if(_packet->frameCnt!=MIBLElights[_idx].lastCnt){ - // AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: MJYD2S after motion:%x"),_packet->frameCnt); + // AddLog(LOG_LEVEL_INFO,PSTR("NRF: MJYD2S after motion:%x"),_packet->frameCnt); MIBLElights[_idx].lastCnt = _packet->frameCnt; if(millis()-MIBLElights[_idx].lastTime>120000){ MIBLElights[_idx].eventType = 1; MIBLElights[_idx].events++; MIBLElights[_idx].shallSendMQTT = 1; MIBLElights[_idx].lastTime = millis(); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: MJYD2S secondary PIR")); + AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: MJYD2S secondary PIR")); } } break; @@ -1373,7 +1373,7 @@ void MINRFhandleMJYD2SPacket(void){ // no MiBeacon if(millis()-MIBLElights[_idx].lastTime>1000){ MIBLElights[_idx].eventType = 1; //PIR MIBLElights[_idx].shallSendMQTT = 1; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: MJYD2S primary PIR")); + AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: MJYD2S primary PIR")); MIBLElights[_idx].events++; } MIBLElights[_idx].lastTime = millis(); @@ -1394,23 +1394,23 @@ void MINRFhandleMJYD2SPacket(void){ // no MiBeacon MIBLElights[_idx].NMT = output[6]<<24 | output[5]<<16 | output[4]<<8 | output[3]; MIBLElights[_idx].eventType = 3; // NMT 0, 120, 300, 600, 1800, ... seconds MIBLElights[_idx].shallSendMQTT = 1; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("NRF: MJYD2S NMT: %u"), MIBLElights[_idx].NMT ); + // AddLog(LOG_LEVEL_DEBUG,PSTR("NRF: MJYD2S NMT: %u"), MIBLElights[_idx].NMT ); break; } } } - // AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT:%x"),_frame_PID); + // AddLog(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT:%x"),_frame_PID); } void MINRFhandleLightPacket(void){ switch(MIBLElights[MINRF.activeLight-1].type){ case NLIGHT: - // AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT!!")); + // AddLog(LOG_LEVEL_INFO,PSTR("NRF: NLIGHT!!")); MINRFhandleNlightPacket(); break; case MJYD2S: - // AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: MJYD2S !!")); + // AddLog(LOG_LEVEL_INFO,PSTR("NRF: MJYD2S !!")); MINRFhandleMJYD2SPacket(); break; } @@ -1420,7 +1420,7 @@ void MINRFhandleLightPacket(void){ void MINRFaddLight(uint8_t _MAC[], uint8_t _type){ // no MiBeacon for(uint32_t i=0; iMAC, 0x0a1c); // This must be a hard-coded fake ID - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("known %s at slot %u"), kMINRFDeviceType[MIBLEsensors[_slot].type-1],_slot); - // AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: ATC: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"),MINRF.buffer.raw[0],MINRF.buffer.raw[1],MINRF.buffer.raw[2],MINRF.buffer.raw[3],MINRF.buffer.raw[4],MINRF.buffer.raw[5],MINRF.buffer.raw[6],MINRF.buffer.raw[7],MINRF.buffer.raw[8],MINRF.buffer.raw[9],MINRF.buffer.raw[10],MINRF.buffer.raw[11]); + // AddLog(LOG_LEVEL_DEBUG,PSTR("known %s at slot %u"), kMINRFDeviceType[MIBLEsensors[_slot].type-1],_slot); + // AddLog(LOG_LEVEL_INFO,PSTR("NRF: ATC: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x"),MINRF.buffer.raw[0],MINRF.buffer.raw[1],MINRF.buffer.raw[2],MINRF.buffer.raw[3],MINRF.buffer.raw[4],MINRF.buffer.raw[5],MINRF.buffer.raw[6],MINRF.buffer.raw[7],MINRF.buffer.raw[8],MINRF.buffer.raw[9],MINRF.buffer.raw[10],MINRF.buffer.raw[11]); if(_slot==0xff) return; MIBLEsensors[_slot].temp = (float)(__builtin_bswap16(_packet->temp))/10.0f; @@ -1472,7 +1472,7 @@ void MINRF_EVERY_50_MSECOND() { // Every 50mseconds MINRF.mode.shallTriggerTele = 0; } // DEBUG_SENSOR_LOG(PSTR("NRF: nothing received")); - // if (MINRF.packetMode==ATC) AddLog_P(LOG_LEVEL_INFO,PSTR("no ATC..")); + // if (MINRF.packetMode==ATC) AddLog(LOG_LEVEL_INFO,PSTR("no ATC..")); } else { diff --git a/tasmota/xsns_62_MI_ESP32.ino b/tasmota/xsns_62_MI_ESP32.ino index 1a9f75989..8bb595625 100644 --- a/tasmota/xsns_62_MI_ESP32.ino +++ b/tasmota/xsns_62_MI_ESP32.ino @@ -385,14 +385,14 @@ enum MI32_BEACON_CMND { class MI32SensorCallback : public NimBLEClientCallbacks { void onConnect(NimBLEClient* pclient) { - AddLog_P(LOG_LEVEL_DEBUG,PSTR("connected %s"), kMI32DeviceType[(MIBLEsensors[MI32.state.sensor].type)-1]); + AddLog(LOG_LEVEL_DEBUG,PSTR("connected %s"), kMI32DeviceType[(MIBLEsensors[MI32.state.sensor].type)-1]); MI32.mode.willConnect = 0; MI32.mode.connected = 1; } void onDisconnect(NimBLEClient* pclient) { MI32.mode.connected = 0; MI32.mode.willReadBatt = 0; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("disconnected %s"), kMI32DeviceType[(MIBLEsensors[MI32.state.sensor].type)-1]); + AddLog(LOG_LEVEL_DEBUG,PSTR("disconnected %s"), kMI32DeviceType[(MIBLEsensors[MI32.state.sensor].type)-1]); } bool onConnParamsUpdateRequest(NimBLEClient* MI32Client, const ble_gap_upd_params* params) { if(params->itvl_min < 24) { /** 1.25ms units */ @@ -410,13 +410,13 @@ class MI32SensorCallback : public NimBLEClientCallbacks { class MI32AdvCallbacks: public NimBLEAdvertisedDeviceCallbacks { void onResult(NimBLEAdvertisedDevice* advertisedDevice) { - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("Advertised Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length()); + // AddLog(LOG_LEVEL_DEBUG,PSTR("Advertised Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length()); int RSSI = advertisedDevice->getRSSI(); uint8_t addr[6]; memcpy(addr,advertisedDevice->getAddress().getNative(),6); MI32_ReverseMAC(addr); if (advertisedDevice->getServiceDataCount() == 0) { - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("No Xiaomi Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length()); + // AddLog(LOG_LEVEL_DEBUG,PSTR("No Xiaomi Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length()); if(MI32.state.beaconScanCounter==0 && !MI32.mode.activeBeacon){ MI32Scan->erase(advertisedDevice->getAddress()); return; @@ -428,7 +428,7 @@ class MI32AdvCallbacks: public NimBLEAdvertisedDeviceCallbacks { } uint16_t UUID = advertisedDevice->getServiceDataUUID(0).getNative()->u16.value; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("UUID: %x"),UUID); + // AddLog(LOG_LEVEL_DEBUG,PSTR("UUID: %x"),UUID); size_t ServiceDataLength = advertisedDevice->getServiceData(0).length(); if(UUID==0xfe95) { @@ -447,7 +447,7 @@ class MI32AdvCallbacks: public NimBLEAdvertisedDeviceCallbacks { if(MI32.state.beaconScanCounter!=0 || MI32.mode.activeBeacon){ MI32HandleGenericBeacon(advertisedDevice->getPayload(), advertisedDevice->getPayloadLength(), RSSI, addr); } - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("No Xiaomi Device: %x: %s Buffer: %u"), UUID, advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length()); + // AddLog(LOG_LEVEL_DEBUG,PSTR("No Xiaomi Device: %x: %s Buffer: %u"), UUID, advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length()); MI32Scan->erase(advertisedDevice->getAddress()); } }; @@ -463,12 +463,12 @@ static NimBLEClient* MI32Client; \*********************************************************************************************/ void MI32scanEndedCB(NimBLEScanResults results){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("Scan ended")); + AddLog(LOG_LEVEL_DEBUG,PSTR("Scan ended")); MI32.mode.runningScan = 0; } void MI32notifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, uint8_t* pData, size_t length, bool isNotify){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("Notified length: %u"),length); + AddLog(LOG_LEVEL_DEBUG,PSTR("Notified length: %u"),length); switch(MIBLEsensors[MI32.state.sensor].type){ case LYWSD03MMC: case LYWSD02: case MHOC401: MI32readHT_LY((char*)pData); @@ -546,12 +546,12 @@ void MI32AddKey(char* payload){ bool unknownKey = true; for(uint32_t i=0; iPID,2); nonce[8] = packet->frameCnt; memcpy((uint8_t*)&nonce+9,(uint8_t*)&_buf[_bufSize-9],3); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("nonceCnt1 and 2: %02x %02x %02x"),nonce[9],nonce[10],nonce[11]); + // AddLog(LOG_LEVEL_DEBUG,PSTR("nonceCnt1 and 2: %02x %02x %02x"),nonce[9],nonce[10],nonce[11]); memcpy((uint8_t*)&tag,(uint8_t*)&_buf[_bufSize-6],4); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("tag: %02x %02x %02x %02x"),tag[0],tag[1],tag[2],tag[3]); + // AddLog(LOG_LEVEL_DEBUG,PSTR("tag: %02x %02x %02x %02x"),tag[0],tag[1],tag[2],tag[3]); MI32_ReverseMAC(packet->MAC); uint8_t _bindkey[16] = {0x0}; bool foundNoKey = true; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Search key for MAC: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Search key for MAC: %02x %02x %02x %02x %02x %02x"), packet->MAC[0], packet->MAC[1], packet->MAC[2], packet->MAC[3], packet->MAC[4], packet->MAC[5]); for(uint32_t i=0; iMAC,MIBLEbindKeys[i].MAC,sizeof(packet->MAC))==0){ memcpy(_bindkey,MIBLEbindKeys[i].key,sizeof(_bindkey)); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Decryption Key found")); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Decryption Key found")); foundNoKey = false; break; } } if(foundNoKey){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: No Key found !!")); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: No Key found !!")); return -2; } @@ -620,7 +620,7 @@ int MI32_decryptPacket(char *_buf, uint16_t _bufSize, uint32_t _type){ ret = br_ccm_check_tag(&ctx, &tag); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Err:%i, Decrypted : %02x %02x %02x %02x %02x "), ret, packet->payload[1],packet->payload[2],packet->payload[3],packet->payload[4],packet->payload[5]); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Err:%i, Decrypted : %02x %02x %02x %02x %02x "), ret, packet->payload[1],packet->payload[2],packet->payload[3],packet->payload[4],packet->payload[5]); return ret-1; } #endif // USE_MI_DECRYPTION @@ -675,9 +675,9 @@ uint32_t MIBLEgetSensorSlot(uint8_t (&_MAC)[6], uint16_t _type, uint8_t counter) for(uint32_t i=0; isetClientCallbacks(&MI32SensorCB , false); MI32Client->setConnectionParams(12,12,0,48); MI32Client->setConnectTimeout(30); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: did create new client"),D_CMND_MI32); + // AddLog(LOG_LEVEL_DEBUG,PSTR("%s: did create new client"),D_CMND_MI32); } vTaskDelay(300/ portTICK_PERIOD_MS); if (!MI32Client->connect(_address,false)) { MI32.mode.willConnect = 0; // NimBLEDevice::deleteClient(MI32Client); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: did not connect client"),D_CMND_MI32); + // AddLog(LOG_LEVEL_DEBUG,PSTR("%s: did not connect client"),D_CMND_MI32); return false; } return true; @@ -899,7 +899,7 @@ void MI32StartScanTask(){ 0, /* Priority of the task */ NULL, /* Task handle. */ 0); /* Core where the task should run */ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Start scanning"),D_CMND_MI32); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Start scanning"),D_CMND_MI32); } void MI32ScanTask(void *pvParameters){ @@ -940,8 +940,8 @@ void MI32StartSensorTask(){ 15, /* Priority of the task */ NULL, /* Task handle. */ 0); /* Core where the task should run */ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Start sensor connections"),D_CMND_MI32); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: with sensor: %u"),D_CMND_MI32, MI32.state.sensor); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Start sensor connections"),D_CMND_MI32); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: with sensor: %u"),D_CMND_MI32, MI32.state.sensor); } void MI32SensorTask(void *pvParameters){ @@ -1014,8 +1014,8 @@ void MI32StartTimeTask(){ 15, /* Priority of the task */ NULL, /* Task handle. */ 0); /* Core where the task should run */ - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Start time set"),D_CMND_MI32); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: with sensor: %u"),D_CMND_MI32, MI32.state.sensor); + // AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Start time set"),D_CMND_MI32); + // AddLog(LOG_LEVEL_DEBUG,PSTR("%s: with sensor: %u"),D_CMND_MI32, MI32.state.sensor); } void MI32TimeTask(void *pvParameters){ @@ -1079,8 +1079,8 @@ void MI32StartUnitTask(){ 15, /* Priority of the task */ NULL, /* Task handle. */ 0); /* Core where the task should run */ - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Start unit set"),D_CMND_MI32); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: with sensor: %u"),D_CMND_MI32, MI32.state.sensor); + // AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Start unit set"),D_CMND_MI32); + // AddLog(LOG_LEVEL_DEBUG,PSTR("%s: with sensor: %u"),D_CMND_MI32, MI32.state.sensor); } void MI32UnitTask(void *pvParameters){ @@ -1270,13 +1270,13 @@ void MI32parseMiBeacon(char * _buf, uint32_t _slot, uint16_t _bufSize){ else return; // 0x3058 holds no data, TODO: check for unpaired devices, that need connections break; case MJYD2S: - AddLog_P(LOG_LEVEL_DEBUG,PSTR("MJYD2S: %x"),_beacon.frame); + AddLog(LOG_LEVEL_DEBUG,PSTR("MJYD2S: %x"),_beacon.frame); if (_beacon.frame == 0x5948){ // Now let's build/recreate a special MiBeacon memmove((uint8_t*)&_beacon.MAC+6,(uint8_t*)&_beacon.MAC, _bufSize); // shift payload by the size of the MAC = 6 bytes memcpy((uint8_t*)&_beacon.MAC,MIBLEsensors[_slot].MAC,6); // now insert the real MAC from our internal vector _bufSize+=6; // the packet has grown MI32_ReverseMAC(_beacon.MAC); // payload MAC is always reversed - AddLog_P(LOG_LEVEL_DEBUG,PSTR("MJYD2S: special packet")); + AddLog(LOG_LEVEL_DEBUG,PSTR("MJYD2S: special packet")); } if (_beacon.frame != 0x5910){ decryptRet = MI32_decryptPacket((char*)&_beacon.productID,_bufSize,MJYD2S); //start with PID @@ -1284,7 +1284,7 @@ void MI32parseMiBeacon(char * _buf, uint32_t _slot, uint16_t _bufSize){ break; } if(decryptRet!=0){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Decryption failed with error: %d"),decryptRet); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Decryption failed with error: %d"),decryptRet); return; } #endif //USE_MI_DECRYPTION @@ -1293,13 +1293,13 @@ if(decryptRet!=0){ DEBUG_SENSOR_LOG(PSTR("CGD1 no support for MiBeacon, type %u"),MIBLEsensors[_slot].type); return; } - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s at slot %u with payload type: %02x"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot,_beacon.type); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s at slot %u with payload type: %02x"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot,_beacon.type); switch(_beacon.type){ case 0x01: MIBLEsensors[_slot].Btn=_beacon.Btn.num + (_beacon.Btn.longPress/2)*6; MIBLEsensors[_slot].eventType.Btn = 1; MI32.mode.shallTriggerTele = 1; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 1: U16: %u Button"), MIBLEsensors[_slot].Btn ); + // AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 1: U16: %u Button"), MIBLEsensors[_slot].Btn ); break; case 0x04: _tempFloat=(float)(_beacon.temp)/10.0f; @@ -1308,7 +1308,7 @@ if(decryptRet!=0){ MIBLEsensors[_slot].eventType.temp = 1; DEBUG_SENSOR_LOG(PSTR("Mode 4: temp updated")); } - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 4: U16: %u Temp"), _beacon.temp ); + // AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 4: U16: %u Temp"), _beacon.temp ); break; case 0x06: _tempFloat=(float)(_beacon.hum)/10.0f; @@ -1317,7 +1317,7 @@ if(decryptRet!=0){ MIBLEsensors[_slot].eventType.hum = 1; DEBUG_SENSOR_LOG(PSTR("Mode 6: hum updated")); } - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 6: U16: %u Hum"), _beacon.hum); + // AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 6: U16: %u Hum"), _beacon.hum); break; case 0x07: MIBLEsensors[_slot].lux=_beacon.lux & 0x00ffffff; @@ -1325,19 +1325,19 @@ if(decryptRet!=0){ MIBLEsensors[_slot].eventType.noMotion = 1; } MIBLEsensors[_slot].eventType.lux = 1; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 7: U24: %u Lux"), _beacon.lux & 0x00ffffff); + // AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 7: U24: %u Lux"), _beacon.lux & 0x00ffffff); break; case 0x08: MIBLEsensors[_slot].moisture=_beacon.moist; MIBLEsensors[_slot].eventType.moist = 1; DEBUG_SENSOR_LOG(PSTR("Mode 8: moisture updated")); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 8: U8: %u Moisture"), _beacon.moist); + // AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 8: U8: %u Moisture"), _beacon.moist); break; case 0x09: MIBLEsensors[_slot].fertility=_beacon.fert; MIBLEsensors[_slot].eventType.fert = 1; DEBUG_SENSOR_LOG(PSTR("Mode 9: fertility updated")); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 9: U16: %u Fertility"), _beacon.fert); + // AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 9: U16: %u Fertility"), _beacon.fert); break; case 0x0a: if(MI32.option.ignoreBogusBattery){ @@ -1350,7 +1350,7 @@ if(decryptRet!=0){ MIBLEsensors[_slot].eventType.bat = 1; DEBUG_SENSOR_LOG(PSTR("Mode a: bat updated")); } - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode a: U8: %u %%"), _beacon.bat); + // AddLog(LOG_LEVEL_DEBUG,PSTR("Mode a: U8: %u %%"), _beacon.bat); break; case 0x0d: _tempFloat=(float)(_beacon.HT.temp)/10.0f; @@ -1364,7 +1364,7 @@ if(decryptRet!=0){ DEBUG_SENSOR_LOG(PSTR("Mode d: hum updated")); } MIBLEsensors[_slot].eventType.tempHum = 1; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode d: U16: %x Temp U16: %x Hum"), _beacon.HT.temp, _beacon.HT.hum); + // AddLog(LOG_LEVEL_DEBUG,PSTR("Mode d: U16: %x Temp U16: %x Hum"), _beacon.HT.temp, _beacon.HT.hum); break; #ifdef USE_MI_DECRYPTION case 0x0f: @@ -1376,13 +1376,13 @@ if(decryptRet!=0){ MIBLEsensors[_slot].eventType.lux = 1; MIBLEsensors[_slot].NMT = 0; MI32.mode.shallTriggerTele = 1; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("PIR: primary"),MIBLEsensors[_slot].lux ); + // AddLog(LOG_LEVEL_DEBUG,PSTR("PIR: primary"),MIBLEsensors[_slot].lux ); break; case 0x17: MIBLEsensors[_slot].NMT = _beacon.NMT; MIBLEsensors[_slot].eventType.NMT = 1; MI32.mode.shallTriggerTele = 1; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 17: NMT: %u seconds"), _beacon.NMT); + // AddLog(LOG_LEVEL_DEBUG,PSTR("Mode 17: NMT: %u seconds"), _beacon.NMT); break; #endif //USE_MI_DECRYPTION default: @@ -1392,7 +1392,7 @@ if(decryptRet!=0){ MIBLEsensors[_slot].NMT = 0; MIBLEsensors[_slot].lastTime = millis(); MI32.mode.shallTriggerTele = 1; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("PIR: primary"),MIBLEsensors[_slot].lux ); + // AddLog(LOG_LEVEL_DEBUG,PSTR("PIR: primary"),MIBLEsensors[_slot].lux ); } else{ AddLogBuffer(LOG_LEVEL_DEBUG,(uint8_t*)_buf,_bufSize); @@ -1407,7 +1407,7 @@ if(decryptRet!=0){ void MI32ParseATCPacket(char * _buf, uint32_t length, uint8_t addr[6], int RSSI){ ATCPacket_t *_packet = (ATCPacket_t*)_buf; uint32_t _slot = MIBLEgetSensorSlot(_packet->MAC, 0x0a1c, _packet->frameCnt); // This must be a hard-coded fake ID - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot); if(_slot==0xff) return; MIBLEsensors[_slot].RSSI=RSSI; @@ -1427,7 +1427,7 @@ void MI32parseCGD1Packet(char * _buf, uint32_t length, uint8_t addr[6], int RSSI uint8_t _addr[6]; memcpy(_addr,addr,6); uint32_t _slot = MIBLEgetSensorSlot(_addr, 0x0576, 0); // This must be hard-coded, no object-id in Cleargrass-packet, we have no packet counter too - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot); if(_slot==0xff) return; MIBLEsensors[_slot].RSSI=RSSI; cg_packet_t _packet; @@ -1469,7 +1469,7 @@ void MI32ParseResponse(char *buf, uint16_t bufsize, uint8_t addr[6], int RSSI) { return; } uint16_t _type= buf[3]*256 + buf[2]; - // AddLog_P(LOG_LEVEL_INFO, PSTR("%02x %02x %02x %02x"),(uint8_t)buf[0], (uint8_t)buf[1],(uint8_t)buf[2],(uint8_t)buf[3]); + // AddLog(LOG_LEVEL_INFO, PSTR("%02x %02x %02x %02x"),(uint8_t)buf[0], (uint8_t)buf[1],(uint8_t)buf[2],(uint8_t)buf[3]); uint8_t _addr[6]; memcpy(_addr,addr,6); uint16_t _slot = MIBLEgetSensorSlot(_addr, _type, buf[4]); @@ -1489,36 +1489,36 @@ void MI32ParseResponse(char *buf, uint16_t bufsize, uint8_t addr[6], int RSSI) { * @param UUID */ void MI32ParseGenericBeacon(uint8_t* payload, size_t payloadLength, uint16_t* CID, uint16_t*SVC, uint16_t* UUID){ - AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Beacon:____________")); + AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Beacon:____________")); for (uint32_t i = 0; i19) { - AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Scan buffer full")); + AddLog(LOG_LEVEL_INFO,PSTR("M32: Scan buffer full")); MI32.state.beaconScanCounter = 1; return; } for(auto _scanResult : MIBLEscanResult){ if(memcmp(addr,_scanResult.MAC,6)==0){ - // AddLog_P(LOG_LEVEL_INFO,PSTR("M32: known device")); + // AddLog(LOG_LEVEL_INFO,PSTR("M32: known device")); return; } } @@ -1583,12 +1583,12 @@ void MI32addBeacon(uint8_t index, char* data){ _new.time = 0; if(memcmp(_empty,_new.MAC,6) == 0){ _new.active = false; - AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Beacon%u deactivated"), index); + AddLog(LOG_LEVEL_INFO,PSTR("M32: Beacon%u deactivated"), index); } else{ _new.active = true; MI32.mode.activeBeacon = 1; - AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Beacon added with MAC: %s"), _MAC); + AddLog(LOG_LEVEL_INFO,PSTR("M32: Beacon added with MAC: %s"), _MAC); } } @@ -1643,7 +1643,7 @@ void MI32readHT_LY(char *_buf){ DEBUG_SENSOR_LOG(PSTR("%s: raw data: %x%x%x%x%x%x%x"),D_CMND_MI32,_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6]); if(_buf[0] != 0 && _buf[1] != 0){ memcpy(&LYWSD0x_HT,(void *)_buf,sizeof(LYWSD0x_HT)); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H: %u, V: %u"),D_CMND_MI32,LYWSD0x_HT.temp,LYWSD0x_HT.hum, LYWSD0x_HT.volt); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H: %u, V: %u"),D_CMND_MI32,LYWSD0x_HT.temp,LYWSD0x_HT.hum, LYWSD0x_HT.volt); uint32_t _slot = MI32.state.sensor; DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot); @@ -1672,7 +1672,7 @@ void MI32readHT_LY(char *_buf){ bool MI32readBat(char *_buf){ DEBUG_SENSOR_LOG(PSTR("%s: raw data: %x%x%x%x%x%x%x"),D_CMND_MI32,_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6]); if(_buf[0] != 0){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Battery: %u"),D_CMND_MI32,_buf[0]); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Battery: %u"),D_CMND_MI32,_buf[0]); uint32_t _slot = MI32.state.sensor; DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot); if(_buf[0]<101){ @@ -1680,7 +1680,7 @@ bool MI32readBat(char *_buf){ if(MIBLEsensors[_slot].type==FLORA){ memcpy(MIBLEsensors[_slot].firmware, _buf+2, 5); MIBLEsensors[_slot].firmware[5] = '\0'; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Firmware: %s"),D_CMND_MI32,MIBLEsensors[_slot].firmware); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Firmware: %s"),D_CMND_MI32,MIBLEsensors[_slot].firmware); } MIBLEsensors[_slot].eventType.bat = 1; MIBLEsensors[_slot].shallSendMQTT = 1; @@ -1795,8 +1795,8 @@ void MI32EverySecond(bool restart){ if(MI32.mode.connected == 0) { if (MI32.mode.shallReadBatt) { //TODO: decide automatically, which sensor can not work without connections - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: active sensor now: %u of %u"),D_CMND_MI32, MI32.state.sensor, MIBLEsensors.size()-1); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("will connect to %s"),kMI32DeviceType[MIBLEsensors[MI32.state.sensor].type-1] ); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: active sensor now: %u of %u"),D_CMND_MI32, MI32.state.sensor, MIBLEsensors.size()-1); + AddLog(LOG_LEVEL_DEBUG, PSTR("will connect to %s"),kMI32DeviceType[MIBLEsensors[MI32.state.sensor].type-1] ); MI32StartTask(MI32_TASK_BATT); } @@ -1843,7 +1843,7 @@ void CmndMi32Time(void) { if (XdrvMailbox.data_len > 0) { if (MIBLEsensors.size() > XdrvMailbox.payload) { if ((LYWSD02 == MIBLEsensors[XdrvMailbox.payload].type) || (MHOC303 == MIBLEsensors[XdrvMailbox.payload].type)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Will set Time")); + AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Will set Time")); MI32.state.sensor = XdrvMailbox.payload; MI32.mode.canScan = 0; MI32.mode.canConnect = 0; @@ -1873,7 +1873,7 @@ void CmndMi32Unit(void) { if (XdrvMailbox.data_len > 0) { if (MIBLEsensors.size() > XdrvMailbox.payload) { if ((LYWSD02 == MIBLEsensors[XdrvMailbox.payload].type) || (MHOC303 == MIBLEsensors[XdrvMailbox.payload].type)) { - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Will set Unit")); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Will set Unit")); MI32.state.sensor = XdrvMailbox.payload; MI32.mode.canScan = 0; MI32.mode.canConnect = 0; @@ -1923,7 +1923,7 @@ void CmndMi32Block(void){ switch (XdrvMailbox.index) { case 0: MIBLEBlockList.clear(); - // AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Size of ilist: %u"), MIBLEBlockList.size()); + // AddLog(LOG_LEVEL_INFO,PSTR("M32: Size of ilist: %u"), MIBLEBlockList.size()); ResponseCmndIdxChar(PSTR("Block list cleared")); break; case 1: @@ -1953,7 +1953,7 @@ void CmndMi32Block(void){ ResponseCmndIdxChar(XdrvMailbox.data); MI32removeMIBLEsensor(_MACasBytes.buf); } - // AddLog_P(LOG_LEVEL_INFO,PSTR("M32: Size of ilist: %u"), MIBLEBlockList.size()); + // AddLog(LOG_LEVEL_INFO,PSTR("M32: Size of ilist: %u"), MIBLEBlockList.size()); break; } } diff --git a/tasmota/xsns_62_MI_ESP32_BLE_ESP32.ino b/tasmota/xsns_62_MI_ESP32_BLE_ESP32.ino index c6a3e3111..2843102d9 100644 --- a/tasmota/xsns_62_MI_ESP32_BLE_ESP32.ino +++ b/tasmota/xsns_62_MI_ESP32_BLE_ESP32.ino @@ -490,7 +490,7 @@ int toggleUnit(BLE_ESP32::generic_sensor_t *op){ bool MI32Operation(int slot, int optype, const char *svc, const char *charactistic, const char *notifychar = nullptr, const uint8_t *data = nullptr, int datalen = 0, uint8_t *addr = nullptr ) { if (!svc || !svc[0]){ - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: Op inv svc")); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: Op inv svc")); return 0; } @@ -499,17 +499,17 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist // ALWAYS use this function to create a new one. int res = BLE_ESP32::newOperation(&op); if (!res){ - AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Can't get a newOperation")); + AddLog(LOG_LEVEL_ERROR,PSTR("M32: Can't get a newOperation")); return 0; } else { - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Got a newOperation")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Got a newOperation")); } if (slot >= 0){ op->addr = NimBLEAddress(MIBLEsensors[slot].MAC); } else { if (!addr){ - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: No addr")); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: No addr")); BLE_ESP32::freeOperation(&op); return 0; } @@ -521,7 +521,7 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist if (!op->serviceUUID.bitSize()){ BLE_ESP32::freeOperation(&op); - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: MI Bad service string %s"), svc); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: MI Bad service string %s"), svc); return 0; } @@ -531,7 +531,7 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist op->characteristicUUID = NimBLEUUID(charactistic); if (!op->characteristicUUID.bitSize()){ BLE_ESP32::freeOperation(&op); - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: MI Bad characteristic string %s"), charactistic); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: MI Bad characteristic string %s"), charactistic); return 0; } } @@ -539,7 +539,7 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist op->notificationCharacteristicUUID = NimBLEUUID(notifychar); if (!op->notificationCharacteristicUUID.bitSize()){ BLE_ESP32::freeOperation(&op); - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: MI Bad notifycharacteristic string %s"), notifychar); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: MI Bad notifycharacteristic string %s"), notifychar); return 0; } } @@ -564,13 +564,13 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist uint32_t context = (optype << 24) | (MIBLEsensors[slot].type << 16) | slot; op->context = (void *)context; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: MI s:%d op:%s"), slot, BLE_ESP32::BLETriggerResponse(op).c_str()); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: MI s:%d op:%s"), slot, BLE_ESP32::BLETriggerResponse(op).c_str()); res = BLE_ESP32::extQueueOperation(&op); if (!res){ // if it fails to add to the queue, do please delete it BLE_ESP32::freeOperation(&op); - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: Failed to queue new operation - deleted")); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: Failed to queue new operation - deleted")); } return res; @@ -611,9 +611,9 @@ int genericBatReadFn(int slot){ break; } if (res > 0){ - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Req batt read slot %d type %d queued"), slot, MIBLEsensors[slot].type); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO, PSTR("M32: Req batt read slot %d type %d queued"), slot, MIBLEsensors[slot].type); } else { - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Req batt read slot %d type %d non-queued res %d"), slot, MIBLEsensors[slot].type, res); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO, PSTR("M32: Req batt read slot %d type %d non-queued res %d"), slot, MIBLEsensors[slot].type, res); } return res; } @@ -653,7 +653,7 @@ int genericSensorReadFn(int slot, int force){ // called once per second int readOneSensor(){ if (MI32.sensorreader.active){ - AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor - already active reading %d"), MI32.sensorreader.slot-1); + AddLog(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor - already active reading %d"), MI32.sensorreader.slot-1); return 0; } @@ -663,12 +663,12 @@ int readOneSensor(){ do { // MI32.sensorreader.slot is reset to zero to trigger a read sequence if (MI32.sensorreader.slot >= MIBLEsensors.size()){ - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: readOneSensor past end of slots - %d > %d"), MI32.sensorreader.slot, MIBLEsensors.size()); + //AddLog(LOG_LEVEL_DEBUG, PSTR("BLE: readOneSensor past end of slots - %d > %d"), MI32.sensorreader.slot, MIBLEsensors.size()); return 0; } res = genericSensorReadFn(MI32.sensorreader.slot, 0); - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: genericSensorReadFn slot %d res %d"), MI32.sensorreader.slot, res); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: genericSensorReadFn slot %d res %d"), MI32.sensorreader.slot, res); // if this sensor in this slot does not need to be read via notify, just move on top the next one if (res < 0){ @@ -680,7 +680,7 @@ int readOneSensor(){ if (res == 0){ // can't read at the moment (no operations available?) - AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor no ops available slot %d res %d"), MI32.sensorreader.slot, res); + AddLog(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor no ops available slot %d res %d"), MI32.sensorreader.slot, res); return 0; } @@ -689,7 +689,7 @@ int readOneSensor(){ // and make it wait until the read/notify is complete // this is cleared in the response callback. MI32.sensorreader.active = 1; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor reading for slot %d res %d"), MI32.sensorreader.slot-1, res); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor reading for slot %d res %d"), MI32.sensorreader.slot-1, res); // started one return 1; @@ -714,7 +714,7 @@ int readOneBat(){ if (res < 0){ MI32.batteryreader.slot++; if (MI32.batteryreader.slot >= MIBLEsensors.size()){ - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Batt loop complete at %d"), MI32.batteryreader.slot); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO, PSTR("M32: Batt loop complete at %d"), MI32.batteryreader.slot); } return 0; } @@ -730,7 +730,7 @@ int readOneBat(){ // this is cleared in the response callback. MI32.batteryreader.active = 1; if (MI32.batteryreader.slot >= MIBLEsensors.size()){ - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Batt loop will complete at %d"), MI32.batteryreader.slot); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_INFO, PSTR("M32: Batt loop will complete at %d"), MI32.batteryreader.slot); } // started one return 1; @@ -816,7 +816,7 @@ int genericTimeWriteFn(int slot){ int genericOpCompleteFn(BLE_ESP32::generic_sensor_t *op){ uint32_t context = (uint32_t) op->context; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: MI op complete context %x"), context); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: MI op complete context %x"), context); int opType = context >> 24; int devType = (context >> 16) & 0xff; @@ -832,12 +832,12 @@ int genericOpCompleteFn(BLE_ESP32::generic_sensor_t *op){ bool fail = false; if (op->addr != addr){ // slot changed during operation? - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: Slot mac changed during an operation")); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: Slot mac changed during an operation")); fail = true; } if (op->state <= GEN_STATE_FAILED){ - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: Operation failed %d for %s"), op->state, slotMAC); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: Operation failed %d for %s"), op->state, slotMAC); fail = true; } @@ -857,7 +857,7 @@ int genericOpCompleteFn(BLE_ESP32::generic_sensor_t *op){ switch(opType){ case OP_TIME_WRITE: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Time write for %s complete"), slotMAC); + AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Time write for %s complete"), slotMAC); return 0; // nothing to do case OP_BATT_READ:{ uint8_t *data = nullptr; @@ -876,33 +876,33 @@ int genericOpCompleteFn(BLE_ESP32::generic_sensor_t *op){ // allow another... MI32.batteryreader.active = 0; - AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Batt read slot %d done state %x"), slot, op->state); + AddLog(LOG_LEVEL_INFO, PSTR("M32: Batt read slot %d done state %x"), slot, op->state); } return 0; case OP_UNIT_WRITE: // nothing more to do? - AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Unit write for %s complete"), slotMAC); + AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Unit write for %s complete"), slotMAC); return 0; case OP_UNIT_READ: { uint8_t currUnit = op->dataRead[0]; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Unit read for %s complete %d"), slotMAC, currUnit); + AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Unit read for %s complete %d"), slotMAC, currUnit); } return 0; case OP_UNIT_TOGGLE: { uint8_t currUnit = op->dataToWrite[0]; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Unit toggle for %s complete %d->%d; datasize was %d"), slotMAC, op->dataRead[0], op->dataToWrite[0], op->readlen); + AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Unit toggle for %s complete %d->%d; datasize was %d"), slotMAC, op->dataRead[0], op->dataToWrite[0], op->readlen); } return 0; case OP_READ_HT_LY: { // allow another... MI32.sensorreader.active = 0; MI32notifyHT_LY(slot, (char*)op->dataNotify, op->notifylen); - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: HT_LY notify for %s complete"), slotMAC); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: HT_LY notify for %s complete"), slotMAC); } return 0; default: - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: OpType %d not recognised?"), opType); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: OpType %d not recognised?"), opType); return 0; } @@ -914,7 +914,7 @@ int MI32advertismentCallback(BLE_ESP32::ble_advertisment_t *pStruct) // we will try not to use this... BLEAdvertisedDevice *advertisedDevice = pStruct->advertisedDevice; - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Advertised Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length()); + // AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Advertised Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length()); int RSSI = pStruct->RSSI; const uint8_t *addr = pStruct->addr; if(MI32isInBlockList(addr) == true) return 0; @@ -937,13 +937,13 @@ int MI32advertismentCallback(BLE_ESP32::ble_advertisment_t *pStruct) char temp[60]; BLE_ESP32::dump(temp, 13, addr, 6); - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("M32: MI:%s svc[0] UUID (%x)"), temp, UUID); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("M32: MI:%s svc[0] UUID (%x)"), temp, UUID); std::string ServiceDataStr = advertisedDevice->getServiceData(0); uint32_t ServiceDataLength = ServiceDataStr.length(); const uint8_t *ServiceData = (const uint8_t *)ServiceDataStr.data(); BLE_ESP32::dump(temp, 60, ServiceData, ServiceDataLength); - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("M32: MI:%s"), temp); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("M32: MI:%s"), temp); if (UUID){ @@ -1041,14 +1041,14 @@ int MI32AddKey(char* payload, char* key = nullptr){ bool unknownKey = true; for(uint32_t i=0; i 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Search key for MAC: %02x%02x%02x%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: Search key for MAC: %02x%02x%02x%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); for(uint32_t i=0; i 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Decryption Key found")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Decryption Key found")); foundNoKey = false; break; } } if(foundNoKey){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: No Key found")); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: No Key found")); return -2; // indicates needs key } @@ -1098,7 +1098,7 @@ int MIDecryptPayload(const uint8_t *macin, const uint8_t *nonce, uint32_t tag, u // returns 1 if matched, else 0 int ret = br_ccm_check_tag(&ctx, &tag); - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Err:%i, Decrypted : %02x %02x %02x %02x %02x"), ret, payload[1],payload[2],payload[3],payload[4],payload[5]); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Err:%i, Decrypted : %02x %02x %02x %02x %02x"), ret, payload[1],payload[2],payload[3],payload[4],payload[5]); return ret-1; // -> -1=fail, 0=success } @@ -1168,7 +1168,7 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const parsed->devicetype = *((uint16_t *)(data + byteindex)); byteindex += 2; parsed->framecnt = data[byteindex]; - //if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: MI frame %d"), parsed->framecnt); + //if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: MI frame %d"), parsed->framecnt); byteindex++; @@ -1217,17 +1217,17 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const break; case 0: // suceeded parsed->needkey = KEY_REQUIRED_AND_FOUND; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Payload decrypted")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Payload decrypted")); break; case -1: // key failed to work parsed->needkey = KEY_REQUIRED_AND_INVALID; - AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Payload decrypt failed")); + AddLog(LOG_LEVEL_ERROR,PSTR("M32: Payload decrypt failed")); parsed->payloadpresent = 0; return 0; break; case -2: // key not present parsed->needkey = KEY_REQUIRED_BUT_NOT_FOUND; - AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Payload encrypted but no key")); + AddLog(LOG_LEVEL_ERROR,PSTR("M32: Payload encrypted but no key")); parsed->payloadpresent = 0; return 0; break; @@ -1262,7 +1262,7 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const } if ((len - byteindex) == 0){ - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: No payload")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: No payload")); parsed->payload.size = 0; parsed->payloadpresent = 0; return 0; @@ -1271,14 +1271,14 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const // we have payload which did not need decrypt. if (decres == 1){ parsed->needkey = KEY_NOT_REQUIRED; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Payload unencrypted")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Payload unencrypted")); } // already decrypted if required parsed->payloadpresent = 1; memcpy(&parsed->payload, (data + byteindex), (len - byteindex)); if (parsed->payload.size != (len - byteindex) - 3){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Payload length mismatch")); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Payload length mismatch")); } return 1; @@ -1319,7 +1319,7 @@ void MI32nullifyEndOfMQTT_DATA(){ */ uint32_t MIBLEgetSensorSlot(const uint8_t *mac, uint16_t _type, uint8_t counter){ - //AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: will test ID-type: %x"),D_CMND_MI32, _type); + //AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: will test ID-type: %x"),D_CMND_MI32, _type); bool _success = false; for (uint32_t i=0; i < MI_MI32_TYPES; i++){ // i < sizeof(kMI32DeviceID) gives compiler warning if(_type == kMI32DeviceID[i]){ @@ -1328,40 +1328,40 @@ uint32_t MIBLEgetSensorSlot(const uint8_t *mac, uint16_t _type, uint8_t counter) break; } else { - //AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: ID-type is not: %x"),D_CMND_MI32,kMI32DeviceID[i]); + //AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: ID-type is not: %x"),D_CMND_MI32,kMI32DeviceID[i]); } } if(!_success) { _type = 1; // unknown } - //AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: vector size %u"),D_CMND_MI32, MIBLEsensors.size()); + //AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: vector size %u"),D_CMND_MI32, MIBLEsensors.size()); for(uint32_t i=0; i 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: slot: %u/%u - ign repeat"),D_CMND_MI32, i, MIBLEsensors.size()); + // AddLog(LOG_LEVEL_DEBUG,PSTR("Old packet")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: slot: %u/%u - ign repeat"),D_CMND_MI32, i, MIBLEsensors.size()); //return 0xff; // packet received before, stop here } - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Frame %d, last %d"), counter, MIBLEsensors[i].lastCnt); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Frame %d, last %d"), counter, MIBLEsensors[i].lastCnt); MIBLEsensors[i].lastCnt = counter; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: slot: %u/%u"),D_CMND_MI32, i, MIBLEsensors.size()); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: slot: %u/%u"),D_CMND_MI32, i, MIBLEsensors.size()); if (MIBLEsensors[i].type != _type){ // this happens on incorrectly configured pvvx ATC firmware - AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: %s: slot: %u - device type 0x%04x(%s) -> 0x%04x(%s) - check device is only sending one type of advert."),D_CMND_MI32, i, + AddLog(LOG_LEVEL_ERROR,PSTR("M32: %s: slot: %u - device type 0x%04x(%s) -> 0x%04x(%s) - check device is only sending one type of advert."),D_CMND_MI32, i, kMI32DeviceID[MIBLEsensors[i].type-1], kMI32DeviceType[MIBLEsensors[i].type-1], kMI32DeviceID[_type-1], kMI32DeviceType[_type-1]); MIBLEsensors[i].type = _type; } return i; } - //AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: i: %x %x %x %x %x %x"),D_CMND_MI32, MIBLEsensors[i].MAC[5], MIBLEsensors[i].MAC[4],MIBLEsensors[i].MAC[3],MIBLEsensors[i].MAC[2],MIBLEsensors[i].MAC[1],MIBLEsensors[i].MAC[0]); - //AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: n: %x %x %x %x %x %x"),D_CMND_MI32, mac[5], mac[4], mac[3],mac[2],mac[1],mac[0]); + //AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: i: %x %x %x %x %x %x"),D_CMND_MI32, MIBLEsensors[i].MAC[5], MIBLEsensors[i].MAC[4],MIBLEsensors[i].MAC[3],MIBLEsensors[i].MAC[2],MIBLEsensors[i].MAC[1],MIBLEsensors[i].MAC[0]); + //AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: n: %x %x %x %x %x %x"),D_CMND_MI32, mac[5], mac[4], mac[3],mac[2],mac[1],mac[0]); } - //AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: new sensor -> slot: %u"),D_CMND_MI32, MIBLEsensors.size()); - //AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: found new sensor"),D_CMND_MI32); + //AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: new sensor -> slot: %u"),D_CMND_MI32, MIBLEsensors.size()); + //AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: found new sensor"),D_CMND_MI32); mi_sensor_t _newSensor; memset(&_newSensor, 0 , sizeof(_newSensor)); memcpy(_newSensor.MAC, mac, 6); @@ -1411,7 +1411,7 @@ uint32_t MIBLEgetSensorSlot(const uint8_t *mac, uint16_t _type, uint8_t counter) break; } MIBLEsensors.push_back(_newSensor); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: new %s at slot: %u"),D_CMND_MI32, kMI32DeviceType[_type-1],MIBLEsensors.size()-1); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: new %s at slot: %u"),D_CMND_MI32, kMI32DeviceType[_type-1],MIBLEsensors.size()-1); MI32.mode.shallShowStatusInfo = 1; return MIBLEsensors.size()-1; }; @@ -1444,7 +1444,7 @@ void MI32StatusInfo() { int MI32scanCompleteCallback(NimBLEScanResults results){ // we actually don't need to do anything here.... - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Scan complete")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Scan complete")); return 0; } @@ -1473,7 +1473,7 @@ void MI32Init(void) { // note: for operations, we will set individual callbacks in the operations we request //void registerForOpCallbacks(const char *tag, BLE_ESP32::OPCOMPLETE_CALLBACK* pFn); - AddLog_P(LOG_LEVEL_INFO,PSTR("M32: init: request callbacks")); + AddLog(LOG_LEVEL_INFO,PSTR("M32: init: request callbacks")); MI32.period = Settings.tele_period; MI32.mode.init = 1; return; @@ -1496,19 +1496,19 @@ int MIParseBatt(int slot, uint8_t *data, int len){ MIBLEsensors[slot].bat = value; if(MIBLEsensors[slot].type==MI_FLORA){ if (len < 7){ - AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: FLORA: not enough bytes read for firmware?")); + AddLog(LOG_LEVEL_ERROR,PSTR("M32: FLORA: not enough bytes read for firmware?")); } else { memcpy(MIBLEsensors[slot].firmware, data+2, 5); MIBLEsensors[slot].firmware[5] = '\0'; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: FLORA Firmware: %s"),D_CMND_MI32,MIBLEsensors[slot].firmware); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: FLORA Firmware: %s"),D_CMND_MI32,MIBLEsensors[slot].firmware); } } MIBLEsensors[slot].eventType.bat = 1; MIBLEsensors[slot].shallSendMQTT = 1; MI32.mode.shallTriggerTele = 1; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Batt read for %s complete %d"), slotMAC, value); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Batt read for %s complete %d"), slotMAC, value); } else { - AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Batt read for %s complete but out of range 1-101 (%d)"), slotMAC, value); + AddLog(LOG_LEVEL_ERROR,PSTR("M32: Batt read for %s complete but out of range 1-101 (%d)"), slotMAC, value); } return 0; @@ -1540,7 +1540,7 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad if(_slot==0xff) return; if ((_slot >= 0) && (_slot < MIBLEsensors.size())){ - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s:pvvx at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s:pvvx at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot); MIBLEsensors[_slot].RSSI=RSSI; MIBLEsensors[_slot].needkey=KEY_NOT_REQUIRED; @@ -1557,7 +1557,7 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad } return; } else { - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: PVVX packet mac mismatch - ignored?")); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: PVVX packet mac mismatch - ignored?")); return; } } @@ -1571,9 +1571,9 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad if (memcmp(addrrev, _packet->MAC, 6)){ MI32_ReverseMAC(_packet->MAC); if (!memcmp(addrrev, _packet->MAC, 6)){ - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: ATC packet with reversed MAC addr?")); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: ATC packet with reversed MAC addr?")); } else { - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: ATC packet with MAC addr mismatch - is this mesh?")); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: ATC packet with MAC addr mismatch - is this mesh?")); memcpy(addrrev, _packet->MAC, 6); } addr = addrrev; @@ -1584,7 +1584,7 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad if(_slot==0xff) return; if ((_slot >= 0) && (_slot < MIBLEsensors.size())){ - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot); MIBLEsensors[_slot].RSSI=RSSI; MIBLEsensors[_slot].needkey=KEY_NOT_REQUIRED; @@ -1616,7 +1616,7 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){ char tmp[20]; BLE_ESP32::dump(tmp, 20, (uint8_t*)&(parsed->payload), parsed->payload.size+3); - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: MI%d payload %s"), _slot, tmp); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: MI%d payload %s"), _slot, tmp); switch(parsed->payload.type){ case 0x01: // button press @@ -1636,22 +1636,22 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){ if(_tempFloat<60){ MIBLEsensors[_slot].temp=_tempFloat; MIBLEsensors[_slot].eventType.temp = 1; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 4: temp updated")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 4: temp updated")); } else { - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 4: temp ignored > 60 (%f)"), _tempFloat); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 4: temp ignored > 60 (%f)"), _tempFloat); } - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 4: U16: %u Temp"), _beacon.temp ); + // AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode 4: U16: %u Temp"), _beacon.temp ); } break; case 0x06: { float _tempFloat=(float)(pld->hum)/10.0f; if(_tempFloat<101){ MIBLEsensors[_slot].hum=_tempFloat; MIBLEsensors[_slot].eventType.hum = 1; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 6: hum updated")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 6: hum updated")); } else { - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 6: hum ignored > 101 (%f)"), _tempFloat); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 6: hum ignored > 101 (%f)"), _tempFloat); } - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 6: U16: %u Hum"), _beacon.hum); + // AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode 6: U16: %u Hum"), _beacon.hum); } break; case 0x07: MIBLEsensors[_slot].lux=pld->lux & 0x00ffffff; @@ -1659,19 +1659,19 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){ MIBLEsensors[_slot].eventType.noMotion = 1; } MIBLEsensors[_slot].eventType.lux = 1; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 7: U24: %u Lux"), _beacon.lux & 0x00ffffff); + // AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode 7: U24: %u Lux"), _beacon.lux & 0x00ffffff); break; case 0x08: MIBLEsensors[_slot].moisture=pld->moist; MIBLEsensors[_slot].eventType.moist = 1; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 8: moisture updated")); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 8: U8: %u Moisture"), _beacon.moist); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 8: moisture updated")); + // AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode 8: U8: %u Moisture"), _beacon.moist); break; case 0x09: // 'conductivity' MIBLEsensors[_slot].fertility=pld->fert; MIBLEsensors[_slot].eventType.fert = 1; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 9: fertility updated")); - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 9: U16: %u Fertility"), _beacon.fert); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 9: fertility updated")); + // AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode 9: U16: %u Fertility"), _beacon.fert); break; case 0x0a: if(MI32.option.ignoreBogusBattery){ @@ -1683,31 +1683,31 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){ if(pld->bat<101){ MIBLEsensors[_slot].bat = pld->bat; MIBLEsensors[_slot].eventType.bat = 1; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode a: bat updated")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode a: bat updated")); } else { MIBLEsensors[_slot].bat = 100; MIBLEsensors[_slot].eventType.bat = 1; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode a: bat > 100 (%d)"), pld->bat); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode a: bat > 100 (%d)"), pld->bat); } - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode a: U8: %u %%"), _beacon.bat); + // AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode a: U8: %u %%"), _beacon.bat); break; case 0x0d:{ float _tempFloat=(float)(pld->HT.temp)/10.0f; if(_tempFloat < 60){ MIBLEsensors[_slot].temp = _tempFloat; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: temp updated")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: temp updated")); } else { - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: temp ignored > 60 (%f)"), _tempFloat); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: temp ignored > 60 (%f)"), _tempFloat); } _tempFloat=(float)(pld->HT.hum)/10.0f; if(_tempFloat < 100){ MIBLEsensors[_slot].hum = _tempFloat; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: hum updated")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: hum updated")); } else { - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: hum ignored > 100 (%f)"), _tempFloat); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: hum ignored > 100 (%f)"), _tempFloat); } MIBLEsensors[_slot].eventType.tempHum = 1; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode d: U16: %x Temp U16: %x Hum"), _beacon.HT.temp, _beacon.HT.hum); + // AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode d: U16: %x Temp U16: %x Hum"), _beacon.HT.temp, _beacon.HT.hum); } break; case 0x0f: if (parsed->payload.ten != 0) break; @@ -1718,7 +1718,7 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){ MIBLEsensors[_slot].eventType.lux = 1; MIBLEsensors[_slot].NMT = 0; MI32.mode.shallTriggerTele = 1; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: PIR: primary"),MIBLEsensors[_slot].lux ); + // AddLog(LOG_LEVEL_DEBUG,PSTR("M32: PIR: primary"),MIBLEsensors[_slot].lux ); break; case 0x10:{ // 'formaldehide' const uint16_t f = uint16_t(parsed->payload.data[0]) | (uint16_t(parsed->payload.data[1]) << 8); @@ -1742,11 +1742,11 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){ MIBLEsensors[_slot].NMT = pld->NMT; MIBLEsensors[_slot].eventType.NMT = 1; MI32.mode.shallTriggerTele = 1; - // AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 17: NMT: %u seconds"), _beacon.NMT); + // AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Mode 17: NMT: %u seconds"), _beacon.NMT); } break; default: { - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Unknown MI pld")); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Unknown MI pld")); res = 0; } break; } @@ -1771,7 +1771,7 @@ void MI32ParseResponse(const uint8_t *buf, uint16_t bufsize, const uint8_t* addr MI32_ReverseMAC(addrrev); if (memcmp(addrrev, parsed.macdata.mac, 6)){ - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: MI packet with MAC addr mismatch - is this mesh?")); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: MI packet with MAC addr mismatch - is this mesh?")); memcpy(addrrev, parsed.macdata.mac, 6); MI32_ReverseMAC(addrrev); addr = addrrev; @@ -1785,7 +1785,7 @@ void MI32ParseResponse(const uint8_t *buf, uint16_t bufsize, const uint8_t* addr } MIBLEsensors[_slot].RSSI=RSSI; if (!res){ // - if the payload is not valid - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: MIParsePacket returned %d"), res); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: MIParsePacket returned %d"), res); return; } else { } @@ -1814,14 +1814,14 @@ void MI32removeMIBLEsensor(uint8_t* MAC){ \***********************************************************************/ void MI32notifyHT_LY(int slot, char *_buf, int len){ - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: raw data: %x%x%x%x%x%x%x"),D_CMND_MI32,_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6]); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: raw data: %x%x%x%x%x%x%x"),D_CMND_MI32,_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6]); // the value 0b00 is 28.16 C? if(_buf[0] != 0 || _buf[1] != 0){ memcpy(&LYWSD0x_HT,(void *)_buf,sizeof(LYWSD0x_HT)); - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: %s: T * 100: %u, H: %u, V: %u"),D_CMND_MI32,LYWSD0x_HT.temp,LYWSD0x_HT.hum, LYWSD0x_HT.volt); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: %s: T * 100: %u, H: %u, V: %u"),D_CMND_MI32,LYWSD0x_HT.temp,LYWSD0x_HT.hum, LYWSD0x_HT.volt); uint32_t _slot = slot; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: MIBLE: Sensor slot: %u"), _slot); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: MIBLE: Sensor slot: %u"), _slot); static float _tempFloat; _tempFloat=(float)(LYWSD0x_HT.temp)/100.0f; if(_tempFloat<60){ @@ -1831,7 +1831,7 @@ void MI32notifyHT_LY(int slot, char *_buf, int len){ _tempFloat=(float)LYWSD0x_HT.hum; if(_tempFloat<100){ MIBLEsensors[_slot].hum = _tempFloat; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: LYWSD0x: hum updated")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG_MORE,PSTR("M32: LYWSD0x: hum updated")); } MIBLEsensors[_slot].eventType.tempHum = 1; if (MIBLEsensors[_slot].type == MI_LYWSD03MMC || MIBLEsensors[_slot].type == MI_MHOC401){ @@ -1875,7 +1875,7 @@ void MI32Every50mSecond(){ void MI32EverySecond(bool restart){ -// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("M32: onesec")); +// AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("M32: onesec")); MI32TimeoutSensors(); MI32ShowSomeSensors(); @@ -1893,7 +1893,7 @@ void MI32EverySecond(bool restart){ if (MI32.secondsCounter >= MI32.period){ // only if we finished the last read if (MI32.sensorreader.slot >= MIBLEsensors.size()){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Kick off readOneSensor")); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Kick off readOneSensor")); // kick off notification sensor reading every period. MI32.sensorreader.slot = 0; MI32.secondsCounter = 0; @@ -1903,11 +1903,11 @@ void MI32EverySecond(bool restart){ if (MI32.secondsCounter2 >= MI32.period){ if (MI32.mqttCurrentSlot >= MIBLEsensors.size()){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Kick off tele sending")); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Kick off tele sending")); MI32.mqttCurrentSlot = 0; MI32.secondsCounter2 = 0; } else { - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Hit tele time, restarted but not finished last - lost from slot %d")+MI32.mqttCurrentSlot); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Hit tele time, restarted but not finished last - lost from slot %d")+MI32.mqttCurrentSlot); MI32.mqttCurrentSlot = 0; MI32.secondsCounter2 = 0; } @@ -1968,15 +1968,15 @@ void CmndMi32Time(void) { if (MIBLEsensors.size() > slot) { int res = genericTimeWriteFn(slot); if (res > 0){ - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: will set Time")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: will set Time")); ResponseCmndNumber(slot); return; } if (res < 0) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: cannot set Time on sensor type")); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: cannot set Time on sensor type")); } if (res == 0) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: cannot set Time right now")); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: cannot set Time right now")); } } } @@ -2009,15 +2009,15 @@ void CmndMi32Unit(void) { // TOGGLE unit? int res = genericUnitWriteFn(slot, -1); if (res > 0){ - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: will toggle Unit")); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG, PSTR("M32: will toggle Unit")); ResponseCmndNumber(slot); return; } if (res < 0) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: cannot toggle Unit on sensor type")); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: cannot toggle Unit on sensor type")); } if (res == 0) { - AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: cannot toggle Unit right now")); + AddLog(LOG_LEVEL_ERROR, PSTR("M32: cannot toggle Unit right now")); } } } @@ -2091,7 +2091,7 @@ void CmndMi32Block(void){ MIBLEBlockList.push_back(_MACasBytes); MI32removeMIBLEsensor(_MACasBytes.buf); } - // AddLog_P(LOG_LEVEL_INFO,PSTR("M32: size of ilist: %u"), MIBLEBlockList.size()); + // AddLog(LOG_LEVEL_INFO,PSTR("M32: size of ilist: %u"), MIBLEBlockList.size()); } break; } MI32BlockListResp(); @@ -2136,7 +2136,7 @@ void MI32KeyListResp(){ void CmndMi32Keys(void){ #ifdef BLE_ESP32_ALIASES int op = XdrvMailbox.index; - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Key %d %s"), op, XdrvMailbox.data); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Key %d %s"), op, XdrvMailbox.data); int res = -1; switch(op){ @@ -2175,7 +2175,7 @@ void CmndMi32Keys(void){ return; } - AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Add key mac %s = key %s"), mac, key); + AddLog(LOG_LEVEL_ERROR,PSTR("M32: Add key mac %s = key %s"), mac, key); char tmp[20]; // convert mac back to string ToHex_P(addr,6,tmp,20,0); @@ -2186,7 +2186,7 @@ void CmndMi32Keys(void){ } while (p); if (added){ - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Added %d Keys"), added); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Added %d Keys"), added); MI32KeyListResp(); } else { MI32KeyListResp(); @@ -2194,7 +2194,7 @@ void CmndMi32Keys(void){ return; } break; case 2:{ // clear - if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Keys clearing %d"), MIBLEbindKeys.size()); + if (BLE_ESP32::BLEDebugMode > 0) AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Keys clearing %d"), MIBLEbindKeys.size()); for (int i = MIBLEbindKeys.size()-1; i >= 0; i--){ MIBLEbindKeys.pop_back(); } @@ -2246,9 +2246,9 @@ const char HTTP_MI_KEY_STYLE[] PROGMEM = ""; #define D_MI32_KEY "MI32 Set Key" void HandleMI32Key(){ - AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: HandleMI32Key hit")); + AddLog(LOG_LEVEL_DEBUG, PSTR("M32: HandleMI32Key hit")); if (!HttpCheckPriviledgedAccess()) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: !HttpCheckPriviledgedAccess()")); + AddLog(LOG_LEVEL_DEBUG, PSTR("M32: !HttpCheckPriviledgedAccess()")); return; } WSContentStart_P(PSTR(D_MI32_KEY)); @@ -2292,7 +2292,7 @@ void MI32TimeoutSensors(){ //if (MIBLEsensors[i].MAC[2] || MIBLEsensors[i].MAC[3] || MIBLEsensors[i].MAC[4] || MIBLEsensors[i].MAC[5]){ if (!BLE_ESP32::devicePresent(MIBLEsensors[i].MAC)){ uint8_t *mac = MIBLEsensors[i].MAC; - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Dev no longer present MAC: %02x%02x%02x%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: Dev no longer present MAC: %02x%02x%02x%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); TasAutoMutex localmutex(&slotmutex, "Mi32Timeout"); MIBLEsensors.erase(MIBLEsensors.begin() + i); } @@ -2497,7 +2497,7 @@ void MI32ShowSomeSensors(){ } ResponseAppend_P(PSTR("}")); MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain); - //AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data); + //AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data); #ifdef USE_RULES RulesTeleperiod(); // Allow rule based HA messages @@ -2547,7 +2547,7 @@ void MI32ShowTriggeredSensors(){ if (cnt){ // if we got one, then publish ResponseAppend_P(PSTR("}")); MqttPublishPrefixTopic_P(STAT, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: triggered %d %s"),D_CMND_MI32, sensor, TasmotaGlobal.mqtt_data); + AddLog(LOG_LEVEL_DEBUG,PSTR("M32: %s: triggered %d %s"),D_CMND_MI32, sensor, TasmotaGlobal.mqtt_data); #ifdef USE_RULES RulesTeleperiod(); // Allow rule based HA messages diff --git a/tasmota/xsns_62_MI_HM10.ino b/tasmota/xsns_62_MI_HM10.ino index af3ce56ca..48057240d 100644 --- a/tasmota/xsns_62_MI_HM10.ino +++ b/tasmota/xsns_62_MI_HM10.ino @@ -624,7 +624,7 @@ uint32_t MIBLEgetSensorSlot(uint8_t (&_MAC)[6], uint16_t _type, int _rssi){ break; } MIBLEsensors.push_back(_newSensor); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: new %s at slot: %u"),D_CMND_HM10, kHM10DeviceType[_type-1],MIBLEsensors.size()-1); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: new %s at slot: %u"),D_CMND_HM10, kHM10DeviceType[_type-1],MIBLEsensors.size()-1); return MIBLEsensors.size()-1; }; @@ -638,7 +638,7 @@ void HM10SerialInit(void) { HM10.serialSpeed = HM10_BAUDRATE; HM10Serial = new TasmotaSerial(Pin(GPIO_HM10_RX), Pin(GPIO_HM10_TX), 1, 0, HM10_MAX_RX_BUF); if (HM10Serial->begin(HM10.serialSpeed)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s start serial communication fixed to 115200 baud"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s start serial communication fixed to 115200 baud"),D_CMND_HM10); if (HM10Serial->hardwareSerial()) { ClaimSerial(); DEBUG_SENSOR_LOG(PSTR("%s: claim HW"),D_CMND_HM10); @@ -681,7 +681,7 @@ void HM10parseMiBeacon(char * _buf, uint32_t _slot){ HM10_ReverseMAC(_beacon.MAC); // if(memcmp(_beacon.MAC,MIBLEsensors[_slot].MAC,sizeof(_beacon.MAC))!=0){ // if (MIBLEsensors[_slot].showedUp>3) return; // probably false alarm from a damaged packet - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: remove garbage sensor"),D_CMND_HM10); + // AddLog(LOG_LEVEL_DEBUG, PSTR("%s: remove garbage sensor"),D_CMND_HM10); // DEBUG_SENSOR_LOG(PSTR("%s i: %x %x %x %x %x %x"),D_CMND_HM10, MIBLEsensors[_slot].MAC[5], MIBLEsensors[_slot].MAC[4],MIBLEsensors[_slot].MAC[3],MIBLEsensors[_slot].MAC[2],MIBLEsensors[_slot].MAC[1],MIBLEsensors[_slot].MAC[0]); // DEBUG_SENSOR_LOG(PSTR("%s n: %x %x %x %x %x %x"),D_CMND_HM10, _beacon.MAC[5], _beacon.MAC[4], _beacon.MAC[3],_beacon.MAC[2],_beacon.MAC[1],_beacon.MAC[0]); // MIBLEsensors.erase(MIBLEsensors.begin()+_slot); @@ -697,7 +697,7 @@ void HM10parseMiBeacon(char * _buf, uint32_t _slot){ DEBUG_SENSOR_LOG(PSTR("LYWSD03 and CGD1 no support for MiBeacon, type %u"),MIBLEsensors[_slot].type); return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: %s mibeacon type: %x"),D_CMND_HM10, kHM10DeviceType[MIBLEsensors[_slot].type-1], _beacon.type); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: %s mibeacon type: %x"),D_CMND_HM10, kHM10DeviceType[MIBLEsensors[_slot].type-1], _beacon.type); DEBUG_SENSOR_LOG(PSTR("%s at slot %u"), kHM10DeviceType[MIBLEsensors[_slot].type-1],_slot); switch(_beacon.type){ @@ -848,7 +848,7 @@ void HM10readHT_LY(char *_buf){ if(_buf[0]==0x4f && _buf[1]==0x4b) return; // "OK" if(_buf[0] != 0 && _buf[1] != 0){ LYWSD0x_HT_t *packet = (LYWSD0x_HT_t*)_buf; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H: %u"),D_CMND_HM10,packet->temp,packet->hum); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H: %u"),D_CMND_HM10,packet->temp,packet->hum); uint32_t _slot = HM10.state.sensor; DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot); @@ -881,7 +881,7 @@ void HM10readHT_CGD1(char *_buf){ if(_buf[0] == 0){ if(_buf[1]==0 && _buf[2]==0 && _buf[3]==0 && _buf[4]==0) return; CGD1_HT_t *_packet = (CGD1_HT_t*)_buf; - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H * 100: %u"),D_CMND_HM10,_packet->temp,_packet->hum); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H * 100: %u"),D_CMND_HM10,_packet->temp,_packet->hum); uint32_t _slot = HM10.state.sensor; DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot); @@ -911,7 +911,7 @@ void HM10readHT_MJ_HT_V1(char *_buf){ // 0123456789012 uint32_t _temp = (atoi(_buf+2) * 10) + atoi(_buf+5); uint32_t _hum = (atoi(_buf+9) * 10) + atoi(_buf+12); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: T * 10: %u, H * 10: %u"),D_CMND_HM10,_temp,_hum); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: T * 10: %u, H * 10: %u"),D_CMND_HM10,_temp,_hum); uint32_t _slot = HM10.state.sensor; DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot); @@ -937,7 +937,7 @@ void HM10readTLMF(char *_buf){ AddLogBuffer(LOG_LEVEL_DEBUG, (uint8_t*)_buf,16); Flora_TLMF_t *_packet = (Flora_TLMF_t*)_buf; if(_packet->ID==0xFB003C02){ // this is a magic word ... hopefully independent of FW version - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: T * 10: %u, L: %u, M: %u, F: %u"),D_CMND_HM10,_packet->temp,_packet->lux,_packet->moist,_packet->fert); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: T * 10: %u, L: %u, M: %u, F: %u"),D_CMND_HM10,_packet->temp,_packet->lux,_packet->moist,_packet->fert); uint32_t _slot = HM10.state.sensor; DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot); MIBLEsensors[_slot].showedUp=255; // this sensor is real @@ -968,7 +968,7 @@ bool HM10readBat(char *_buf){ // if (MIBLEsensors[_slot].type == LYWSD03MMC || MIBLEsensors[_slot].type == MHOC401) return true; // } if(_buf[0] != 0){ - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Battery: %u"),D_CMND_HM10,_buf[0]); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s: Battery: %u"),D_CMND_HM10,_buf[0]); DEBUG_SENSOR_LOG(PSTR("MIBLE: Sensor slot: %u"), _slot); if(_buf[0]<101){ MIBLEsensors[_slot].bat=_buf[0]; @@ -1008,13 +1008,13 @@ void HM10HandleGenericBeacon(void){ } // else handle scan if(MIBLEscanResult.size()>19) { - AddLog_P(LOG_LEVEL_INFO,PSTR("HM10: Scan buffer full")); + AddLog(LOG_LEVEL_INFO,PSTR("HM10: Scan buffer full")); HM10.state.beaconScanCounter = 1; return; } for(auto _scanResult : MIBLEscanResult){ if(memcmp(HM10.rxAdvertisement.MAC,_scanResult.MAC,6)==0){ - // AddLog_P(LOG_LEVEL_INFO,PSTR("HM10: known device")); + // AddLog(LOG_LEVEL_INFO,PSTR("HM10: known device")); return; } } @@ -1036,12 +1036,12 @@ void HM10addBeacon(uint8_t index, char* data){ _new.time = 0; if(memcmp(_empty,_new.MAC,6) == 0){ _new.active = false; - AddLog_P(LOG_LEVEL_INFO,PSTR("HM10: beacon%u deactivated"), index); + AddLog(LOG_LEVEL_INFO,PSTR("HM10: beacon%u deactivated"), index); } else{ _new.active = true; HM10.mode.activeBeacon = 1; - AddLog_P(LOG_LEVEL_INFO,PSTR("HM10: beacon added with MAC: %s"), _MAC); + AddLog(LOG_LEVEL_INFO,PSTR("HM10: beacon added with MAC: %s"), _MAC); } } @@ -1105,7 +1105,7 @@ bool HM10SerialHandleFeedback(){ // every 50 milliseconds *_rx= HM10Serial->read(); if(i==18){ if(memcmp(HM10.rxBuffer+4,"ISA:",4)==0){ //last 4 bytes of "OK+DISA:" should be safe enough - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s packet size: %u"),D_CMND_HM10,HM10.rxBuffer[16]); + // AddLog(LOG_LEVEL_DEBUG, PSTR("%s packet size: %u"),D_CMND_HM10,HM10.rxBuffer[16]); _targetsize = HM10.rxBuffer[16] + 19; // this is the size byte according to HM-10 docs if(_targetsize>64) _targetsize=64; memcpy(HM10.rxAdvertisement.MAC,HM10.rxBuffer+8,6); @@ -1180,7 +1180,7 @@ bool HM10SerialHandleFeedback(){ // every 50 milliseconds HM10HandleGenericBeacon(); } uint16_t _type = (uint8_t)HM10.rxAdvertisement.svcData[5]*256 + (uint8_t)HM10.rxAdvertisement.svcData[4]; - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("%04x %02x %04x %04x %04x"),HM10.rxAdvertisement.UUID,HM10.rxAdvertisement.TX,HM10.rxAdvertisement.CID,HM10.rxAdvertisement.SVC, _type); + // AddLog(LOG_LEVEL_DEBUG, PSTR("%04x %02x %04x %04x %04x"),HM10.rxAdvertisement.UUID,HM10.rxAdvertisement.TX,HM10.rxAdvertisement.CID,HM10.rxAdvertisement.SVC, _type); if(HM10.rxAdvertisement.SVC==0x181a) _type = 0xa1c; else if(HM10.rxAdvertisement.SVC==0xfdcd) _type = 0x0576; uint16_t _slot = MIBLEgetSensorSlot(HM10.rxAdvertisement.MAC, _type, HM10.rxAdvertisement.RSSI); @@ -1199,9 +1199,9 @@ bool HM10SerialHandleFeedback(){ // every 50 milliseconds break; case none: if(success) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: response: %s"),D_CMND_HM10, (char *)HM10.rxBuffer); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: response: %s"),D_CMND_HM10, (char *)HM10.rxBuffer); // for(uint32_t j = 0; jwrite("AT+ROLE1"); break; case TASK_HM10_IMME1: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: set imme to 1"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: set imme to 1"),D_CMND_HM10); HM10.current_task_delay = 5; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; HM10Serial->write("AT+IMME1"); break; case TASK_HM10_DISC: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: start discovery"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: start discovery"),D_CMND_HM10); HM10.current_task_delay = 90; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1247,14 +1247,14 @@ void HM10_TaskEvery100ms(){ HM10Serial->write("AT+DISA?"); break; case TASK_HM10_VERSION: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read version"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read version"),D_CMND_HM10); HM10.current_task_delay = 5; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; HM10Serial->write("AT+VERR?"); break; case TASK_HM10_NAME: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read name"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read name"),D_CMND_HM10); HM10.current_task_delay = 5; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1263,7 +1263,7 @@ void HM10_TaskEvery100ms(){ case TASK_HM10_CONN: char _con[20]; sprintf_P(_con,"AT+CON%02x%02x%02x%02x%02x%02x",MIBLEsensors[HM10.state.sensor].MAC[0],MIBLEsensors[HM10.state.sensor].MAC[1],MIBLEsensors[HM10.state.sensor].MAC[2],MIBLEsensors[HM10.state.sensor].MAC[3],MIBLEsensors[HM10.state.sensor].MAC[4],MIBLEsensors[HM10.state.sensor].MAC[5]); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: %s connect %s"),D_CMND_HM10,kHM10DeviceType[MIBLEsensors[HM10.state.sensor].type-1],_con); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: %s connect %s"),D_CMND_HM10,kHM10DeviceType[MIBLEsensors[HM10.state.sensor].type-1],_con); HM10.current_task_delay = 2; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1272,21 +1272,21 @@ void HM10_TaskEvery100ms(){ HM10.mode.connected = true; break; case TASK_HM10_DISCONN: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: disconnect"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: disconnect"),D_CMND_HM10); HM10.current_task_delay = 5; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; HM10Serial->write("AT"); break; case TASK_HM10_RESET: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: Reset Device"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: Reset Device"),D_CMND_HM10); HM10Serial->write("AT+RESET"); HM10.current_task_delay = 5; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; break; case TASK_HM10_SUB_L3: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: subscribe"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: subscribe"),D_CMND_HM10); HM10.current_task_delay = 25; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); HM10.mode.awaiting = tempHumLY; @@ -1294,7 +1294,7 @@ void HM10_TaskEvery100ms(){ HM10Serial->write("AT+NOTIFY_ON0037"); break; case TASK_HM10_UN_L3: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: un-subscribe"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: un-subscribe"),D_CMND_HM10); HM10.current_task_delay = 5; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1302,7 +1302,7 @@ void HM10_TaskEvery100ms(){ HM10Serial->write("AT+NOTIFYOFF0037"); break; case TASK_HM10_SUB_L2: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: subscribe"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: subscribe"),D_CMND_HM10); HM10.current_task_delay = 85; // set task delay HM10.mode.awaiting = tempHumLY; HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); @@ -1311,7 +1311,7 @@ void HM10_TaskEvery100ms(){ else HM10Serial->write("AT+NOTIFY_ON004B"); //MHO-C303 break; case TASK_HM10_UN_L2: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: un-subscribe"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: un-subscribe"),D_CMND_HM10); HM10.current_task_delay = 5; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1320,7 +1320,7 @@ void HM10_TaskEvery100ms(){ else HM10Serial->write("AT+NOTIFY_OFF004B"); //MHO-C303 break; case TASK_HM10_TIME_L2: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: set time"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: set time"),D_CMND_HM10); HM10.current_task_delay = 5; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1328,10 +1328,10 @@ void HM10_TaskEvery100ms(){ HM10Serial->write("AT+SEND_DATAWR002F"); HM10Serial->write(HM10.timebuf,4); HM10Serial->write(Rtc.time_timezone / 60); - AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s Time-string: %x%x%x%x%x"),D_CMND_HM10, HM10.timebuf[0],HM10.timebuf[1],HM10.timebuf[2],HM10.timebuf[3],(Rtc.time_timezone /60)); + AddLog(LOG_LEVEL_DEBUG,PSTR("%s Time-string: %x%x%x%x%x"),D_CMND_HM10, HM10.timebuf[0],HM10.timebuf[1],HM10.timebuf[2],HM10.timebuf[3],(Rtc.time_timezone /60)); break; // case TASK_HM10_READ_BT_L3: - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read handle 003A"),D_CMND_HM10); + // AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read handle 003A"),D_CMND_HM10); // HM10.current_task_delay = 2; // set task delay // HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); // runningTaskLoop = false; @@ -1339,7 +1339,7 @@ void HM10_TaskEvery100ms(){ // HM10.mode.awaiting = bat; // break; case TASK_HM10_READ_BT_L2: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0043"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0043"),D_CMND_HM10); HM10.current_task_delay = 2; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1348,7 +1348,7 @@ void HM10_TaskEvery100ms(){ HM10.mode.awaiting = bat; break; case TASK_HM10_READ_BF_FL: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0038"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0038"),D_CMND_HM10); HM10.current_task_delay = 2; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1356,7 +1356,7 @@ void HM10_TaskEvery100ms(){ HM10.mode.awaiting = bat; break; case TASK_HM10_CALL_TLMF_FL: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: write to handle 0033"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: write to handle 0033"),D_CMND_HM10); HM10.current_task_delay = 5; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_READ_TLMF_FL,i); runningTaskLoop = false; @@ -1366,7 +1366,7 @@ void HM10_TaskEvery100ms(){ HM10.mode.awaiting = none; break; case TASK_HM10_READ_TLMF_FL: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0035"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0035"),D_CMND_HM10); HM10.current_task_delay = 2; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1374,7 +1374,7 @@ void HM10_TaskEvery100ms(){ HM10.mode.awaiting = TLMF; break; case TASK_HM10_READ_B_CGD1: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0011"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0011"),D_CMND_HM10); HM10.current_task_delay = 2; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1382,7 +1382,7 @@ void HM10_TaskEvery100ms(){ HM10.mode.awaiting = bat; break; case TASK_HM10_SUB_HT_CGD1: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: subscribe 4b"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: subscribe 4b"),D_CMND_HM10); HM10.current_task_delay = 5; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1390,7 +1390,7 @@ void HM10_TaskEvery100ms(){ HM10Serial->write("AT+NOTIFY_ON004b"); break; case TASK_HM10_UN_HT_CGD1: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: un-subscribe 4b"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: un-subscribe 4b"),D_CMND_HM10); HM10.current_task_delay = 5; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1398,14 +1398,14 @@ void HM10_TaskEvery100ms(){ HM10Serial->write("AT+NOTIFYOFF004b"); break; case TASK_HM10_SCAN9: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: scan time to 9"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: scan time to 9"),D_CMND_HM10); HM10.current_task_delay = 2; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; HM10Serial->write("AT+SCAN9"); break; case TASK_HM10_READ_B_MJ: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0x18"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: read handle 0x18"),D_CMND_HM10); HM10.current_task_delay = 2; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1413,7 +1413,7 @@ void HM10_TaskEvery100ms(){ HM10.mode.awaiting = bat; break; case TASK_HM10_SUB_HT_MJ: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: subscribe to 0x0f"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: subscribe to 0x0f"),D_CMND_HM10); HM10.current_task_delay = 10; // set task delay HM10_TaskReplaceInSlot(TASK_HM10_FEEDBACK,i); runningTaskLoop = false; @@ -1421,22 +1421,22 @@ void HM10_TaskEvery100ms(){ HM10.mode.awaiting = tempHumMJ; break; case TASK_HM10_FEEDBACK: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: get response"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: get response"),D_CMND_HM10); HM10SerialHandleFeedback(); HM10.current_task_delay = HM10_TASK_LIST[i+1][1];; // set task delay HM10_TASK_LIST[i][0] = TASK_HM10_DONE; // no feedback for reset runningTaskLoop = false; break; case TASK_HM10_STATUS_EVENT: - AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: show status"),D_CMND_HM10); + AddLog(LOG_LEVEL_DEBUG, PSTR("%s: show status"),D_CMND_HM10); HM10StatusInfo(); HM10.current_task_delay = HM10_TASK_LIST[i+1][1];; // set task delay HM10_TASK_LIST[i][0] = TASK_HM10_DONE; // no feedback for reset runningTaskLoop = false; break; case TASK_HM10_DONE: // this entry was already handled - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFound done HM10_TASK"),D_CMND_HM10); - // AddLog_P(LOG_LEVEL_DEBUG, PSTR("%snext slot:%u, i: %u"),D_CMND_HM10, HM10_TASK_LIST[i+1][0],i); + // AddLog(LOG_LEVEL_DEBUG, PSTR("%sFound done HM10_TASK"),D_CMND_HM10); + // AddLog(LOG_LEVEL_DEBUG, PSTR("%snext slot:%u, i: %u"),D_CMND_HM10, HM10_TASK_LIST[i+1][0],i); if(HM10_TASK_LIST[i+1][0] == TASK_HM10_NOTASK) { // check the next entry and if there is none DEBUG_SENSOR_LOG(PSTR("%sno Tasks left"),D_CMND_HM10); DEBUG_SENSOR_LOG(PSTR("%sHM10_TASK_DONE current slot %u"),D_CMND_HM10, i); @@ -1462,7 +1462,7 @@ void HM10StatusInfo() { /* char stemp[20]; snprintf_P(stemp, sizeof(stemp),PSTR("{%s:{\"found\": %u}}"),D_CMND_HM10, MIBLEsensors.size()); - AddLog_P(LOG_LEVEL_INFO, stemp); + AddLog(LOG_LEVEL_INFO, stemp); RulesProcessEvent(stemp); */ Response_P(PSTR("{\"%s\":{\"found\":%u}}"), D_CMND_HM10, MIBLEsensors.size()); @@ -1688,7 +1688,7 @@ void CmndHM10Block(void){ switch (XdrvMailbox.index) { case 0: MIBLEBlockList.clear(); - // AddLog_P(LOG_LEVEL_INFO,PSTR("HM10: size of ilist: %u"), MIBLEBlockList.size()); + // AddLog(LOG_LEVEL_INFO,PSTR("HM10: size of ilist: %u"), MIBLEBlockList.size()); ResponseCmndIdxChar(PSTR("block list cleared")); break; case 1: @@ -1718,7 +1718,7 @@ void CmndHM10Block(void){ ResponseCmndIdxChar(XdrvMailbox.data); HM10removeMIBLEsensor(_MACasBytes.buf); } - // AddLog_P(LOG_LEVEL_INFO,PSTR("HM10: size of ilist: %u"), MIBLEBlockList.size()); + // AddLog(LOG_LEVEL_INFO,PSTR("HM10: size of ilist: %u"), MIBLEBlockList.size()); break; } } diff --git a/tasmota/xsns_65_hdc1080.ino b/tasmota/xsns_65_hdc1080.ino index d20241ab8..a684f36ec 100644 --- a/tasmota/xsns_65_hdc1080.ino +++ b/tasmota/xsns_65_hdc1080.ino @@ -176,7 +176,7 @@ bool HdcTriggerRead(void) { hdc_next_read = millis() + HDC1080_CONV_TIME; if(status) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("HdcTriggerRead: failed to open the transaction for HDC_REG_TEMP. Status = %d"), status); + AddLog(LOG_LEVEL_DEBUG, PSTR("HdcTriggerRead: failed to open the transaction for HDC_REG_TEMP. Status = %d"), status); return false; } @@ -205,7 +205,7 @@ bool HdcRead(void) { status = HdcTransactionClose(HDC1080_ADDR, sensor_data, 4); if(status) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("HdcRead: failed to read HDC_REG_TEMP. Status = %d"), status); + AddLog(LOG_LEVEL_DEBUG, PSTR("HdcRead: failed to read HDC_REG_TEMP. Status = %d"), status); return false; } @@ -213,7 +213,7 @@ bool HdcRead(void) { temp_data = (uint16_t) ((sensor_data[0] << 8) | sensor_data[1]); rh_data = (uint16_t) ((sensor_data[2] << 8) | sensor_data[3]); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("HdcRead: temperature raw data: 0x%04x; humidity raw data: 0x%04x"), temp_data, rh_data); + AddLog(LOG_LEVEL_DEBUG, PSTR("HdcRead: temperature raw data: 0x%04x; humidity raw data: 0x%04x"), temp_data, rh_data); // read the temperature from the first 16 bits of the result @@ -237,7 +237,7 @@ bool HdcRead(void) { void HdcDetect(void) { if (I2cActive(HDC1080_ADDR)) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("HdcDetect: Address = 0x%02X already in use."), HDC1080_ADDR); +// AddLog(LOG_LEVEL_DEBUG, PSTR("HdcDetect: Address = 0x%02X already in use."), HDC1080_ADDR); return; } @@ -245,7 +245,7 @@ void HdcDetect(void) { hdc_manufacturer_id = HdcReadManufacturerId(); hdc_device_id = HdcReadDeviceId(); - AddLog_P(LOG_LEVEL_DEBUG, PSTR("HdcDetect: detected device with manufacturerId = 0x%04X and deviceId = 0x%04X"), hdc_manufacturer_id, hdc_device_id); + AddLog(LOG_LEVEL_DEBUG, PSTR("HdcDetect: detected device with manufacturerId = 0x%04X and deviceId = 0x%04X"), hdc_manufacturer_id, hdc_device_id); if (hdc_device_id == HDC1080_DEV_ID) { HdcInit(); @@ -284,7 +284,7 @@ void HdcShow(bool json) { bool Xsns65(uint8_t function) { if (!I2cEnabled(XI2C_45)) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("Xsns65: I2C driver not enabled for this device.")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("Xsns65: I2C driver not enabled for this device.")); return false; } diff --git a/tasmota/xsns_66_iAQ.ino b/tasmota/xsns_66_iAQ.ino index fc3dff2da..0cbf17276 100644 --- a/tasmota/xsns_66_iAQ.ino +++ b/tasmota/xsns_66_iAQ.ino @@ -69,7 +69,7 @@ void IAQ_Read(void) { for( uint32_t i=0; i<9; i++ ) { buf[i]= Wire.read(); } - // AddLog_P(LOG_LEVEL_DEBUG, "iAQ: buffer %x %x %x %x %x %x %x %x %x ", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8]); + // AddLog(LOG_LEVEL_DEBUG, "iAQ: buffer %x %x %x %x %x %x %x %x %x ", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8]); iAQ.pred = (buf[0]<<8) + buf[1]; iAQ.status = buf[2]; iAQ.resistance = ((uint32_t)buf[3]<<24) + ((uint32_t)buf[4]<<16) + ((uint32_t)buf[5]<<8) + (uint32_t)buf[6]; @@ -95,7 +95,7 @@ void IAQ_Show(uint8_t json) if (json) { if (iAQ.status!=IAQ_STATUS_OK){ - AddLog_P(LOG_LEVEL_INFO, PSTR("iAQ: " D_ERROR " %x" ),iAQ.status); + AddLog(LOG_LEVEL_INFO, PSTR("iAQ: " D_ERROR " %x" ),iAQ.status); return; } else { diff --git a/tasmota/xsns_67_as3935.ino b/tasmota/xsns_67_as3935.ino index 030581768..10df27a6e 100644 --- a/tasmota/xsns_67_as3935.ino +++ b/tasmota/xsns_67_as3935.ino @@ -218,7 +218,7 @@ bool AS3935AutoTuneCaps(uint8_t irqpin) { // functions bool AS3935CalRCOResult(void) { if(AS3935ReadRegister(CAL_SRCO_NOK) || AS3935ReadRegister(CAL_TRCO_NOK)) { - AddLog_P(LOG_LEVEL_INFO, PSTR("I2C: AS3935 Fatal Failure of TRCO or SRCO calibration")); + AddLog(LOG_LEVEL_INFO, PSTR("I2C: AS3935 Fatal Failure of TRCO or SRCO calibration")); return false; } return true; @@ -514,7 +514,7 @@ void AS3935Detect(void) { if (!AS3935Setup()) return; as3935_sensor.active = true; } else { - AddLog_P(LOG_LEVEL_INFO, PSTR("I2C: AS3935 GPIO Pin not defined!")); + AddLog(LOG_LEVEL_INFO, PSTR("I2C: AS3935 GPIO Pin not defined!")); } } } diff --git a/tasmota/xsns_68_windmeter.ino b/tasmota/xsns_68_windmeter.ino index 6b552ee38..463a6ebbe 100644 --- a/tasmota/xsns_68_windmeter.ino +++ b/tasmota/xsns_68_windmeter.ino @@ -79,7 +79,7 @@ void ICACHE_RAM_ATTR WindMeterUpdateSpeed(void) if (time_diff > Settings.windmeter_pulse_debounce * 1000) { WindMeter.counter_time = time; WindMeter.counter++; -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMET: Counter %d"), WindMeter.counter); +// AddLog(LOG_LEVEL_DEBUG, PSTR("WMET: Counter %d"), WindMeter.counter); } } @@ -119,7 +119,7 @@ void WindMeterEverySecond(void) { //uint32_t time = micros(); //uint32_t delta_time = time - WindMeter.speed_time; - //AddLog_P(LOG_LEVEL_INFO, PSTR("delta_time: %d"), delta_time); + //AddLog(LOG_LEVEL_INFO, PSTR("delta_time: %d"), delta_time); // speed = ( (pulses / pulses_per_rotation) * (2 * pi * radius) ) / delta_time WindMeter.speed = ((WindMeter.counter / Settings.windmeter_pulses_x_rot) * (windmeter_2pi * ((float)Settings.windmeter_radius / 1000))) * ((float)Settings.windmeter_speed_factor / 1000); @@ -131,7 +131,7 @@ void WindMeterEverySecond(void) //dtostrfd(WindMeter.speed, 2, speed_string); //char uspeed_string[FLOATSZ]; //dtostrfd(ConvertSpeed(WindMeter.speed), 2, uspeed_string); - //AddLog_P(LOG_LEVEL_DEBUG, PSTR("WMET: Speed %s [m/s] - %s [unit]"), speed_string, uspeed_string); + //AddLog(LOG_LEVEL_DEBUG, PSTR("WMET: Speed %s [m/s] - %s [unit]"), speed_string, uspeed_string); #ifndef USE_WINDMETER_NOSTATISTICS if (WindMeter.speed < WindMeter.speed_min) { diff --git a/tasmota/xsns_69_opentherm.ino b/tasmota/xsns_69_opentherm.ino index adcef07b0..1f8bd1609 100644 --- a/tasmota/xsns_69_opentherm.ino +++ b/tasmota/xsns_69_opentherm.ino @@ -165,7 +165,7 @@ void ICACHE_RAM_ATTR sns_opentherm_handleInterrupt() void sns_opentherm_processResponseCallback(unsigned long response, int st) { OpenThermResponseStatus status = (OpenThermResponseStatus)st; - AddLog_P(LOG_LEVEL_DEBUG_MORE, + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("[OTH]: Processing response. Status=%s, Response=0x%lX"), sns_ot_master->statusToString(status), response); @@ -311,7 +311,7 @@ void sns_ot_start_handshake() return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("[OTH]: perform handshake")); + AddLog(LOG_LEVEL_DEBUG, PSTR("[OTH]: perform handshake")); sns_ot_master->sendRequestAync( OpenTherm::buildRequest(OpenThermMessageType::READ_DATA, OpenThermMessageID::SConfigSMemberIDcode, 0)); @@ -325,14 +325,14 @@ void sns_ot_process_handshake(unsigned long response, int st) if (status != OpenThermResponseStatus::SUCCESS || !sns_ot_master->isValidResponse(response)) { - AddLog_P(LOG_LEVEL_ERROR, + AddLog(LOG_LEVEL_ERROR, PSTR("[OTH]: getSlaveConfiguration failed. Status=%s"), sns_ot_master->statusToString(status)); sns_ot_connection_status = OpenThermConnectionStatus::OTC_DISCONNECTED; return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR("[OTH]: getLastResponseStatus SUCCESS. Slave Cfg: %lX"), response); + AddLog(LOG_LEVEL_DEBUG, PSTR("[OTH]: getLastResponseStatus SUCCESS. Slave Cfg: %lX"), response); sns_ot_boiler_status.m_slave_flags = (response & 0xFF00) >> 8; diff --git a/tasmota/xsns_69_opentherm_protocol.ino b/tasmota/xsns_69_opentherm_protocol.ino index 6158be9c7..f08d6b8a6 100644 --- a/tasmota/xsns_69_opentherm_protocol.ino +++ b/tasmota/xsns_69_opentherm_protocol.ino @@ -168,7 +168,7 @@ unsigned long sns_opentherm_set_slave_flags(struct OpenThermCommandT *self, stru } if (self->m_results[1].m_bool != centralHeatingIsOn) { - AddLog_P(LOG_LEVEL_INFO, + AddLog(LOG_LEVEL_INFO, PSTR("[OTH]: Central Heating transitioning from %s to %s"), self->m_results[1].m_bool ? "on" : "off", status->m_enableCentralHeating ? "on" : "off"); @@ -219,7 +219,7 @@ unsigned long sns_opentherm_set_boiler_temperature(struct OpenThermCommandT *sel { return -1; } - AddLog_P(LOG_LEVEL_INFO, + AddLog(LOG_LEVEL_INFO, PSTR("[OTH]: Setting Boiler Temp. Old: %d, New: %d"), (int)self->m_results[0].m_float, (int)status->m_boilerSetpoint); @@ -258,7 +258,7 @@ unsigned long sns_opentherm_set_boiler_dhw_temperature(struct OpenThermCommandT { return -1; } - AddLog_P(LOG_LEVEL_INFO, + AddLog(LOG_LEVEL_INFO, PSTR("[OTH]: Setting Hot Water Temp. Old: %d, New: %d"), (int)self->m_results[0].m_float, (int)status->m_hotWaterSetpoint); @@ -400,7 +400,7 @@ void sns_opentherm_check_retry_request() if (!canRetry && !cmd->m_flags.supported) { cmd->m_flags.notSupported = true; - AddLog_P(LOG_LEVEL_ERROR, + AddLog(LOG_LEVEL_ERROR, PSTR("[OTH]: command %s is not supported by the boiler. Last status: %s"), cmd->m_command_name, sns_ot_master->statusToString(sns_ot_master->getLastResponseStatus())); diff --git a/tasmota/xsns_75_prometheus.ino b/tasmota/xsns_75_prometheus.ino index 0dac5ed9f..bbdb303c5 100644 --- a/tasmota/xsns_75_prometheus.ino +++ b/tasmota/xsns_75_prometheus.ino @@ -63,7 +63,7 @@ String FormatMetricName(const char *metric) { // cleanup spaces and uppercases void HandleMetrics(void) { if (!HttpCheckPriviledgedAccess()) { return; } - AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Prometheus")); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Prometheus")); WSContentBegin(200, CT_PLAIN); diff --git a/tasmota/xsns_77_vl53l1x.ino b/tasmota/xsns_77_vl53l1x.ino index f245fda86..76908ad6e 100644 --- a/tasmota/xsns_77_vl53l1x.ino +++ b/tasmota/xsns_77_vl53l1x.ino @@ -36,8 +36,8 @@ VL53L1X vl53l1x = VL53L1X(); // create object copy #define VL53L1X_ADDRESS 0x29 struct { - bool ready = false; uint16_t distance = 0; + bool ready = false; } vl53l1x_sensors; /********************************************************************************************/ @@ -54,13 +54,7 @@ void Vl53l1Detect(void) { vl53l1x_sensors.ready = true; } -#ifdef USE_WEBSERVER -const char HTTP_SNS_VL53L1X[] PROGMEM = - "{s}VL53L1X " D_DISTANCE "{m}%d" D_UNIT_MILLIMETER "{e}"; // {s} = , {m} = , {e} = -#endif // USE_WEBSERVER - void Vl53l1Every_250MSecond(void) { - // every 250 ms uint16_t dist = vl53l1x.read(); if (!dist || dist > 4000) { dist = 9999; @@ -78,15 +72,15 @@ void Vl53l1Every_Second(void) { void Vl53l1Show(bool json) { if (json) { + ResponseAppend_P(PSTR(",\"VL53L1X\":{\"" D_JSON_DISTANCE "\":%d}"), vl53l1x_sensors.distance); #ifdef USE_DOMOTICZ if (0 == TasmotaGlobal.tele_period) { Vl53l1Every_Second(); } #endif // USE_DOMOTICZ - ResponseAppend_P(PSTR(",\"VL53L1X\":{\"" D_JSON_DISTANCE "\":%d}"), vl53l1x_sensors.distance); #ifdef USE_WEBSERVER } else { - WSContentSend_PD(HTTP_SNS_VL53L1X, vl53l1x_sensors.distance); + WSContentSend_PD(HTTP_SNS_DISTANCE, PSTR("VL53L1X"), vl53l1x_sensors.distance); #endif } } @@ -95,9 +89,9 @@ void Vl53l1Show(bool json) { * Interface \*********************************************************************************************/ -bool Xsns77(uint8_t function) -{ +bool Xsns77(uint8_t function) { if (!I2cEnabled(XI2C_54)) { return false; } + bool result = false; if (FUNC_INIT == function) { diff --git a/tasmota/xsns_79_as608.ino b/tasmota/xsns_79_as608.ino index 7bff7736c..fba9e8afc 100644 --- a/tasmota/xsns_79_as608.ino +++ b/tasmota/xsns_79_as608.ino @@ -103,7 +103,7 @@ void As608Init(void) { if (As608Finger->verifyPassword()) { As608Finger->getTemplateCount(); - AddLog_P(LOG_LEVEL_INFO, PSTR("AS6: Detected with %d fingerprint(s) stored"), As608Finger->templateCount); + AddLog(LOG_LEVEL_INFO, PSTR("AS6: Detected with %d fingerprint(s) stored"), As608Finger->templateCount); As608.selected = true; } } @@ -147,7 +147,7 @@ void As608Loop(void) { // p = As608Finger->fingerFastSearch(); // Match found - fails on R503 p = As608Finger->fingerSearch(); // Match found if (p != FINGERPRINT_OK) { -// AddLog_P(LOG_LEVEL_DEBUG, PSTR("AS6: No matching finger")); +// AddLog(LOG_LEVEL_DEBUG, PSTR("AS6: No matching finger")); return; } diff --git a/tasmota/xsns_80_mfrc522.ino b/tasmota/xsns_80_mfrc522.ino index 9a9b19e21..29207819c 100644 --- a/tasmota/xsns_80_mfrc522.ino +++ b/tasmota/xsns_80_mfrc522.ino @@ -25,7 +25,7 @@ * Connections: * MFRC522 ESP8266 Tasmota * ------- -------------- ---------- - * SDA GPIO0..5,15,16 SPI CS + * SDA GPIO0..5,15,16 RC522 CS * SCK GPIO14 SPI CLK * MOSI GPIO13 SPI MOSI * MISO GPIO12 SPI MISO @@ -113,7 +113,7 @@ void RC522Init(void) { } uint8_t empty_uid[4] = { 0 }; ToHex_P((unsigned char*)empty_uid, sizeof(empty_uid), Rc522.uids, sizeof(Rc522.uids)); - AddLog_P(LOG_LEVEL_INFO, PSTR("MFR: RC522 Rfid Reader detected %s"), ver); + AddLog(LOG_LEVEL_INFO, PSTR("MFR: RC522 Rfid Reader detected %s"), ver); Rc522.present = true; // } // Mfrc522->PCD_Init(); // Re-init as SelfTest blows init diff --git a/tasmota/xsns_81_seesaw_soil.ino b/tasmota/xsns_81_seesaw_soil.ino index 87c679a1a..e18a5db5c 100644 --- a/tasmota/xsns_81_seesaw_soil.ino +++ b/tasmota/xsns_81_seesaw_soil.ino @@ -159,7 +159,7 @@ void seeSoilDetect(void) { // detect sensors buf = (uint8_t) Wire.read(); if (buf != SEESAW_HW_ID_CODE) { // check hardware id #ifdef DEBUG_SEESAW_SOIL - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SEE: HWID mismatch ADDR=%X, ID=%X"), addr, buf); + AddLog(LOG_LEVEL_DEBUG, PSTR("SEE: HWID mismatch ADDR=%X, ID=%X"), addr, buf); #endif // DEBUG_SEESAW_SOIL continue; } @@ -173,7 +173,7 @@ void seeSoilDetect(void) { // detect sensors SeeSoil.count++; SeeSoil.present = true; #ifdef DEBUG_SEESAW_SOIL - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SEE: FOUND sensor %u at %02X"), i, addr); + AddLog(LOG_LEVEL_DEBUG, PSTR("SEE: FOUND sensor %u at %02X"), i, addr); #endif // DEBUG_SEESAW_SOIL } } @@ -201,7 +201,7 @@ void seeSoilCommand(uint32_t command) { // issue commands to sensors break; default: #ifdef DEBUG_SEESAW_SOIL - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SEE: ILL CMD:%02X"), command); + AddLog(LOG_LEVEL_DEBUG, PSTR("SEE: ILL CMD:%02X"), command); #endif // DEBUG_SEESAW_SOIL return; } @@ -212,7 +212,7 @@ void seeSoilCommand(uint32_t command) { // issue commands to sensors Wire.write((uint8_t) regLow); uint32_t err = Wire.endTransmission(); #ifdef DEBUG_SEESAW_SOIL - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SEE: SNS=%u ADDR=%02X CMD=%02X ERR=%u"), i, addr, command, err); + AddLog(LOG_LEVEL_DEBUG, PSTR("SEE: SNS=%u ADDR=%02X CMD=%02X ERR=%u"), i, addr, command, err); #endif // DEBUG_SEESAW_SOIL } } @@ -242,7 +242,7 @@ void seeSoilRead(uint32_t command) { // read values from sensors #endif // SEESAW_SOIL_RAW } #ifdef DEBUG_SEESAW_SOIL - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SEE: READ #%u ADDR=%02X NUM=%u RET=%X"), i, SeeSoilSNS[i].address, num, ret); + AddLog(LOG_LEVEL_DEBUG, PSTR("SEE: READ #%u ADDR=%02X NUM=%u RET=%X"), i, SeeSoilSNS[i].address, num, ret); #endif // DEBUG_SEESAW_SOIL } } diff --git a/tasmota/xsns_82_wiegand.ino b/tasmota/xsns_82_wiegand.ino index ca707eaf7..b0607ef07 100644 --- a/tasmota/xsns_82_wiegand.ino +++ b/tasmota/xsns_82_wiegand.ino @@ -1,5 +1,5 @@ /* - xsns_82_wiegand.ino - Support for Wiegand Interface 125kHz NFC Tag Reader for Tasmota + xsns_82_wiegand.ino - Support for Wiegand Interface 125kHz Rfid Tag Reader for Tasmota Copyright (C) 2021 Sigurd Leuther and Theo Arends @@ -19,21 +19,33 @@ #ifdef USE_WIEGAND /*********************************************************************************************\ - MQTT: - %prefix%/%topic%/SENSOR = {"Time":"2021-01-13T12:30:38","Wiegand":{"UID":"rfid tag"}} - - Domoticz: - The nvalue will be always 0 and the svalue will contain the tag UID as string. + * Wiegand 24, 26, 32, 34 bit Rfid reader 125 kHz + * + * Wire connections for https://www.benselectronics.nl/wiegand-2634-bit-rfid-reader-125khze248d29925d602d.html + * Red Vdc + * Black Gnd + * Green D0 + * White D1 + * Yellow/Grey Sound Buzzer if connected to Gnd + * Blue Light Led if connected to Gnd + * Grey/Purple 34-bit if connected to Gnd + * + * MQTT: + * %prefix%/%topic%/SENSOR = {"Time":"2021-01-21T16:04:12","Wiegand":{"UID":7748328,"Size":26}} + * %prefix%/%topic%/SENSOR = {"Time":"2021-01-21T15:48:49","Wiegand":{"UID":4302741608,"Size":34}} + * + * Rule: + * on wiegand#uid=4302741608 do publish cmnd/ailight/power 2 endon \*********************************************************************************************/ #warning **** Wiegand interface enabled **** #define XSNS_82 82 -#define WIEGAND_BIT_TIMEOUT 25 //time to be wait after last bit detected. +#define WIEGAND_BIT_TIMEOUT 25 // Time in mSec to be wait after last bit detected. // Use only a randomly generate RFID for testing. using #define will save some space in the final code // DEV_WIEGAND_TEST_MODE 1 : testing with random rfid without hardware connected, but GPIOs set correctly -// DEV_WIEGAND_TEST_MODE 2 : testing with hardware corretly connected. +// DEV_WIEGAND_TEST_MODE 2 : testing with hardware correctly connected. #define DEV_WIEGAND_TEST_MODE 0 #ifdef DEV_WIEGAND_TEST_MODE @@ -55,7 +67,10 @@ class Wiegand { void ScanForTag(void); #ifdef USE_WEBSERVER void Show(void); -#endif +#endif // USE_WEBSERVER + + bool isInit = false; + uint8_t scanDelay; private: @@ -74,22 +89,20 @@ class Wiegand { static volatile uint16_t bitCount; static volatile uint32_t lastFoundTime; static volatile uint8_t timeOut; - bool isInit = false; #if (DEV_WIEGAND_TEST_MODE)==1 uint64_t GetRandomRfid(uint8_t); -#endif +#endif // DEV_WIEGAND_TEST_MODE==1 }; Wiegand* oWiegand = new Wiegand(); -uint8_t scanDelay; volatile uint64_t Wiegand::rfidBuffer; volatile uint16_t Wiegand::bitCount; volatile uint32_t Wiegand::lastFoundTime; volatile uint8_t Wiegand::timeOut; -Wiegand::Wiegand() { +Wiegand::Wiegand() { rfid = 0; lastFoundTime = 0; tagSize = 0; @@ -97,6 +110,7 @@ Wiegand::Wiegand() { bitCount = 0 ; timeOut = 0; isInit = false; + scanDelay = 1; } #if (DEV_WIEGAND_TEST_MODE)==1 @@ -128,7 +142,7 @@ uint64_t Wiegand::GetRandomRfid(uint8_t tag_size=34) { parities = CalculateParities(result, tag_size); result = (result << 1) | (parities & 0x01); // Set LSB parity - if (parities & 0x80) { // MSB parity is 1 + if (parities & 0x80) { // MSB parity is 1 switch (tag_size) { case 24: result |= 0x800000; @@ -147,9 +161,9 @@ uint64_t Wiegand::GetRandomRfid(uint8_t tag_size=34) { } } - return result; + return result; } -#endif +#endif // DEV_WIEGAND_TEST_MODE==1 void ICACHE_RAM_ATTR Wiegand::handleD1Interrupt() { // Receive a 1 bit. (D0=high & D1=low) rfidBuffer = (rfidBuffer << 1) | 1; // Leftshift + 1 bit @@ -165,28 +179,26 @@ void ICACHE_RAM_ATTR Wiegand::handleD0Interrupt() { // Receive a 0 bit. (D0=low void Wiegand::Init() { isInit = false; - if (PinUsed(GPIO_WIEGAND_D0) && PinUsed(GPIO_WIEGAND_D1)) { // Only start, if the Wiegang pins are + if (PinUsed(GPIO_WIEGAND_D0) && PinUsed(GPIO_WIEGAND_D1)) { // Only start, if the Wiegang pins are selected #if (DEV_WIEGAND_TEST_MODE)>0 - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: Init()")); -#endif + AddLog(LOG_LEVEL_INFO, PSTR("WIE: Init()")); +#endif // DEV_WIEGAND_TEST_MODE>0 pinMode(Pin(GPIO_WIEGAND_D0), INPUT_PULLUP); pinMode(Pin(GPIO_WIEGAND_D1), INPUT_PULLUP); attachInterrupt(Pin(GPIO_WIEGAND_D0), handleD0Interrupt, FALLING); attachInterrupt(Pin(GPIO_WIEGAND_D1), handleD1Interrupt, FALLING); - isInit = true; // Helps to run only if correctly setup + isInit = true; // Helps to run only if correctly setup #if (DEV_WIEGAND_TEST_MODE)>0 - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: Testmode")); // For tests without reader attaiched - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: D0:%u"),Pin(GPIO_WIEGAND_D0)); - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: D1:%u"),Pin(GPIO_WIEGAND_D1)); + AddLog(LOG_LEVEL_INFO, PSTR("WIE: Testmode, D0:%u, D1:%u"), Pin(GPIO_WIEGAND_D0), Pin(GPIO_WIEGAND_D1)); // For tests without reader attaiched #else - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: D0=%u, D1=%u"),Pin(GPIO_WIEGAND_D0), Pin(GPIO_WIEGAND_D1)); -#endif + AddLog(LOG_LEVEL_INFO, PSTR("WIE: Wiegand Rfid Reader detected")); +#endif // DEV_WIEGAND_TEST_MODE>0 } #if (DEV_WIEGAND_TEST_MODE)>0 else { - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: no GPIOs.")); + AddLog(LOG_LEVEL_INFO, PSTR("WIE: no GPIOs.")); } -#endif +#endif // DEV_WIEGAND_TEST_MODE>0 } uint64_t Wiegand::CheckAndConvertRfid(uint64_t rfidIn, uint16_t bitcount) { @@ -217,17 +229,17 @@ uint64_t Wiegand::CheckAndConvertRfid(uint64_t rfidIn, uint16_t bitcount) { default: break; } - calcParity = CalculateParities(rfidIn, bitCount); // check result on http://www.ccdesignworks.com/wiegand_calc.htm with raw tag as input - if (calcParity != (evenParityBit | oddParityBit)) { // Paritybit is wrong + calcParity = CalculateParities(rfidIn, bitCount); // Check result on http://www.ccdesignworks.com/wiegand_calc.htm with raw tag as input + if (calcParity != (evenParityBit | oddParityBit)) { // Parity bit is wrong rfidIn=0; - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: %llu parity error"), rfidIn); + AddLog(LOG_LEVEL_DEBUG, PSTR("WIE: %llu parity error"), rfidIn); } #if (DEV_WIEGAND_TEST_MODE)>0 - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: even (left) parity: %u "), (evenParityBit>>7)); - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: even (calc) parity: %u "), (calcParity & 0x80)>>7); - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: odd (right) parity: %u "), oddParityBit); - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: odd (calc) parity: %u "), (calcParity & 0x01)); -#endif + AddLog(LOG_LEVEL_INFO, PSTR("WIE: even (left) parity: %u "), (evenParityBit>>7)); + AddLog(LOG_LEVEL_INFO, PSTR("WIE: even (calc) parity: %u "), (calcParity & 0x80)>>7); + AddLog(LOG_LEVEL_INFO, PSTR("WIE: odd (right) parity: %u "), oddParityBit); + AddLog(LOG_LEVEL_INFO, PSTR("WIE: odd (calc) parity: %u "), (calcParity & 0x01)); +#endif // DEV_WIEGAND_TEST_MODE>0 return rfidIn; } @@ -270,8 +282,7 @@ char Wiegand::translateEnterEscapeKeyPress(char oKeyPressed) { } } -bool Wiegand::WiegandConversion () -{ +bool Wiegand::WiegandConversion () { bool bRet = false; unsigned long nowTick = millis(); // Add a maximum wait time for new bits @@ -282,68 +293,57 @@ bool Wiegand::WiegandConversion () lastFoundTime = nowTick; return bRet; } - if (diffTicks > WIEGAND_BIT_TIMEOUT) { // Last bit found is WIEGAND_BIT_TIMEOUT ms ago + if (diffTicks > WIEGAND_BIT_TIMEOUT) { // Last bit found is WIEGAND_BIT_TIMEOUT ms ago #if (DEV_WIEGAND_TEST_MODE)>0 - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: raw tag: %llu "), rfidBuffer); - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: bit count: %u "), bitCount); -#endif - if ((bitCount==4)||(bitCount==8)||(bitCount==24)||(bitCount==26)||(bitCount==32)||(bitCount==34)) { - if ((bitCount==24)||(bitCount==26)||(bitCount==32)||(bitCount==34)) { - // 24,26,32,34-bit Wiegand codes - rfid = CheckAndConvertRfid( rfidBuffer, bitCount); - tagSize=bitCount; - bitCount=0; - rfidBuffer=0; - bRet=true; - } - if (bitCount==4) { - // 4-bit Wiegand codes for keypads - rfid = (int)translateEnterEscapeKeyPress(rfidBuffer & 0x0000000F); - tagSize = bitCount; - bitCount = 0; - rfidBuffer = 0; - bRet=true; - } - if (bitCount==8){ - // 8-bit Wiegand codes for keypads with integrity - // 8-bit Wiegand keyboard data, high nibble is the "NOT" of low nibble - // eg if key 1 pressed, data=E1 in binary 11100001 , high nibble=1110 , low nibble = 0001 - char highNibble = (rfidBuffer & 0xf0) >>4; - char lowNibble = (rfidBuffer & 0x0f); - if (lowNibble == (~highNibble & 0x0f)) { // Check if low nibble matches the "NOT" of high nibble. - rfid = (int)translateEnterEscapeKeyPress(lowNibble); - bRet = true; - } else { - lastFoundTime = nowTick; - bRet = false; - } - tagSize = bitCount; - bitCount = 0; - rfidBuffer = 0; + AddLog(LOG_LEVEL_INFO, PSTR("WIE: Raw tag %llu, Bit count %u"), rfidBuffer, bitCount); +#endif // DEV_WIEGAND_TEST_MODE>0 + if ((24 == bitCount) || (26 == bitCount) || (32 == bitCount) || (34 == bitCount)) { + // 24, 26, 32, 34-bit Wiegand codes + rfid = CheckAndConvertRfid(rfidBuffer, bitCount); + tagSize = bitCount; + bRet = true; + } + else if (4 == bitCount) { + // 4-bit Wiegand codes for keypads + rfid = (int)translateEnterEscapeKeyPress(rfidBuffer & 0x0000000F); + tagSize = bitCount; + bRet = true; + } + else if (8 == bitCount) { + // 8-bit Wiegand codes for keypads with integrity + // 8-bit Wiegand keyboard data, high nibble is the "NOT" of low nibble + // eg if key 1 pressed, data=E1 in binary 11100001 , high nibble=1110 , low nibble = 0001 + char highNibble = (rfidBuffer & 0xf0) >>4; + char lowNibble = (rfidBuffer & 0x0f); + if (lowNibble == (~highNibble & 0x0f)) { // Check if low nibble matches the "NOT" of high nibble. + rfid = (int)translateEnterEscapeKeyPress(lowNibble); + bRet = true; + } else { + lastFoundTime = nowTick; + bRet = false; } + tagSize = bitCount; } else { // Time reached but unknown bitCount, clear and start again lastFoundTime = nowTick; - bitCount = 0; - rfidBuffer = 0; bRet = false; } + bitCount = 0; + rfidBuffer = 0; } else { - bRet = false; // watching time not finished + bRet = false; // Watching time not finished } #if (DEV_WIEGAND_TEST_MODE)>0 - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: tag out: %llu "), rfid); - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: tag size: %u"), tagSize); -#endif + AddLog(LOG_LEVEL_INFO, PSTR("WIE: Tag out %llu, tag size %u "), rfid, tagSize); +#endif // DEV_WIEGAND_TEST_MODE>0 return bRet; } void Wiegand::ScanForTag() { - if (!isInit) { return;} #if (DEV_WIEGAND_TEST_MODE)>0 - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: ScanForTag().")); + AddLog(LOG_LEVEL_INFO, PSTR("WIE: ScanForTag().")); #if (DEV_WIEGAND_TEST_MODE==1) - switch (millis() %4 ) { + switch (millis() %4) { case 0: rfidBuffer = GetRandomRfid(24); break; @@ -360,21 +360,20 @@ void Wiegand::ScanForTag() { rfidBuffer = GetRandomRfid(34); break; } - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: raw generated: %lX"), rfidBuffer); // for tests without reader attaiched -#endif -#endif + AddLog(LOG_LEVEL_INFO, PSTR("WIE: Raw generated %lX"), rfidBuffer); // For tests without reader attaiched +#endif // DEV_WIEGAND_TEST_MODE==1 +#endif // DEV_WIEGAND_TEST_MODE>0 if (bitCount > 0) { uint64_t oldTag = rfid; bool validKey = WiegandConversion(); #if (DEV_WIEGAND_TEST_MODE)>0 - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: previous tag: %llu"), oldTag); -#endif - // only in case of valid key do action. Issue#10585 - if(validKey) { - if (oldTag != rfid) { AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: new= %llu"), rfid); } - else { AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: prev= %llu"), rfid); } - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: bits= %u"), tagSize); - ResponseTime_P(PSTR(",\"Wiegand\":{\"UID\":\"%0llu\"}}"), rfid); + AddLog(LOG_LEVEL_INFO, PSTR("WIE: Previous tag %llu"), oldTag); +#endif // DEV_WIEGAND_TEST_MODE>0 + if (validKey) { // Only in case of valid key do action. Issue#10585 + if (oldTag == rfid) { + AddLog(LOG_LEVEL_DEBUG, PSTR("WIE: Old tag")); + } + ResponseTime_P(PSTR(",\"Wiegand\":{\"UID\":%0llu,\"" D_JSON_SIZE "\":%u}}"), rfid, tagSize); MqttPublishTeleSensor(); } } @@ -382,16 +381,13 @@ void Wiegand::ScanForTag() { #ifdef USE_WEBSERVER void Wiegand::Show(void) { - if (!isInit) { return; } WSContentSend_PD(PSTR("{s}Wiegand UID{m}%llu {e}"), rfid); - #if (DEV_WIEGAND_TEST_MODE)>0 - AddLog_P(LOG_LEVEL_INFO,PSTR("WIE: Tag: %llu"), rfid); - AddLog_P(LOG_LEVEL_INFO, PSTR("WIE: %u bits"), bitCount); - #endif +#if (DEV_WIEGAND_TEST_MODE)>0 + AddLog(LOG_LEVEL_INFO, PSTR("WIE: Tag %llu, Bits %u"), rfid, bitCount); +#endif // DEV_WIEGAND_TEST_MODE>0 } #endif // USE_WEBSERVER - /*********************************************************************************************\ * Interface \*********************************************************************************************/ @@ -399,30 +395,30 @@ void Wiegand::Show(void) { bool Xsns82(byte function) { bool result = false; - switch (function) { - case FUNC_INIT: - oWiegand->Init(); - scanDelay = 1; - break; - - case FUNC_EVERY_250_MSECOND: // Some tags need more time, don't try shorter period + if (FUNC_INIT == function) { + oWiegand->Init(); + } + else if (oWiegand->isInit) { + switch (function) { + case FUNC_EVERY_250_MSECOND: // Some tags need more time, don't try shorter period #if (DEV_WIEGAND_TEST_MODE)==1 - if (scanDelay >= 4) // Give a second because of the log entries to be send. + if (oWiegand->scanDelay >= 4) // Give a second because of the log entries to be send. #else - if (scanDelay >= 2) // Only run every (delay * 250 ms) (every 250ms is too fast for some tags) + if (oWiegand->scanDelay >= 2) // Only run every (delay * 250 ms) (every 250ms is too fast for some tags) #endif - { - oWiegand->ScanForTag(); - scanDelay = 1; - } else { - scanDelay++; - } - break; + { + oWiegand->ScanForTag(); + oWiegand->scanDelay = 1; + } else { + oWiegand->scanDelay++; + } + break; #ifdef USE_WEBSERVER - case FUNC_WEB_SENSOR: - oWiegand->Show(); - break; + case FUNC_WEB_SENSOR: + oWiegand->Show(); + break; #endif // USE_WEBSERVER + } } return result; } diff --git a/tasmota/xsns_83_neopool.ino b/tasmota/xsns_83_neopool.ino index 164649192..97db189f2 100644 --- a/tasmota/xsns_83_neopool.ino +++ b/tasmota/xsns_83_neopool.ino @@ -1,7 +1,7 @@ /* xsns_83_neopool.ino - Sugar Valley NeoPool Control System Modbus support for Tasmota - Copyright (C) 2021 Norbert Richter + Copyright (C) 2021 Norbert Richter This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -592,14 +592,14 @@ void NeoPool250ms(void) // Every 250 mSec } #ifdef DEBUG_TASMOTA_SENSOR else { - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: modbus receive error %d"), error); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: modbus receive error %d"), error); } #endif // DEBUG_TASMOTA_SENSOR free(buffer); } #ifdef DEBUG_TASMOTA_SENSOR else { - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: modbus block 0x%04X - 0x%04X skipped"), NeoPoolReg[neopool_read_state].addr, NeoPoolReg[neopool_read_state].addr+NeoPoolReg[neopool_read_state].cnt); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: modbus block 0x%04X - 0x%04X skipped"), NeoPoolReg[neopool_read_state].addr, NeoPoolReg[neopool_read_state].addr+NeoPoolReg[neopool_read_state].cnt); } #endif // DEBUG_TASMOTA_SENSOR @@ -620,7 +620,7 @@ void NeoPool250ms(void) // Every 250 mSec (NeoPoolGetData(MBF_NOTIFICATION) & (1 << (NeoPoolReg[neopool_read_state].addr >> 8)-1))) { #endif // NEOPOOL_OPTIMIZE_READINGS #ifdef DEBUG_TASMOTA_SENSOR - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: modbus send(%d, %d, 0x%04X, %d)"), NEOPOOL_MODBUS_ADDRESS, NEOPOOL_READ_REGISTER, NeoPoolReg[neopool_read_state].addr, NeoPoolReg[neopool_read_state].cnt); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: modbus send(%d, %d, 0x%04X, %d)"), NEOPOOL_MODBUS_ADDRESS, NEOPOOL_READ_REGISTER, NeoPoolReg[neopool_read_state].addr, NeoPoolReg[neopool_read_state].cnt); #endif // DEBUG_TASMOTA_SENSOR NeoPoolModbus->Send(NEOPOOL_MODBUS_ADDRESS, NEOPOOL_READ_REGISTER, NeoPoolReg[neopool_read_state].addr, NeoPoolReg[neopool_read_state].cnt); #ifdef NEOPOOL_OPTIMIZE_READINGS @@ -629,7 +629,7 @@ void NeoPool250ms(void) // Every 250 mSec // search next addr block having notification while( (NeoPoolReg[neopool_read_state].addr & 0x0F00) != 0x100 || (NeoPoolGetData(MBF_NOTIFICATION) & (1 << (NeoPoolReg[neopool_read_state].addr >> 8)-1)) ) { #ifdef DEBUG_TASMOTA_SENSOR - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: notify 0x%04X - addr block 0x%04X ignored"), NeoPoolGetData(MBF_NOTIFICATION), NeoPoolReg[neopool_read_state].addr); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: notify 0x%04X - addr block 0x%04X ignored"), NeoPoolGetData(MBF_NOTIFICATION), NeoPoolReg[neopool_read_state].addr); #endif // DEBUG_TASMOTA_SENSOR ++neopool_read_state %= ARRAY_SIZE(NeoPoolReg); // neopool_read_state++; @@ -686,13 +686,13 @@ bool NeoPoolInitData(void) if (nullptr != NeoPoolReg[i].data) { memset(NeoPoolReg[i].data, 0, sizeof(uint16_t)*NeoPoolReg[i].cnt); #ifdef DEBUG_TASMOTA_SENSOR - AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: Init - addr 0x%04x cnt %d data %p"), NeoPoolReg[i].addr, NeoPoolReg[i].cnt, NeoPoolReg[i].data); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: Init - addr 0x%04x cnt %d data %p"), NeoPoolReg[i].addr, NeoPoolReg[i].cnt, NeoPoolReg[i].data); #endif // DEBUG_TASMOTA_SENSOR res = true; } #ifdef DEBUG_TASMOTA_SENSOR else { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: Init - out of memory")); + AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: Init - out of memory")); } #endif // DEBUG_TASMOTA_SENSOR } @@ -720,7 +720,7 @@ uint8_t NeoPoolReadRegister(uint16_t addr, uint16_t *data, uint16_t cnt) uint8_t error = NeoPoolModbus->ReceiveBuffer(buffer, cnt); if (error) { #ifdef DEBUG_TASMOTA_SENSOR - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X read data error %d"), addr, error); + AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X read data error %d"), addr, error); #endif // DEBUG_TASMOTA_SENSOR neopool_poll = true; return NEOPOOL_ERROR_RW_DATA; @@ -734,12 +734,12 @@ uint8_t NeoPoolReadRegister(uint16_t addr, uint16_t *data, uint16_t cnt) return 0; } #ifdef DEBUG_TASMOTA_SENSOR - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X read out of memory"), addr); + AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X read out of memory"), addr); #endif // DEBUG_TASMOTA_SENSOR return NEOPOOL_ERROR_OUT_OF_MEM; } #ifdef DEBUG_TASMOTA_SENSOR - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X read data timeout"), addr); + AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X read data timeout"), addr); #endif // DEBUG_TASMOTA_SENSOR neopool_poll = true; return NEOPOOL_ERROR_TIMEOUT; @@ -760,7 +760,7 @@ uint8_t NeoPoolWriteRegister(uint16_t addr, uint16_t *data, uint16_t cnt) frame = (uint8_t*)malloc(numbytes+2); if (nullptr == frame) { #ifdef DEBUG_TASMOTA_SENSOR - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X write out of memory"), addr); + AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X write out of memory"), addr); #endif // DEBUG_TASMOTA_SENSOR return NEOPOOL_ERROR_OUT_OF_MEM; } @@ -793,7 +793,7 @@ uint8_t NeoPoolWriteRegister(uint16_t addr, uint16_t *data, uint16_t cnt) uint8_t error = NeoPoolModbus->ReceiveBuffer(buffer, 1); if (0!=error && 9!=error) { // ReceiveBuffer can't handle 0x10 code result #ifdef DEBUG_TASMOTA_SENSOR - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X write data response error %d"), addr, error); + AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X write data response error %d"), addr, error); #endif // DEBUG_TASMOTA_SENSOR neopool_poll = true; return NEOPOOL_ERROR_RW_DATA; @@ -809,7 +809,7 @@ uint8_t NeoPoolWriteRegister(uint16_t addr, uint16_t *data, uint16_t cnt) return NEOPOOL_OK; } #ifdef DEBUG_TASMOTA_SENSOR - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X write data response timeout"), addr); + AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: addr 0x%04X write data response timeout"), addr); #endif // DEBUG_TASMOTA_SENSOR neopool_poll = true; return NEOPOOL_ERROR_TIMEOUT; @@ -1001,7 +1001,7 @@ void NeoPoolShow(bool json) // Hydrolysis #ifdef DEBUG_TASMOTA_SENSOR - //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: MBF_PAR_MODEL 0x%04X MBF_HIDRO_STATUS 0x%04X"), NeoPoolGetData(MBF_PAR_MODEL), NeoPoolGetData(MBF_HIDRO_STATUS)); + //AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("NEO: MBF_PAR_MODEL 0x%04X MBF_HIDRO_STATUS 0x%04X"), NeoPoolGetData(MBF_PAR_MODEL), NeoPoolGetData(MBF_HIDRO_STATUS)); #endif // DEBUG_TASMOTA_SENSOR if ((NeoPoolGetData(MBF_PAR_MODEL) & MBMSK_MODEL_HIDRO) && (NeoPoolGetData(MBF_HIDRO_STATUS) & MBMSK_HIDRO_STATUS_MODULE_ACTIVE)) { char spol[32]; @@ -1291,7 +1291,7 @@ bool NeoPoolCmnd(void) data[0] = (uint16_t)(new_time & 0xFFFF); data[1] = (uint16_t)((new_time>>16) & 0xFFFF); #ifdef DEBUG_TASMOTA_SENSOR - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: set time to %ld (%04X%04X)"), new_time, data[0], data[1]); + AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: set time to %ld (%04X%04X)"), new_time, t_low, t_high); #endif // DEBUG_TASMOTA_SENSOR serviced = (NEOPOOL_OK == NeoPoolWriteRegister(MBF_PAR_TIME_LOW, data, 2)); if (serviced) { @@ -1302,7 +1302,7 @@ bool NeoPoolCmnd(void) else if (0 == params_cnt) { serviced = (NEOPOOL_OK == NeoPoolReadRegister(MBF_PAR_TIME_LOW, data, 2)); #ifdef DEBUG_TASMOTA_SENSOR - AddLog_P(LOG_LEVEL_DEBUG, PSTR("NEO: time read 0x%04X%04X %ld"), data[1], data[0], (uint32_t)data[0] + ((uint32_t)data[1] << 16)); + AddLog(LOG_LEVEL_DEBUG, PSTR("NEO: time read 0x%04X%04X %ld"), t_high, t_low, (uint32_t)t_low + ((uint32_t)t_high << 16)); #endif // DEBUG_TASMOTA_SENSOR } else { diff --git a/tasmota/xsns_84_tof10120.ino b/tasmota/xsns_84_tof10120.ino new file mode 100644 index 000000000..233a8cde8 --- /dev/null +++ b/tasmota/xsns_84_tof10120.ino @@ -0,0 +1,144 @@ +/* + xsns_84_tof10120.ino - TOF10120 sensor support for Tasmota + + Copyright (C) 2021 Cyril Pawelko and Theo Arends + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef USE_I2C +#ifdef USE_TOF10120 +/*********************************************************************************************\ + * TOF10120 I2C Mode (Serial not supported) + * + * I2C Address: 0x52 + * + * Connections: + * 1 - Black Gnd + * 2 - Red Vcc + * 3 - Yellow Rxd - Not supported + * 4 - White Txd - Not supported + * 5 - Blue I2C SDA + * 6 - Green I2C SCL +\*********************************************************************************************/ + +#define XSNS_84 84 +#define XI2C_57 57 // See I2CDEVICES.md + +#define TOF10120_ADDRESS 0x52 +#define TOF10120_INCORRECT_DISTANCE 0xFFFF + +struct { + uint16_t distance = 0; + bool ready = false; +} tof10120_sensor; + +/********************************************************************************************/ + +uint16_t Tof10120Read() { + uint16_t distance; + + Wire.beginTransmission(TOF10120_ADDRESS); + Wire.write(byte(0x00)); + Wire.endTransmission(); + delay(1); + Wire.requestFrom(TOF10120_ADDRESS, 2); + if (Wire.available() == 2) { + distance = Wire.read(); + distance = distance <<8; + distance |= Wire.read(); + } else { // Incorrect value read + AddLog(LOG_LEVEL_DEBUG, "TOF: No value read"); + return TOF10120_INCORRECT_DISTANCE; + } + AddLog(LOG_LEVEL_DEBUG_MORE, "TOF: Distance %u", distance); + return distance; +} + +void Tof10120Detect(void) { + if (!I2cSetDevice(TOF10120_ADDRESS)) { return; } + if (Tof10120Read() == TOF10120_INCORRECT_DISTANCE) { return; } + + I2cSetActiveFound(TOF10120_ADDRESS, "TOF10120"); + tof10120_sensor.ready = true; +} + +void Tof10120Every_250MSecond(void) { + uint16_t dist = Tof10120Read(); +// if ( dist < 400000) { +// dist = TOF10120_INCORRECT_DISTANCE; +// } + tof10120_sensor.distance = dist; +} + +#ifdef USE_DOMOTICZ +void Tof10120Every_Second(void) { + char distance[FLOATSZ]; + dtostrfd((float)tof10120_sensor.distance / 10, 1, distance); + DomoticzSensor(DZ_ILLUMINANCE, distance); +} +#endif // USE_DOMOTICZ + +void Tof10120Show(bool json) { + if (json) { + ResponseAppend_P(PSTR(",\"TOF10120\":{\"" D_JSON_DISTANCE "\":%d}"), tof10120_sensor.distance); +#ifdef USE_DOMOTICZ + if (0 == TasmotaGlobal.tele_period) { + Tof10120Every_Second(); + } +#endif // USE_DOMOTICZ +#ifdef USE_WEBSERVER + } else { + WSContentSend_PD(HTTP_SNS_DISTANCE, PSTR("TOF10120"), tof10120_sensor.distance); +#endif + } +} + +/*********************************************************************************************\ + * Interface +\*********************************************************************************************/ + +bool Xsns84(uint8_t function) { + if (!I2cEnabled(XI2C_57)) { return false; } + + bool result = false; + + if (FUNC_INIT == function) { + Tof10120Detect(); + } + else if (tof10120_sensor.ready) { + switch (function) { + case FUNC_EVERY_250_MSECOND: + Tof10120Every_250MSecond(); + break; +#ifdef USE_DOMOTICZ + case FUNC_EVERY_SECOND: + Tof10120Every_Second(); + break; +#endif // USE_DOMOTICZ + case FUNC_JSON_APPEND: + Tof10120Show(1); + break; +#ifdef USE_WEBSERVER + case FUNC_WEB_SENSOR: + Tof10120Show(0); + break; +#endif // USE_WEBSERVER + } + } + return result; +} + +#endif // USE_TOF10120 +#endif // USE_I2C \ No newline at end of file diff --git a/tasmota/xsns_interface.ino b/tasmota/xsns_interface.ino index f41de7920..db1611801 100644 --- a/tasmota/xsns_interface.ino +++ b/tasmota/xsns_interface.ino @@ -1032,7 +1032,7 @@ bool XsnsCall(uint8_t Function) { uint32_t profile_millis = millis() - profile_start_millis; if (profile_millis) { if (FUNC_EVERY_SECOND == Function) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("PRF: At %08u XsnsCall %d to Sensor %d took %u mS"), TasmotaGlobal.uptime, Function, x, profile_millis); + AddLog(LOG_LEVEL_DEBUG, PSTR("PRF: At %08u XsnsCall %d to Sensor %d took %u mS"), TasmotaGlobal.uptime, Function, x, profile_millis); } } #endif // PROFILE_XSNS_SENSOR_EVERY_SECOND @@ -1052,7 +1052,7 @@ bool XsnsCall(uint8_t Function) { uint32_t profile_millis = millis() - profile_start_millis; if (profile_millis) { if (FUNC_EVERY_SECOND == Function) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("PRF: At %08u XsnsCall %d took %u mS"), TasmotaGlobal.uptime, Function, profile_millis); + AddLog(LOG_LEVEL_DEBUG, PSTR("PRF: At %08u XsnsCall %d took %u mS"), TasmotaGlobal.uptime, Function, profile_millis); } } #endif // PROFILE_XSNS_EVERY_SECOND diff --git a/tools/Esptool/Odroid_go/Odroid_flash.bat b/tools/Esptool/Odroid_go/Odroid_flash.bat deleted file mode 100644 index 06891d00c..000000000 --- a/tools/Esptool/Odroid_go/Odroid_flash.bat +++ /dev/null @@ -1 +0,0 @@ -esptool.py --chip esp32 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dout --flash_freq 40m --flash_size detect 0x1000 bootloader_dout_40m.bin 0x8000 partitions_spiffs_12M.bin 0xe000 boot_app0.bin 0x10000 tasmota32-odroid.bin \ No newline at end of file diff --git a/tools/Esptool/Odroid_go/bootloader_dout_40m.bin b/tools/Esptool/Odroid_go/bootloader_dout_40m.bin deleted file mode 100644 index 267abf3da..000000000 Binary files a/tools/Esptool/Odroid_go/bootloader_dout_40m.bin and /dev/null differ diff --git a/tools/Esptool/Odroid_go_and_core2/Core2_flash.bat b/tools/Esptool/Odroid_go_and_core2/Core2_flash.bat new file mode 100644 index 000000000..b9ba35654 --- /dev/null +++ b/tools/Esptool/Odroid_go_and_core2/Core2_flash.bat @@ -0,0 +1 @@ +esptool.py --chip esp32 --baud 2000000 --before default_reset --after hard_reset write_flash -z --flash_mode qio --flash_freq 80m --flash_size detect 0x1000 bootloader_qio_80m.bin 0x8000 partitions_spiffs_12M.bin 0xe000 boot_app0.bin 0x10000 tasmota32-core2.bin \ No newline at end of file diff --git a/tools/Esptool/Odroid_go_and_core2/Odroid_flash.bat b/tools/Esptool/Odroid_go_and_core2/Odroid_flash.bat new file mode 100644 index 000000000..001850a1f --- /dev/null +++ b/tools/Esptool/Odroid_go_and_core2/Odroid_flash.bat @@ -0,0 +1 @@ +esptool.py --chip esp32 --baud 2000000 --before default_reset --after hard_reset write_flash -z --flash_mode qio --flash_freq 80m --flash_size detect 0x1000 bootloader_qio_80m.bin 0x8000 partitions_spiffs_12M.bin 0xe000 boot_app0.bin 0x10000 tasmota32-odroid.bin \ No newline at end of file diff --git a/tools/Esptool/Odroid_go/boot_app0.bin b/tools/Esptool/Odroid_go_and_core2/boot_app0.bin similarity index 100% rename from tools/Esptool/Odroid_go/boot_app0.bin rename to tools/Esptool/Odroid_go_and_core2/boot_app0.bin diff --git a/tools/Esptool/Odroid_go_and_core2/bootloader_qio_80m.bin b/tools/Esptool/Odroid_go_and_core2/bootloader_qio_80m.bin new file mode 100644 index 000000000..d0a5182b9 Binary files /dev/null and b/tools/Esptool/Odroid_go_and_core2/bootloader_qio_80m.bin differ diff --git a/tools/Esptool/Odroid_go/partitions_spiffs_12M.bin b/tools/Esptool/Odroid_go_and_core2/partitions_spiffs_12M.bin similarity index 100% rename from tools/Esptool/Odroid_go/partitions_spiffs_12M.bin rename to tools/Esptool/Odroid_go_and_core2/partitions_spiffs_12M.bin diff --git a/tools/decode-status.py b/tools/decode-status.py index bb5b4e6c3..040ae94d4 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -245,6 +245,15 @@ a_features = [[ "USE_DISPLAY_ILI9488","USE_DISPLAY_SSD1351","USE_DISPLAY_RA8876","USE_DISPLAY_ST7789", "USE_DISPLAY_SSD1331","USE_UFILESYS","USE_TIMEPROP","USE_PID", "USE_BS814A2","USE_SEESAW_SOIL","USE_WIEGAND","USE_NEOPOOL", + "USE_TOF10120","","","" + ],[ + "","","","", + "","","","", + "","","","", + "","","","", + "","","","", + "","","","", + "","","","", "","","","" ]] @@ -273,7 +282,7 @@ else: obj = json.load(fp) def StartDecode(): - print ("\n*** decode-status.py v20210116 by Theo Arends and Jacek Ziolkowski ***") + print ("\n*** decode-status.py v20210122 by Theo Arends and Jacek Ziolkowski ***") # print("Decoding\n{}".format(obj)) diff --git a/tools/fw_SonoffZigbeeBridge_ezsp/readme.txt b/tools/fw_SonoffZigbeeBridge_ezsp/readme.txt index f8a4b0bb2..a8191b352 100644 --- a/tools/fw_SonoffZigbeeBridge_ezsp/readme.txt +++ b/tools/fw_SonoffZigbeeBridge_ezsp/readme.txt @@ -3,7 +3,8 @@ ## EmberZNet NCP UART EZSP firmware signed for Sonoff ZBBridge - `ncp-uart-sw_6.7.6_115200.ota` - recommended stable version for EZSP v6, EZSP v7, and EZSP v8 compatible hosts. -- `ncp-uart-sw_6.7.8_115200.ota` - release candidate, supposedly fixing IKEA battery drain issue. +- `ncp-uart-sw-6.7.8_115200.ota` - latest version for EZSP v6, EZSP v7, and EZSP v8 compatible hosts. +- `ncp-uart-sw_6.5.5_115200.ota` - legacy version for EZSP v4, EZSP v5, EZSP v6, or EZSP v7 compatible hosts. ## EmberZNet and EZSP Protocol Versions @@ -13,6 +14,4 @@ The largest change was between EZSP v4 (first added in EmberZNet 4.7.2 SDK) and Perhaps more important to know is that EZSP v5, v6 and v7 (EmberZNet 6.6.x.x) use the same framing format, but EmberZNet 6.7.x.x/EZSP v8 introduced new framing format and expanded command id field from 8 bits to 16 bits. -## Archived Versions - -- `ncp-uart-sw_6.5.5_115200.ota` - legacy version for EZSP v4, EZSP v5, EZSP v6, or EZSP v7 compatible hosts. \ No newline at end of file +See Silabs [Zigbee & Thread Knowledge Base Articles List](https://silabs-prod.adobecqms.net/community/wireless/zigbee-and-thread/knowledge-base.entry.html/2020/04/01/zigbee_thread_knowledgebasearticleslist-ih5r) for background information. \ No newline at end of file