-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWunderground.ino
58 lines (44 loc) · 1 KB
/
Wunderground.ino
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
/*
Function to parse HTML reply from Weather Underground
*/
/**************************************************/
String getValuesFromKey(const String response, const String sKey)
{
String sKey_ = sKey;
sKey_ = "\"" + sKey + "\":";
char key[sKey_.length()];
sKey_.toCharArray(key, sizeof(key));
int keySize = sizeof(key)-1;
String strResult = "";
int n = response.length();
for(int i=0; i < (n-keySize-1); i++)
{
char c[keySize];
for(int k=0; k<keySize; k++)
{
c[k] = response.charAt(i+k);
}
boolean isEqual = true;
for(int k=0; k<keySize; k++)
{
if(!(c[k] == key[k]))
{
isEqual = false;
break;
}
}
if(isEqual)
{
int j= i + keySize + 1;
while(!(response.charAt(j) == ','))
{
strResult += response.charAt(j);
j++;
}
//Remove char '"'
strResult.replace("\"","");
break;
}
}
return strResult;
}