Port the guarded NMEA buffer, validated RMC clock samples and coordinate bounds from meshcore-dev/MeshCore#3624, #3625 and #3626. Adapt clock admission to retain this branch's signed date limits, bounded loop work, tracker acquisitions, sample consumption, diagnostics and periodic settings. Upstream-PR: https://github.com/meshcore-dev/MeshCore/pull/3624 Upstream-Commit: 1ac389bbef0084623a3115c526156ae8f414d3ea Upstream-PR: https://github.com/meshcore-dev/MeshCore/pull/3625 Upstream-Commit: 72ed4dcf08869c6900ef579e7af1b28471a86895 Upstream-PR: https://github.com/meshcore-dev/MeshCore/pull/3626 Upstream-Commit: 499727a71c564a7b5d451b8f480d940e185fe742 Co-authored-by: nullrouten0 <201262769+nullrouten0@users.noreply.github.com>
43 lines
1.5 KiB
C++
43 lines
1.5 KiB
C++
#include "gps_test_support.h"
|
|
|
|
TEST(MicroNMEAProvider, ParsesWellFormedSentences) {
|
|
g_mock_millis = 1000;
|
|
MockSerial serial;
|
|
MicroNMEALocationProvider gps(serial, nullptr, -1, -1);
|
|
feedAndLoop(gps, serial, withChecksum(kGoodGga));
|
|
feedAndLoop(gps, serial, withChecksum(kGoodRmc));
|
|
|
|
EXPECT_TRUE(gps.isValid());
|
|
EXPECT_EQ(47268723L, gps.getLatitude()); // 47 deg 16.1234' N
|
|
EXPECT_EQ(-122559463L, gps.getLongitude()); // 122 deg 33.5678' W
|
|
EXPECT_EQ(8L, gps.satellitesCount());
|
|
EXPECT_EQ(125000L, gps.getAltitude());
|
|
EXPECT_EQ(1792238434L, gps.getTimestamp()); // 2026-10-17 12:00:34 UTC
|
|
}
|
|
|
|
TEST(MicroNMEAProvider, LongestSentenceTheBufferHoldsStillParses) {
|
|
std::string body = kGoodRmc;
|
|
while (body.size() < 99 - 4) body.push_back('Z'); // pad the final field
|
|
const std::string sentence = withChecksum(body);
|
|
ASSERT_EQ(99u, sentence.size());
|
|
|
|
g_mock_millis = 1000;
|
|
MockSerial serial;
|
|
MicroNMEALocationProvider gps(serial, nullptr, -1, -1);
|
|
feedAndLoop(gps, serial, sentence);
|
|
EXPECT_TRUE(gps.isValid());
|
|
EXPECT_EQ(47268723L, gps.getLatitude());
|
|
}
|
|
|
|
TEST(MicroNMEAProvider, LoopRetainsTheForegroundByteBudget) {
|
|
g_mock_millis = 1000;
|
|
MockSerial serial;
|
|
MicroNMEALocationProvider gps(serial, nullptr, -1, -1);
|
|
const size_t length = GPS_LOOP_MAX_BYTES * 2 + 7;
|
|
serial.feed(std::string(length, 'X'));
|
|
gps.loop();
|
|
EXPECT_EQ(length - GPS_LOOP_MAX_BYTES, serial.queue.size());
|
|
gps.loop();
|
|
EXPECT_EQ(7u, serial.queue.size());
|
|
}
|