From 8c240b59f6f0a9f67f2d5662325dca2c6fc56bcb Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 16 Sep 2020 09:08:35 -0700 Subject: [PATCH 01/10] fix #393. immediately save node db to disk if user changes name --- src/mesh/MeshService.cpp | 7 +++++++ src/mesh/MeshService.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index f5d0ac173..4b75b4ee7 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -206,6 +206,13 @@ void MeshService::reloadConfig() nodeDB.saveToDisk(); } +/// The owner User record just got updated, update our node DB and broadcast the info into the mesh +void MeshService::reloadOwner() +{ + sendOurOwner(); + nodeDB.saveToDisk(); +} + /** * Given a ToRadio buffer parse it and properly handle it (setup radio, owner or send packet into the mesh) * Called by PhoneAPI.handleToRadio. Note: p is a scratch buffer, this function is allowed to write to it but it can not keep a diff --git a/src/mesh/MeshService.h b/src/mesh/MeshService.h index 7e8810778..a12f087b3 100644 --- a/src/mesh/MeshService.h +++ b/src/mesh/MeshService.h @@ -67,7 +67,7 @@ class MeshService void reloadConfig(); /// The owner User record just got updated, update our node DB and broadcast the info into the mesh - void reloadOwner() { sendOurOwner(); } + void reloadOwner(); /// Called when the user wakes up our GUI, normally sends our latest location to the mesh (if we have it), otherwise at least /// sends our owner From 8e988cc926a3523de625a05d16e51411126935a5 Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 16 Sep 2020 09:18:44 -0700 Subject: [PATCH 02/10] fix #397 from @a-f-G-U-C - bogus GPS positions during locking could be reported btw - from my read of the NMEA, the lowest value that means 'has a valid position' is 1 not 2. But I only know this because you pointed me at it ;-) Thanks! --- src/gps/NEMAGPS.cpp | 12 +++++++++--- src/mesh/MeshService.cpp | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/gps/NEMAGPS.cpp b/src/gps/NEMAGPS.cpp index a1d848ad8..b933836d0 100644 --- a/src/gps/NEMAGPS.cpp +++ b/src/gps/NEMAGPS.cpp @@ -44,6 +44,9 @@ void NEMAGPS::loop() isConnected = true; // we seem to have a real GPS (but not necessarily a lock) } + uint8_t fixtype = reader.fixQuality(); + hasValidLocation = ((fixtype >= 1) && (fixtype <= 5)); + if (reader.location.isUpdated()) { if (reader.altitude.isValid()) altitude = reader.altitude.meters(); @@ -58,18 +61,21 @@ void NEMAGPS::loop() dop = reader.hdop.value(); } if (reader.course.isValid()) { - heading = reader.course.value() * 1e3; //Scale the heading (in degrees * 10^-2) to match the expected degrees * 10^-5 + heading = + reader.course.value() * 1e3; // Scale the heading (in degrees * 10^-2) to match the expected degrees * 10^-5 } if (reader.satellites.isValid()) { numSatellites = reader.satellites.value(); } // expect gps pos lat=37.520825, lon=-122.309162, alt=158 - DEBUG_MSG("new NEMA GPS pos lat=%f, lon=%f, alt=%d, hdop=%f, heading=%f\n", latitude * 1e-7, longitude * 1e-7, altitude, dop * 1e-2, heading * 1e-5); + DEBUG_MSG("new NEMA GPS pos lat=%f, lon=%f, alt=%d, hdop=%f, heading=%f\n", latitude * 1e-7, longitude * 1e-7, + altitude, dop * 1e-2, heading * 1e-5); } // Notify any status instances that are observing us - const meshtastic::GPSStatus status = meshtastic::GPSStatus(hasLock(), isConnected, latitude, longitude, altitude, dop, heading, numSatellites); + const meshtastic::GPSStatus status = + meshtastic::GPSStatus(hasLock(), isConnected, latitude, longitude, altitude, dop, heading, numSatellites); newStatus.notifyObservers(&status); } } \ No newline at end of file diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 4b75b4ee7..c614c0866 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -299,8 +299,8 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *unused) p->decoded.which_payload = SubPacket_position_tag; Position &pos = p->decoded.position; - // !zero or !zero lat/long means valid - if (gps->latitude != 0 || gps->longitude != 0) { + + if (gps->hasLock()) { if (gps->altitude != 0) pos.altitude = gps->altitude; pos.latitude_i = gps->latitude; From fc20f658e61186ff4dc790342153200a522bb779 Mon Sep 17 00:00:00 2001 From: geeksville Date: Wed, 16 Sep 2020 09:22:03 -0700 Subject: [PATCH 03/10] Fix #362 by @a-f-G-U-C - I was mispelling NMEA ;-) --- docs/software/nrf52-TODO.md | 2 +- src/gps/{NEMAGPS.cpp => NMEAGPS.cpp} | 6 +++--- src/gps/{NEMAGPS.h => NMEAGPS.h} | 8 ++++---- src/gps/UBloxGPS.cpp | 2 +- src/main.cpp | 14 +++++++------- 5 files changed, 16 insertions(+), 16 deletions(-) rename src/gps/{NEMAGPS.cpp => NMEAGPS.cpp} (96%) rename src/gps/{NEMAGPS.h => NMEAGPS.h} (77%) diff --git a/docs/software/nrf52-TODO.md b/docs/software/nrf52-TODO.md index 0b0cfb6d5..46d320346 100644 --- a/docs/software/nrf52-TODO.md +++ b/docs/software/nrf52-TODO.md @@ -196,7 +196,7 @@ Nice ideas worth considering someday... - DONE neg 7 error code from receive - DONE remove unused sx1262 lib from github - at boot we are starting our message IDs at 1, rather we should start them at a random number. also, seed random based on timer. this could be the cause of our first message not seen bug. -- add a NEMA based GPS driver to test GPS +- add a NMEA based GPS driver to test GPS - DONE use "variants" to get all gpio bindings - DONE plug in correct variants for the real board - turn on DFU assistance in the appload using the nordic DFU helper lib call diff --git a/src/gps/NEMAGPS.cpp b/src/gps/NMEAGPS.cpp similarity index 96% rename from src/gps/NEMAGPS.cpp rename to src/gps/NMEAGPS.cpp index b933836d0..6b797fd7d 100644 --- a/src/gps/NEMAGPS.cpp +++ b/src/gps/NMEAGPS.cpp @@ -1,4 +1,4 @@ -#include "NEMAGPS.h" +#include "NMEAGPS.h" #include "configuration.h" #include "timing.h" @@ -11,7 +11,7 @@ static int32_t toDegInt(RawDegrees d) return r; } -void NEMAGPS::loop() +void NMEAGPS::loop() { while (_serial_gps->available() > 0) { int c = _serial_gps->read(); @@ -69,7 +69,7 @@ void NEMAGPS::loop() } // expect gps pos lat=37.520825, lon=-122.309162, alt=158 - DEBUG_MSG("new NEMA GPS pos lat=%f, lon=%f, alt=%d, hdop=%f, heading=%f\n", latitude * 1e-7, longitude * 1e-7, + DEBUG_MSG("new NMEA GPS pos lat=%f, lon=%f, alt=%d, hdop=%f, heading=%f\n", latitude * 1e-7, longitude * 1e-7, altitude, dop * 1e-2, heading * 1e-5); } diff --git a/src/gps/NEMAGPS.h b/src/gps/NMEAGPS.h similarity index 77% rename from src/gps/NEMAGPS.h rename to src/gps/NMEAGPS.h index 2640bcef1..71b24a65a 100644 --- a/src/gps/NEMAGPS.h +++ b/src/gps/NMEAGPS.h @@ -1,19 +1,19 @@ #pragma once +#include "../concurrency/PeriodicTask.h" #include "GPS.h" #include "Observer.h" -#include "../concurrency/PeriodicTask.h" #include "TinyGPS++.h" /** - * A gps class thatreads from a NEMA GPS stream (and FIXME - eventually keeps the gps powered down except when reading) + * A gps class thatreads from a NMEA GPS stream (and FIXME - eventually keeps the gps powered down except when reading) * * When new data is available it will notify observers. */ -class NEMAGPS : public GPS +class NMEAGPS : public GPS { TinyGPSPlus reader; - + uint32_t lastUpdateMsec = 0; public: diff --git a/src/gps/UBloxGPS.cpp b/src/gps/UBloxGPS.cpp index 624ab77b8..93e8a01cf 100644 --- a/src/gps/UBloxGPS.cpp +++ b/src/gps/UBloxGPS.cpp @@ -103,7 +103,7 @@ bool UBloxGPS::factoryReset() { bool ok = false; - // It is useful to force back into factory defaults (9600baud, NEMA to test the behavior of boards that don't have + // It is useful to force back into factory defaults (9600baud, NMEA to test the behavior of boards that don't have // GPS_TX connected) ublox.factoryReset(); delay(5000); diff --git a/src/main.cpp b/src/main.cpp index f7af6d232..0a474e087 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,7 +23,7 @@ #include "MeshRadio.h" #include "MeshService.h" -#include "NEMAGPS.h" +#include "NMEAGPS.h" #include "NodeDB.h" #include "PowerFSM.h" #include "UBloxGPS.h" @@ -256,16 +256,16 @@ void setup() if (GPS::_serial_gps) { // Some boards might have only the TX line from the GPS connected, in that case, we can't configure it at all. Just - // assume NEMA at 9600 baud. - DEBUG_MSG("Hoping that NEMA might work\n"); + // assume NMEA at 9600 baud. + DEBUG_MSG("Hoping that NMEA might work\n"); - // dumb NEMA access only work for serial GPSes) - gps = new NEMAGPS(); + // dumb NMEA access only work for serial GPSes) + gps = new NMEAGPS(); gps->setup(); } } #else - gps = new NEMAGPS(); + gps = new NMEAGPS(); gps->setup(); #endif gpsStatus->observe(&gps->newStatus); @@ -407,7 +407,7 @@ void loop() // Update the screen last, after we've figured out what to show. screen.debug_info()->setChannelNameStatus(getChannelName()); - + // No GPS lock yet, let the OS put the main CPU in low power mode for 100ms (or until another interrupt comes in) // i.e. don't just keep spinning in loop as fast as we can. // DEBUG_MSG("msecs %d\n", msecstosleep); From 91305c2c847c9cf21364ff7b65e6c4845224c287 Mon Sep 17 00:00:00 2001 From: r51n Date: Thu, 17 Sep 2020 12:02:38 +0000 Subject: [PATCH 04/10] add AU/NZ channel definitions --- src/mesh/MeshRadio.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mesh/MeshRadio.h b/src/mesh/MeshRadio.h index 5b3a27b9c..14b649dad 100644 --- a/src/mesh/MeshRadio.h +++ b/src/mesh/MeshRadio.h @@ -36,6 +36,11 @@ #define CH_SPACING_TW 0.2 #define NUM_CHANNELS_TW 10 +// AU/NZ channel settings 915-928MHz +#define CH0_ANZ 916.0f // MHz - avoid overcrowding on 915.0 +#define CH_SPACING_ANZ 0.5f +#define NUM_CHANNELS_ANZ 20 + // FIXME add defs for other regions and use them here #ifdef HW_VERSION_US #define CH0 CH0_US @@ -63,6 +68,11 @@ #define CH0 CH0_TW #define CH_SPACING CH_SPACING_TW #define NUM_CHANNELS NUM_CHANNELS_TW +#elif defined(HW_VERSION_ANZ) +// Australia and NZ +#define CH0 CH0_ANZ +#define CH_SPACING CH_SPACING_ANZ +#define NUM_CHANNELS NUM_CHANNELS_ANZ #else // HW version not set - assume US #define CH0 CH0_US From 1a1a0fbfbe1a509ccf7da9e8647bef9089be43ce Mon Sep 17 00:00:00 2001 From: r51n Date: Thu, 17 Sep 2020 12:04:38 +0000 Subject: [PATCH 05/10] add ANZ to build list --- bin/build-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/build-all.sh b/bin/build-all.sh index 5a860bc49..2f52a47fd 100755 --- a/bin/build-all.sh +++ b/bin/build-all.sh @@ -4,7 +4,7 @@ set -e source bin/version.sh -COUNTRIES="US EU433 EU865 CN JP" +COUNTRIES="US EU433 EU865 CN JP ANZ" #COUNTRIES=US #COUNTRIES=CN From 9b1d1ad0a5aaf37eed8dc7066451d57bb57649f5 Mon Sep 17 00:00:00 2001 From: geeksville Date: Thu, 17 Sep 2020 11:23:46 -0700 Subject: [PATCH 06/10] add linux/portduino to the CI test build Signed-off-by: geeksville --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8031b8da7..3f0d994df 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,4 +23,4 @@ jobs: run: | pip install -U adafruit-nrfutil - name: Build - run: platformio run -e tbeam -e heltec -e lora-relay-v1 + run: platformio run -e tbeam -e heltec -e lora-relay-v1 -e linux From 3541228c1fe87c52c920512d0d9ee2bfba3ff8c0 Mon Sep 17 00:00:00 2001 From: geeksville Date: Thu, 17 Sep 2020 11:41:34 -0700 Subject: [PATCH 07/10] update to my latest radiolib --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 6ef76e7d1..e60b93b84 100644 --- a/platformio.ini +++ b/platformio.ini @@ -58,7 +58,7 @@ lib_deps = 1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib https://github.com/meshtastic/arduino-fsm.git https://github.com/meshtastic/SparkFun_Ublox_Arduino_Library.git - https://github.com/meshtastic/RadioLib.git#7989a269be590a5d4914ac04069b58f4930c45c1 + https://github.com/meshtastic/RadioLib.git#ac7feac00f5e0bd95a3ac5d5852b4cc7344cf95c https://github.com/meshtastic/TinyGPSPlus.git https://github.com/meshtastic/AXP202X_Library.git#8404abb6d4b486748636bc6ad72d2a47baaf5460 Wire ; explicitly needed here because the AXP202 library forgets to add it From bd126b866c0a5739d81a65ef148f2f1897d628d5 Mon Sep 17 00:00:00 2001 From: geeksville Date: Sat, 19 Sep 2020 10:32:57 -0700 Subject: [PATCH 08/10] 1.1.0 --- bin/version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/version.sh b/bin/version.sh index 02a3c9d62..a2c90861a 100644 --- a/bin/version.sh +++ b/bin/version.sh @@ -1,3 +1,3 @@ -export VERSION=1.0.0 \ No newline at end of file +export VERSION=1.1.0 \ No newline at end of file From 55cb0c52eed3dae658b3b4414c50bb3df2ec58a9 Mon Sep 17 00:00:00 2001 From: comgram Date: Mon, 21 Sep 2020 16:10:20 +0900 Subject: [PATCH 09/10] Add Korean Frequency --- bin/build-all.sh | 2 +- src/mesh/MeshRadio.h | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/build-all.sh b/bin/build-all.sh index 2f52a47fd..63dfc01c1 100755 --- a/bin/build-all.sh +++ b/bin/build-all.sh @@ -4,7 +4,7 @@ set -e source bin/version.sh -COUNTRIES="US EU433 EU865 CN JP ANZ" +COUNTRIES="US EU433 EU865 CN JP ANZ KR" #COUNTRIES=US #COUNTRIES=CN diff --git a/src/mesh/MeshRadio.h b/src/mesh/MeshRadio.h index 14b649dad..070c7c9a7 100644 --- a/src/mesh/MeshRadio.h +++ b/src/mesh/MeshRadio.h @@ -41,6 +41,12 @@ #define CH_SPACING_ANZ 0.5f #define NUM_CHANNELS_ANZ 20 +// KR channel settings (KR920-923) +// Start from TTN download channel freq. (921.9f is for download, others are for uplink) +#define CH0_KR 921.9f // MHz +#define CH_SPACING_KR 0.2f +#define NUM_CHANNELS_KR 8 + // FIXME add defs for other regions and use them here #ifdef HW_VERSION_US #define CH0 CH0_US @@ -73,9 +79,14 @@ #define CH0 CH0_ANZ #define CH_SPACING CH_SPACING_ANZ #define NUM_CHANNELS NUM_CHANNELS_ANZ +#elif defined(HW_VERSION_KR) +// Republic of Korea +#define CH0 CH0_KR +#define CH_SPACING CH_SPACING_KR +#define NUM_CHANNELS NUM_CHANNELS_KR #else // HW version not set - assume US #define CH0 CH0_US #define CH_SPACING CH_SPACING_US #define NUM_CHANNELS NUM_CHANNELS_US -#endif +#endif \ No newline at end of file From 829c5f493c77398b46adbf3459d061afd5139799 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Wed, 23 Sep 2020 20:16:21 +0200 Subject: [PATCH 10/10] Fix for broken link to device API docs bluetooth-api.md -> device-api.md --- docs/software/sw-design.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/software/sw-design.md b/docs/software/sw-design.md index d6413dda7..90ebb4d19 100644 --- a/docs/software/sw-design.md +++ b/docs/software/sw-design.md @@ -5,5 +5,5 @@ This is a mini design doc for developing the meshtastic software. * Our [project board](https://github.com/orgs/meshtastic/projects/1) - shows what things we are currently working on and remaining work items for the current release. * [Power Management](power.md) * [Mesh algorithm](mesh-alg.md) -* [Bluetooth API](bluetooth-api.md) and porting guide for new clients (iOS, python, etc...) +* [Device API](device-api.md) and porting guide for new clients (iOS, python, etc...) * TODO: how to port the device code to a new device.