您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

102 行
2.8 KiB

  1. #include <Arduino.h>
  2. #include <SIM808.h>
  3. #include "Debug.h"
  4. #include "MainUnit.h"
  5. #include "Hardware.h"
  6. #include "Gps.h"
  7. #include "Config.h"
  8. #include "Core.h"
  9. #include "Positions.h"
  10. #include "Logging.h"
  11. #define CURRENT_LOGGER "GpsTracker"
  12. bool bypassMenu = false;
  13. uint16_t menuTimeout = MENU_TIMEOUT;
  14. void setup() {
  15. logging::setup();
  16. config::main::setup();
  17. rtc::setup();
  18. hardware::sim808::setup();
  19. positions::setup();
  20. }
  21. void loop() {
  22. #define CURRENT_LOGGER_FUNCTION "loop"
  23. debug::GPSTRACKER_DEBUG_COMMAND command = debug::GPSTRACKER_DEBUG_COMMAND::RUN;
  24. if (Serial && !bypassMenu) command = debug::menu(menuTimeout);
  25. if (command == debug::GPSTRACKER_DEBUG_COMMAND::RUN) bypassMenu = true;
  26. else menuTimeout = 0; //disable timeout once a command has been entered
  27. bypassMenu = command == debug::GPSTRACKER_DEBUG_COMMAND::RUN;
  28. switch (command) {
  29. case debug::GPSTRACKER_DEBUG_COMMAND::RUN:
  30. case debug::GPSTRACKER_DEBUG_COMMAND::ONCE:
  31. core::main();
  32. break;
  33. case debug::GPSTRACKER_DEBUG_COMMAND::RAM:
  34. debug::displayFreeRam();
  35. break;
  36. case debug::GPSTRACKER_DEBUG_COMMAND::BATTERY:
  37. debug::getAndDisplayBattery();
  38. break;
  39. case debug::GPSTRACKER_DEBUG_COMMAND::GPS_ON:
  40. gps::powerOn();
  41. break;
  42. case debug::GPSTRACKER_DEBUG_COMMAND::GPS_OFF:
  43. gps::powerOff();
  44. break;
  45. case debug::GPSTRACKER_DEBUG_COMMAND::GPS_GET:
  46. debug::getAndDisplayGpsPosition();
  47. break;
  48. case debug::GPSTRACKER_DEBUG_COMMAND::GPS_SET:
  49. debug::setFakeGpsPosition();
  50. break;
  51. case debug::GPSTRACKER_DEBUG_COMMAND::RTC_GET:
  52. debug::getAndDisplayRtcTime();
  53. break;
  54. case debug::GPSTRACKER_DEBUG_COMMAND::RTC_SET:
  55. debug::setRtcTime();
  56. break;
  57. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_GET_CONFIG:
  58. debug::getAndDisplayEepromConfig();
  59. break;
  60. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_RESET_CONFIG:
  61. config::main::reset();
  62. break;
  63. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_GET_CONTENT:
  64. debug::getAndDisplayEepromContent();
  65. break;
  66. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_GET_ENTRIES:
  67. debug::getAndDisplayEepromPositions(config::main::value.firstEntry);
  68. break;
  69. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_GET_LAST_ENTRY:
  70. debug::getAndDisplayEepromPositions(config::main::value.lastEntry);
  71. break;
  72. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_ADD_ENTRY:
  73. debug::addLastPositionToEeprom();
  74. break;
  75. case debug::GPSTRACKER_DEBUG_COMMAND::EEPROM_BACKUP_ENTRIES:
  76. positions::doBackup(true);
  77. break;
  78. case debug::GPSTRACKER_DEBUG_COMMAND::NOTIFY_FAILURES:
  79. debug::notifyFailures();
  80. break;
  81. case debug::GPSTRACKER_DEBUG_COMMAND::CLEAR_ALERTS:
  82. debug::clearAlerts();
  83. break;
  84. case debug::GPSTRACKER_DEBUG_COMMAND::SLEEP_DEEP:
  85. mainunit::deepSleep(10);
  86. break;
  87. default:
  88. NOTICE_MSG("Unsupported");
  89. }
  90. }