diff --git a/library.json b/library.json index efe21cf..f0acc67 100644 --- a/library.json +++ b/library.json @@ -17,7 +17,7 @@ "platforms": ["espressif32"], "dependencies": [ { "name": "Adafruit GFX Library" }, - { "name": "Arduino_JSON" }, + { "name": "ArduinoJSON" }, { "name": "DS3232RTC" }, { "name": "NTPClient" }, { diff --git a/src/BLE.h b/src/BLE.h index 18f4a1e..54b98c6 100644 --- a/src/BLE.h +++ b/src/BLE.h @@ -12,8 +12,6 @@ #include "config.h" -class BLE; - class BLE { public: BLE(void); diff --git a/src/Watchy.cpp b/src/Watchy.cpp index 98e94e3..6a9f453 100644 --- a/src/Watchy.cpp +++ b/src/Watchy.cpp @@ -604,13 +604,16 @@ weatherData Watchy::getWeatherData(String cityID, String units, String lang, http.begin(weatherQueryURL.c_str()); int httpResponseCode = http.GET(); if (httpResponseCode == 200) { - String payload = http.getString(); - JSONVar responseObject = JSON.parse(payload); - currentWeather.temperature = int(responseObject["main"]["temp"]); - currentWeather.weatherConditionCode = - int(responseObject["weather"][0]["id"]); - currentWeather.weatherDescription = - responseObject["weather"][0]["main"]; + String payload = http.getString(); + DynamicJsonDocument doc(1024); + if (auto error = deserializeJson(doc, payload)) { + Serial.println(error.c_str()); + } else { + currentWeather.temperature = doc["main"]["temp"].as(); + currentWeather.isMetric = settings.weatherUnit == String("metric"); + currentWeather.weatherConditionCode = doc["weather"][0]["id"].as(); + currentWeather.weatherDescription = doc["weather"][0]["main"].as(); + } } else { // http error } diff --git a/src/Watchy.h b/src/Watchy.h index 43fa9ae..04d21ae 100644 --- a/src/Watchy.h +++ b/src/Watchy.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include