mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-22 18:26:30 +00:00
Merge branch 'development' of github.com:arendst/Tasmota into pr_tm1638
This commit is contained in:
commit
5132794170
@ -37,11 +37,6 @@ no math hierarchy (costs ram and execution time, better group with brackets, an
|
||||
keywords if then else endif, or, and are better readable for beginners (others may use {})
|
||||
|
||||
// to doo
|
||||
remove all filesystem inititialization and gui
|
||||
adapt 3 options
|
||||
1. ufilesystem
|
||||
2. eeprom hardware and emulation
|
||||
3. compression
|
||||
|
||||
\*********************************************************************************************/
|
||||
|
||||
@ -5992,6 +5987,7 @@ bool ScriptMqttData(void)
|
||||
value = sres;
|
||||
}
|
||||
#endif // SUPPORT_MQTT_EVENT_MORE
|
||||
}
|
||||
if (json_valid) {
|
||||
value.trim();
|
||||
char sbuffer[128];
|
||||
@ -6010,7 +6006,6 @@ bool ScriptMqttData(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return serviced;
|
||||
}
|
||||
|
||||
@ -7397,6 +7392,7 @@ int32_t http_req(char *host, char *request) {
|
||||
#include <WiFiClientSecure.h>
|
||||
#endif //ESP8266
|
||||
|
||||
|
||||
// get tesla powerwall info page json string
|
||||
uint32_t call2https(const char *host, const char *path) {
|
||||
if (TasmotaGlobal.global_state.wifi_down) return 1;
|
||||
@ -7409,9 +7405,29 @@ uint32_t call2https(const char *host, const char *path) {
|
||||
httpsClient = new BearSSL::WiFiClientSecure_light(1024, 1024);
|
||||
#endif
|
||||
|
||||
httpsClient->setTimeout(1500);
|
||||
httpsClient->setTimeout(2000);
|
||||
httpsClient->setInsecure();
|
||||
|
||||
#if 0
|
||||
File file = ufsp->open("/tesla.cer", FS_FILE_READ);
|
||||
uint16_t fsize = 0;
|
||||
char *cert = 0;
|
||||
if (file) {
|
||||
fsize = file.size();
|
||||
if (fsize) {
|
||||
cert = (char*)malloc(fsize +2);
|
||||
if (cert) {
|
||||
file.read((uint8_t*)cert, fsize);
|
||||
file.close();
|
||||
httpsClient->setCACert(cert);
|
||||
}
|
||||
AddLog(LOG_LEVEL_INFO,PSTR(">>> cert %d"),fsize);
|
||||
}
|
||||
} else {
|
||||
httpsClient->setCACert(root_ca);
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t retry = 0;
|
||||
while ((!httpsClient->connect(host, 443)) && (retry < 5)) {
|
||||
delay(100);
|
||||
@ -7420,11 +7436,43 @@ uint32_t call2https(const char *host, const char *path) {
|
||||
if (retry == 5) {
|
||||
return 2;
|
||||
}
|
||||
String request = String("GET ") + path +
|
||||
AddLog(LOG_LEVEL_INFO,PSTR("connected"));
|
||||
|
||||
String request;
|
||||
#if 0
|
||||
|
||||
File file = ufsp->open("/login.txt", FS_FILE_READ);
|
||||
uint16_t fsize = 0;
|
||||
char *cert = 0;
|
||||
if (file) {
|
||||
fsize = file.size();
|
||||
if (fsize) {
|
||||
cert = (char*)calloc(fsize +2, 1);
|
||||
if (cert) {
|
||||
file.read((uint8_t*)cert, fsize);
|
||||
file.close();
|
||||
//httpsClient->setCACert(cert);
|
||||
}
|
||||
AddLog(LOG_LEVEL_INFO,PSTR(">>> cert %d"),fsize);
|
||||
}
|
||||
}
|
||||
|
||||
request = String("POST ") + "/api/login/Basic" + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + cert + "\r\n" + "Content-Type: application/json" + "\r\n";
|
||||
httpsClient->print(request);
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR(">>> post request %s"),(char*)request.c_str());
|
||||
|
||||
String line = httpsClient->readStringUntil('\n');
|
||||
AddLog(LOG_LEVEL_INFO,PSTR(">>> post response 1a %s"),(char*)line.c_str());
|
||||
line = httpsClient->readStringUntil('\n');
|
||||
AddLog(LOG_LEVEL_INFO,PSTR(">>> post response 1b %s"),(char*)line.c_str());
|
||||
#endif
|
||||
|
||||
request = String("GET ") + path +
|
||||
" HTTP/1.1\r\n" +
|
||||
"Host: " + host +
|
||||
"\r\n" + "Connection: close\r\n\r\n";
|
||||
httpsClient->print(request);
|
||||
// AddLog_P(LOG_LEVEL_INFO,PSTR(">>> get request %s"),(char*)request.c_str());
|
||||
|
||||
while (httpsClient->connected()) {
|
||||
String line = httpsClient->readStringUntil('\n');
|
||||
@ -7441,6 +7489,7 @@ uint32_t call2https(const char *host, const char *path) {
|
||||
}
|
||||
httpsClient->stop();
|
||||
delete httpsClient;
|
||||
// AddLog(LOG_LEVEL_INFO,PSTR(">>> response 2 %s"),(char*)result.c_str());
|
||||
Run_Scripter(">jp", 3, (char*)result.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
@ -1296,6 +1296,7 @@ void sml_shift_in(uint32_t meters,uint32_t shard) {
|
||||
}
|
||||
} else if (meter_desc_p[meters].type=='v') {
|
||||
if (iob==EBUS_SYNC) {
|
||||
sb_counter = 0;
|
||||
SML_Decode(meters);
|
||||
smltbuf[meters][0] = iob;
|
||||
meter_spos[meters] = 1;
|
||||
@ -1385,6 +1386,7 @@ void SML_Decode(uint8_t index) {
|
||||
uint8_t *cp;
|
||||
uint8_t dindex = 0, vindex = 0;
|
||||
delay(0);
|
||||
|
||||
while (mp != NULL) {
|
||||
// check list of defines
|
||||
if (*mp == 0) break;
|
||||
@ -1418,17 +1420,17 @@ void SML_Decode(uint8_t index) {
|
||||
// 1. index
|
||||
double dvar;
|
||||
uint8_t opr;
|
||||
uint32_t ind;
|
||||
ind=atoi(mp);
|
||||
while (*mp>='0' && *mp<='9') mp++;
|
||||
if (ind<1 || ind>SML_MAX_VARS) ind=1;
|
||||
dvar=meter_vars[ind-1];
|
||||
for (uint8_t p = 0; p < 5; p++) {
|
||||
uint8_t mind;
|
||||
int32_t ind;
|
||||
mind = strtol((char*)mp, (char**)&mp, 10);
|
||||
if (mind < 1 || mind > SML_MAX_VARS) mind = 1;
|
||||
dvar = meter_vars[mind - 1];
|
||||
while (*mp==' ') mp++;
|
||||
for (uint8_t p = 0; p < 8; p++) {
|
||||
if (*mp == '@') {
|
||||
// store result
|
||||
meter_vars[vindex] = dvar;
|
||||
mp++;
|
||||
SML_Immediate_MQTT((const char*)mp,vindex,mindex);
|
||||
break;
|
||||
}
|
||||
opr = *mp;
|
||||
@ -1438,25 +1440,25 @@ void SML_Decode(uint8_t index) {
|
||||
iflg = 1;
|
||||
mp++;
|
||||
}
|
||||
ind=atoi(mp);
|
||||
while (*mp>='0' && *mp<='9') mp++;
|
||||
if (ind<1 || ind>SML_MAX_VARS) ind=1;
|
||||
ind = strtol((char*)mp, (char**)&mp, 10);
|
||||
mind = ind;
|
||||
if (mind < 1 || mind > SML_MAX_VARS) mind = 1;
|
||||
switch (opr) {
|
||||
case '+':
|
||||
if (iflg) dvar += ind;
|
||||
else dvar+=meter_vars[ind-1];
|
||||
else dvar += meter_vars[mind - 1];
|
||||
break;
|
||||
case '-':
|
||||
if (iflg) dvar -= ind;
|
||||
else dvar-=meter_vars[ind-1];
|
||||
else dvar -= meter_vars[mind - 1];
|
||||
break;
|
||||
case '*':
|
||||
if (iflg) dvar *= ind;
|
||||
else dvar*=meter_vars[ind-1];
|
||||
else dvar *= meter_vars[mind - 1];
|
||||
break;
|
||||
case '/':
|
||||
if (iflg) dvar /= ind;
|
||||
else dvar/=meter_vars[ind-1];
|
||||
else dvar /= meter_vars[mind - 1];
|
||||
break;
|
||||
}
|
||||
while (*mp==' ') mp++;
|
||||
@ -1464,10 +1466,13 @@ void SML_Decode(uint8_t index) {
|
||||
// store result
|
||||
meter_vars[vindex] = dvar;
|
||||
mp++;
|
||||
SML_Immediate_MQTT((const char*)mp,vindex,mindex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
double fac = CharToDouble((char*)mp);
|
||||
meter_vars[vindex] /= fac;
|
||||
SML_Immediate_MQTT((const char*)mp, vindex, mindex);
|
||||
// get sfac
|
||||
} else if (*mp=='d') {
|
||||
// calc deltas d ind 10 (eg every 10 secs)
|
||||
if (dindex < MAX_DVARS) {
|
||||
@ -1489,6 +1494,8 @@ void SML_Decode(uint8_t index) {
|
||||
mp=strchr(mp,'@');
|
||||
if (mp) {
|
||||
mp++;
|
||||
double fac = CharToDouble((char*)mp);
|
||||
meter_vars[vindex] /= fac;
|
||||
SML_Immediate_MQTT((const char*)mp, vindex, mindex);
|
||||
}
|
||||
}
|
||||
@ -1953,6 +1960,12 @@ void SML_Show(boolean json) {
|
||||
} else {
|
||||
mid=0;
|
||||
}
|
||||
} else if (*cp=='b') {
|
||||
// bit value
|
||||
#ifdef SML_BIT_TEXT
|
||||
sprintf_P(tpowstr, PSTR("\"%s\""), (uint8_t)meter_vars[index]?D_ON:D_OFF);
|
||||
mid = 2;
|
||||
#endif
|
||||
} else {
|
||||
mid = 0;
|
||||
}
|
||||
@ -2721,7 +2734,7 @@ uint8_t sml_hexnibble(char chr) {
|
||||
|
||||
// send sequence every N Seconds
|
||||
void SML_Send_Seq(uint32_t meter,char *seq) {
|
||||
uint8_t sbuff[32];
|
||||
uint8_t sbuff[48];
|
||||
uint8_t *ucp = sbuff, slen = 0;
|
||||
char *cp = seq;
|
||||
uint8_t rflg = 0;
|
||||
@ -2736,7 +2749,7 @@ void SML_Send_Seq(uint32_t meter,char *seq) {
|
||||
cp += 2;
|
||||
*ucp++ = iob;
|
||||
slen++;
|
||||
if (slen>=sizeof(sbuff)) break;
|
||||
if (slen >= sizeof(sbuff)-6) break; // leave space for checksum
|
||||
}
|
||||
if (script_meter_desc[meter].type == 'm' || script_meter_desc[meter].type == 'M') {
|
||||
if (!rflg) {
|
||||
@ -2766,10 +2779,14 @@ void SML_Send_Seq(uint32_t meter,char *seq) {
|
||||
}
|
||||
meter_ss[meter]->write(sbuff, slen);
|
||||
if (dump2log) {
|
||||
#ifdef SML_DUMP_OUT_ALL
|
||||
Hexdump(sbuff, slen);
|
||||
#else
|
||||
uint8_t type = meter_desc_p[(dump2log&7) - 1].type;
|
||||
if (type == 'm' || type == 'M') {
|
||||
Hexdump(sbuff, slen);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user