|
|
|
@ -52,9 +52,9 @@ void measure(WifiState& wifiState, TinyGPSLocation& loc) {
|
|
|
|
|
DEBUG_OUT << "numNetworks: " << wifiState.numNetworks << EOL;
|
|
|
|
|
DEBUG_OUT << "numUnencrypted: " << wifiState.numUnencrypted << EOL;
|
|
|
|
|
DEBUG_OUT.print("lat: ");
|
|
|
|
|
DEBUG_OUT.print(loc.lat(), 6);
|
|
|
|
|
DEBUG_OUT.print(loc.lat(), 8);
|
|
|
|
|
DEBUG_OUT.print(" lng: ");
|
|
|
|
|
DEBUG_OUT.println(loc.lng(), 6);
|
|
|
|
|
DEBUG_OUT.println(loc.lng(), 8);
|
|
|
|
|
DEBUG_OUT << dateString << EOL;
|
|
|
|
|
|
|
|
|
|
// IDEA: write location update to separate file?
|
|
|
|
@ -152,15 +152,18 @@ void setup() {
|
|
|
|
|
wifi.begin(WIFI_SSID, WIFI_PASS);
|
|
|
|
|
DEBUG_OUT.begin(115200);
|
|
|
|
|
|
|
|
|
|
// wait until we got a first fix from GPS, and thus an initial *time*
|
|
|
|
|
DEBUG_OUT << "Getting GPS fix..";
|
|
|
|
|
while (!gps.updateLocation()) {
|
|
|
|
|
adaptiveDelay(0, location); // poll for telnet connections
|
|
|
|
|
DEBUG_OUT << ".";
|
|
|
|
|
// wait until we got a first fix from GPS, and thus an initial time
|
|
|
|
|
// exception: measure mode is disabled (for quick upload only)
|
|
|
|
|
if (digitalRead(PIN_MEASURE_MODE) == HIGH) {
|
|
|
|
|
DEBUG_OUT << "Getting GPS fix..";
|
|
|
|
|
while (!gps.updateLocation()) {
|
|
|
|
|
adaptiveDelay(0, location); // poll for telnet connections
|
|
|
|
|
DEBUG_OUT << ".";
|
|
|
|
|
}
|
|
|
|
|
location = gps.getLocation();
|
|
|
|
|
DEBUG_OUT << " done!" << EOL;
|
|
|
|
|
digitalWrite(BUILTIN_LED, HIGH);
|
|
|
|
|
}
|
|
|
|
|
location = gps.getLocation();
|
|
|
|
|
DEBUG_OUT << " done!" << EOL;
|
|
|
|
|
digitalWrite(BUILTIN_LED, HIGH);
|
|
|
|
|
|
|
|
|
|
// DEBUG
|
|
|
|
|
//while (!wifi.isConnected()) adaptiveDelay(500, location);
|
|
|
|
@ -185,11 +188,11 @@ void loop() {
|
|
|
|
|
if (digitalRead(PIN_UPLOAD_MODE) == HIGH)
|
|
|
|
|
upload(wifiState);
|
|
|
|
|
|
|
|
|
|
if (digitalRead(PIN_MEASURE_MODE) == HIGH) {
|
|
|
|
|
// run the measurements in a fixed interval, using an adaptive delay
|
|
|
|
|
// the interval is defined by a duration and/or distance from our last fix
|
|
|
|
|
// run the measurements in a fixed interval, using an adaptive delay
|
|
|
|
|
// the interval is defined by a duration and/or distance from our last fix
|
|
|
|
|
if (digitalRead(PIN_MEASURE_MODE) == HIGH)
|
|
|
|
|
return adaptiveDelay(MEASUREMENT_INTERVAL, location, millis() - cycleStart, MEASUREMENT_DISTANCE_ENABLED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// run as fast as possible when not measuring.
|
|
|
|
|
// smartDelay has to be called anyway, as some polling functions are run within
|
|
|
|
|
adaptiveDelay(0, location);
|
|
|
|
|