You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
683 B

  1. #include "GpsTracker.h"
  2. void setup() {
  3. #ifdef _DEBUG
  4. debug::waitForSerial();
  5. Log.begin(LOG_LEVEL_VERBOSE, &Serial);
  6. #endif
  7. rtc::powerOn();
  8. rtc::setup();
  9. rtc::powerOff();
  10. }
  11. void loop() {
  12. gps::powerOn();
  13. SIM808_GPS_STATUS gpsStatus = gps::acquireCurrentPosition(GPS_DEFAULT_TOTAL_TIMEOUT_MS);
  14. gps::powerOff();
  15. if (gpsStatus > SIM808_GPS_STATUS::NO_FIX) {
  16. tmElements_t time;
  17. gps::getTime(time);
  18. rtc::powerOn();
  19. rtc::setTime(time);
  20. rtc::powerOff();
  21. positions::appendLast();
  22. uint8_t velocity;
  23. gps::getVelocity(velocity);
  24. core::setSleepTime(velocity);
  25. }
  26. if (positions::needsToSend()) {
  27. positions::send();
  28. }
  29. mainunit::deepSleep(core::sleepTime);
  30. }