Hi All,
My problem is this: I am connecting to an MQTT broker with a certificate.. That works ok.
But then further down I have to send data to a few weather services, they accept https and http requests.
The code that is sent is correct. It worked before I added the certificate and it works when I copy and paste it int chrome.
I really dont know what to do. I have found a few similar things but none have worked or I was unsuccessful implementing them...
the sending part is basically this:
Link = "https://www.windguru.cz/upload/api.php?";
getData = Link + getData + "uid=" + String(Station_1_uid); // WindGuru ID
getData = getData + "&salt=" + String(time); // Time
getData = getData + "&hash=" + md5.toString(); // Identification
getData = getData + "&wind_min=" + String(WindMin1ms * kKnots, 2);
if (!isnan(bmpT))
getData = getData + "&temperature=" + String(bmpT, 1); // temperature
#ifdef DataDEBUG
Serial.println(getData);
#endif
std::unique_ptr<BearSSL::WiFiClientSecure> client(new BearSSL::WiFiClientSecure);
client->setInsecure();
HTTPClient https; // must be declared after WiFiClient for correct destruction order, because used by http.begin(client,...)
https.begin(*client, getData); // Specify request destination
int httpCode = https.GET(); // Send the request
#ifdef DataDEBUG
Serial.println(httpCode); // ACT!
// Serial.printf("[HTTP] GET failed, error: %s\n", https.errorToString(httpCode).c_str());
#endif
if (httpCode > 0)
{ // Check the returning code
String payload = https.getString(); // Get the request response payload
#ifdef DataDEBUG
Serial.println(payload); // Print the response payload
#endif
if (mqttClient.connected() && (payload != "OK"))
mqttClient.publish((MQTT_TOPIC + "/debug").c_str(), payload.c_str());
}
https.end(); // Close connection
}
else
{
Serial.println("No wind data available");
return false; // fail
}
return true; // done
}
Hi All, My problem is this: I am connecting to an MQTT broker with a certificate.. That works ok. But then further down I have to send data to a few weather services, they accept https and http requests. The code that is sent is correct. It worked before I added the certificate and it works when I copy and paste it int chrome.
I really dont know what to do. I have found a few similar things but none have worked or I was unsuccessful implementing them...
the sending part is basically this:
Thanks for any help. (board ESP8266 07s)