Skip to content

Commit

Permalink
Switched to non ssl for esp8266 for barhelper
Browse files Browse the repository at this point in the history
  • Loading branch information
mp-se committed Sep 11, 2024
1 parent 70c4980 commit da3d013
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/barhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,33 @@ void Barhelper::sendKegInformation(UnitIndex idx, float kegVol) {
EspSerial.print(out.c_str());
EspSerial.print(CR);
// #endif

#if defined(ESP8266)
constexpr auto BARHELPER_URL = "http://europe-west1-barhelper-app.cloudfunctions.net/api/customKegMon";
#else
constexpr auto BARHELPER_URL = "https://europe-west1-barhelper-app.cloudfunctions.net/api/customKegMon";
#endif
Log.info(F("BARH: Using URL %s." CR), BARHELPER_URL);
out = _push->sendHttpPost(
out,
"https://europe-west1-barhelper-app.cloudfunctions.net/api/customKegMon",
BARHELPER_URL,
"Content-Type: application/json", header.c_str());
updateStatus(out);

Log.info(F("BARH: Response %s." CR), out.c_str());

// Note! the server does not return a valid json so it cant be parsed. Just
// print the value for now.

/*DeserializationError err = deserializeJson(doc, out);
/*
DeserializationError err = deserializeJson(doc, out);
/*if (err) {
if (err) {
Log.error(
F("BARH: Failed to parse response from barhelper, Err: %s, %s." CR),
err.c_str(), out.c_str());
return;
}*/
}
// Typical response
// {
Expand All @@ -146,11 +154,12 @@ void Barhelper::sendKegInformation(UnitIndex idx, float kegVol) {
// "message": "Keg Monitor updated successfully"
// }
/*JsonObject obj = doc.as<JsonObject>();
JsonObject obj = doc.as<JsonObject>();
Log.info(F("BARH: Server responded: %s, new level=%F, message=%s." CR),
obj["success"].as<bool>() ? "True" : "False",
obj["newKegAmount"].as<float>(),
obj["message"].as<String>().c_str());*/
obj["message"].as<String>().c_str());
*/
}

void Barhelper::updateStatus(String& response) {
Expand Down

0 comments on commit da3d013

Please sign in to comment.