Fix a bunch of bugs, but ti's still not linking

master
Starbeamrainbowlabs 4 years ago
parent 0cdd8f5539
commit 9b76570be8
  1. 2
      iot/EntropyTest/EntropyTest.ino
  2. 22
      iot/main/gps.cpp
  3. 6
      iot/main/gps.h
  4. 12
      iot/main/main.ino
  5. 10
      iot/main/random.cpp
  6. 15
      iot/main/random.h
  7. 5
      iot/main/storage.cpp

@ -24,7 +24,7 @@
void setup() {
Serial.begin(9600);
// This routine sets up the watch dog timer with interrupt handler to maintain a
// pool of real entropy for use in sketches. This mechanism is relatively slow
// since it will only produce a little less than two 32-bit random values per

@ -1,22 +1,40 @@
#include "gps.h"
#include "settings.h"
// The GPS message decoder
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial serial_gps(PIN_GPS_RX, PIN_GPS_TX);
void gps_begin() {
// Initialise the software-based serial connection to the GPS device
serial_gps.begin(BAUD_GPS);
}
TinyGPSLocation gps_location() {
Serial.print("[gps] Getting location: ");
while(serial_gps.available() > 0) {
// We WILL discover our location - if it's the last thing we do!
while(true) {
// Make sure there's something to read
if(serial_gps.available() <= 0) {
Serial.print("!");
delay(100);
continue;
}
// If it failed, go around again
if(!gps.encode(serial_gps.read()))
continue;
if(!gps.location.isValid() || gis.location.isUpdated()) {
// If we haven't acquired a lock yet, go around again
// Also go around again if the location is the same hasn't yet been updated (GPS devices are strange)
if(!gps.location.isValid() || gps.location.isUpdated()) {
Serial.print(".");
delay(100);
continue;
}
// Hooray!
Serial.println("ok");
return gps.location;
}

@ -6,12 +6,6 @@
#include "settings.h"
// The GPS message decoder
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial serial_gps(PIN_GPS_RX, PIN_GPS_TX);
/**
* Initialises the connection to the GPS device.
*/

@ -2,18 +2,26 @@
#include <TinyGPS++.h>
#include "settings.h"
#include "random.h"
#include "gps.h"
void setup() {
Serial.begin(BAUD_PC);
random_begin();
gps_begin();
TinyGPSLocation loc = get_location();
TinyGPSLocation loc = gps_location();
gps_end();
Serial.print("[main] Location: ("); Serial.print(loc.longitude()); Serial.print(", "); Serial.print(loc.latitude()); Serial.println();
Serial.print("[main] Location: ("); Serial.print(loc.lat()); Serial.print(", "); Serial.print(loc.lng()); Serial.println();
uint32_t id = random_get();
Serial.print("[main] id: ");
Serial.println(id);
}

@ -0,0 +1,10 @@
#include <Entropy.h>
inline void random_begin() {
// Initialise the system to start gathering entropy ready to generate random numbers later
Entropy.initialize();
}
inline uint32_t random_get() {
return Entropy.random();
}

@ -1 +1,16 @@
#pragma once
/**
* Initialises the random number generation system.
* It's important to do this as early as possible, as it takes a while to
* gather the necessary entropy in order to actually generate a random number.
*/
void random_begin();
// FUTURE: Swap this out for LoRa untuned wideband radio static?
/**
* Gets an unsigned 32-bit random number.
* @return {uint32_t} A random number.
*/
uint32_t random_get();

@ -1,5 +1,6 @@
#include <Arduino.h>
#include <SD.h>
#include <TinyGPS++.h>
#include "settings.h"
@ -19,10 +20,10 @@ void store_reading(uint32_t id, TinyGPSLocation location) {
handle.print(id);
handle.print("\t");
handle.print(location.longitude());
handle.print(location.lat());
handle.print("\t");
handle.print(location.latitude());
handle.print(location.lng());
handle.println();
handle.close();

Loading…
Cancel
Save