Merge branch 'development' into neopool-dev

This commit is contained in:
Norbert Richter 2021-01-25 12:23:28 +01:00
commit 2f0ba08df0
No known key found for this signature in database
GPG Key ID: 6628701A626FA674
216 changed files with 3319 additions and 2610 deletions

View File

@ -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 |

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -0,0 +1,7 @@
name=Ext-printf
version=1.0
author=Stephan Hadinger
maintainer=Stephan <stephan.hadinger@gmail.com>
sentence=Extension of snprintf() and vsnprintf()
paragraph=This library provides extended types support for snprintf (float, uint64_t)
architectures=esp8266, esp32

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ext_printf.h"
#include <Arduino.h>
#include <IPAddress.h>
/*********************************************************************************************\
* 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;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef EXT_PRINTF_H
#define EXT_PRINTF_H
#include <cstddef>
#include <cstdint>
#include <cstdarg>
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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include "ext_printf.h"
#include <Arduino.h>
// 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<typename T, typename... Targs>
// 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);
// }
// }

View File

@ -10,8 +10,5 @@
"exclude": "tests",
"examples": "examples/*/*.ino",
"frameworks": "arduino",
"platforms": [
"atmelavr",
"espressif"
]
"platforms": ["espressif8266", "espressif32"]
}

View File

@ -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

View File

@ -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

View File

@ -11,5 +11,5 @@
"url": "https://github.com/arendst/Tasmota/lib/TasmotaModbus"
},
"frameworks": "arduino",
"platforms": "espressif8266"
"platforms": ["espressif8266", "espressif32"]
}

View File

@ -6,4 +6,4 @@ sentence=Basic modbus wrapper for TasmotaSerial for ESP8266.
paragraph=
category=Signal Input/Output
url=
architectures=esp8266
architectures=esp8266,esp32

View File

@ -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

View File

@ -10,6 +10,6 @@
"frameworks": "arduino",
"platforms":
[
"atmelavr"
"*"
]
}
}

View File

@ -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=*

View File

@ -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;

View File

@ -6,4 +6,4 @@ sentence=Sensor driver for BME680 sensor
paragraph=Sensor driver for BME680 sensor
category=Sensor
url=
architectures=esp8266
architectures=esp8266,esp32

View File

@ -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."
}
}

View File

@ -9,5 +9,5 @@
"url": "https://github.com/jrowberg/i2cdevlib.git"
},
"frameworks": "arduino",
"platforms": "atmelavr"
"platforms": "*"
}

View File

@ -6,4 +6,4 @@ sentence=.
paragraph=
category=
url=
architectures=esp8266
architectures=esp8266,esp32

View File

@ -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

View File

@ -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=*

View File

@ -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

View File

@ -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}";

View File

@ -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_

View File

@ -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

View File

