|
1 |
| -/** The MIT License (MIT) |
2 |
| -
|
3 |
| -Copyright (c) 2018 David Payne |
4 |
| -
|
5 |
| -Permission is hereby granted, free of charge, to any person obtaining a copy |
6 |
| -of this software and associated documentation files (the "Software"), to deal |
7 |
| -in the Software without restriction, including without limitation the rights |
8 |
| -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9 |
| -copies of the Software, and to permit persons to whom the Software is |
10 |
| -furnished to do so, subject to the following conditions: |
11 |
| -
|
12 |
| -The above copyright notice and this permission notice shall be included in all |
13 |
| -copies or substantial portions of the Software. |
14 |
| -
|
15 |
| -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16 |
| -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 |
| -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18 |
| -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19 |
| -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20 |
| -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
21 |
| -SOFTWARE. |
22 |
| -*/ |
23 |
| - |
24 |
| -#pragma once |
25 |
| -#include <ESP8266WiFi.h> |
26 |
| -#include <ArduinoJson.h> |
27 |
| - |
28 |
| -class OpenWeatherMapClient { |
29 |
| - |
30 |
| -private: |
31 |
| - String myCityIDs = ""; |
32 |
| - String myApiKey = ""; |
33 |
| - String units = ""; |
34 |
| - String lang = ""; |
35 |
| - |
36 |
| - const char* servername = "api.openweathermap.org"; // remote server we will connect to |
37 |
| - String result; |
38 |
| - |
39 |
| - typedef struct { |
40 |
| - String lat; |
41 |
| - String lon; |
42 |
| - String dt; |
43 |
| - String city; |
44 |
| - String country; |
45 |
| - String temp; |
46 |
| - String humidity; |
47 |
| - String condition; |
48 |
| - String wind; |
49 |
| - String weatherId; |
50 |
| - String description; |
51 |
| - String icon; |
52 |
| - boolean cached; |
53 |
| - String error; |
54 |
| - } weather; |
55 |
| - |
56 |
| - weather weathers[5]; |
57 |
| - |
58 |
| - String roundValue(String value); |
59 |
| - |
60 |
| -public: |
61 |
| - OpenWeatherMapClient(String ApiKey, int CityIDs[], int cityCount, boolean isMetric, String language); |
62 |
| - void updateWeather(); |
63 |
| - void updateWeatherApiKey(String ApiKey); |
64 |
| - void updateCityIdList(int CityIDs[], int cityCount); |
65 |
| - void updateLanguage(String language); |
66 |
| - void setMetric(boolean isMetric); |
67 |
| - |
68 |
| - String getWeatherResults(); |
69 |
| - |
70 |
| - String getLat(int index); |
71 |
| - String getLon(int index); |
72 |
| - String getDt(int index); |
73 |
| - String getCity(int index); |
74 |
| - String getCountry(int index); |
75 |
| - String getTemp(int index); |
76 |
| - String getTempRounded(int index); |
77 |
| - String getHumidity(int index); |
78 |
| - String getHumidityRounded(int index); |
79 |
| - String getCondition(int index); |
80 |
| - String getWind(int index); |
81 |
| - String getWindRounded(int index); |
82 |
| - String getWeatherId(int index); |
83 |
| - String getDescription(int index); |
84 |
| - String getIcon(int index); |
85 |
| - boolean getCached(); |
86 |
| - String getMyCityIDs(); |
87 |
| - String getWeatherIcon(int index); |
88 |
| - String getError(); |
89 |
| -}; |
| 1 | +/** The MIT License (MIT) |
90 | 2 |
|
| 3 | +Copyright (c) 2018 David Payne |
| 4 | +
|
| 5 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +of this software and associated documentation files (the "Software"), to deal |
| 7 | +in the Software without restriction, including without limitation the rights |
| 8 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +copies of the Software, and to permit persons to whom the Software is |
| 10 | +furnished to do so, subject to the following conditions: |
| 11 | +
|
| 12 | +The above copyright notice and this permission notice shall be included in all |
| 13 | +copies or substantial portions of the Software. |
| 14 | +
|
| 15 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | +SOFTWARE. |
| 22 | +*/ |
| 23 | + |
| 24 | +#pragma once |
| 25 | +#include <ESP8266WiFi.h> |
| 26 | +#include "libs/ArduinoJson/ArduinoJson.h" |
| 27 | + |
| 28 | +class OpenWeatherMapClient { |
| 29 | + |
| 30 | +private: |
| 31 | + String myCityIDs = ""; |
| 32 | + String myApiKey = ""; |
| 33 | + String units = ""; |
| 34 | + String lang = ""; |
| 35 | + |
| 36 | + const char* servername = "api.openweathermap.org"; // remote server we will connect to |
| 37 | + String result; |
| 38 | + |
| 39 | + typedef struct { |
| 40 | + String lat; |
| 41 | + String lon; |
| 42 | + String dt; |
| 43 | + String city; |
| 44 | + String country; |
| 45 | + String temp; |
| 46 | + String humidity; |
| 47 | + String condition; |
| 48 | + String wind; |
| 49 | + String weatherId; |
| 50 | + String description; |
| 51 | + String icon; |
| 52 | + boolean cached; |
| 53 | + String error; |
| 54 | + } weather; |
| 55 | + |
| 56 | + weather weathers[5]; |
| 57 | + |
| 58 | + String roundValue(String value); |
| 59 | + |
| 60 | +public: |
| 61 | + OpenWeatherMapClient(String ApiKey, int CityIDs[], int cityCount, boolean isMetric, String language); |
| 62 | + void updateWeather(); |
| 63 | + void updateWeatherApiKey(String ApiKey); |
| 64 | + void updateCityIdList(int CityIDs[], int cityCount); |
| 65 | + void updateLanguage(String language); |
| 66 | + void setMetric(boolean isMetric); |
| 67 | + |
| 68 | + String getWeatherResults(); |
| 69 | + |
| 70 | + String getLat(int index); |
| 71 | + String getLon(int index); |
| 72 | + String getDt(int index); |
| 73 | + String getCity(int index); |
| 74 | + String getCountry(int index); |
| 75 | + String getTemp(int index); |
| 76 | + String getTempRounded(int index); |
| 77 | + String getHumidity(int index); |
| 78 | + String getHumidityRounded(int index); |
| 79 | + String getCondition(int index); |
| 80 | + String getWind(int index); |
| 81 | + String getWindRounded(int index); |
| 82 | + String getWeatherId(int index); |
| 83 | + String getDescription(int index); |
| 84 | + String getIcon(int index); |
| 85 | + boolean getCached(); |
| 86 | + String getMyCityIDs(); |
| 87 | + String getWeatherIcon(int index); |
| 88 | + String getError(); |
| 89 | +}; |
0 commit comments