mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 11:16:34 +00:00
Merge remote-tracking branch 'Tasmota/development'
This commit is contained in:
commit
ecf5ad0232
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -6,7 +6,7 @@
|
||||
- [ ] The pull request is done against the latest dev branch
|
||||
- [ ] Only relevant files were touched
|
||||
- [ ] Only one feature/fix was added per PR.
|
||||
- [ ] The code change is tested and works on core ESP8266 V.2.7.2
|
||||
- [ ] The code change is tested and works on Tasmota core ESP8266 V.2.7.2.1
|
||||
- [ ] The code change is tested and works on core ESP32 V.1.12.2
|
||||
- [ ] I accept the [CLA](https://github.com/arendst/Tasmota/blob/development/CONTRIBUTING.md#contributor-license-agreement-cla).
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||

|
||||
|
||||
Alternative firmware for [ESP8266](https://en.wikipedia.org/wiki/ESP8266) based devices with **easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX**.
|
||||
_Written for Arduino IDE and PlatformIO._
|
||||
_Written for PlatformIO with limited support for Arduino IDE._
|
||||
|
||||
[](https://github.com/arendst/Tasmota/releases/latest)
|
||||
[](https://github.com/arendst/Tasmota/releases/latest)
|
||||
[](LICENSE.txt)
|
||||
[](https://discord.gg/Ks2Kzd4)
|
||||
|
||||
If you like **Tasmota**, give it a star, or fork it and contribute!
|
||||
If you like **Tasmota**, give it a star, or fork it and contribute!
|
||||
|
||||
[](https://github.com/arendst/Tasmota/stargazers)
|
||||
[](https://github.com/arendst/Tasmota/network)
|
||||
|
@ -1,14 +1,14 @@
|
||||

|
||||
|
||||
Alternative firmware for [ESP8266](https://en.wikipedia.org/wiki/ESP8266) based devices with **easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX**.
|
||||
_Written for Arduino IDE and PlatformIO._
|
||||
_Written for PlatformIO with limited support for Arduino IDE._
|
||||
|
||||
[](https://github.com/arendst/Tasmota/releases/latest)
|
||||
[](https://github.com/arendst/Tasmota/releases/latest)
|
||||
[](LICENSE.txt)
|
||||
[](https://discord.gg/Ks2Kzd4)
|
||||
|
||||
If you like **Tasmota**, give it a star, or fork it and contribute!
|
||||
If you like **Tasmota**, give it a star, or fork it and contribute!
|
||||
|
||||
[](https://github.com/arendst/Tasmota/stargazers)
|
||||
[](https://github.com/arendst/Tasmota/network)
|
||||
|
@ -52,8 +52,10 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
||||
|
||||
## Changelog
|
||||
|
||||
### Version 8.3.1.6
|
||||
### Version 8.3.1.7
|
||||
|
||||
- Remove Arduino ESP8266 Core support for versions before 2.7.1
|
||||
- Change to limited support of Arduino IDE as an increasing amount of features cannot be compiled with Arduino IDE
|
||||
- Change IRremoteESP8266 library from v2.7.6 to v2.7.8
|
||||
- Change Adafruit_SGP30 library from v1.0.3 to v1.2.0 (#8519)
|
||||
- Change Energy JSON Total field from ``"Total":[33.736,11.717,16.978]`` to ``"Total":33.736,"TotalTariff":[11.717,16.978]``
|
||||
@ -68,6 +70,8 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
|
||||
- Add command ``SetOption94 0/1`` to select MAX31855 or MAX6675 thermocouple support (#8616)
|
||||
- Add command ``SetOption97 0/1`` to switch between Tuya serial speeds 9600 bps (0) or 115200 bps (1)
|
||||
- Add command ``SetOption98 0/1`` to provide rotary rule triggers (1) instead of controlling light (0)
|
||||
- Add command ``SetOption99 0/1`` to enable zero cross detection on PWM dimmer
|
||||
- Add command ``SetOption100 0/1`` to remove ``ZbReceived`` value from ``{"ZbReceived":{xxx:yyy}}`` JSON message
|
||||
- Add command ``Module2`` to configure fallback module on fast reboot (#8464)
|
||||
- Add commands ``LedPwmOn 0..255``, ``LedPwmOff 0..255`` and ``LedPwmMode1 0/1`` to control led brightness by George (#8491)
|
||||
- Add ESP32 ethernet commands ``EthType 0/1``, ``EthAddress 0..31`` and ``EthClockMode 0..3``
|
||||
|
98
lib/LinkedList-1.2.3/LinkedList.h
Normal file → Executable file
98
lib/LinkedList-1.2.3/LinkedList.h
Normal file → Executable file
@ -39,8 +39,11 @@ protected:
|
||||
|
||||
ListNode<T>* getNode(int index);
|
||||
|
||||
ListNode<T>* findEndOfSortedString(ListNode<T> *p, int (*cmp)(T &, T &));
|
||||
|
||||
public:
|
||||
LinkedList();
|
||||
LinkedList(int sizeIndex, T _t); //initiate list size and default value
|
||||
~LinkedList();
|
||||
|
||||
/*
|
||||
@ -65,7 +68,6 @@ public:
|
||||
virtual bool unshift(T);
|
||||
/*
|
||||
Set the object at index, with T;
|
||||
Increment _size;
|
||||
*/
|
||||
virtual bool set(int index, T);
|
||||
/*
|
||||
@ -94,6 +96,16 @@ public:
|
||||
*/
|
||||
virtual void clear();
|
||||
|
||||
/*
|
||||
Sort the list, given a comparison function
|
||||
*/
|
||||
virtual void sort(int (*cmp)(T &, T &));
|
||||
|
||||
// add support to array brakets [] operator
|
||||
inline T& operator[](int index);
|
||||
inline T& operator[](size_t& i) { return this->get(i); }
|
||||
inline const T& operator[](const size_t& i) const { return this->get(i); }
|
||||
|
||||
};
|
||||
|
||||
// Initialize LinkedList with false values
|
||||
@ -157,7 +169,7 @@ ListNode<T>* LinkedList<T>::getNode(int index){
|
||||
return current;
|
||||
}
|
||||
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -165,6 +177,13 @@ int LinkedList<T>::size(){
|
||||
return _size;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
LinkedList<T>::LinkedList(int sizeIndex, T _t){
|
||||
for (int i = 0; i < sizeIndex; i++){
|
||||
add(_t);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool LinkedList<T>::add(int index, T _t){
|
||||
|
||||
@ -226,6 +245,12 @@ bool LinkedList<T>::unshift(T _t){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T& LinkedList<T>::operator[](int index) {
|
||||
return getNode(index)->data;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool LinkedList<T>::set(int index, T _t){
|
||||
// Check if index position is in bounds
|
||||
@ -322,4 +347,73 @@ void LinkedList<T>::clear(){
|
||||
shift();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void LinkedList<T>::sort(int (*cmp)(T &, T &)){
|
||||
if(_size < 2) return; // trivial case;
|
||||
|
||||
for(;;) {
|
||||
|
||||
ListNode<T> **joinPoint = &root;
|
||||
|
||||
while(*joinPoint) {
|
||||
ListNode<T> *a = *joinPoint;
|
||||
ListNode<T> *a_end = findEndOfSortedString(a, cmp);
|
||||
|
||||
if(!a_end->next ) {
|
||||
if(joinPoint == &root) {
|
||||
last = a_end;
|
||||
isCached = false;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ListNode<T> *b = a_end->next;
|
||||
ListNode<T> *b_end = findEndOfSortedString(b, cmp);
|
||||
|
||||
ListNode<T> *tail = b_end->next;
|
||||
|
||||
a_end->next = NULL;
|
||||
b_end->next = NULL;
|
||||
|
||||
while(a && b) {
|
||||
if(cmp(a->data, b->data) <= 0) {
|
||||
*joinPoint = a;
|
||||
joinPoint = &a->next;
|
||||
a = a->next;
|
||||
}
|
||||
else {
|
||||
*joinPoint = b;
|
||||
joinPoint = &b->next;
|
||||
b = b->next;
|
||||
}
|
||||
}
|
||||
|
||||
if(a) {
|
||||
*joinPoint = a;
|
||||
while(a->next) a = a->next;
|
||||
a->next = tail;
|
||||
joinPoint = &a->next;
|
||||
}
|
||||
else {
|
||||
*joinPoint = b;
|
||||
while(b->next) b = b->next;
|
||||
b->next = tail;
|
||||
joinPoint = &b->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ListNode<T>* LinkedList<T>::findEndOfSortedString(ListNode<T> *p, int (*cmp)(T &, T &)) {
|
||||
while(p->next && cmp(p->data, p->next->data) <= 0) {
|
||||
p = p->next;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "TasmotaSerial",
|
||||
"version": "3.0.0",
|
||||
"version": "3.1.0",
|
||||
"keywords": [
|
||||
"serial", "io", "TasmotaSerial"
|
||||
],
|
@ -1,5 +1,5 @@
|
||||
name=TasmotaSerial
|
||||
version=3.0.0
|
||||
version=3.1.0
|
||||
author=Theo Arends
|
||||
maintainer=Theo Arends <theo@arends.com>
|
||||
sentence=Implementation of software serial with hardware serial fallback for ESP8266 and ESP32.
|
@ -29,66 +29,19 @@ extern "C" {
|
||||
|
||||
#ifdef ESP8266
|
||||
|
||||
// for STAGE and pre-2.6, we can have a single wrapper using attachInterruptArg()
|
||||
void ICACHE_RAM_ATTR callRxRead(void *self) { ((TasmotaSerial*)self)->rxRead(); };
|
||||
|
||||
// As the Arduino attachInterrupt has no parameter, lists of objects
|
||||
// and callbacks corresponding to each possible GPIO pins have to be defined
|
||||
TasmotaSerial *tms_obj_list[16];
|
||||
|
||||
#ifdef TM_SERIAL_USE_IRAM
|
||||
void ICACHE_RAM_ATTR tms_isr_0() { tms_obj_list[0]->rxRead(); };
|
||||
void ICACHE_RAM_ATTR tms_isr_1() { tms_obj_list[1]->rxRead(); };
|
||||
void ICACHE_RAM_ATTR tms_isr_2() { tms_obj_list[2]->rxRead(); };
|
||||
void ICACHE_RAM_ATTR tms_isr_3() { tms_obj_list[3]->rxRead(); };
|
||||
void ICACHE_RAM_ATTR tms_isr_4() { tms_obj_list[4]->rxRead(); };
|
||||
void ICACHE_RAM_ATTR tms_isr_5() { tms_obj_list[5]->rxRead(); };
|
||||
// Pin 6 to 11 can not be used
|
||||
void ICACHE_RAM_ATTR tms_isr_12() { tms_obj_list[12]->rxRead(); };
|
||||
void ICACHE_RAM_ATTR tms_isr_13() { tms_obj_list[13]->rxRead(); };
|
||||
void ICACHE_RAM_ATTR tms_isr_14() { tms_obj_list[14]->rxRead(); };
|
||||
void ICACHE_RAM_ATTR tms_isr_15() { tms_obj_list[15]->rxRead(); };
|
||||
#else
|
||||
void tms_isr_0() { tms_obj_list[0]->rxRead(); };
|
||||
void tms_isr_1() { tms_obj_list[1]->rxRead(); };
|
||||
void tms_isr_2() { tms_obj_list[2]->rxRead(); };
|
||||
void tms_isr_3() { tms_obj_list[3]->rxRead(); };
|
||||
void tms_isr_4() { tms_obj_list[4]->rxRead(); };
|
||||
void tms_isr_5() { tms_obj_list[5]->rxRead(); };
|
||||
// Pin 6 to 11 can not be used
|
||||
void tms_isr_12() { tms_obj_list[12]->rxRead(); };
|
||||
void tms_isr_13() { tms_obj_list[13]->rxRead(); };
|
||||
void tms_isr_14() { tms_obj_list[14]->rxRead(); };
|
||||
void tms_isr_15() { tms_obj_list[15]->rxRead(); };
|
||||
#endif // TM_SERIAL_USE_IRAM
|
||||
|
||||
static void (*ISRList[16])() = {
|
||||
tms_isr_0,
|
||||
tms_isr_1,
|
||||
tms_isr_2,
|
||||
tms_isr_3,
|
||||
tms_isr_4,
|
||||
tms_isr_5,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
tms_isr_12,
|
||||
tms_isr_13,
|
||||
tms_isr_14,
|
||||
tms_isr_15
|
||||
};
|
||||
|
||||
#else // ESP32
|
||||
|
||||
static int tasmota_serial_index = 2; // Allow UART2 and UART1 only
|
||||
static int tasmota_serial_index = 2; // Allow UART2 and UART1 only
|
||||
|
||||
#endif // ESP8266
|
||||
|
||||
TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback, int nwmode, int buffer_size)
|
||||
{
|
||||
TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fallback, int nwmode, int buffer_size) {
|
||||
m_valid = false;
|
||||
m_hardserial = false;
|
||||
m_hardswap = false;
|
||||
@ -118,11 +71,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal
|
||||
m_bit_start_time = m_bit_time + m_bit_time/3 - 500; // pre-compute first wait
|
||||
pinMode(m_rx_pin, INPUT);
|
||||
tms_obj_list[m_rx_pin] = this;
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) || defined(ARDUINO_ESP8266_RELEASE_2_5_2)
|
||||
attachInterrupt(m_rx_pin, ISRList[m_rx_pin], (m_nwmode) ? CHANGE : FALLING);
|
||||
#else
|
||||
attachInterruptArg(m_rx_pin, callRxRead, this, (m_nwmode) ? CHANGE : FALLING);
|
||||
#endif
|
||||
}
|
||||
if (m_tx_pin > -1) {
|
||||
pinMode(m_tx_pin, OUTPUT);
|
||||
@ -136,8 +85,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal
|
||||
m_valid = true;
|
||||
}
|
||||
|
||||
TasmotaSerial::~TasmotaSerial()
|
||||
{
|
||||
TasmotaSerial::~TasmotaSerial() {
|
||||
#ifdef ESP8266
|
||||
if (!m_hardserial) {
|
||||
if (m_rx_pin > -1) {
|
||||
@ -151,8 +99,7 @@ TasmotaSerial::~TasmotaSerial()
|
||||
#endif // ESP8266
|
||||
}
|
||||
|
||||
bool TasmotaSerial::isValidGPIOpin(int pin)
|
||||
{
|
||||
bool TasmotaSerial::isValidGPIOpin(int pin) {
|
||||
return (pin >= -1 && pin <= 5) || (pin >= 12 && pin <= 15);
|
||||
}
|
||||
|
||||
@ -234,8 +181,7 @@ int TasmotaSerial::peek() {
|
||||
}
|
||||
}
|
||||
|
||||
int TasmotaSerial::read()
|
||||
{
|
||||
int TasmotaSerial::read() {
|
||||
if (m_hardserial) {
|
||||
#ifdef ESP8266
|
||||
return Serial.read();
|
||||
@ -250,8 +196,7 @@ int TasmotaSerial::read()
|
||||
}
|
||||
}
|
||||
|
||||
int TasmotaSerial::available()
|
||||
{
|
||||
int TasmotaSerial::available() {
|
||||
if (m_hardserial) {
|
||||
#ifdef ESP8266
|
||||
return Serial.available();
|
||||
@ -265,23 +210,12 @@ int TasmotaSerial::available()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TM_SERIAL_USE_IRAM
|
||||
#define TM_SERIAL_WAIT_SND { while (ESP.getCycleCount() < (wait + start)) if (!m_high_speed) optimistic_yield(1); wait += m_bit_time; } // Watchdog timeouts
|
||||
#define TM_SERIAL_WAIT_SND_FAST { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; }
|
||||
#define TM_SERIAL_WAIT_RCV { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; }
|
||||
#define TM_SERIAL_WAIT_RCV_LOOP { while (ESP.getCycleCount() < (wait + start)); }
|
||||
#else
|
||||
#define TM_SERIAL_WAIT_SND { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; }
|
||||
#define TM_SERIAL_WAIT_SND_FAST { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; }
|
||||
#define TM_SERIAL_WAIT_RCV { while (ESP.getCycleCount() < (wait + start)); wait += m_bit_time; }
|
||||
#define TM_SERIAL_WAIT_RCV_LOOP { while (ESP.getCycleCount() < (wait + start)); }
|
||||
#endif
|
||||
|
||||
#ifdef TM_SERIAL_USE_IRAM
|
||||
void ICACHE_RAM_ATTR TasmotaSerial::_fast_write(uint8_t b) {
|
||||
#else
|
||||
void TasmotaSerial::_fast_write(uint8_t b) {
|
||||
#endif
|
||||
uint32_t wait = m_bit_time;
|
||||
uint32_t start = ESP.getCycleCount();
|
||||
// Start bit;
|
||||
@ -299,8 +233,7 @@ void TasmotaSerial::_fast_write(uint8_t b) {
|
||||
}
|
||||
}
|
||||
|
||||
size_t TasmotaSerial::write(uint8_t b)
|
||||
{
|
||||
size_t TasmotaSerial::write(uint8_t b) {
|
||||
if (m_hardserial) {
|
||||
#ifdef ESP8266
|
||||
return Serial.write(b);
|
||||
@ -337,13 +270,7 @@ size_t TasmotaSerial::write(uint8_t b)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TM_SERIAL_USE_IRAM
|
||||
void ICACHE_RAM_ATTR TasmotaSerial::rxRead()
|
||||
{
|
||||
#else
|
||||
void TasmotaSerial::rxRead()
|
||||
{
|
||||
#endif
|
||||
void ICACHE_RAM_ATTR TasmotaSerial::rxRead() {
|
||||
if (!m_nwmode) {
|
||||
int32_t loop_read = m_very_high_speed ? serial_buffer_size : 1;
|
||||
// Advance the starting point for the samples but compensate for the
|
@ -28,11 +28,6 @@
|
||||
#define TM_SERIAL_BAUDRATE 9600 // Default baudrate
|
||||
#define TM_SERIAL_BUFFER_SIZE 64 // Receive buffer size
|
||||
|
||||
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
#define TM_SERIAL_USE_IRAM // Enable to use iram (+368 bytes)
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <Stream.h>
|
||||
|
@ -124,6 +124,6 @@ build_flags = -DUSE_IR_REMOTE_FULL
|
||||
[core]
|
||||
; *** Esp8266 Tasmota modified Arduino core based on core 2.7.2
|
||||
platform = espressif8266@2.5.1
|
||||
platform_packages = framework-arduinoespressif8266 @ https://github.com/tasmota/Arduino/releases/download/2.8.0-tasmota/esp8266-2.8.0.zip
|
||||
platform_packages = framework-arduinoespressif8266 @ https://github.com/tasmota/Arduino/releases/download/2.7.2.1/esp8266-2.7.2.1.zip
|
||||
build_unflags = ${esp_defaults.build_unflags}
|
||||
build_flags = ${esp82xx_defaults.build_flags}
|
||||
|
@ -87,10 +87,14 @@ extra_scripts = ${scripts_defaults.extra_scripts}
|
||||
|
||||
[tasmota_stage]
|
||||
; *** Esp8266 core for Arduino version Tasmota stage
|
||||
platform = espressif8266@2.6.0
|
||||
platform_packages = framework-arduinoespressif8266 @ https://github.com/tasmota/Arduino/releases/download/2.8.0-tasmota/esp8266-2.8.0.zip
|
||||
platform = espressif8266@2.5.1
|
||||
platform_packages = framework-arduinoespressif8266 @ https://github.com/Jason2866/Arduino/releases/download/2.7.3.1/esp8266-2.7.3.1.zip
|
||||
build_unflags = ${esp_defaults.build_unflags}
|
||||
-std=c17
|
||||
-std=gnu++17
|
||||
build_flags = ${esp82xx_defaults.build_flags}
|
||||
-std=gnu99
|
||||
-std=c++11
|
||||
|
||||
; *********** Alternative Options, enable only if you know exactly what you do ********
|
||||
; NONOSDK221
|
||||
@ -143,8 +147,6 @@ build_flags = ${esp82xx_defaults.build_flags}
|
||||
; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_191122
|
||||
; NONOSDK3V0 (known issues)
|
||||
; -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK3
|
||||
; lwIP 1.4
|
||||
; -DPIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH
|
||||
; lwIP 2 - Low Memory
|
||||
; -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
||||
; lwIP 2 - Higher Bandwidth
|
||||
|
@ -1,10 +1,17 @@
|
||||
## Unreleased (development)
|
||||
|
||||
### 8.3.1.7 20200716
|
||||
|
||||
- Remove Arduino ESP8266 Core support for versions before 2.7.1
|
||||
- Change to limited support of Arduino IDE as an increasing amount of features cannot be compiled with Arduino IDE
|
||||
- Add command ``SetOption100 0/1`` to remove ``ZbReceived`` value from ``{"ZbReceived":{xxx:yyy}}`` JSON message
|
||||
|
||||
### 8.3.1.6 20200617
|
||||
|
||||
- Add command ``Module2`` to configure fallback module on fast reboot (#8464)
|
||||
- Add command ``SetOption97 0/1`` to switch between Tuya serial speeds 9600 bps (0) or 115200 bps (1)
|
||||
- Add command ``SetOption98 0/1`` to provide rotary rule triggers (1) instead of controlling light (0)
|
||||
- Add command ``SetOption99 0/1`` to enable zero cross detection on PWM dimmer
|
||||
- Add support for Energy sensor (Denky) for French Smart Metering meter provided by global Energy Providers, need a adaptater. See dedicated full [blog](http://hallard.me/category/tinfo/) about French teleinformation stuff
|
||||
- Add library to be used for decoding Teleinfo (French Metering Smart Meter)
|
||||
- Add support for single wire LMT01 temperature Sensor by justifiably (#8713)
|
||||
|
@ -50,9 +50,7 @@ extern "C" {
|
||||
#include "c_types.h"
|
||||
|
||||
#include <core_version.h>
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_5_2
|
||||
#undef DEBUG_TLS
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_TLS
|
||||
#include "coredecls.h"
|
||||
@ -255,24 +253,14 @@ void WiFiClientSecure_light::setBufferSizes(int recv, int xmit) {
|
||||
}
|
||||
|
||||
bool WiFiClientSecure_light::stop(unsigned int maxWaitMs) {
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_4_2
|
||||
WiFiClient::stop(); // calls our virtual flush()
|
||||
_freeSSL();
|
||||
return true;
|
||||
#else
|
||||
bool ret = WiFiClient::stop(maxWaitMs); // calls our virtual flush()
|
||||
_freeSSL();
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool WiFiClientSecure_light::flush(unsigned int maxWaitMs) {
|
||||
(void) _run_until(BR_SSL_SENDAPP);
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_4_2
|
||||
WiFiClient::flush();
|
||||
#else
|
||||
return WiFiClient::flush(maxWaitMs);
|
||||
#endif
|
||||
}
|
||||
|
||||
int WiFiClientSecure_light::connect(IPAddress ip, uint16_t port) {
|
||||
@ -695,18 +683,56 @@ extern "C" {
|
||||
xc->done_cert = true; // first cert already processed
|
||||
}
|
||||
|
||||
// **** Start patch Castellucci
|
||||
/*
|
||||
static void pubkeyfingerprint_pubkey_fingerprint(br_sha1_context *shactx, br_rsa_public_key rsakey) {
|
||||
br_sha1_init(shactx);
|
||||
br_sha1_update(shactx, "ssh-rsa", 7); // tag
|
||||
br_sha1_update(shactx, rsakey.e, rsakey.elen); // exponent
|
||||
br_sha1_update(shactx, rsakey.n, rsakey.nlen); // modulus
|
||||
}
|
||||
*/
|
||||
// If `compat` id false, adds a u32be length prefixed value to the sha1 state.
|
||||
// If `compat` is true, the length will be omitted for compatibility with
|
||||
// data from older versions of Tasmota.
|
||||
static void sha1_update_len(br_sha1_context *shactx, const void *msg, uint32_t len, bool compat) {
|
||||
uint8_t buf[] = {0, 0, 0, 0};
|
||||
|
||||
if (!compat) {
|
||||
buf[0] = (len >> 24) & 0xff;
|
||||
buf[1] = (len >> 16) & 0xff;
|
||||
buf[2] = (len >> 8) & 0xff;
|
||||
buf[3] = (len >> 0) & 0xff;
|
||||
br_sha1_update(shactx, buf, 4); // length
|
||||
}
|
||||
br_sha1_update(shactx, msg, len); // message
|
||||
}
|
||||
|
||||
// Update the received fingerprint based on the certificate's public key.
|
||||
// If `compat` is true, an insecure version of the fingerprint will be
|
||||
// calcualted for compatibility with older versions of Tasmota. Normally,
|
||||
// `compat` should be false.
|
||||
static void pubkeyfingerprint_pubkey_fingerprint(br_x509_pubkeyfingerprint_context *xc, bool compat) {
|
||||
br_rsa_public_key rsakey = xc->ctx.pkey.key.rsa;
|
||||
|
||||
br_sha1_context shactx;
|
||||
|
||||
br_sha1_init(&shactx);
|
||||
|
||||
sha1_update_len(&shactx, "ssh-rsa", 7, compat); // tag
|
||||
sha1_update_len(&shactx, rsakey.e, rsakey.elen, compat); // exponent
|
||||
sha1_update_len(&shactx, rsakey.n, rsakey.nlen, compat); // modulus
|
||||
|
||||
br_sha1_out(&shactx, xc->pubkey_recv_fingerprint); // copy to fingerprint
|
||||
}
|
||||
// **** End patch Castellucci
|
||||
|
||||
// Callback when complete chain has been parsed.
|
||||
// Return 0 on validation success, !0 on validation error
|
||||
static unsigned pubkeyfingerprint_end_chain(const br_x509_class **ctx) {
|
||||
br_x509_pubkeyfingerprint_context *xc = (br_x509_pubkeyfingerprint_context *)ctx;
|
||||
|
||||
// **** Start patch Castellucci
|
||||
/*
|
||||
br_sha1_context sha1_context;
|
||||
pubkeyfingerprint_pubkey_fingerprint(&sha1_context, xc->ctx.pkey.key.rsa);
|
||||
br_sha1_out(&sha1_context, xc->pubkey_recv_fingerprint); // copy to fingerprint
|
||||
@ -723,6 +749,59 @@ extern "C" {
|
||||
// Default (no validation at all) or no errors in prior checks = success.
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
// set fingerprint status byte to zero
|
||||
// FIXME: find a better way to pass this information
|
||||
xc->pubkey_recv_fingerprint[20] = 0;
|
||||
// Try matching using the the new fingerprint algorithm
|
||||
pubkeyfingerprint_pubkey_fingerprint(xc, false);
|
||||
if (!xc->fingerprint_all) {
|
||||
if (0 == memcmp_P(xc->pubkey_recv_fingerprint, xc->fingerprint1, 20)) {
|
||||
return 0;
|
||||
}
|
||||
if (0 == memcmp_P(xc->pubkey_recv_fingerprint, xc->fingerprint2, 20)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// No match under new algorithm, do some basic checking on the key.
|
||||
//
|
||||
// RSA keys normally have an e value of 65537, which is three bytes long.
|
||||
// Other e values are suspicious, but if the modulus is a standard size
|
||||
// (multiple of 512 bits/64 bytes), any public exponent up to eight bytes
|
||||
// long will be allowed.
|
||||
//
|
||||
// A legitimate key could possibly be marked as bad by this check, but
|
||||
// the user would have had to really worked at making a strange key.
|
||||
if (!(xc->ctx.pkey.key.rsa.elen == 3
|
||||
&& xc->ctx.pkey.key.rsa.e[0] == 1
|
||||
&& xc->ctx.pkey.key.rsa.e[1] == 0
|
||||
&& xc->ctx.pkey.key.rsa.e[2] == 1)) {
|
||||
if (xc->ctx.pkey.key.rsa.nlen & 63 != 0 || xc->ctx.pkey.key.rsa.elen > 8) {
|
||||
return 2; // suspicious key, return error
|
||||
}
|
||||
}
|
||||
|
||||
// try the old algorithm and potentially mark for update
|
||||
pubkeyfingerprint_pubkey_fingerprint(xc, true);
|
||||
if (0 == memcmp_P(xc->pubkey_recv_fingerprint, xc->fingerprint1, 20)) {
|
||||
xc->pubkey_recv_fingerprint[20] |= 1; // mark for update
|
||||
}
|
||||
if (0 == memcmp_P(xc->pubkey_recv_fingerprint, xc->fingerprint2, 20)) {
|
||||
xc->pubkey_recv_fingerprint[20] |= 2; // mark for update
|
||||
}
|
||||
if (!xc->pubkey_recv_fingerprint[20]) {
|
||||
return 1; // not marked for update because no match, error
|
||||
}
|
||||
|
||||
// the old fingerprint format matched, recompute new one for update
|
||||
pubkeyfingerprint_pubkey_fingerprint(xc, false);
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
// Default (no validation at all) or no errors in prior checks = success.
|
||||
return 0;
|
||||
}
|
||||
// **** End patch Castellucci
|
||||
}
|
||||
|
||||
// Return the public key from the validator (set by x509_minimal)
|
||||
|
@ -121,7 +121,12 @@ class WiFiClientSecure_light : public WiFiClient {
|
||||
bool _fingerprint_any; // accept all fingerprints
|
||||
const uint8_t *_fingerprint1; // fingerprint1 to be checked against
|
||||
const uint8_t *_fingerprint2; // fingerprint2 to be checked against
|
||||
// **** Start patch Castellucci
|
||||
/*
|
||||
uint8_t _recv_fingerprint[20]; // fingerprint received
|
||||
*/
|
||||
uint8_t _recv_fingerprint[21]; // fingerprint received
|
||||
// **** End patch Castellucci
|
||||
|
||||
unsigned char *_recvapp_buf;
|
||||
size_t _recvapp_len;
|
||||
|
@ -616,7 +616,7 @@
|
||||
|
||||
// xsns_70_veml6075.ino
|
||||
#define D_JSON_UVA_INTENSITY "UvaIntensity"
|
||||
#define D_JSON_UVB_INTENSITY "UvbItensity"
|
||||
#define D_JSON_UVB_INTENSITY "UvbIntensity"
|
||||
#define D_CMND_VEML6075_POWER "power"
|
||||
#define D_CMND_VEML6075_DYNAMIC "dynamic"
|
||||
#define D_CMND_VEML6075_INTTIME "inttime"
|
||||
|
@ -245,22 +245,22 @@
|
||||
#define D_SECONDS "secondi"
|
||||
#define D_DEVICE_WILL_RESTART "Il dispositivo verrà riavviato tra pochi secondi"
|
||||
#define D_BUTTON_TOGGLE "ON/OFF"
|
||||
#define D_CONFIGURATION "Configurazione"
|
||||
#define D_CONFIGURATION "Impostazioni"
|
||||
#define D_INFORMATION "Informazioni"
|
||||
#define D_FIRMWARE_UPGRADE "Aggiorna firmware"
|
||||
#define D_CONSOLE "Console"
|
||||
#define D_CONFIRM_RESTART "Conferma riavvio"
|
||||
|
||||
#define D_CONFIGURE_MODULE "Configura modulo"
|
||||
#define D_CONFIGURE_WIFI "Configura WiFi"
|
||||
#define D_CONFIGURE_MQTT "Configura MQTT"
|
||||
#define D_CONFIGURE_DOMOTICZ "Configura Domoticz"
|
||||
#define D_CONFIGURE_LOGGING "Livello registro"
|
||||
#define D_CONFIGURE_MODULE "Modulo"
|
||||
#define D_CONFIGURE_WIFI "Rete WiFi"
|
||||
#define D_CONFIGURE_MQTT "MQTT"
|
||||
#define D_CONFIGURE_DOMOTICZ "Domoticz"
|
||||
#define D_CONFIGURE_LOGGING "Livelli registri"
|
||||
#define D_CONFIGURE_OTHER "Altre impostazioni"
|
||||
#define D_CONFIRM_RESET_CONFIGURATION "Conferma ripristino configurazione"
|
||||
#define D_RESET_CONFIGURATION "Ripristino configurazione"
|
||||
#define D_BACKUP_CONFIGURATION "Backup configurazione"
|
||||
#define D_RESTORE_CONFIGURATION "Ripristino configurazione"
|
||||
#define D_CONFIRM_RESET_CONFIGURATION "Conferma ripristino impostazioni"
|
||||
#define D_RESET_CONFIGURATION "Ripristino impostazioni"
|
||||
#define D_BACKUP_CONFIGURATION "Backup impostazioni"
|
||||
#define D_RESTORE_CONFIGURATION "Ripristino impostazioni"
|
||||
#define D_MAIN_MENU "Menu principale"
|
||||
|
||||
#define D_MODULE_PARAMETERS "Parametri modulo"
|
||||
@ -291,7 +291,7 @@
|
||||
#define D_CLIENT "Client"
|
||||
#define D_FULL_TOPIC "Full topic"
|
||||
|
||||
#define D_LOGGING_PARAMETERS "Livelli registro eventi"
|
||||
#define D_LOGGING_PARAMETERS "Livelli registri eventi"
|
||||
#define D_SERIAL_LOG_LEVEL "Livello registro seriale"
|
||||
#define D_MQTT_LOG_LEVEL "Livello registro MQTT"
|
||||
#define D_WEB_LOG_LEVEL "Livello registro web"
|
||||
@ -313,15 +313,15 @@
|
||||
#define D_SINGLE_DEVICE "dispositivo singolo"
|
||||
#define D_MULTI_DEVICE "dispositivo multiplo"
|
||||
|
||||
#define D_CONFIGURE_TEMPLATE "Configura modello"
|
||||
#define D_CONFIGURE_TEMPLATE "Modello"
|
||||
#define D_TEMPLATE_PARAMETERS "Parametri modello"
|
||||
#define D_TEMPLATE_NAME "Nome"
|
||||
#define D_BASE_TYPE "Basato su"
|
||||
#define D_TEMPLATE_FLAGS "Opzioni"
|
||||
|
||||
#define D_SAVE_CONFIGURATION "Salva configurazione"
|
||||
#define D_CONFIGURATION_SAVED "Configurazione salvata"
|
||||
#define D_CONFIGURATION_RESET "Configurazione ripristinata"
|
||||
#define D_SAVE_CONFIGURATION "Salva impostazioni"
|
||||
#define D_CONFIGURATION_SAVED "Impostazioni salvate"
|
||||
#define D_CONFIGURATION_RESET "Impostazioni ripristinate"
|
||||
|
||||
#define D_PROGRAM_VERSION "Versione programma"
|
||||
#define D_BUILD_DATE_AND_TIME "Data/ora compilazione"
|
||||
@ -416,7 +416,7 @@
|
||||
#define D_DOMOTICZ_UPDATE_TIMER "Intervallo aggiornamento"
|
||||
|
||||
// xdrv_09_timers.ino
|
||||
#define D_CONFIGURE_TIMER "Configura timer"
|
||||
#define D_CONFIGURE_TIMER "Timer"
|
||||
#define D_TIMER_PARAMETERS "Parametri timer"
|
||||
#define D_TIMER_ENABLE "Abilita timer"
|
||||
#define D_TIMER_ARM "Attiva"
|
||||
@ -427,7 +427,7 @@
|
||||
#define D_TIMER_ACTION "Azione"
|
||||
|
||||
// xdrv_10_knx.ino
|
||||
#define D_CONFIGURE_KNX "Configura KNX"
|
||||
#define D_CONFIGURE_KNX "KNX"
|
||||
#define D_KNX_PARAMETERS "Parametri KNX"
|
||||
#define D_KNX_GENERAL_CONFIG "Generale"
|
||||
#define D_KNX_PHYSICAL_ADDRESS "Indirizzo fisico"
|
||||
@ -461,7 +461,7 @@
|
||||
#define D_DOMOTICZ_SHUTTER "Serranda"
|
||||
|
||||
// xdrv_28_pcf8574.ino
|
||||
#define D_CONFIGURE_PCF8574 "Configura PCF8574"
|
||||
#define D_CONFIGURE_PCF8574 "PCF8574"
|
||||
#define D_PCF8574_PARAMETERS "Parametri PCF8574"
|
||||
#define D_INVERT_PORTS "Inverti porte"
|
||||
#define D_DEVICE "Dispositivo"
|
||||
@ -511,7 +511,7 @@
|
||||
#define D_HX_CAL_DONE "Calibrato"
|
||||
#define D_HX_CAL_FAIL "Calibrazione fallita"
|
||||
#define D_RESET_HX711 "Ripristino scala"
|
||||
#define D_CONFIGURE_HX711 "Configura scala"
|
||||
#define D_CONFIGURE_HX711 "Scala"
|
||||
#define D_HX711_PARAMETERS "Parametri scala"
|
||||
#define D_ITEM_WEIGHT "Peso oggetto"
|
||||
#define D_REFERENCE_WEIGHT "Peso di riferimento"
|
||||
@ -703,8 +703,8 @@
|
||||
#define D_SENSOR_ETH_PHY_MDIO "ETH MDIO"
|
||||
#define D_SENSOR_TCP_TXD "TCP - TX"
|
||||
#define D_SENSOR_TCP_RXD "TCP - RX"
|
||||
#define D_SENSOR_IEM3000_TX "iEM3000 TX"
|
||||
#define D_SENSOR_IEM3000_RX "iEM3000 RX"
|
||||
#define D_SENSOR_IEM3000_TX "iEM3000 - TX"
|
||||
#define D_SENSOR_IEM3000_RX "iEM3000 - RX"
|
||||
|
||||
// Units
|
||||
#define D_UNIT_AMPERE "A"
|
||||
|
@ -25,12 +25,8 @@ class SendEmail
|
||||
const bool ssl;
|
||||
const int auth_used;
|
||||
#ifdef ESP8266
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
|
||||
WiFiClient* client;
|
||||
#else
|
||||
// use bear ssl
|
||||
BearSSL::WiFiClientSecure_light *client;
|
||||
#endif
|
||||
#else
|
||||
WiFiClient *client;
|
||||
#endif
|
||||
|
@ -118,8 +118,8 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
|
||||
uint32_t network_ethernet : 1; // bit 14 (v8.3.1.3) - CMND_ETHERNET
|
||||
uint32_t tuyamcu_baudrate : 1; // bit 15 (v8.3.1.6) - SetOption97 - Set Baud rate for TuyaMCU serial communication (0 = 9600 or 1 = 115200)
|
||||
uint32_t rotary_uses_rules : 1; // bit 16 (v8.3.1.6) - SetOption98 - Use rules instead of light control
|
||||
uint32_t zerocross_dimmer : 1; // bit 17 (v8.3.1.4) = SetOption99 - Enable zerocross dimmer on PWM DIMMER
|
||||
uint32_t spare18 : 1;
|
||||
uint32_t zerocross_dimmer : 1; // bit 17 (v8.3.1.4) - SetOption99 - Enable zerocross dimmer on PWM DIMMER
|
||||
uint32_t remove_zbreceived : 1; // bit 18 (v8.3.1.7) - SetOption100 - Remove ZbReceived form JSON message
|
||||
uint32_t spare19 : 1;
|
||||
uint32_t spare20 : 1;
|
||||
uint32_t spare21 : 1;
|
||||
|
@ -159,14 +159,6 @@ extern "C" {
|
||||
|
||||
#ifdef ESP8266
|
||||
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) || defined(ARDUINO_ESP8266_RELEASE_2_5_0) || defined(ARDUINO_ESP8266_RELEASE_2_5_1) || defined(ARDUINO_ESP8266_RELEASE_2_5_2)
|
||||
|
||||
extern "C" uint32_t _SPIFFS_end;
|
||||
// From libraries/EEPROM/EEPROM.cpp EEPROMClass
|
||||
const uint32_t SPIFFS_END = ((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE;
|
||||
|
||||
#else // Core > 2.5.2 and STAGE
|
||||
|
||||
#if AUTOFLASHSIZE
|
||||
|
||||
#include "flash_hal.h"
|
||||
@ -182,8 +174,6 @@ const uint32_t SPIFFS_END = ((uint32_t)&_FS_end - 0x40200000) / SPI_FLASH_SEC_SI
|
||||
|
||||
#endif // AUTOFLASHSIZE
|
||||
|
||||
#endif // All cores < pre-2.6.0
|
||||
|
||||
// Version 4.2 config = eeprom area
|
||||
const uint32_t SETTINGS_LOCATION = SPIFFS_END; // No need for SPIFFS as it uses EEPROM area
|
||||
|
||||
@ -632,11 +622,7 @@ void EspErase(uint32_t start_sector, uint32_t end_sector)
|
||||
// bool result = EsptoolEraseSector(sector); // Esptool - erases flash completely (slow)
|
||||
|
||||
if (serial_output) {
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
Serial.printf(D_LOG_APPLICATION D_ERASED_SECTOR " %d %s\n", sector, (result) ? D_OK : D_ERROR);
|
||||
#else
|
||||
Serial.printf_P(PSTR(D_LOG_APPLICATION D_ERASED_SECTOR " %d %s\n"), sector, (result) ? D_OK : D_ERROR);
|
||||
#endif
|
||||
delay(10);
|
||||
} else {
|
||||
yield();
|
||||
|
@ -1080,12 +1080,8 @@ int ResponseJsonEndEnd(void)
|
||||
* GPIO Module and Template management
|
||||
\*********************************************************************************************/
|
||||
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception
|
||||
uint32_t Pin(uint32_t gpio, uint32_t index) ICACHE_RAM_ATTR;
|
||||
#endif
|
||||
|
||||
uint32_t Pin(uint32_t gpio, uint32_t index = 0);
|
||||
uint32_t Pin(uint32_t gpio, uint32_t index) {
|
||||
uint32_t ICACHE_RAM_ATTR Pin(uint32_t gpio, uint32_t index = 0);
|
||||
uint32_t ICACHE_RAM_ATTR Pin(uint32_t gpio, uint32_t index) {
|
||||
#ifdef ESP8266
|
||||
uint16_t real_gpio = gpio + index;
|
||||
#else // ESP32
|
||||
|
@ -112,11 +112,7 @@ DEBUG_SENSOR_LOG(PSTR("FLOG: init ..."));
|
||||
size = ESP.getSketchSize();
|
||||
// round one sector up
|
||||
start = (size + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) || defined(ARDUINO_ESP8266_RELEASE_2_5_0) || defined(ARDUINO_ESP8266_RELEASE_2_5_1) || defined(ARDUINO_ESP8266_RELEASE_2_5_2)
|
||||
end = (uint32_t)&_SPIFFS_start - 0x40200000;
|
||||
#else // Core > 2.5.2 and STAGE
|
||||
end = (uint32_t)&_FS_start - 0x40200000;
|
||||
#endif
|
||||
num_sectors = (end - start)/FLASH_SECTOR_SIZE;
|
||||
DEBUG_SENSOR_LOG(PSTR("FLOG: size: 0x%lx, start: 0x%lx, end: 0x%lx, num_sectors(dec): %lu"), size, start, end, num_sectors );
|
||||
_findFirstErasedSector();
|
||||
|
@ -17,9 +17,6 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//#ifdef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
// Functions not available in 2.3.0
|
||||
|
||||
float fmodf(float x, float y)
|
||||
{
|
||||
// https://github.com/micropython/micropython/blob/master/lib/libm/fmodf.c
|
||||
@ -83,7 +80,6 @@ float fmodf(float x, float y)
|
||||
ux.i = uxi;
|
||||
return ux.f;
|
||||
}
|
||||
//#endif // ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
|
||||
double FastPrecisePow(double a, double b)
|
||||
{
|
||||
|
@ -17,147 +17,6 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
/*********************************************************************************************\
|
||||
* Functions not available in core 2.3.0
|
||||
\*********************************************************************************************/
|
||||
|
||||
// http://clc-wiki.net/wiki/C_standard_library:string.h:memchr
|
||||
void* memchr(const void* ptr, int value, size_t num)
|
||||
{
|
||||
unsigned char *p = (unsigned char*)ptr;
|
||||
while (num--) {
|
||||
if (*p != (unsigned char)value) {
|
||||
p++;
|
||||
} else {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// http://clc-wiki.net/wiki/C_standard_library:string.h:strcspn
|
||||
// Get span until any character in string
|
||||
size_t strcspn(const char *str1, const char *str2)
|
||||
{
|
||||
size_t ret = 0;
|
||||
while (*str1) {
|
||||
if (strchr(str2, *str1)) { // Slow
|
||||
return ret;
|
||||
} else {
|
||||
str1++;
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// https://clc-wiki.net/wiki/C_standard_library:string.h:strpbrk
|
||||
// Locate the first occurrence in the string pointed to by s1 of any character from the string pointed to by s2
|
||||
char* strpbrk(const char *s1, const char *s2)
|
||||
{
|
||||
while(*s1) {
|
||||
if (strchr(s2, *s1++)) {
|
||||
return (char*)--s1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// https://opensource.apple.com/source/Libc/Libc-583/stdlib/FreeBSD/strtoull.c
|
||||
// Convert a string to an unsigned long long integer
|
||||
#ifndef __LONG_LONG_MAX__
|
||||
#define __LONG_LONG_MAX__ 9223372036854775807LL
|
||||
#endif
|
||||
#ifndef ULLONG_MAX
|
||||
#define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1)
|
||||
#endif
|
||||
|
||||
unsigned long long strtoull(const char *__restrict nptr, char **__restrict endptr, int base)
|
||||
{
|
||||
const char *s = nptr;
|
||||
char c;
|
||||
do { c = *s++; } while (isspace((unsigned char)c)); // Trim leading spaces
|
||||
|
||||
int neg = 0;
|
||||
if (c == '-') { // Set minus flag and/or skip sign
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
} else {
|
||||
if (c == '+') {
|
||||
c = *s++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((base == 0 || base == 16) && (c == '0') && (*s == 'x' || *s == 'X')) { // Set Hexadecimal
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0) { base = (c == '0') ? 8 : 10; } // Set Octal or Decimal
|
||||
|
||||
unsigned long long acc = 0;
|
||||
int any = 0;
|
||||
if (base > 1 && base < 37) {
|
||||
unsigned long long cutoff = ULLONG_MAX / base;
|
||||
int cutlim = ULLONG_MAX % base;
|
||||
for ( ; ; c = *s++) {
|
||||
if (c >= '0' && c <= '9')
|
||||
c -= '0';
|
||||
else if (c >= 'A' && c <= 'Z')
|
||||
c -= 'A' - 10;
|
||||
else if (c >= 'a' && c <= 'z')
|
||||
c -= 'a' - 10;
|
||||
else
|
||||
break;
|
||||
|
||||
if (c >= base)
|
||||
break;
|
||||
|
||||
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
|
||||
any = -1;
|
||||
else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
if (any < 0) {
|
||||
acc = ULLONG_MAX; // Range error
|
||||
}
|
||||
else if (any && neg) {
|
||||
acc = -acc;
|
||||
}
|
||||
}
|
||||
|
||||
if (endptr != nullptr) { *endptr = (char *)(any ? s - 1 : nptr); }
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
|
||||
|
||||
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) || defined(ARDUINO_ESP8266_RELEASE_2_5_0) || defined(ARDUINO_ESP8266_RELEASE_2_5_1) || defined(ARDUINO_ESP8266_RELEASE_2_5_2)
|
||||
/*********************************************************************************************\
|
||||
* Functions not available in core before 2.6.0
|
||||
\*********************************************************************************************/
|
||||
|
||||
// https://github.com/arendst/Tasmota/issues/6856#issuecomment-554258914
|
||||
void* memmove_P(void *dest, const void *src, size_t n)
|
||||
{
|
||||
if (src > (void*)0x40000000) {
|
||||
return memcpy_P(dest, src, n);
|
||||
} else {
|
||||
return memmove(dest, src, n);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ARDUINO_ESP8266_RELEASE < 2_6_0
|
||||
|
||||
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Core overrides
|
||||
\*********************************************************************************************/
|
||||
|
@ -852,11 +852,8 @@ void PerformEverySecond(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
// Wifi keep alive to send Gratuitous ARP
|
||||
wifiKeepAlive();
|
||||
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
|
||||
|
||||
#ifdef ESP32
|
||||
if (11 == uptime) { // Perform one-time ESP32 houskeeping
|
||||
@ -1027,13 +1024,8 @@ void Every250mSeconds(void)
|
||||
}
|
||||
#endif // FIRMWARE_MINIMAL
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "%s"), mqtt_data);
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
|
||||
ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(mqtt_data));
|
||||
#else
|
||||
// If using core stage or 2.5.0+ the syntax has changed
|
||||
WiFiClient OTAclient;
|
||||
ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(OTAclient, mqtt_data));
|
||||
#endif
|
||||
if (!ota_result) {
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
int ota_error = ESPhttpUpdate.getLastError();
|
||||
|
@ -153,14 +153,11 @@ void WiFiSetSleepMode(void)
|
||||
*/
|
||||
|
||||
// Sleep explanation: https://github.com/esp8266/Arduino/blob/3f0c601cfe81439ce17e9bd5d28994a7ed144482/libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp#L255
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
|
||||
#else // Enabled in 2.3.0, 2.4.0 and stage
|
||||
if (ssleep && Settings.flag3.sleep_normal) { // SetOption60 - Enable normal sleep instead of dynamic sleep
|
||||
WiFi.setSleepMode(WIFI_LIGHT_SLEEP); // Allow light sleep during idle times
|
||||
} else {
|
||||
WiFi.setSleepMode(WIFI_MODEM_SLEEP); // Disable sleep (Esp8288/Arduino core and sdk default)
|
||||
}
|
||||
#endif
|
||||
WifiSetOutputPower();
|
||||
}
|
||||
|
||||
@ -172,12 +169,6 @@ void WifiBegin(uint8_t flag, uint8_t channel)
|
||||
UdpDisconnect();
|
||||
#endif // USE_EMULATION
|
||||
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_3_0 // (!strncmp_P(ESP.getSdkVersion(),PSTR("1.5.3"),5))
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_WIFI, PSTR(D_PATCH_ISSUE_2186));
|
||||
// WiFi.mode(WIFI_OFF); // See https://github.com/esp8266/Arduino/issues/2186
|
||||
WifiSetMode(WIFI_OFF);
|
||||
#endif
|
||||
|
||||
WiFi.persistent(false); // Solve possible wifi init errors (re-add at 6.2.1.16 #4044, #4083)
|
||||
WiFi.disconnect(true); // Delete SDK wifi config
|
||||
delay(200);
|
||||
@ -652,7 +643,6 @@ void EspRestart(void)
|
||||
ESP_Restart();
|
||||
}
|
||||
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
//
|
||||
// Gratuitous ARP, backported from https://github.com/esp8266/Arduino/pull/6889
|
||||
//
|
||||
@ -700,4 +690,3 @@ void wifiKeepAlive(void) {
|
||||
SetNextTimeInterval(wifiTimer, wifiTimerSec * 1000);
|
||||
}
|
||||
}
|
||||
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
|
@ -16,22 +16,25 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*====================================================
|
||||
Prerequisites:
|
||||
- Change libraries/PubSubClient/src/PubSubClient.h
|
||||
#define MQTT_MAX_PACKET_SIZE 1200
|
||||
|
||||
Arduino IDE 1.8.12 and up parameters
|
||||
- Select IDE Tools - Board: "Generic ESP8266 Module"
|
||||
- Select IDE Tools - Flash Mode: "DOUT (compatible)"
|
||||
- Select IDE Tools - Flash Size: "1M (FS:none OTA:~502KB)"
|
||||
- Select IDE Tools - LwIP Variant: "v2 Higher Bandwidth (no feature)"
|
||||
- Select IDE Tools - VTables: "Flash"
|
||||
- Select IDE Tools - Espressif FW: "nonos-sdk-2.2.1+100 (190703)"
|
||||
====================================================*/
|
||||
/*********************************************************************************************\
|
||||
* Preferred IDE is Visual Studio Code with PlatformIO extension which doesn't need prerequisites
|
||||
*
|
||||
* Limited support for Arduino IDE needs Prerequisites:
|
||||
* - Change libraries/PubSubClient/src/PubSubClient.h
|
||||
* #define MQTT_MAX_PACKET_SIZE 1200
|
||||
*
|
||||
* Arduino IDE 1.8.12 and up parameters for partly support
|
||||
* - Select IDE Tools - Board: "Generic ESP8266 Module"
|
||||
* - Select IDE Tools - Flash Mode: "DOUT (compatible)"
|
||||
* - Select IDE Tools - Flash Size: "1M (FS:none OTA:~502KB)"
|
||||
* - Select IDE Tools - LwIP Variant: "v2 Higher Bandwidth (no feature)"
|
||||
* - Select IDE Tools - VTables: "Flash"
|
||||
* - Select IDE Tools - Espressif FW: "nonos-sdk-2.2.1+100 (190703)"
|
||||
\*********************************************************************************************/
|
||||
|
||||
// Location specific includes
|
||||
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)
|
||||
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_7_1)
|
||||
#include "tasmota_compat.h"
|
||||
#include "tasmota_version.h" // Tasmota version information
|
||||
#include "tasmota.h" // Enumeration used in my_user_config.h
|
||||
@ -43,13 +46,6 @@
|
||||
#include "i18n.h" // Language support configured by my_user_config.h
|
||||
#include "tasmota_template.h" // Hardware configuration
|
||||
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_4_0
|
||||
#include "lwip/init.h"
|
||||
#if LWIP_VERSION_MAJOR != 1
|
||||
#error Please use stable lwIP v1.4
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Libraries
|
||||
#include <ESP8266HTTPClient.h> // Ota
|
||||
#include <ESP8266httpUpdate.h> // Ota
|
||||
|
@ -176,7 +176,7 @@
|
||||
#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_LMT01 // Add support for TI LMT01 temperature sensor, count pulses on single GPIO (+0k5 code)
|
||||
#define USE_SR04 // Add support for HC-SR04 ultrasonic devices (+1k 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)
|
||||
@ -280,13 +280,11 @@
|
||||
|
||||
#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_DISPLAY_ILI9341 // [DisplayModel 4] Enable ILI9341 Tft 480x320 display (+19k code)
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // There is not enough spare RAM with core 2.3.0 to support the following
|
||||
#define USE_DISPLAY_EPAPER_29 // [DisplayModel 5] Enable e-paper 2.9 inch display (+19k code)
|
||||
#define USE_DISPLAY_EPAPER_42 // [DisplayModel 6] Enable e-paper 4.2 inch display
|
||||
// #define USE_DISPLAY_ILI9488 // [DisplayModel 8]
|
||||
// #define USE_DISPLAY_SSD1351 // [DisplayModel 9]
|
||||
// #define USE_DISPLAY_RA8876 // [DisplayModel 10]
|
||||
#endif
|
||||
|
||||
#undef DEBUG_THEO // Disable debug code
|
||||
#undef USE_DEBUG_DRIVER // Disable debug code
|
||||
@ -539,16 +537,17 @@
|
||||
#undef CODE_IMAGE_STR
|
||||
#define CODE_IMAGE_STR "minimal"
|
||||
|
||||
#undef FIRMWARE_LITE // Disable tasmota-lite with no sensors
|
||||
#undef FIRMWARE_SENSORS // Disable tasmota-sensors with useful sensors enabled
|
||||
#undef FIRMWARE_KNX_NO_EMULATION // Disable tasmota-knx with KNX but without Emulation
|
||||
#undef FIRMWARE_DISPLAYS // Disable tasmota-display with display drivers enabled
|
||||
#undef FIRMWARE_IR // Disable tasmota-ir with IR full protocols activated
|
||||
#undef FIRMWARE_IR_CUSTOM // Disable tasmota customizable with special marker to add all IR protocols
|
||||
#undef FIRMWARE_LITE // Disable tasmota-lite with no sensors
|
||||
#undef FIRMWARE_SENSORS // Disable tasmota-sensors with useful sensors enabled
|
||||
#undef FIRMWARE_KNX_NO_EMULATION // Disable tasmota-knx with KNX but without Emulation
|
||||
#undef FIRMWARE_DISPLAYS // Disable tasmota-display with display drivers enabled
|
||||
#undef FIRMWARE_IR // Disable tasmota-ir with IR full protocols activated
|
||||
#undef FIRMWARE_IR_CUSTOM // Disable tasmota customizable with special marker to add all IR protocols
|
||||
|
||||
#undef USE_ARDUINO_OTA // Disable support for Arduino OTA
|
||||
#undef USE_DOMOTICZ // Disable Domoticz
|
||||
#undef USE_HOME_ASSISTANT // Disable Home Assistant
|
||||
#undef USE_TELEGRAM // Disable support for Telegram protocol (+49k code, +7.0k mem and +4.8k additional during connection handshake)
|
||||
//#undef USE_MQTT_TLS // Disable TLS support won't work as the MQTTHost is not set
|
||||
#undef USE_KNX // Disable KNX IP Protocol Support
|
||||
//#undef USE_WEBSERVER // Disable Webserver
|
||||
@ -561,6 +560,8 @@
|
||||
#undef USE_TIMERS // Disable support for up to 16 timers
|
||||
#undef USE_TIMERS_WEB // Disable support for timer webpage
|
||||
#undef USE_SUNRISE // Disable support for Sunrise and sunset tools
|
||||
#undef USE_PING // Disable Ping command (+2k code)
|
||||
#undef USE_UNISHOX_COMPRESSION // Disable support for string compression in Rules or Scripts
|
||||
#undef USE_RULES // Disable support for rules
|
||||
#undef USE_SCRIPT // Disable support for script
|
||||
|
||||
@ -594,6 +595,7 @@
|
||||
#undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control
|
||||
#undef USE_ELECTRIQ_MOODL // Disable support for ElectriQ iQ-wifiMOODL RGBW LED controller
|
||||
#undef USE_LIGHT_PALETTE // Disable support for color palette (+0k9 code)
|
||||
#undef USE_DGR_LIGHT_SEQUENCE // Disable support for device group light sequencing (requires USE_DEVICE_GROUPS) (+0k2 code)
|
||||
|
||||
#undef USE_COUNTER // Disable counters
|
||||
#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices
|
||||
@ -609,6 +611,7 @@
|
||||
#undef USE_NOVA_SDS // Disable support for SDS011 and SDS021 particle concentration sensor
|
||||
#undef USE_HPMA // Disable support for Honeywell HPMA115S0 particle concentration sensor
|
||||
#undef USE_SERIAL_BRIDGE // Disable support for software Serial Bridge
|
||||
#undef USE_TCP_BRIDGE // DIsable support for Serial to TCP bridge (+1.3k code)
|
||||
#undef USE_MP3_PLAYER // Disable DFPlayer Mini MP3 Player RB-DFR-562 commands: play, volume and stop
|
||||
#undef USE_AZ7798 // Disable support for AZ-Instrument 7798 CO2 datalogger
|
||||
#undef USE_PN532_HSU // Disable support for PN532 using HSU (Serial) interface (+1k8 code, 140 bytes mem)
|
||||
@ -633,11 +636,14 @@
|
||||
#undef USE_DDSU666 // Disable support for Chint DDSU666 Modbus energy monitor (+0k6 code)
|
||||
#undef USE_SOLAX_X1 // Disable support for Solax X1 series Modbus log info (+3k1 code)
|
||||
#undef USE_LE01MR // Disable support for F&F LE-01MR Modbus energy meter (+2k code)
|
||||
#undef USE_BL0940 // Disable support for BL0940 Energy monitor as used in Blitzwolf SHP-10 (+1k6 code)
|
||||
#undef USE_TELEINFO // Disable support for French Energy Provider metering telemetry
|
||||
#undef USE_IEM3000 // Disable support for Schneider Electric iEM3000-Modbus series energy monitor (+0k8 code)
|
||||
|
||||
#undef USE_DHT // Disable support for DHT11, AM2301 (DHT21, DHT22, AM2302, AM2321) and SI7021 Temperature and Humidity sensor
|
||||
#undef USE_MAX31855 // Disable MAX31855 K-Type thermocouple sensor using softSPI
|
||||
#undef USE_MAX31865 // Disable support for MAX31865 RTD sensors using softSPI
|
||||
#undef USE_LMT01 // Disable support for TI LMT01 temperature sensor, count pulses on single GPIO (+0k5 code)
|
||||
#undef USE_IR_REMOTE // Disable IR driver
|
||||
#undef USE_SR04 // Disable support for for HC-SR04 ultrasonic devices
|
||||
#undef USE_TM1638 // Disable support for TM1638 switches copying Switch1 .. Switch8
|
||||
@ -650,6 +656,7 @@
|
||||
#undef USE_HRE // Disable support for Badger HR-E Water Meter (+1k4 code)
|
||||
#undef USE_A4988_STEPPER // Disable support for A4988_Stepper
|
||||
#undef USE_THERMOSTAT // Disable support for Thermostat
|
||||
#undef USE_PROMETHEUS // Disable support for https://prometheus.io/ metrics exporting over HTTP /metrics endpoint
|
||||
#undef DEBUG_THEO // Disable debug code
|
||||
#undef USE_DEBUG_DRIVER // Disable debug code
|
||||
#endif // FIRMWARE_MINIMAL
|
||||
|
@ -128,8 +128,8 @@ String EthernetMacAddress(void);
|
||||
const uint16_t WEB_LOG_SIZE = 4000; // Max number of characters in weblog
|
||||
#endif
|
||||
|
||||
#if defined(USE_TLS) && defined(ARDUINO_ESP8266_RELEASE_2_3_0)
|
||||
#error "TLS is no more supported on Core 2.3.0, use 2.4.2 or higher."
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2) || defined(ARDUINO_ESP8266_RELEASE_2_5_0) || defined(ARDUINO_ESP8266_RELEASE_2_5_1) || defined(ARDUINO_ESP8266_RELEASE_2_5_2)
|
||||
#error "Arduino ESP8266 Core versions before 2.7.1 are not supported"
|
||||
#endif
|
||||
|
||||
#ifndef MQTT_MAX_PACKET_SIZE
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef _TASMOTA_VERSION_H_
|
||||
#define _TASMOTA_VERSION_H_
|
||||
|
||||
const uint32_t VERSION = 0x08030106;
|
||||
const uint32_t VERSION = 0x08030107;
|
||||
|
||||
// Lowest compatible version
|
||||
const uint32_t VERSION_COMPATIBLE = 0x07010006;
|
||||
|
@ -913,14 +913,8 @@ void WifiManagerBegin(bool reset_only)
|
||||
int channel = WIFI_SOFT_AP_CHANNEL;
|
||||
if ((channel < 1) || (channel > 13)) { channel = 1; }
|
||||
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
// bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0);
|
||||
WiFi.softAP(my_hostname, WIFI_AP_PASSPHRASE, channel, 0);
|
||||
#else
|
||||
// bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4);
|
||||
WiFi.softAP(my_hostname, WIFI_AP_PASSPHRASE, channel, 0, 1);
|
||||
#endif
|
||||
|
||||
delay(500); // Without delay I've seen the IP address blank
|
||||
/* Setup the DNS server redirecting all the domains to the apIP */
|
||||
DnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
||||
@ -992,10 +986,6 @@ void WSContentBegin(int code, int ctype)
|
||||
{
|
||||
Webserver->client().flush();
|
||||
WSHeaderSend();
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
Webserver->sendHeader(F("Accept-Ranges"),F("none"));
|
||||
Webserver->sendHeader(F("Transfer-Encoding"),F("chunked"));
|
||||
#endif
|
||||
Webserver->setContentLength(CONTENT_LENGTH_UNKNOWN);
|
||||
WSSend(code, ctype, ""); // Signal start of chunked content
|
||||
Web.chunk_buffer = "";
|
||||
@ -1004,15 +994,7 @@ void WSContentBegin(int code, int ctype)
|
||||
void _WSContentSend(const String& content) // Low level sendContent for all core versions
|
||||
{
|
||||
size_t len = content.length();
|
||||
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
const char * footer = "\r\n";
|
||||
char chunk_size[11];
|
||||
sprintf(chunk_size, "%x\r\n", len);
|
||||
Webserver->sendContent(String() + chunk_size + content + footer);
|
||||
#else
|
||||
Webserver->sendContent(content);
|
||||
#endif
|
||||
|
||||
#ifdef USE_DEBUG_DRIVER
|
||||
ShowFreeMem(PSTR("WSContentSend"));
|
||||
@ -1377,7 +1359,7 @@ void HandleRoot(void)
|
||||
"c", // c - Unique HTML id
|
||||
"#000", "#fff", // Black to White
|
||||
4, // sl4 - Unique range HTML id - Used as source for Saturation begin color
|
||||
Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100%
|
||||
Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100% (SetOption77 - Do not power off if slider moved to far left)
|
||||
Settings.light_dimmer,
|
||||
'd', 0); // d0 - Value id is related to lc("d0", value) and WebGetArg("d0", tmp, sizeof(tmp));
|
||||
|
||||
@ -1389,7 +1371,7 @@ void HandleRoot(void)
|
||||
"f", // f - Unique HTML id
|
||||
"#000", "#fff", // Black to White
|
||||
5, // sl5 - Unique range HTML id - Not used
|
||||
Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100%
|
||||
Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100% (SetOption77 - Do not power off if slider moved to far left)
|
||||
LightGetDimmer(2),
|
||||
'w', 0); // w0 - Value id is related to lc("w0", value) and WebGetArg("w0", tmp, sizeof(tmp));
|
||||
}
|
||||
@ -2367,14 +2349,7 @@ void HandleBackupConfiguration(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
size_t written = myClient.write((const char*)settings_buffer, sizeof(Settings));
|
||||
if (written < sizeof(Settings)) { // https://github.com/esp8266/Arduino/issues/3218
|
||||
myClient.write((const char*)settings_buffer +written, sizeof(Settings) -written);
|
||||
}
|
||||
#else
|
||||
myClient.write((const char*)settings_buffer, sizeof(Settings));
|
||||
#endif
|
||||
|
||||
SettingsBufferFree();
|
||||
|
||||
@ -2623,6 +2598,9 @@ void HandleUploadDone(void)
|
||||
WifiConfigCounter();
|
||||
restart_flag = 0;
|
||||
MqttRetryCounter(0);
|
||||
#ifdef USE_COUNTER
|
||||
CounterInterruptDisable(false);
|
||||
#endif
|
||||
|
||||
WSContentStart_P(S_INFORMATION);
|
||||
if (!Web.upload_error) {
|
||||
@ -2698,6 +2676,9 @@ void HandleUploadLoop(void)
|
||||
}
|
||||
} else {
|
||||
MqttRetryCounter(60);
|
||||
#ifdef USE_COUNTER
|
||||
CounterInterruptDisable(true);
|
||||
#endif
|
||||
#ifdef USE_EMULATION
|
||||
UdpDisconnect();
|
||||
#endif // USE_EMULATION
|
||||
@ -2893,6 +2874,9 @@ void HandleUploadLoop(void)
|
||||
} else if (UPLOAD_FILE_ABORTED == upload.status) {
|
||||
restart_flag = 0;
|
||||
MqttRetryCounter(0);
|
||||
#ifdef USE_COUNTER
|
||||
CounterInterruptDisable(false);
|
||||
#endif
|
||||
Web.upload_error = 7; // Upload aborted
|
||||
if (UPL_TASMOTA == Web.upload_file_type) { Update.end(); }
|
||||
}
|
||||
@ -3152,14 +3136,9 @@ int WebSend(char *buffer)
|
||||
|
||||
DEBUG_CORE_LOG(PSTR("WEB: Uri |%s|"), url.c_str());
|
||||
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
|
||||
HTTPClient http;
|
||||
if (http.begin(UrlEncode(url))) { // UrlEncode(url) = |http://192.168.178.86/cm?cmnd=POWER1%20ON|
|
||||
#else
|
||||
WiFiClient http_client;
|
||||
HTTPClient http;
|
||||
if (http.begin(http_client, UrlEncode(url))) { // UrlEncode(url) = |http://192.168.178.86/cm?cmnd=POWER1%20ON|
|
||||
#endif
|
||||
int http_code = http.GET(); // Start connection and send HTTP header
|
||||
if (http_code > 0) { // http_code will be negative on error
|
||||
if (http_code == HTTP_CODE_OK || http_code == HTTP_CODE_MOVED_PERMANENTLY) {
|
||||
|
@ -637,6 +637,8 @@ void MqttReconnect(void)
|
||||
AddLog_P(LOG_LEVEL_INFO, S_LOG_MQTT, PSTR("MFLN not supported by TLS server"));
|
||||
}
|
||||
#ifndef USE_MQTT_TLS_CA_CERT // don't bother with fingerprints if using CA validation
|
||||
// **** Start patch Castellucci
|
||||
/*
|
||||
// create a printable version of the fingerprint received
|
||||
char buf_fingerprint[64];
|
||||
ToHex_P((unsigned char *)tlsClient->getRecvPubKeyFingerprint(), 20, buf_fingerprint, sizeof(buf_fingerprint), ' ');
|
||||
@ -665,6 +667,35 @@ void MqttReconnect(void)
|
||||
SettingsSaveAll(); // save settings
|
||||
}
|
||||
}
|
||||
*/
|
||||
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_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT "Server fingerprint: %s"), buf_fingerprint);
|
||||
|
||||
bool learned = false;
|
||||
|
||||
// If the fingerprint slot is marked for update, we'll do so.
|
||||
// Otherwise, if the fingerprint slot had the magic trust-on-first-use
|
||||
// value, we will save the current fingerprint there, but only if the other fingerprint slot
|
||||
// *didn't* match it.
|
||||
if (recv_fingerprint[20] & 0x1 || (learn_fingerprint1 && 0 != memcmp(recv_fingerprint, Settings.mqtt_fingerprint[1], 20))) {
|
||||
memcpy(Settings.mqtt_fingerprint[0], recv_fingerprint, 20);
|
||||
learned = true;
|
||||
}
|
||||
// As above, but for the other slot.
|
||||
if (recv_fingerprint[20] & 0x2 || (learn_fingerprint2 && 0 != memcmp(recv_fingerprint, Settings.mqtt_fingerprint[0], 20))) {
|
||||
memcpy(Settings.mqtt_fingerprint[1], recv_fingerprint, 20);
|
||||
learned = true;
|
||||
}
|
||||
|
||||
if (learned) {
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "Fingerprint learned: %s"), buf_fingerprint);
|
||||
|
||||
SettingsSaveAll(); // save settings
|
||||
}
|
||||
// **** End patch Castellucci
|
||||
#endif // !USE_MQTT_TLS_CA_CERT
|
||||
#endif // USE_MQTT_TLS
|
||||
MqttConnected();
|
||||
@ -1186,11 +1217,7 @@ void CmndTlsDump(void) {
|
||||
uint32_t end = start + tls_block_len -1;
|
||||
for (uint32_t pos = start; pos < end; pos += 0x10) {
|
||||
uint32_t* values = (uint32_t*)(pos);
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
Serial.printf("%08x: %08x %08x %08x %08x\n", pos, bswap32(values[0]), bswap32(values[1]), bswap32(values[2]), bswap32(values[3]));
|
||||
#else
|
||||
Serial.printf_P(PSTR("%08x: %08x %08x %08x %08x\n"), pos, bswap32(values[0]), bswap32(values[1]), bswap32(values[2]), bswap32(values[3]));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif // DEBUG_DUMP_TLS
|
||||
|
@ -194,7 +194,7 @@ void LoadFile(const char *name,uint8_t *buf,uint32_t len) {
|
||||
#define EPOCH_OFFSET 1546300800
|
||||
|
||||
enum {OPER_EQU=1,OPER_PLS,OPER_MIN,OPER_MUL,OPER_DIV,OPER_PLSEQU,OPER_MINEQU,OPER_MULEQU,OPER_DIVEQU,OPER_EQUEQU,OPER_NOTEQU,OPER_GRTEQU,OPER_LOWEQU,OPER_GRT,OPER_LOW,OPER_PERC,OPER_XOR,OPER_AND,OPER_OR,OPER_ANDEQU,OPER_OREQU,OPER_XOREQU,OPER_PERCEQU};
|
||||
enum {SCRIPT_LOGLEVEL=1,SCRIPT_TELEPERIOD};
|
||||
enum {SCRIPT_LOGLEVEL=1,SCRIPT_TELEPERIOD,SCRIPT_EVENT_HANDLED};
|
||||
|
||||
#ifdef USE_SCRIPT_FATFS
|
||||
|
||||
@ -379,6 +379,7 @@ struct SCRIPT_MEM {
|
||||
#endif
|
||||
} glob_script_mem;
|
||||
|
||||
bool event_handeled = false;
|
||||
|
||||
|
||||
#ifdef USE_SCRIPT_GLOBVARS
|
||||
@ -1163,11 +1164,9 @@ uint32_t pulse_ltime_hl;
|
||||
uint32_t pulse_ltime_lh;
|
||||
uint8_t pt_pin;
|
||||
|
||||
void MP_Timer(void) ICACHE_RAM_ATTR;
|
||||
|
||||
#define MPT_DEBOUNCE 10
|
||||
|
||||
void MP_Timer(void) {
|
||||
void ICACHE_RAM_ATTR MP_Timer(void) {
|
||||
uint32_t level = digitalRead(pt_pin&0x3f);
|
||||
uint32_t ms = millis();
|
||||
uint32_t time;
|
||||
@ -1573,6 +1572,11 @@ chknext:
|
||||
fvar=UtcTime()-(uint32_t)EPOCH_OFFSET;
|
||||
goto exit;
|
||||
}
|
||||
if (!strncmp(vname,"eres",4)) {
|
||||
fvar=event_handeled;
|
||||
tind->index=SCRIPT_EVENT_HANDLED;
|
||||
goto exit_settable;
|
||||
}
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
if (!strncmp(vname,"enrg[",5)) {
|
||||
lp+=5;
|
||||
@ -2893,19 +2897,6 @@ char *getop(char *lp, uint8_t *operand) {
|
||||
|
||||
|
||||
#ifdef ESP8266
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1)
|
||||
// All version before core 2.4.2
|
||||
// https://github.com/esp8266/Arduino/issues/2557
|
||||
extern "C" {
|
||||
#include <cont.h>
|
||||
extern cont_t g_cont;
|
||||
}
|
||||
uint16_t GetStack(void) {
|
||||
register uint32_t *sp asm("a1");
|
||||
return (4 * (sp - g_cont.stack));
|
||||
}
|
||||
|
||||
#else
|
||||
extern "C" {
|
||||
#include <cont.h>
|
||||
extern cont_t* g_pcont;
|
||||
@ -2914,7 +2905,6 @@ uint16_t GetStack(void) {
|
||||
register uint32_t *sp asm("a1");
|
||||
return (4 * (sp - g_pcont->stack));
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
uint16_t GetStack(void) {
|
||||
register uint8_t *sp asm("a1");
|
||||
@ -3901,6 +3891,9 @@ int16_t Run_script_sub(const char *type, int8_t tlen, JsonObject *jo) {
|
||||
if (*dfvar>300) *dfvar=300;
|
||||
Settings.tele_period=*dfvar;
|
||||
break;
|
||||
case SCRIPT_EVENT_HANDLED:
|
||||
event_handeled=*dfvar;
|
||||
break;
|
||||
}
|
||||
sysv_type=0;
|
||||
}
|
||||
@ -4063,7 +4056,9 @@ void ScripterEvery100ms(void) {
|
||||
Run_Scripter(">T",2, mqtt_data);
|
||||
}
|
||||
}
|
||||
if (fast_script==99) Run_Scripter(">F",2,0);
|
||||
if (Settings.rule_enabled) {
|
||||
if (fast_script==99) Run_Scripter(">F",2,0);
|
||||
}
|
||||
}
|
||||
|
||||
//mems[5] is 50 bytes in 6.5
|
||||
@ -4338,18 +4333,10 @@ uint8_t reject(char *name) {
|
||||
if (*name=='_') return 1;
|
||||
if (*name=='.') return 1;
|
||||
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
if (!strncasecmp(name,"SPOTLI~1",REJCMPL)) return 1;
|
||||
if (!strncasecmp(name,"TRASHE~1",REJCMPL)) return 1;
|
||||
if (!strncasecmp(name,"FSEVEN~1",REJCMPL)) return 1;
|
||||
if (!strncasecmp(name,"SYSTEM~1",REJCMPL)) return 1;
|
||||
#else
|
||||
if (!strcasecmp(name,"SPOTLI~1")) return 1;
|
||||
if (!strcasecmp(name,"TRASHE~1")) return 1;
|
||||
if (!strcasecmp(name,"FSEVEN~1")) return 1;
|
||||
if (!strcasecmp(name,"SYSTEM~1")) return 1;
|
||||
#endif
|
||||
|
||||
if (!strncasecmp(name,"System Volume",13)) return 1;
|
||||
return 0;
|
||||
}
|
||||
@ -6619,6 +6606,7 @@ void cpy2lf(char *dst,uint32_t dstlen, char *src) {
|
||||
bool Xdrv10(uint8_t function)
|
||||
{
|
||||
bool result = false;
|
||||
event_handeled = false;
|
||||
char *sprt;
|
||||
|
||||
switch (function) {
|
||||
@ -6778,11 +6766,17 @@ bool Xdrv10(uint8_t function)
|
||||
#ifdef SCRIPT_POWER_SECTION
|
||||
if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">P",2,0);
|
||||
#else
|
||||
if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">E",2,0);
|
||||
if (bitRead(Settings.rule_enabled, 0)) {
|
||||
Run_Scripter(">E",2,0);
|
||||
result=event_handeled;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case FUNC_RULES_PROCESS:
|
||||
if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">E",2,mqtt_data);
|
||||
if (bitRead(Settings.rule_enabled, 0)) {
|
||||
Run_Scripter(">E",2,mqtt_data);
|
||||
result=event_handeled;
|
||||
}
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_WEB_ADD_BUTTON:
|
||||
|
@ -540,9 +540,6 @@ void TuyaNormalPowerModePacketProcess(void)
|
||||
if (Tuya.buffer[6] == 0) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Detected MCU restart"));
|
||||
Tuya.wifi_state = -2;
|
||||
#ifdef USE_TUYA_TIME
|
||||
TuyaSetTime();
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
@ -805,8 +802,9 @@ void TuyaSetWifiLed(void)
|
||||
}
|
||||
|
||||
#ifdef USE_TUYA_TIME
|
||||
void TuyaSetTime(void)
|
||||
{
|
||||
void TuyaSetTime(void) {
|
||||
if (!RtcTime.valid) { return; }
|
||||
|
||||
uint16_t payload_len = 8;
|
||||
uint8_t payload_buffer[8];
|
||||
payload_buffer[0] = 0x01;
|
||||
@ -881,8 +879,13 @@ bool Xdrv16(uint8_t function)
|
||||
Tuya.heartbeat_timer = 0;
|
||||
TuyaSendCmd(TUYA_CMD_HEARTBEAT);
|
||||
}
|
||||
#ifdef USE_TUYA_TIME
|
||||
if (!(uptime % 60)) {
|
||||
TuyaSetTime();
|
||||
}
|
||||
#endif //USE_TUYA_TIME
|
||||
} else {
|
||||
TuyaSendLowPowerSuccessIfNeeded();
|
||||
TuyaSendLowPowerSuccessIfNeeded();
|
||||
}
|
||||
break;
|
||||
case FUNC_SET_CHANNELS:
|
||||
|
@ -102,7 +102,7 @@ typedef struct Z_Deferred {
|
||||
uint16_t groupaddr; // group address (if needed)
|
||||
uint16_t cluster; // cluster to use for the timer
|
||||
uint8_t endpoint; // endpoint to use for timer
|
||||
uint8_t category; // which category of deferred is it
|
||||
uint8_t category; // which category of deferred is it
|
||||
uint32_t value; // any raw value to use for the timer
|
||||
Z_DeviceTimer func; // function to call when timer occurs
|
||||
} Z_Deferred;
|
||||
@ -213,7 +213,7 @@ public:
|
||||
private:
|
||||
std::vector<Z_Device*> _devices = {};
|
||||
std::vector<Z_Deferred> _deferred = {}; // list of deferred calls
|
||||
uint32_t _saveTimer = 0;
|
||||
uint32_t _saveTimer = 0;
|
||||
uint8_t _seqNumber = 0; // global seqNumber if device is unknown
|
||||
|
||||
template < typename T>
|
||||
@ -738,7 +738,7 @@ bool Z_Devices::getHueState(uint16_t shortaddr,
|
||||
void Z_Devices::resetTimersForDevice(uint16_t shortaddr, uint16_t groupaddr, uint8_t category) {
|
||||
// iterate the list of deferred, and remove any linked to the shortaddr
|
||||
for (auto it = _deferred.begin(); it != _deferred.end(); it++) {
|
||||
// Notice that the iterator is decremented after it is passed
|
||||
// Notice that the iterator is decremented after it is passed
|
||||
// to erase() but before erase() is executed
|
||||
// see https://www.techiedelight.com/remove-elements-vector-inside-loop-cpp/
|
||||
if ((it->shortaddr == shortaddr) && (it->groupaddr == groupaddr)) {
|
||||
@ -937,9 +937,17 @@ void Z_Devices::jsonPublishFlush(uint16_t shortaddr) {
|
||||
zigbee_devices.jsonClear(shortaddr);
|
||||
|
||||
if (use_fname) {
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"%s\":%s}}"), fname, msg.c_str());
|
||||
if (Settings.flag4.remove_zbreceived) {
|
||||
Response_P(PSTR("{\"%s\":%s}"), fname, msg.c_str());
|
||||
} else {
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"%s\":%s}}"), fname, msg.c_str());
|
||||
}
|
||||
} else {
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"0x%04X\":%s}}"), shortaddr, msg.c_str());
|
||||
if (Settings.flag4.remove_zbreceived) {
|
||||
Response_P(PSTR("{\"0x%04X\":%s}"), shortaddr, msg.c_str());
|
||||
} else {
|
||||
Response_P(PSTR("{\"" D_JSON_ZIGBEE_RECEIVED "\":{\"0x%04X\":%s}}"), shortaddr, msg.c_str());
|
||||
}
|
||||
}
|
||||
if (Settings.flag4.zigbee_distinct_topics) {
|
||||
char subtopic[16];
|
||||
|
@ -45,11 +45,9 @@ struct ARILUX {
|
||||
uint8_t rf_toggle = 0;
|
||||
} Arilux;
|
||||
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception
|
||||
#ifndef USE_WS2812_DMA // Collides with Neopixelbus but solves RF misses
|
||||
void AriluxRfInterrupt(void) ICACHE_RAM_ATTR; // As iram is tight and it works this way too
|
||||
#endif // USE_WS2812_DMA
|
||||
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
|
||||
void AriluxRfInterrupt(void)
|
||||
{
|
||||
|
@ -189,24 +189,6 @@ void CpuLoadLoop(void)
|
||||
/*******************************************************************************************/
|
||||
|
||||
#ifdef ESP8266
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1)
|
||||
// All version before core 2.4.2
|
||||
// https://github.com/esp8266/Arduino/issues/2557
|
||||
|
||||
extern "C" {
|
||||
#include <cont.h>
|
||||
extern cont_t g_cont;
|
||||
}
|
||||
|
||||
void DebugFreeMem(void)
|
||||
{
|
||||
register uint32_t *sp asm("a1");
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d, UnmodifiedStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_cont.stack), cont_get_free_stack(&g_cont), XdrvMailbox.data);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_cont.stack), XdrvMailbox.data);
|
||||
}
|
||||
|
||||
#else
|
||||
// All version from core 2.4.2
|
||||
// https://github.com/esp8266/Arduino/pull/5018
|
||||
// https://github.com/esp8266/Arduino/pull/4553
|
||||
@ -223,8 +205,6 @@ void DebugFreeMem(void)
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_pcont->stack), XdrvMailbox.data);
|
||||
}
|
||||
|
||||
#endif // ARDUINO_ESP8266_RELEASE_2_x_x
|
||||
|
||||
#else // ESP32
|
||||
|
||||
void DebugFreeMem(void)
|
||||
|
@ -236,6 +236,7 @@ uint8_t solaxX1_ParseErrorCode(uint32_t code){
|
||||
if (ErrCode.TemperatureOverFault) return 6;
|
||||
if (ErrCode.FanFault) return 7;
|
||||
if (ErrCode.OtherDeviceFault) return 8;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************************************/
|
||||
|
@ -36,6 +36,8 @@ const char kCounterCommands[] PROGMEM = D_PRFX_COUNTER "|" // Prefix
|
||||
void (* const CounterCommand[])(void) PROGMEM = {
|
||||
&CmndCounter, &CmndCounterType, &CmndCounterDebounce, &CmndCounterDebounceLow, &CmndCounterDebounceHigh };
|
||||
|
||||
uint8_t ctr_index[MAX_COUNTERS] = { 0, 1, 2, 3 };
|
||||
|
||||
struct COUNTER {
|
||||
uint32_t timer[MAX_COUNTERS]; // Last counter time in micro seconds
|
||||
uint32_t timer_low_high[MAX_COUNTERS]; // Last low/high counter time in micro seconds
|
||||
@ -47,16 +49,10 @@ struct COUNTER {
|
||||
uint32_t last_cycle;
|
||||
uint32_t cycle_time;
|
||||
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception
|
||||
void CounterUpdate(uint8_t index) ICACHE_RAM_ATTR;
|
||||
void CounterUpdate1(void) ICACHE_RAM_ATTR;
|
||||
void CounterUpdate2(void) ICACHE_RAM_ATTR;
|
||||
void CounterUpdate3(void) ICACHE_RAM_ATTR;
|
||||
void CounterUpdate4(void) ICACHE_RAM_ATTR;
|
||||
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
//void ICACHE_RAM_ATTR CounterUpdate(uint8_t index) {
|
||||
void ICACHE_RAM_ATTR CounterIsrArg(void *arg) {
|
||||
uint32_t index = *static_cast<uint8_t*>(arg);
|
||||
|
||||
void CounterUpdate(uint8_t index)
|
||||
{
|
||||
uint32_t time = micros();
|
||||
uint32_t debounce_time;
|
||||
|
||||
@ -124,29 +120,46 @@ void CounterUpdate(uint8_t index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CounterUpdate1(void)
|
||||
/*
|
||||
void ICACHE_RAM_ATTR CounterUpdate1(void)
|
||||
{
|
||||
CounterUpdate(0);
|
||||
}
|
||||
|
||||
void CounterUpdate2(void)
|
||||
void ICACHE_RAM_ATTR CounterUpdate2(void)
|
||||
{
|
||||
CounterUpdate(1);
|
||||
}
|
||||
|
||||
void CounterUpdate3(void)
|
||||
void ICACHE_RAM_ATTR CounterUpdate3(void)
|
||||
{
|
||||
CounterUpdate(2);
|
||||
}
|
||||
|
||||
void CounterUpdate4(void)
|
||||
void ICACHE_RAM_ATTR CounterUpdate4(void)
|
||||
{
|
||||
CounterUpdate(3);
|
||||
}
|
||||
|
||||
*/
|
||||
/********************************************************************************************/
|
||||
|
||||
void CounterInterruptDisable(bool state) {
|
||||
if (state) { // Disable interrupts
|
||||
if (Counter.any_counter) {
|
||||
for (uint32_t i = 0; i < MAX_COUNTERS; i++) {
|
||||
if (PinUsed(GPIO_CNTR1, i)) {
|
||||
detachInterrupt(Pin(GPIO_CNTR1, i));
|
||||
}
|
||||
}
|
||||
Counter.any_counter = false;
|
||||
}
|
||||
} else { // Enable interrupts
|
||||
if (!Counter.any_counter) {
|
||||
CounterInit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CounterPinState(void)
|
||||
{
|
||||
if ((XdrvMailbox.index >= AGPIO(GPIO_CNTR1_NP)) && (XdrvMailbox.index < (AGPIO(GPIO_CNTR1_NP) + MAX_COUNTERS))) {
|
||||
@ -159,8 +172,8 @@ bool CounterPinState(void)
|
||||
|
||||
void CounterInit(void)
|
||||
{
|
||||
typedef void (*function) () ;
|
||||
function counter_callbacks[] = { CounterUpdate1, CounterUpdate2, CounterUpdate3, CounterUpdate4 };
|
||||
// typedef void (*function) () ;
|
||||
// function counter_callbacks[] = { CounterUpdate1, CounterUpdate2, CounterUpdate3, CounterUpdate4 };
|
||||
|
||||
for (uint32_t i = 0; i < MAX_COUNTERS; i++) {
|
||||
if (PinUsed(GPIO_CNTR1, i)) {
|
||||
@ -168,10 +181,12 @@ void CounterInit(void)
|
||||
pinMode(Pin(GPIO_CNTR1, i), bitRead(Counter.no_pullup, i) ? INPUT : INPUT_PULLUP);
|
||||
if ((0 == Settings.pulse_counter_debounce_low) && (0 == Settings.pulse_counter_debounce_high) && !Settings.flag4.zerocross_dimmer) {
|
||||
Counter.pin_state = 0;
|
||||
attachInterrupt(Pin(GPIO_CNTR1, i), counter_callbacks[i], FALLING);
|
||||
// attachInterrupt(Pin(GPIO_CNTR1, i), counter_callbacks[i], FALLING);
|
||||
attachInterruptArg(Pin(GPIO_CNTR1, i), CounterIsrArg, &ctr_index[i], FALLING);
|
||||
} else {
|
||||
Counter.pin_state = 0x8f;
|
||||
attachInterrupt(Pin(GPIO_CNTR1, i), counter_callbacks[i], CHANGE);
|
||||
// attachInterrupt(Pin(GPIO_CNTR1, i), counter_callbacks[i], CHANGE);
|
||||
attachInterruptArg(Pin(GPIO_CNTR1, i), CounterIsrArg, &ctr_index[i], CHANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,11 +150,7 @@ uint32_t tx2x_last_available = 0;
|
||||
uint32_t tx23_stage = 0;
|
||||
#endif // USE_TX23_WIND_SENSOR
|
||||
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception
|
||||
void TX2xStartRead(void) ICACHE_RAM_ATTR; // As iram is tight and it works this way too
|
||||
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
|
||||
void TX2xStartRead(void)
|
||||
void ICACHE_RAM_ATTR TX2xStartRead(void)
|
||||
{
|
||||
/**
|
||||
* La Crosse TX20 Anemometer datagram every 2 seconds
|
||||
|
@ -559,6 +559,7 @@ bool PN532_Command(void)
|
||||
return serviced;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // USE_PN532_DATA_FUNCTION
|
||||
|
@ -1811,16 +1811,7 @@ struct SML_COUNTER {
|
||||
#endif
|
||||
} sml_counters[MAX_COUNTERS];
|
||||
|
||||
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception
|
||||
void SML_CounterUpd(uint8_t index) ICACHE_RAM_ATTR;
|
||||
void SML_CounterUpd1(void) ICACHE_RAM_ATTR;
|
||||
void SML_CounterUpd2(void) ICACHE_RAM_ATTR;
|
||||
void SML_CounterUpd3(void) ICACHE_RAM_ATTR;
|
||||
void SML_CounterUpd4(void) ICACHE_RAM_ATTR;
|
||||
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
|
||||
void SML_CounterUpd(uint8_t index) {
|
||||
void ICACHE_RAM_ATTR SML_CounterUpd(uint8_t index) {
|
||||
|
||||
uint8_t level=digitalRead(meter_desc_p[sml_counters[index].sml_cnt_old_state].srcpin);
|
||||
if (!level) {
|
||||
@ -1838,19 +1829,19 @@ void SML_CounterUpd(uint8_t index) {
|
||||
}
|
||||
}
|
||||
|
||||
void SML_CounterUpd1(void) {
|
||||
void ICACHE_RAM_ATTR SML_CounterUpd1(void) {
|
||||
SML_CounterUpd(0);
|
||||
}
|
||||
|
||||
void SML_CounterUpd2(void) {
|
||||
void ICACHE_RAM_ATTR SML_CounterUpd2(void) {
|
||||
SML_CounterUpd(1);
|
||||
}
|
||||
|
||||
void SML_CounterUpd3(void) {
|
||||
void ICACHE_RAM_ATTR SML_CounterUpd3(void) {
|
||||
SML_CounterUpd(2);
|
||||
}
|
||||
|
||||
void SML_CounterUpd4(void) {
|
||||
void ICACHE_RAM_ATTR SML_CounterUpd4(void) {
|
||||
SML_CounterUpd(3);
|
||||
}
|
||||
|
||||
|
@ -72,11 +72,7 @@ struct WINDMETER {
|
||||
#endif // USE_WINDMETER_NOSTATISTICS
|
||||
} WindMeter;
|
||||
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception
|
||||
void WindMeterUpdateSpeed(void) ICACHE_RAM_ATTR;
|
||||
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
|
||||
void WindMeterUpdateSpeed(void)
|
||||
void ICACHE_RAM_ATTR WindMeterUpdateSpeed(void)
|
||||
{
|
||||
uint32_t time = micros();
|
||||
uint32_t time_diff = time - WindMeter.counter_time;
|
||||
|
@ -40,13 +40,9 @@ void LMT01_Init(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception
|
||||
void LMT01_countPulse(void) ICACHE_RAM_ATTR;
|
||||
#endif // ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
|
||||
volatile int lmt01_pulseCount = 0;
|
||||
|
||||
void LMT01_countPulse(void) {
|
||||
void ICACHE_RAM_ATTR LMT01_countPulse(void) {
|
||||
lmt01_pulseCount++;
|
||||
}
|
||||
|
||||
@ -81,7 +77,7 @@ int LMT01_getPulses(void) {
|
||||
hold = lmt01_pulseCount;
|
||||
delay(1);
|
||||
}
|
||||
// discard spurious low counts
|
||||
// discard spurious low counts
|
||||
if (timeout > 0 && hold >= 10) {
|
||||
return hold;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user