@ -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<SEND_MAIL32_MINRAM) {
return 4;
}
@ -581,7 +581,7 @@ uint16_t SendMail(char *buffer) {
#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,":");
@ -736,7 +736,7 @@ smtpData.setFileStorageType(MailClientStorageType::Univ);
//Start sending Email, can be set callback function to track the status
if (!MailClient.sendMail(smtpData)) {
//Serial.println("Error sending Email, " + MailClient.smtpErrorReason());
AddLog_P(LOG_LEVEL_INFO, PSTR("Error sending Email, %s"), MailClient.smtpErrorReason().c_str());
AddLog(LOG_LEVEL_INFO, PSTR("Error sending Email, %s"), MailClient.smtpErrorReason().c_str());
} else {
status=0;

View File

@ -647,9 +647,7 @@ struct {
// Only 32 bit boundary variables below
uint64_t rf_protocol_mask; // FA8
uint32_t free_fb0[1]; // FB0
uint32_t device_group_maps; // FB0
SysBitfield5 flag5; // FB4
uint16_t pulse_counter_debounce_low; // FB8
uint16_t pulse_counter_debounce_high; // FBA

View File

@ -25,8 +25,7 @@ const uint16_t RTC_MEM_VALID = 0xA55A;
uint32_t rtc_settings_crc = 0;
uint32_t GetRtcSettingsCrc(void)
{
uint32_t GetRtcSettingsCrc(void) {
uint32_t crc = 0;
uint8_t *bytes = (uint8_t*)&RtcSettings;
@ -36,8 +35,7 @@ uint32_t GetRtcSettingsCrc(void)
return crc;
}
void RtcSettingsSave(void)
{
void RtcSettingsSave(void) {
RtcSettings.baudrate = Settings.baudrate * 300;
if (GetRtcSettingsCrc() != rtc_settings_crc) {
RtcSettings.valid = RTC_MEM_VALID;
@ -80,8 +78,7 @@ bool RtcSettingsLoad(uint32_t update) {
return read_valid;
}
bool RtcSettingsValid(void)
{
bool RtcSettingsValid(void) {
return (RTC_MEM_VALID == RtcSettings.valid);
}
@ -89,8 +86,7 @@ bool RtcSettingsValid(void)
uint32_t rtc_reboot_crc = 0;
uint32_t GetRtcRebootCrc(void)
{
uint32_t GetRtcRebootCrc(void) {
uint32_t crc = 0;
uint8_t *bytes = (uint8_t*)&RtcReboot;
@ -100,8 +96,7 @@ uint32_t GetRtcRebootCrc(void)
return crc;
}
void RtcRebootSave(void)
{
void RtcRebootSave(void) {
if (GetRtcRebootCrc() != rtc_reboot_crc) {
RtcReboot.valid = RTC_MEM_VALID;
#ifdef ESP8266
@ -114,14 +109,12 @@ void RtcRebootSave(void)
}
}
void RtcRebootReset(void)
{
void RtcRebootReset(void) {
RtcReboot.fast_reboot_count = 0;
RtcRebootSave();
}
void RtcRebootLoad(void)
{
void RtcRebootLoad(void) {
#ifdef ESP8266
ESP.rtcUserMemoryRead(100 - sizeof(RtcReboot), (uint32_t*)&RtcReboot, sizeof(RtcReboot)); // 0x280
#endif // ESP8266
@ -137,8 +130,7 @@ void RtcRebootLoad(void)
rtc_reboot_crc = GetRtcRebootCrc();
}
bool RtcRebootValid(void)
{
bool RtcRebootValid(void) {
return (RTC_MEM_VALID == RtcReboot.valid);
}
@ -172,7 +164,7 @@ bool RtcRebootValid(void)
* 0x000FB000 0x001FA000 0x003FA000 - 0k, 980k or 2980k Core FS end (LittleFS)
* 0x001FAFFF 0x003FAFFF
*
* 0x000FB000 0x001FB000 0x003FB000 - 4k Core EEPROM = Tasmota settings page during OTA and when no flash rotation is active (FLASH_EEPROM_START)
* 0x000FB000 0x001FB000 0x003FB000 - 4k Core EEPROM = Tasmota settings page during OTA and when no flash rotation is active (EEPROM_LOCATION)
* 0x000FBFFF 0x001FBFFF 0x003FBFFF
*
* 0x000FC000 0x001FC000 0x003FC000 - 4k SDK - Uses first 128 bytes for phy init data mirrored by Core in RAM. See core_esp8266_phy.cpp phy_init_data[128] = Core user_rf_cal_sector
@ -191,25 +183,25 @@ extern "C" {
extern "C" uint32_t _FS_start; // 1M = 0x402fb000, 2M = 0x40300000, 4M = 0x40300000
const uint32_t FLASH_FS_START = (((uint32_t)&_FS_start - 0x40200000) / SPI_FLASH_SEC_SIZE);
uint32_t SETTINGS_LOCATION = FLASH_FS_START -1; // 0xFA, 0x0FF or 0x0FF
uint32_t SETTINGS_LOCATION = FLASH_FS_START -1; // 0xFA, 0x0FF or 0x0FF
// From libraries/EEPROM/EEPROM.cpp EEPROMClass
extern "C" uint32_t _EEPROM_start; // 1M = 0x402FB000, 2M = 0x403FB000, 4M = 0x405FB000
const uint32_t FLASH_EEPROM_START = ((uint32_t)&_EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE; // 0xFB, 0x1FB or 0x3FB
const uint32_t EEPROM_LOCATION = ((uint32_t)&_EEPROM_start - 0x40200000) / SPI_FLASH_SEC_SIZE; // 0xFB, 0x1FB or 0x3FB
#endif // ESP8266
#ifdef ESP32
// dummy defines
#define FLASH_EEPROM_START (SPI_FLASH_SEC_SIZE * 200)
uint32_t SETTINGS_LOCATION = FLASH_EEPROM_START;
#define EEPROM_LOCATION (SPI_FLASH_SEC_SIZE * 200)
uint32_t SETTINGS_LOCATION = EEPROM_LOCATION;
#endif // ESP32
const uint8_t CFG_ROTATES = 7; // Number of flash sectors used (handles uploads)
uint32_t settings_location = FLASH_EEPROM_START;
uint32_t settings_location = EEPROM_LOCATION;
uint32_t settings_crc32 = 0;
uint8_t *settings_buffer = nullptr;
@ -223,8 +215,7 @@ void SettingsInit(void) {
/*
* Based on cores/esp8266/Updater.cpp
*/
void SetFlashModeDout(void)
{
void SetFlashModeDout(void) {
#ifdef ESP8266
uint8_t *_buffer;
uint32_t address;
@ -246,26 +237,23 @@ void SetFlashModeDout(void)
#endif // ESP8266
}
void SettingsBufferFree(void)
{
void SettingsBufferFree(void) {
if (settings_buffer != nullptr) {
free(settings_buffer);
settings_buffer = nullptr;
}
}
bool SettingsBufferAlloc(void)
{
bool SettingsBufferAlloc(void) {
SettingsBufferFree();
if (!(settings_buffer = (uint8_t *)malloc(sizeof(Settings)))) {
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_UPLOAD_ERR_2)); // Not enough (memory) space
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_UPLOAD_ERR_2)); // Not enough (memory) space
return false;
}
return true;
}
uint16_t GetCfgCrc16(uint8_t *bytes, uint32_t size)
{
uint16_t GetCfgCrc16(uint8_t *bytes, uint32_t size) {
uint16_t crc = 0;
for (uint32_t i = 0; i < size; i++) {
@ -274,15 +262,13 @@ uint16_t GetCfgCrc16(uint8_t *bytes, uint32_t size)
return crc;
}
uint16_t GetSettingsCrc(void)
{
uint16_t GetSettingsCrc(void) {
// Fix miscalculation if previous Settings was 3584 and current Settings is 4096 between 0x06060007 and 0x0606000A
uint32_t size = ((Settings.version < 0x06060007) || (Settings.version > 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

View File

@ -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;
}

View File

@ -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));
}
}
}

View File

@ -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)

View File

@ -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);

View File

@ -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));

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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) {

View File

@ -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);

View File

@ -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) ||

View File

@ -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<uint32_t>(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;

View File

@ -52,6 +52,7 @@
#include <ESP8266HTTPClient.h> // Ota
#include <ESP8266httpUpdate.h> // Ota
#include <StreamString.h> // Webserver, Updater
#include <ext_printf.h>
#include <JsonParser.h>
#include <JsonGenerator.h>
#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();

View File

@ -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)

View File

@ -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_

View File

@ -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<uint32_t>(WiFi.softAPIP()) != 0)) {
WSContentSend_P(PSTR("}1<hr/>}2<hr/>"));
@ -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.

View File

@ -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();

View File

@ -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);
}

View File

@ -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]);

View File

@ -132,7 +132,7 @@ void RgbToHsb(uint8_t ir, uint8_t ig, uint8_t ib, uint16_t *r_hue, uint8_t *r_sa
if (r_hue) *r_hue = hue;
if (r_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) {

View File

@ -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(); }

View File

@ -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(); }

View File

@ -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);
}

View File

@ -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();

View File

@ -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();

View File

@ -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 <LinkedList.h> // 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;

View File

@ -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 (uplsize<tsiz) {
@ -4874,20 +4863,20 @@ void script_upload_start(void) {
script_ex_ptr += csiz;
uplsize += csiz;
}
//Script_AddLog_P(LOG_LEVEL_INFO, PSTR("HTP: write %d - %d"),csiz,uplsize);
//AddLog(LOG_LEVEL_INFO, PSTR("HTP: write %d - %d"),csiz,uplsize);
}
//if (upload_file) upload_file.write(upload.buf,upload.currentSize);
} else if(upload.status == UPLOAD_FILE_END) {
//if (upload_file) upload_file.close();
if (Web.upload_error) {
Script_AddLog_P(LOG_LEVEL_INFO, PSTR("HTP: upload error"));
AddLog(LOG_LEVEL_INFO, PSTR("HTP: upload error"));
} else {
*script_ex_ptr = 0;
bitWrite(Settings.rule_enabled, 0, sc_state);
SaveScript();
SaveScriptEnd();
//Script_AddLog_P(LOG_LEVEL_INFO, PSTR("HTP: upload success"));
//AddLog(LOG_LEVEL_INFO, PSTR("HTP: upload success"));
}
} else {
Web.upload_error = 1;
@ -4907,13 +4896,13 @@ uint8_t DownloadFile(char *file) {
WiFiClient download_Client;
if (!ufsp->exists(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; }

View File

@ -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);

View File

@ -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."));
}
}

View File

@ -1289,7 +1289,7 @@ void DisplayInitDriver(void)
}
// AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model);
// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model);
if (Settings.display_model) {
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; count<MAX_TOUCH_BUTTONS; count++) {
if (buttons[count] && !buttons[count]->vpower.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

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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:");

View File

@ -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();
}

View File

@ -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);

View File

@ -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';

View File

@ -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);

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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
//

View File

@ -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"

View File

@ -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
}

View File

@ -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

View File

@ -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"));
}
}

View File

@ -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;

View File

@ -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:

View File

@ -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);

View File

@ -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}"

View File

@ -101,14 +101,14 @@ void ZigbeeInputLoop(void) {
// in this case the first bit (lsb) is missed and Tasmota receives 0xFF instead of 0xFE
// 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

View File

@ -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);

View File

@ -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);
}

View File

@ -97,7 +97,7 @@ void BuzzerBeep(uint32_t count, uint32_t on, uint32_t off, uint32_t tune, uint32
Buzzer.freq_mode = 0;
}
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) {

View File

@ -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];

View File

@ -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;

View File

@ -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];
}
}

View File

@ -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();

View File

@ -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

View File

@ -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++) {

View File

@ -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"));
}
}
}

View File

@ -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);
}

View File

@ -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:

View File

@ -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();
}

View File

@ -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

View File

@ -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; }

View File

@ -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);

View File

@ -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!
}

Some files were not shown because too many files have changed in this diff Show More