Merge branch 'development' into pre-release-9.6.0

This commit is contained in:
Theo Arends 2021-10-10 16:41:47 +02:00
commit e96ce2f637
8 changed files with 300 additions and 247 deletions

40
.github/workflows/copy_change.yml vendored Normal file
View File

@ -0,0 +1,40 @@
name: Copy to docs repo
on:
workflow_dispatch: # Manually start a workflow
push:
branches: development
paths:
- 'BUILDS.md'
- 'I2CDEVICES.md'
jobs:
copy_change:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Push I2CDevices.md to https://github.com/Tasmota/docs
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
with:
source_file: 'I2CDEVICES.md'
destination_repo: 'Tasmota/docs'
destination_branch: 'development'
destination_folder: 'docs'
user_email: 'github-actions@github.com'
user_name: 'github-actions'
commit_message: 'I2CDevices.md changed'
- name: Push Builds.md to https://github.com/Tasmota/docs
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
with:
source_file: 'BUILDS.md'
destination_repo: 'Tasmota/docs'
destination_branch: 'development'
destination_folder: 'docs'
user_email: 'github-actions@github.com'
user_name: 'github-actions'
commit_message: 'Builds.md changed'

View File

@ -191,6 +191,11 @@ void WiFiClientSecure_light::_clear() {
_last_error = 0;
_recvapp_buf = nullptr;
_recvapp_len = 0;
#ifdef USE_MQTT_TLS_CA_CERT
_insecure = false; // insecure (fingerprint) mode is only enabled if setPubKeyFingerprint() is called
#else
_insecure = true; // force insecure if CA validation is not enabled
#endif
_fingerprint_any = true; // by default accept all fingerprints
_fingerprint1 = nullptr;
_fingerprint2 = nullptr;
@ -954,10 +959,9 @@ extern "C" {
bool WiFiClientSecure_light::_connectSSL(const char* hostName) {
// Validation context, either full CA validation or checking only fingerprints
#ifdef USE_MQTT_TLS_CA_CERT
br_x509_minimal_context *x509_minimal;
#else
br_x509_pubkeyfingerprint_context *x509_insecure;
br_x509_minimal_context *x509_minimal = nullptr;
#endif
br_x509_pubkeyfingerprint_context *x509_insecure = nullptr;
LOG_HEAP_SIZE("_connectSSL.start");
@ -984,24 +988,26 @@ bool WiFiClientSecure_light::_connectSSL(const char* hostName) {
// Allocatte and initialize Decoder Context
LOG_HEAP_SIZE("_connectSSL before DecoderContext allocation");
// Only failure possible in the installation is OOM
#ifdef USE_MQTT_TLS_CA_CERT
x509_minimal = (br_x509_minimal_context*) malloc(sizeof(br_x509_minimal_context));
if (!x509_minimal) break;
br_x509_minimal_init(x509_minimal, &br_sha256_vtable, _ta_P, _ta_size);
br_x509_minimal_set_rsa(x509_minimal, br_ssl_engine_get_rsavrfy(_eng));
br_x509_minimal_set_hash(x509_minimal, br_sha256_ID, &br_sha256_vtable);
br_ssl_engine_set_x509(_eng, &x509_minimal->vtable);
uint32_t now = UtcTime();
uint32_t cfg_time = CfgTime();
if (cfg_time > now) { now = cfg_time; }
br_x509_minimal_set_time(x509_minimal, now / 86400 + 719528, now % 86400);
#else
x509_insecure = (br_x509_pubkeyfingerprint_context*) malloc(sizeof(br_x509_pubkeyfingerprint_context));
//x509_insecure = std::unique_ptr<br_x509_pubkeyfingerprint_context>(new br_x509_pubkeyfingerprint_context);
if (!x509_insecure) break;
br_x509_pubkeyfingerprint_init(x509_insecure, _fingerprint1, _fingerprint2, _recv_fingerprint, _fingerprint_any);
br_ssl_engine_set_x509(_eng, &x509_insecure->vtable);
#ifdef USE_MQTT_TLS_CA_CERT
if (!_insecure) {
x509_minimal = (br_x509_minimal_context*) malloc(sizeof(br_x509_minimal_context));
if (!x509_minimal) break;
br_x509_minimal_init(x509_minimal, &br_sha256_vtable, _ta_P, _ta_size);
br_x509_minimal_set_rsa(x509_minimal, br_ssl_engine_get_rsavrfy(_eng));
br_x509_minimal_set_hash(x509_minimal, br_sha256_ID, &br_sha256_vtable);
br_ssl_engine_set_x509(_eng, &x509_minimal->vtable);
uint32_t now = UtcTime();
uint32_t cfg_time = CfgTime();
if (cfg_time > now) { now = cfg_time; }
br_x509_minimal_set_time(x509_minimal, now / 86400 + 719528, now % 86400);
}
#endif
LOG_HEAP_SIZE("_connectSSL after DecoderContext allocation");
@ -1043,9 +1049,8 @@ bool WiFiClientSecure_light::_connectSSL(const char* hostName) {
#ifdef USE_MQTT_TLS_CA_CERT
free(x509_minimal);
#else
free(x509_insecure);
#endif
free(x509_insecure);
LOG_HEAP_SIZE("_connectSSL after release of Priv Key");
return ret;
} while (0);
@ -1059,9 +1064,8 @@ bool WiFiClientSecure_light::_connectSSL(const char* hostName) {
#endif
#ifdef USE_MQTT_TLS_CA_CERT
free(x509_minimal);
#else
free(x509_insecure);
#endif
free(x509_insecure);
LOG_HEAP_SIZE("_connectSSL clean_on_error");
return false;
}

View File

@ -82,6 +82,7 @@ class WiFiClientSecure_light : public WiFiClient {
_fingerprint1 = f1;
_fingerprint2 = f2;
_fingerprint_any = f_any;
_insecure = true;
}
const uint8_t * getRecvPubKeyFingerprint(void) {
return _recv_fingerprint;
@ -132,7 +133,8 @@ class WiFiClientSecure_light : public WiFiClient {
bool _handshake_done;
uint64_t _last_error;
bool _fingerprint_any; // accept all fingerprints
bool _fingerprint_any; // accept all fingerprints
bool _insecure; // force fingerprint
const uint8_t *_fingerprint1; // fingerprint1 to be checked against
const uint8_t *_fingerprint2; // fingerprint2 to be checked against
// **** Start patch Castellucci

View File

@ -7,139 +7,6 @@
*******************************************************************/
#include "be_constobj.h"
/********************************************************************
** Solidified function: tostring
********************************************************************/
be_local_closure(tostring, /* name */
be_nested_proto(
8, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 4]) { /* constants */
/* K0 */ be_nested_string("string", 398550328, 6),
/* K1 */ be_nested_string("format", -1180859054, 6),
/* K2 */ be_nested_string("<instance: %s(%s)>", 1553432777, 18),
/* K3 */ be_nested_string("_p", 1594591802, 2),
}),
(be_nested_const_str("tostring", -1995258651, 8)),
(be_nested_const_str("input", -103256197, 5)),
( &(const binstruction[11]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0x8C080301, // 0001 GETMET R2 R1 K1
0x58100002, // 0002 LDCONST R4 K2
0x60140005, // 0003 GETGBL R5 G5
0x5C180000, // 0004 MOVE R6 R0
0x7C140200, // 0005 CALL R5 1
0x60180008, // 0006 GETGBL R6 G8
0x881C0103, // 0007 GETMBR R7 R0 K3
0x7C180200, // 0008 CALL R6 1
0x7C080800, // 0009 CALL R2 4
0x80040400, // 000A RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: member
********************************************************************/
be_local_closure(member, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_string("_p", 1594591802, 2),
/* K1 */ be_nested_string("find", -1108310694, 4),
}),
(be_nested_const_str("member", 719708611, 6)),
(be_nested_const_str("input", -103256197, 5)),
( &(const binstruction[ 5]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x8C080501, // 0001 GETMET R2 R2 K1
0x5C100200, // 0002 MOVE R4 R1
0x7C080400, // 0003 CALL R2 2
0x80040400, // 0004 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: setmember
********************************************************************/
be_local_closure(setmember, /* name */
be_nested_proto(
4, /* nstack */
3, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_string("_p", 1594591802, 2),
/* K1 */ be_nested_string("_dirty", 283846766, 6),
}),
(be_nested_const_str("setmember", 1432909441, 9)),
(be_nested_const_str("input", -103256197, 5)),
( &(const binstruction[ 5]) { /* code */
0x880C0100, // 0000 GETMBR R3 R0 K0
0x980C0202, // 0001 SETIDX R3 R1 R2
0x500C0200, // 0002 LDBOOL R3 1 0
0x90020203, // 0003 SETMBR R0 K1 R3
0x80000000, // 0004 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: zero
********************************************************************/
be_local_closure(zero, /* name */
be_nested_proto(
2, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_string("_p", 1594591802, 2),
/* K1 */ be_nested_string("_dirty", 283846766, 6),
}),
(be_nested_const_str("zero", -1955600541, 4)),
(be_nested_const_str("input", -103256197, 5)),
( &(const binstruction[ 6]) { /* code */
0x60040013, // 0000 GETGBL R1 G19
0x7C040000, // 0001 CALL R1 0
0x90020001, // 0002 SETMBR R0 K0 R1
0x50040200, // 0003 LDBOOL R1 1 0
0x90020201, // 0004 SETMBR R0 K1 R1
0x80000000, // 0005 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: save
********************************************************************/
@ -203,12 +70,12 @@ be_local_closure(save, /* name */
/********************************************************************
** Solidified function: has
** Solidified function: setmember
********************************************************************/
be_local_closure(has, /* name */
be_local_closure(setmember, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
4, /* nstack */
3, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
@ -217,16 +84,16 @@ be_local_closure(has, /* name */
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_string("_p", 1594591802, 2),
/* K1 */ be_nested_string("has", -306245661, 3),
/* K1 */ be_nested_string("_dirty", 283846766, 6),
}),
(be_nested_const_str("has", -306245661, 3)),
(be_nested_const_str("setmember", 1432909441, 9)),
(be_nested_const_str("input", -103256197, 5)),
( &(const binstruction[ 5]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x8C080501, // 0001 GETMET R2 R2 K1
0x5C100200, // 0002 MOVE R4 R1
0x7C080400, // 0003 CALL R2 2
0x80040400, // 0004 RET 1 R2
0x880C0100, // 0000 GETMBR R3 R0 K0
0x980C0202, // 0001 SETIDX R3 R1 R2
0x500C0200, // 0002 LDBOOL R3 1 0
0x90020203, // 0003 SETMBR R0 K1 R3
0x80000000, // 0004 RET 0
})
)
);
@ -234,11 +101,11 @@ be_local_closure(has, /* name */
/********************************************************************
** Solidified function: remove
** Solidified function: init
********************************************************************/
be_local_closure(remove, /* name */
be_local_closure(init, /* name */
be_nested_proto(
5, /* nstack */
6, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
@ -246,21 +113,37 @@ be_local_closure(remove, /* name */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 3]) { /* constants */
/* K0 */ be_nested_string("_p", 1594591802, 2),
/* K1 */ be_nested_string("remove", -611183107, 6),
/* K2 */ be_nested_string("_dirty", 283846766, 6),
( &(const bvalue[ 6]) { /* constants */
/* K0 */ be_nested_string("_filename", 1430813195, 9),
/* K1 */ be_nested_string("_persist.json", 2008425138, 13),
/* K2 */ be_nested_string("_p", 1594591802, 2),
/* K3 */ be_nested_string("copy", -446502332, 4),
/* K4 */ be_nested_string("load", -435725847, 4),
/* K5 */ be_nested_string("_dirty", 283846766, 6),
}),
(be_nested_const_str("remove", -611183107, 6)),
(be_nested_const_str("init", 380752755, 4)),
(be_nested_const_str("input", -103256197, 5)),
( &(const binstruction[ 7]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x8C080501, // 0001 GETMET R2 R2 K1
0x5C100200, // 0002 MOVE R4 R1
0x7C080400, // 0003 CALL R2 2
0x50080200, // 0004 LDBOOL R2 1 0
0x90020402, // 0005 SETMBR R0 K2 R2
0x80000000, // 0006 RET 0
( &(const binstruction[20]) { /* code */
0x90020101, // 0000 SETMBR R0 K0 K1
0x6008000F, // 0001 GETGBL R2 G15
0x5C0C0200, // 0002 MOVE R3 R1
0x60100013, // 0003 GETGBL R4 G19
0x7C080400, // 0004 CALL R2 2
0x780A0003, // 0005 JMPF R2 #000A
0x8C080303, // 0006 GETMET R2 R1 K3
0x7C080200, // 0007 CALL R2 1
0x90020402, // 0008 SETMBR R0 K2 R2
0x70020002, // 0009 JMP #000D
0x60080013, // 000A GETGBL R2 G19
0x7C080000, // 000B CALL R2 0
0x90020402, // 000C SETMBR R0 K2 R2
0x8C080104, // 000D GETMET R2 R0 K4
0x88100102, // 000E GETMBR R4 R0 K2
0x88140100, // 000F GETMBR R5 R0 K0
0x7C080600, // 0010 CALL R2 3
0x50080000, // 0011 LDBOOL R2 0 0
0x90020A02, // 0012 SETMBR R0 K5 R2
0x80000000, // 0013 RET 0
})
)
);
@ -339,11 +222,11 @@ be_local_closure(load, /* name */
/********************************************************************
** Solidified function: init
** Solidified function: has
********************************************************************/
be_local_closure(init, /* name */
be_local_closure(has, /* name */
be_nested_proto(
6, /* nstack */
5, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
@ -351,37 +234,115 @@ be_local_closure(init, /* name */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 6]) { /* constants */
/* K0 */ be_nested_string("_filename", 1430813195, 9),
/* K1 */ be_nested_string("_persist.json", 2008425138, 13),
/* K2 */ be_nested_string("_p", 1594591802, 2),
/* K3 */ be_nested_string("copy", -446502332, 4),
/* K4 */ be_nested_string("load", -435725847, 4),
/* K5 */ be_nested_string("_dirty", 283846766, 6),
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_string("_p", 1594591802, 2),
/* K1 */ be_nested_string("has", -306245661, 3),
}),
(be_nested_const_str("init", 380752755, 4)),
(be_nested_const_str("has", -306245661, 3)),
(be_nested_const_str("input", -103256197, 5)),
( &(const binstruction[20]) { /* code */
0x90020101, // 0000 SETMBR R0 K0 K1
0x6008000F, // 0001 GETGBL R2 G15
0x5C0C0200, // 0002 MOVE R3 R1
0x60100013, // 0003 GETGBL R4 G19
0x7C080400, // 0004 CALL R2 2
0x780A0003, // 0005 JMPF R2 #000A
0x8C080303, // 0006 GETMET R2 R1 K3
0x7C080200, // 0007 CALL R2 1
0x90020402, // 0008 SETMBR R0 K2 R2
0x70020002, // 0009 JMP #000D
0x60080013, // 000A GETGBL R2 G19
0x7C080000, // 000B CALL R2 0
0x90020402, // 000C SETMBR R0 K2 R2
0x8C080104, // 000D GETMET R2 R0 K4
0x88100102, // 000E GETMBR R4 R0 K2
0x88140100, // 000F GETMBR R5 R0 K0
0x7C080600, // 0010 CALL R2 3
0x50080000, // 0011 LDBOOL R2 0 0
0x90020A02, // 0012 SETMBR R0 K5 R2
0x80000000, // 0013 RET 0
( &(const binstruction[ 5]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x8C080501, // 0001 GETMET R2 R2 K1
0x5C100200, // 0002 MOVE R4 R1
0x7C080400, // 0003 CALL R2 2
0x80040400, // 0004 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: zero
********************************************************************/
be_local_closure(zero, /* name */
be_nested_proto(
2, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_string("_p", 1594591802, 2),
/* K1 */ be_nested_string("_dirty", 283846766, 6),
}),
(be_nested_const_str("zero", -1955600541, 4)),
(be_nested_const_str("input", -103256197, 5)),
( &(const binstruction[ 6]) { /* code */
0x60040013, // 0000 GETGBL R1 G19
0x7C040000, // 0001 CALL R1 0
0x90020001, // 0002 SETMBR R0 K0 R1
0x50040200, // 0003 LDBOOL R1 1 0
0x90020201, // 0004 SETMBR R0 K1 R1
0x80000000, // 0005 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: member
********************************************************************/
be_local_closure(member, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_string("_p", 1594591802, 2),
/* K1 */ be_nested_string("find", -1108310694, 4),
}),
(be_nested_const_str("member", 719708611, 6)),
(be_nested_const_str("input", -103256197, 5)),
( &(const binstruction[ 5]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x8C080501, // 0001 GETMET R2 R2 K1
0x5C100200, // 0002 MOVE R4 R1
0x7C080400, // 0003 CALL R2 2
0x80040400, // 0004 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: remove
********************************************************************/
be_local_closure(remove, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 3]) { /* constants */
/* K0 */ be_nested_string("_p", 1594591802, 2),
/* K1 */ be_nested_string("remove", -611183107, 6),
/* K2 */ be_nested_string("_dirty", 283846766, 6),
}),
(be_nested_const_str("remove", -611183107, 6)),
(be_nested_const_str("input", -103256197, 5)),
( &(const binstruction[ 7]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x8C080501, // 0001 GETMET R2 R2 K1
0x5C100200, // 0002 MOVE R4 R1
0x7C080400, // 0003 CALL R2 2
0x50080200, // 0004 LDBOOL R2 1 0
0x90020402, // 0005 SETMBR R0 K2 R2
0x80000000, // 0006 RET 0
})
)
);
@ -426,21 +387,20 @@ be_local_closure(find, /* name */
be_local_class(Persist,
3,
NULL,
be_nested_map(13,
be_nested_map(12,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_closure(tostring_closure) },
{ be_nested_key("member", 719708611, 6, 3), be_const_closure(member_closure) },
{ be_nested_key("setmember", 1432909441, 9, 5), be_const_closure(setmember_closure) },
{ be_nested_key("zero", -1955600541, 4, 9), be_const_closure(zero_closure) },
{ be_nested_key("save", -855671224, 4, -1), be_const_closure(save_closure) },
{ be_nested_key("has", -306245661, 3, -1), be_const_closure(has_closure) },
{ be_nested_key("_filename", 1430813195, 9, 10), be_const_var(0) },
{ be_nested_key("remove", -611183107, 6, -1), be_const_closure(remove_closure) },
{ be_nested_key("_dirty", 283846766, 6, -1), be_const_var(2) },
{ be_nested_key("load", -435725847, 4, -1), be_const_closure(load_closure) },
{ be_nested_key("setmember", 1432909441, 9, 4), be_const_closure(setmember_closure) },
{ be_nested_key("_p", 1594591802, 2, 5), be_const_var(1) },
{ be_nested_key("init", 380752755, 4, -1), be_const_closure(init_closure) },
{ be_nested_key("_p", 1594591802, 2, 1), be_const_var(1) },
{ be_nested_key("load", -435725847, 4, -1), be_const_closure(load_closure) },
{ be_nested_key("_dirty", 283846766, 6, -1), be_const_var(2) },
{ be_nested_key("has", -306245661, 3, -1), be_const_closure(has_closure) },
{ be_nested_key("zero", -1955600541, 4, 8), be_const_closure(zero_closure) },
{ be_nested_key("member", 719708611, 6, 6), be_const_closure(member_closure) },
{ be_nested_key("remove", -611183107, 6, -1), be_const_closure(remove_closure) },
{ be_nested_key("find", -1108310694, 4, -1), be_const_closure(find_closure) },
{ be_nested_key("_filename", 1430813195, 9, -1), be_const_var(0) },
})),
(be_nested_const_str("Persist", 1456346147, 7))
);

View File

@ -60,12 +60,6 @@ persist_module.init = def (m)
return self._p.find(k, d)
end
#- custom tostring -#
def tostring()
import string
return string.format("<instance: %s(%s)>", classname(self), str(self._p))
end
def load()
import json
import path

View File

@ -479,6 +479,12 @@ void *special_calloc(size_t num, size_t size) {
float CpuTemperature(void) {
#ifdef CONFIG_IDF_TARGET_ESP32
return (float)temperatureRead(); // In Celsius
/*
// These jumps are not stable either. Sometimes it jumps to 77.3
float t = (float)temperatureRead(); // In Celsius
if (t > 81) { t = t - 27.2; } // Fix temp jump observed on some ESP32 like DualR3
return t;
*/
#else
// Currently (20210801) repeated calls to temperatureRead() on ESP32C3 and ESP32S2 result in IDF error messages
static float t = NAN;
@ -489,6 +495,39 @@ float CpuTemperature(void) {
#endif
}
/*
#ifdef __cplusplus
extern "C" {
#endif
uint8_t temprature_sens_read();
#ifdef __cplusplus
}
#endif
#ifdef CONFIG_IDF_TARGET_ESP32
uint8_t temprature_sens_read();
float CpuTemperature(void) {
uint8_t t = temprature_sens_read();
AddLog(LOG_LEVEL_DEBUG, PSTR("TMP: value %d"), t);
return (t - 32) / 1.8;
}
#else
float CpuTemperature(void) {
// Currently (20210801) repeated calls to temperatureRead() on ESP32C3 and ESP32S2 result in IDF error messages
static float t = NAN;
if (isnan(t)) {
t = (float)temperatureRead(); // In Celsius
}
return t;
}
#endif
*/
/*
#if CONFIG_IDF_TARGET_ESP32S2
#include "esp32s2/esp_efuse.h"

View File

@ -1818,6 +1818,7 @@ void LightAnimate(void)
memcpy(Light.fade_start_10, cur_col_10, sizeof(Light.fade_start_10));
// push the final values at 8 and 10 bits resolution to the PWMs
LightSetOutputs(cur_col_10);
LightStopFade();
Light.fade_initialized = true; // it is now ok to fade
Light.fade_once_enabled = false; // light has been set, reset fade_once_enabled
Light.speed_once_enabled = false; // light has been set, reset speed_once_enabled
@ -1842,10 +1843,6 @@ void LightAnimate(void)
LightSetOutputs(Light.fade_cur_10);
}
}
#ifdef USE_PWM_DIMMER
// If the power is off and the fade is done, turn the relay off.
if (PWM_DIMMER == TasmotaGlobal.module_type && !Light.power && !Light.fade_running) PWMDimmerSetPower();
#endif // USE_PWM_DIMMER
// For WYZE bulbs we must set the CT pin (PWM2) to INPUT to fully turn it off
if (TasmotaGlobal.gpio_optiona.pwm1_input && !Light.power && !Light.fade_running) { // GPIO Option_A1
if (PinUsed(GPIO_PWM1, 1)) { pinMode(Pin(GPIO_PWM1, 1), INPUT); }
@ -1902,6 +1899,14 @@ uint8_t LightGetCurFadeBri(void) {
return max_bri;
}
void LightStopFade(void) {
Light.fade_running = false;
#ifdef USE_PWM_DIMMER
// If the power is off and the fade is done, turn the relay off.
if (PWM_DIMMER == TasmotaGlobal.module_type && !Light.power) PWMDimmerSetPower();
#endif // USE_PWM_DIMMER
}
bool LightApplyFade(void) { // did the value chanegd and needs to be applied
static uint32_t last_millis = 0;
uint32_t now = millis();
@ -1940,7 +1945,7 @@ bool LightApplyFade(void) { // did the value chanegd and needs to be applied
}
} else {
// no fade needed, we keep the duration at zero, it will fallback directly to end of fade
Light.fade_running = false;
LightStopFade();
}
}
@ -1960,7 +1965,7 @@ bool LightApplyFade(void) { // did the value chanegd and needs to be applied
} else {
// stop fade
//AddLop_P2(LOG_LEVEL_DEBUG, PSTR("Stop fade"));
Light.fade_running = false;
LightStopFade();
Light.fade_start = 0;
Light.fade_duration = 0;
// set light to target value
@ -2937,7 +2942,7 @@ void CmndFade(void)
#ifdef USE_DEVICE_GROUPS
if (XdrvMailbox.payload >= 0 && XdrvMailbox.payload <= 2) SendDeviceGroupMessage(Light.device, DGR_MSGTYP_UPDATE, DGR_ITEM_LIGHT_FADE, Settings->light_fade);
#endif // USE_DEVICE_GROUPS
if (!Settings->light_fade) { Light.fade_running = false; }
if (!Settings->light_fade) { LightStopFade(); }
}
ResponseCmndStateText(Settings->light_fade);
}
@ -2951,7 +2956,7 @@ void CmndSpeed(void)
Light.fade_once_value = (XdrvMailbox.payload > 0);
Light.speed_once_enabled = true;
Light.speed_once_value = XdrvMailbox.payload;
if (!Light.fade_once_value) { Light.fade_running = false; }
if (!Light.fade_once_value) { LightStopFade(); }
}
ResponseCmndIdxNumber(Light.speed_once_value);
} else {

View File

@ -271,7 +271,8 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
{
bool handle_tap = false;
bool state_updated = false;
int32_t bri_offset = 0;
int8_t bri_hold = 0;
int8_t bri_tap = 0;
uint8_t power_on_bri = 0;
uint8_t dgr_item = 0;
uint8_t dgr_value = 0;
@ -294,7 +295,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
uint32_t now = millis();
// If the button was pressed and released but was not processed by support_button because the
// button interval had not elapsed,
// button interval had not elapsed, publish an MQTT message.
if (button_unprocessed[button_index]) {
mqtt_trigger = 5;
#ifdef USE_PWM_DIMMER_REMOTE
@ -314,9 +315,9 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
// The new brightness will be calculated below.
if (power_is_on) {
#ifdef USE_PWM_DIMMER_REMOTE
bri_offset = (active_remote_pwm_dimmer ? (active_remote_pwm_dimmer->power_button_increases_bri ? 1 : -1) : (power_button_increases_bri ? 1 : -1));
bri_hold = (active_remote_pwm_dimmer ? (active_remote_pwm_dimmer->power_button_increases_bri ? 1 : -1) : (power_button_increases_bri ? 1 : -1));
#else // USE_PWM_DIMMER_REMOTE
bri_offset = (power_button_increases_bri ? 1 : -1);
bri_hold = (power_button_increases_bri ? 1 : -1);
#endif // USE_PWM_DIMMER_REMOTE
invert_power_button_bri_direction = true;
}
@ -351,7 +352,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
// Otherwise, if the power is on and remote mode is enabled, adjust the brightness. Set the
// direction based on which button is pressed. The new brightness will be calculated below.
else if (power_is_on && Settings->flag4.multiple_device_groups) {
bri_offset = (is_down_button ? -1 : 1);
bri_hold = (is_down_button ? -1 : 1);
}
// Otherwise, publish MQTT Event Trigger#.
@ -365,7 +366,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
// Otherwise, if the power is on, adjust the brightness. Set the direction based on which
// button is pressed. The new brightness will be calculated below.
else if (power_is_on && !button_tapped) {
bri_offset = (is_down_button ? -1 : 1);
bri_hold = (is_down_button ? -1 : 1);
}
}
}
@ -465,7 +466,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
// If the button was not held, adjust the brightness. Set the direction based on which
// button is pressed. The new brightness will be calculated below.
if (!button_was_held) {
bri_offset = (is_down_button ? -5 : 5);
bri_tap = (is_down_button ? -1 : 1);
dgr_more_to_come = false;
state_updated = true;
}
@ -494,7 +495,7 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
// If we need to adjust the brightness, do it.
int32_t negated_device_group_index = -power_button_index;
if (bri_offset) {
if (bri_hold || bri_tap) {
int32_t bri;
#ifdef USE_PWM_DIMMER_REMOTE
if (active_remote_pwm_dimmer)
@ -502,8 +503,16 @@ void PWMDimmerHandleButton(uint32_t button_index, bool pressed)
else
#endif // USE_PWM_DIMMER_REMOTE
bri = light_state.getBri();
int32_t new_bri = bri + bri_offset * (Settings->light_correction ? 4 : bri / 16 + 1);
int32_t bri_offset = Settings->dimmer_step;
if (bri_tap)
bri_offset *= bri_tap;
else {
bri_offset /= 5;
if (!Settings->light_correction) bri_offset *= bri / 32;
if (bri_offset < 1) bri_offset = 1;
bri_offset *= bri_hold;
}
int32_t new_bri = bri + bri_offset;
if (bri_offset > 0) {
if (new_bri > 255) new_bri = 255;
}