forked from fairecasoimeme/ESPMetric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WundergroundClient.h
215 lines (164 loc) · 7.32 KB
/
WundergroundClient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/**The MIT License (MIT)
Copyright (c) 2015 by Daniel Eichhorn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
See more at http://blog.squix.ch
*/
#pragma once
#include <JsonListener.h>
#include <JsonStreamingParser.h>
#define MAX_FORECAST_PERIODS 20 // Changed from 7 to 12 to support 6 day / 2 screen forecast (Neptune)
// Changed to 20 to support max 10-day forecast returned from 'forecast10day' API (fowlerk)
#define MAX_WEATHER_ALERTS 6 // The maximum number of concurrent weather alerts supported by the library
class WundergroundClient: public JsonListener {
private:
String currentKey;
String currentParent = "";
long localEpoc = 0;
int gmtOffset = 1;
long localMillisAtUpdate;
String date = "-";
String observationDate = "-";
boolean isMetric = true;
String currentTemp;
// JJG added ... ////////////////////////////////// define returns /////////////////////////////////
String moonPctIlum; // not used
String moonAge; // make this a long?
String moonPhase;
String sunriseTime;
String sunsetTime;
String moonriseTime;
String moonsetTime;
String windSpeed;
String windDir;
// end JJG add ////////////////////////////////////////////////////////////////////////////////////
String weatherIcon;
String weatherText;
String humidity;
String pressure;
String dewPoint;
String precipitationToday;
// fowlerk added...
String feelslike;
String UV;
String observationTime; // fowlerk add, 04-Dec-2016
// end fowlerk add
void doUpdate(String url);
// forecast
boolean isForecast = false;
boolean isSimpleForecast = false; // true; fowlerk
boolean isCurrentObservation = false; // Added by fowlerk
boolean isAlerts = false; // Added by fowlerk
boolean isAlertUS = false; // Added by fowlerk
boolean isAlertEU = false; // Added by fowlerk
int currentForecastPeriod;
String forecastIcon [MAX_FORECAST_PERIODS];
String forecastTitle [MAX_FORECAST_PERIODS];
String forecastLowTemp [MAX_FORECAST_PERIODS];
String forecastHighTemp [MAX_FORECAST_PERIODS];
// fowlerk added...
String forecastDay [MAX_FORECAST_PERIODS/2];
String forecastMonth [MAX_FORECAST_PERIODS/2];
String forecastText [MAX_FORECAST_PERIODS];
String PoP [MAX_FORECAST_PERIODS];
// Active alerts...added 18-Dec-2016
String activeAlerts [MAX_WEATHER_ALERTS]; // For a max of 6 currently-active alerts
String activeAlertsMessage [MAX_WEATHER_ALERTS]; // Alert full-text message
bool activeAlertsMessageTrunc [MAX_WEATHER_ALERTS]; // Alert full-text message truncation flag
String activeAlertsText [MAX_WEATHER_ALERTS]; // Alerts description text
String activeAlertsStart [MAX_WEATHER_ALERTS]; // Start of alert date/time
String activeAlertsEnd [MAX_WEATHER_ALERTS]; // Expiration of alert date/time
String activeAlertsPhenomena [MAX_WEATHER_ALERTS]; // Alert phenomena code
String activeAlertsSignificance [MAX_WEATHER_ALERTS]; // Alert significance code
String activeAlertsAttribution [MAX_WEATHER_ALERTS]; // Alert significance code
int activeAlertsCnt; // Number of active alerts
int currentAlert; // For indexing the current active alert
// end fowlerk add
public:
WundergroundClient(boolean isMetric);
void updateConditions(String apiKey, String language, String country, String city);
void updateConditions(String apiKey, String language, String zmwCode);
void updateConditionsPWS(String apiKey, String language, String pws);
void updateForecast(String apiKey, String language, String country, String city);
void updateForecastPWS(String apiKey, String language, String pws);
void updateForecastZMW(String apiKey, String language, String zmwCode);
void updateAstronomy(String apiKey, String language, String country, String city);
void updateAstronomyPWS(String apiKey, String language, String pws);
void updateAlerts(String apiKey, String language, String country, String city); // Added by fowlerk, 18-Dec-2016
void updateAlertsPWS(String apiKey, String language, String country, String pws);
void initMetric(boolean isMetric); // Added by fowlerk, 12/22/16, as an option to change metric setting other than at instantiation
// JJG added
String getHours();
String getMinutes();
String getSeconds();
String getDate();
String getObservationDate();
// JJG added ... ///////////////////function name to string ////////////////////////////
String getMoonPctIlum();
String getMoonAge();
String getMoonPhase();
String getSunriseTime();
String getSunsetTime();
String getMoonriseTime();
String getMoonsetTime();
String getWindSpeed();
String getWindDir();
// end JJG add ///////////////////////////////////////////////////////////////////////
long getCurrentEpoch();
String getCurrentTemp();
String getTodayIcon();
String getTodayIconText();
String getMeteoconIcon(String iconText);
String getWeatherText();
String getHumidity();
String getPressure();
String getDewPoint();
String getPrecipitationToday();
// fowlerk added...
String getFeelsLike();
String getUV();
String getObservationTime(); // fowlerk add, 04-Dec-2016
// end fowlerk add
String getForecastIcon(int period);
String getForecastTitle(int period);
String getForecastLowTemp(int period);
String getForecastHighTemp(int period);
// fowlerk added...
String getForecastDay(int period);
String getForecastMonth(int period);
String getForecastText(int period);
String getPoP(int period);
int getActiveAlertsCnt();
String getActiveAlerts(int alertIndex);
String getActiveAlertsText(int alertIndex);
String getActiveAlertsMessage(int alertIndex);
bool getActiveAlertsMessageTrunc(int alertIndex);
String getActiveAlertsStart(int alertIndex);
String getActiveAlertsEnd(int alertIndex);
String getActiveAlertsPhenomena(int alertIndex);
String getActiveAlertsSignificance(int alertIndex);
String getActiveAlertsAttribution(int alertIndex);
// end fowlerk add
virtual void whitespace(char c);
virtual void startDocument();
virtual void key(String key);
virtual void value(String value);
virtual void endArray();
virtual void endObject();
virtual void endDocument();
virtual void startArray();
virtual void startObject();
};