fixed crash:

use wificlient
This commit is contained in:
Martijn Scheepers
2021-01-28 08:57:36 +01:00
parent 303d311d66
commit 5ad02ee00c
2 changed files with 16 additions and 14 deletions

View File

@@ -24,15 +24,16 @@ int noderedServerUpdate() {
Serial.println(JSONmessageBuffer);
#endif
WiFiClient httpClient;
HTTPClient http; //Declare object of class HTTPClient
String server = String(eepromStruct.noderedHost) + "/" + String(eepromStruct.noderedUrl);
String url = String(eepromStruct.noderedHost) + "/" + String(eepromStruct.noderedUrl);
#ifdef DEBUG_MSG
Serial.print("server = ");
Serial.println(server);
Serial.println(url);
#endif
if (http.begin(server) == false)
if (http.begin(httpClient, url) == false)
{
return -1;
}

View File

@@ -3,29 +3,30 @@
int prtgServerUpdate()
{
// We now create a URI for the request
String url = "/";
url += eepromStruct.device;
url += "?content=<prtg>";
String request = "/";
request += eepromStruct.device;
request += "?content=<prtg>";
for (int i = 1; i < 5; i++) {
if (eepromStruct.channel[i].enable == true) {
url += "<result><channel>";
url += eepromStruct.channel[i].channel;
url += "</channel><value>" + String(inputValue[i]) + "</value></result>";
request += "<result><channel>";
request += eepromStruct.channel[i].channel;
request += "</channel><value>" + String(inputValue[i]) + "</value></result>";
}
}
url += "</prtg>";
request += "</prtg>";
WiFiClient httpClient;
HTTPClient http; //Declare object of class HTTPClient
String server = String(eepromStruct.prtgHost) + ":" + String(eepromStruct.prtgHttpPort) + url;
String url = String(eepromStruct.prtgHost) + ":" + String(eepromStruct.prtgHttpPort) + request;
#ifdef DEBUG_MSG
Serial.println("-- PRTG --");
Serial.print("server = ");
Serial.println(server);
Serial.println(url);
#endif
if ( http.begin(server) == false)
if ( http.begin(httpClient, url) == false)
{
#ifdef DEBUG_MSG
Serial.print("http.begin failed");