From 2a067e7f6bf73aae62350a66c22d48a6ac2f86c8 Mon Sep 17 00:00:00 2001 From: geeksville Date: Sun, 6 Sep 2020 14:45:43 -0700 Subject: [PATCH] make gps optional. Portduino almost works in sim! --- platformio.ini | 2 +- src/main.cpp | 8 ++++++-- src/mesh/MeshService.cpp | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/platformio.ini b/platformio.ini index 4ee70850..95db806e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -251,6 +251,6 @@ lib_deps = [env:linux] platform = https://github.com/geeksville/platform-portduino.git src_filter = ${env.src_filter} - - - -build_flags = ${arduino_base.build_flags} +build_flags = ${arduino_base.build_flags} -O0 framework = arduino board = linux_x86_64 diff --git a/src/main.cpp b/src/main.cpp index aaea60a6..655d8a8b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -268,7 +268,10 @@ void setup() gps = new NEMAGPS(); gps->setup(); #endif - gpsStatus->observe(&gps->newStatus); + if (gps) + gpsStatus->observe(&gps->newStatus); + else + DEBUG_MSG("Warning: No GPS found - running without GPS\n"); nodeStatus->observe(&nodeDB.newStatus); service.init(); @@ -362,7 +365,8 @@ void loop() { uint32_t msecstosleep = 1000 * 30; // How long can we sleep before we again need to service the main loop? - gps->loop(); // FIXME, remove from main, instead block on read + if (gps) + gps->loop(); // FIXME, remove from main, instead block on read router.loop(); powerFSM.run_machine(); service.loop(); diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 70070b12..6dc24893 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -67,8 +67,8 @@ void MeshService::init() sendOwnerPeriod.setup(); nodeDB.init(); - assert(gps); - gpsObserver.observe(&gps->newStatus); + if (gps) + gpsObserver.observe(&gps->newStatus); packetReceivedObserver.observe(&router.notifyPacketReceived); }