mirror of https://github.com/sqfmi/Watchy.git
Merge 3a592df5b9
into fdfe7ee2be
commit
c6e2c39eaf
|
@ -17,7 +17,7 @@
|
||||||
"platforms": ["espressif32"],
|
"platforms": ["espressif32"],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{ "name": "Adafruit GFX Library" },
|
{ "name": "Adafruit GFX Library" },
|
||||||
{ "name": "Arduino_JSON" },
|
{ "name": "ArduinoJSON" },
|
||||||
{ "name": "DS3232RTC" },
|
{ "name": "DS3232RTC" },
|
||||||
{ "name": "NTPClient" },
|
{ "name": "NTPClient" },
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
class BLE;
|
|
||||||
|
|
||||||
class BLE {
|
class BLE {
|
||||||
public:
|
public:
|
||||||
BLE(void);
|
BLE(void);
|
||||||
|
|
|
@ -605,13 +605,16 @@ weatherData Watchy::getWeatherData(String cityID, String units, String lang,
|
||||||
http.begin(weatherQueryURL.c_str());
|
http.begin(weatherQueryURL.c_str());
|
||||||
int httpResponseCode = http.GET();
|
int httpResponseCode = http.GET();
|
||||||
if (httpResponseCode == 200) {
|
if (httpResponseCode == 200) {
|
||||||
String payload = http.getString();
|
String payload = http.getString();
|
||||||
JSONVar responseObject = JSON.parse(payload);
|
DynamicJsonDocument doc(1024);
|
||||||
currentWeather.temperature = int(responseObject["main"]["temp"]);
|
if (auto error = deserializeJson(doc, payload)) {
|
||||||
currentWeather.weatherConditionCode =
|
Serial.println(error.c_str());
|
||||||
int(responseObject["weather"][0]["id"]);
|
} else {
|
||||||
currentWeather.weatherDescription =
|
currentWeather.temperature = doc["main"]["temp"].as<int>();
|
||||||
responseObject["weather"][0]["main"];
|
currentWeather.isMetric = settings.weatherUnit == String("metric");
|
||||||
|
currentWeather.weatherConditionCode = doc["weather"][0]["id"].as<int16_t>();
|
||||||
|
currentWeather.weatherDescription = doc["weather"][0]["main"].as<String>();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// http error
|
// http error
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <HTTPClient.h>
|
#include <HTTPClient.h>
|
||||||
#include <NTPClient.h>
|
#include <NTPClient.h>
|
||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#include <Arduino_JSON.h>
|
#include <ArduinoJson.h>
|
||||||
#include <GxEPD2_BW.h>
|
#include <GxEPD2_BW.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <Fonts/FreeMonoBold9pt7b.h>
|
#include <Fonts/FreeMonoBold9pt7b.h>
|
||||||
|
|
Loading…
Reference in New Issue