Skip to content

Commit

Permalink
Change to ArduinoJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkZeros committed Aug 2, 2022
1 parent 3e3a885 commit 43269a1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"platforms": ["espressif32"],
"dependencies": [
{ "name": "Adafruit GFX Library" },
{ "name": "Arduino_JSON" },
{ "name": "ArduinoJSON" },
{ "name": "DS3232RTC" },
{ "name": "NTPClient" },
{
Expand Down
2 changes: 0 additions & 2 deletions src/BLE.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#include "config.h"

class BLE;

class BLE {
public:
BLE(void);
Expand Down
17 changes: 10 additions & 7 deletions src/Watchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>();
currentWeather.isMetric = settings.weatherUnit == String("metric");
currentWeather.weatherConditionCode = doc["weather"][0]["id"].as<int16_t>();
currentWeather.weatherDescription = doc["weather"][0]["main"].as<String>();
}
} else {
// http error
}
Expand Down
2 changes: 1 addition & 1 deletion src/Watchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <HTTPClient.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <Arduino_JSON.h>
#include <ArduinoJson.h>
#include <GxEPD2_BW.h>
#include <Wire.h>
#include <Fonts/FreeMonoBold9pt7b.h>
Expand Down

0 comments on commit 43269a1

Please sign in to comment.