mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 10:46:31 +00:00
fix subscribe with no key
This commit is contained in:
parent
ec330d70f8
commit
4b1dc136c1
@ -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 {})
|
keywords if then else endif, or, and are better readable for beginners (others may use {})
|
||||||
|
|
||||||
// to doo
|
// 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;
|
value = sres;
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_MQTT_EVENT_MORE
|
#endif // SUPPORT_MQTT_EVENT_MORE
|
||||||
|
}
|
||||||
if (json_valid) {
|
if (json_valid) {
|
||||||
value.trim();
|
value.trim();
|
||||||
char sbuffer[128];
|
char sbuffer[128];
|
||||||
@ -6010,7 +6006,6 @@ bool ScriptMqttData(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return serviced;
|
return serviced;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7397,6 +7392,7 @@ int32_t http_req(char *host, char *request) {
|
|||||||
#include <WiFiClientSecure.h>
|
#include <WiFiClientSecure.h>
|
||||||
#endif //ESP8266
|
#endif //ESP8266
|
||||||
|
|
||||||
|
|
||||||
// get tesla powerwall info page json string
|
// get tesla powerwall info page json string
|
||||||
uint32_t call2https(const char *host, const char *path) {
|
uint32_t call2https(const char *host, const char *path) {
|
||||||
if (TasmotaGlobal.global_state.wifi_down) return 1;
|
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);
|
httpsClient = new BearSSL::WiFiClientSecure_light(1024, 1024);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
httpsClient->setTimeout(1500);
|
httpsClient->setTimeout(2000);
|
||||||
httpsClient->setInsecure();
|
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;
|
uint32_t retry = 0;
|
||||||
while ((!httpsClient->connect(host, 443)) && (retry < 5)) {
|
while ((!httpsClient->connect(host, 443)) && (retry < 5)) {
|
||||||
delay(100);
|
delay(100);
|
||||||
@ -7420,11 +7436,43 @@ uint32_t call2https(const char *host, const char *path) {
|
|||||||
if (retry == 5) {
|
if (retry == 5) {
|
||||||
return 2;
|
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" +
|
" HTTP/1.1\r\n" +
|
||||||
"Host: " + host +
|
"Host: " + host +
|
||||||
"\r\n" + "Connection: close\r\n\r\n";
|
"\r\n" + "Connection: close\r\n\r\n";
|
||||||
httpsClient->print(request);
|
httpsClient->print(request);
|
||||||
|
// AddLog_P(LOG_LEVEL_INFO,PSTR(">>> get request %s"),(char*)request.c_str());
|
||||||
|
|
||||||
while (httpsClient->connected()) {
|
while (httpsClient->connected()) {
|
||||||
String line = httpsClient->readStringUntil('\n');
|
String line = httpsClient->readStringUntil('\n');
|
||||||
@ -7441,6 +7489,7 @@ uint32_t call2https(const char *host, const char *path) {
|
|||||||
}
|
}
|
||||||
httpsClient->stop();
|
httpsClient->stop();
|
||||||
delete httpsClient;
|
delete httpsClient;
|
||||||
|
// AddLog(LOG_LEVEL_INFO,PSTR(">>> response 2 %s"),(char*)result.c_str());
|
||||||
Run_Scripter(">jp", 3, (char*)result.c_str());
|
Run_Scripter(">jp", 3, (char*)result.c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user