Skip to content

Commit f3b0180

Browse files
authored
Add files via upload
1 parent 08867d5 commit f3b0180

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2392
-424
lines changed

AdsbExchangeClient.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,14 @@
2525

2626
#pragma once
2727

28-
//#include <Arduino.h>
2928
#include <JsonListener.h>
3029
#include <JsonStreamingParser.h> // https://github.com/squix78/json-streaming-parser
3130
#include "GeoMap.h"
3231

3332
#define MAX_AIRCRAFTS 8
3433
#define MAX_HISTORY 20
35-
#define MAX_HISTORY_TEMP 40 //80
34+
#define MAX_HISTORY_TEMP 40
3635

37-
//#define MAX_AGE_MILLIS 15000
3836
#define min(a,b) ((a)<(b)?(a):(b))
3937

4038
struct AircraftPosition {

AnalogMeter.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/********************************************************/
2+
/* ATMOSCAN */
3+
/* */
4+
/* Author: Marc Finns 2017 */
5+
/* */
6+
/********************************************************/
17

28
#pragma once
39

Bitmaps.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/********************************************************/
2+
/* ATMOSCAN */
3+
/* */
4+
/* Author: Marc Finns 2017 */
5+
/* */
6+
/********************************************************/
7+
18
#pragma once
29

310

GeoMap.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,7 @@ GeoMap::GeoMap(MapProvider mapProvider, String apiKey, int mapWidth, int mapHeig
3636
mapHeight_ = mapHeight;
3737
}
3838

39-
GeoMap::~GeoMap()
40-
{
41-
/*
42-
// Remove map file from SPIFFS
43-
String filename = getMapName();
44-
45-
if (SPIFFS.exists(filename) == true)
46-
{
47-
// Exiting, removing map file
48-
SPIFFS.remove(filename);
49-
}
50-
else
51-
{
52-
// Exiting, but no file to remove
53-
}
54-
*/
55-
}
39+
GeoMap::~GeoMap() {}
5640

5741
int GeoMap::getMapWidth() {
5842
return mapWidth_;

Geocode.cpp

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
/********************************************************/
2+
/* ATMOSCAN */
3+
/* */
4+
/* Author: Marc Finns 2017 */
5+
/* */
6+
/********************************************************/
7+
8+
#include <ArduinoJson.h>
9+
#include "ESP8266WiFi.h"
10+
#include <NtpClientLib.h> // http://github.com/gmag11/NtpClient
11+
#include <JsonStreamingParser.h>
12+
#include <Syslog.h> // https://github.com/arcao/ESP8266_Syslog
13+
#include "Wsclient.h"
14+
#include "TimeSpace.h"
15+
#include "GlobalDefinitions.h"
16+
17+
extern struct Configuration config;
18+
extern Syslog syslog;
19+
20+
// **********************************************************
21+
// Step 3 - Geocoding
22+
// Get Location name from latitude and longitude
23+
// **********************************************************
24+
25+
bool Geocode::acquire(double latitude, double longitude)
26+
{
27+
28+
#ifdef DEBUG_SYSLOG
29+
String myBuffer;
30+
#endif
31+
32+
//Connect to the client and make the api call
33+
if (httpConnect())
34+
{
35+
// Concatenate url and key
36+
String url = FPSTR(geoCodeURL);
37+
url += F("&lat=");
38+
url += String(latitude, 8);
39+
url += F("&lng=");
40+
url += String(longitude, 8);
41+
url += F("&username=" );
42+
url += config.geonames_user;
43+
44+
// Serial.println("URL = " + url);
45+
46+
#ifdef DEBUG_SYSLOG
47+
syslog.log(LOG_DEBUG, "URL = " + url);
48+
#endif
49+
50+
if (httpGet(url) && skipResponseHeaders())
51+
{
52+
// Invalidate current values
53+
locality = FPSTR(empty);
54+
country = FPSTR(empty);
55+
countryCode = FPSTR(empty);
56+
57+
// Allow for slow server...
58+
int retryCounter = 0;
59+
while (!client.available())
60+
{
61+
delay(1000);
62+
retryCounter++;
63+
if (retryCounter > 10)
64+
{
65+
return false;
66+
}
67+
}
68+
69+
while (client.available())
70+
{
71+
JsonStreamingParser parser;
72+
parser.setListener(this);
73+
char c;
74+
75+
while (client.available())
76+
{
77+
c = client.read();
78+
79+
#ifdef DEBUG_SERIAL
80+
Serial.print(c);
81+
#endif
82+
83+
#ifdef DEBUG_SYSLOG
84+
myBuffer = myBuffer + String(c);
85+
#endif
86+
87+
parser.parse(c);
88+
89+
// Improves reliability from ESP version 2.4.0
90+
yield();
91+
}
92+
}
93+
}
94+
else
95+
// Get failed
96+
return false;
97+
}
98+
else
99+
// Could not connect
100+
return false;
101+
102+
disconnect();
103+
104+
#ifdef DEBUG_SYSLOG
105+
syslog.log(LOG_DEBUG, "RESPONSE = " + myBuffer);
106+
#endif
107+
108+
if (country == "" || countryCode == "")
109+
return false;
110+
else
111+
return true;
112+
}
113+
114+
void Geocode::whitespace(char c) {
115+
#ifdef DEBUG_LOG
116+
Serial.println("whitespace");
117+
#endif
118+
}
119+
120+
void Geocode::startDocument() {
121+
#ifdef DEBUG_LOG
122+
Serial.println("start document");
123+
#endif
124+
}
125+
126+
void Geocode::key(String key)
127+
{
128+
#ifdef DEBUG_LOG
129+
Serial.println("key: " + key);
130+
#endif
131+
currentKey = key;
132+
}
133+
134+
void Geocode::value(String value)
135+
{
136+
#ifdef DEBUG_LOG
137+
Serial.println("value: " + value);
138+
#endif
139+
if (currentKey == F("name"))
140+
{
141+
locality = value;
142+
}
143+
else if (currentKey == F("countryName"))
144+
{
145+
country = value;
146+
}
147+
else if (currentKey == F("countryCode"))
148+
{
149+
countryCode = value;
150+
}
151+
}
152+
153+
154+
void Geocode::endArray() {
155+
#ifdef DEBUG_LOG
156+
Serial.println("end array. ");
157+
#endif
158+
}
159+
160+
void Geocode::endObject() {
161+
#ifdef DEBUG_LOG
162+
Serial.println("end object. ");
163+
#endif
164+
}
165+
166+
void Geocode::endDocument() {
167+
#ifdef DEBUG_LOG
168+
Serial.println("end document. ");
169+
#endif
170+
}
171+
172+
void Geocode::startArray() {
173+
#ifdef DEBUG_LOG
174+
Serial.println("start array. ");
175+
#endif
176+
}
177+
178+
void Geocode::startObject() {
179+
#ifdef DEBUG_LOG
180+
Serial.println("start object. ");
181+
#endif
182+
}
183+
184+
String Geocode::getLocality()
185+
{
186+
return locality;
187+
}
188+
189+
String Geocode::getCountry()
190+
{
191+
return country;
192+
}
193+
194+
String Geocode::getCountryCode()
195+
{
196+
return countryCode;
197+
}
198+

0 commit comments

Comments
 (0)