Skip to content

Commit 9a8a921

Browse files
committed
Stop PPL if selected service no longer needs it
1 parent fbcae70 commit 9a8a921

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Firmware/RTK_Everywhere/PointPerfectLibrary.ino

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ void beginPPL()
153153
pplConfigOptionsMask = PPL_CFG_ENABLE_AUX_CHANNEL; // auxiliary channel support
154154
else
155155
pplConfigOptionsMask = PPL_CFG_DEFAULT_CFG; // IP and L-Band support
156+
156157
ePPL_ReturnStatus result = PPL_Initialize(pplConfigOptionsMask);
157158

158159
if (result != ePPL_Success)
@@ -230,7 +231,10 @@ void updatePPL()
230231

231232
static unsigned long pplTime3dFixStarted;
232233

233-
if ((online.ppl == false) && (pointPerfectIsEnabled() == true) && (gnss->isFixed()))
234+
// Start the PPL only if the selected PointPerfect service is encrypted, and the current hardware needs the PPL to
235+
// decrypt
236+
if ((online.ppl == false) && (pointPerfectServiceUsesKeys() == true) && (productVariantNeedsPpl() == true) &&
237+
(gnss->isFixed()))
234238
{
235239
// Start PPL only after GNSS is outputting appropriate NMEA+RTCM, we have a key, and the MQTT broker is
236240
// connected or L-Band SPARTN is being received. Don't restart the PPL if we've already tried.
@@ -245,8 +249,9 @@ void updatePPL()
245249
}
246250
}
247251
}
248-
else if (online.ppl == true)
252+
else if ((online.ppl == true) && (pointPerfectServiceUsesKeys() == true))
249253
{
254+
250255
if (settings.debugCorrections == true)
251256
{
252257
if (millis() - pplReport > 5000)
@@ -322,6 +327,11 @@ void updatePPL()
322327
}
323328
}
324329

330+
// Stop PPL if the PointPerfect service changes and no longer needs it
331+
else if ((online.ppl == true) && (pointPerfectServiceUsesKeys() == false))
332+
{
333+
stopPPL(); // Stop PPL and mark it offline. It will auto-restart at the next update().
334+
}
325335
// The PPL is fed during updatePplTask()
326336
}
327337

@@ -460,6 +470,11 @@ bool sendAuxSpartnToPpl(uint8_t *buffer, int numDataBytes)
460470
{
461471
if ((settings.debugCorrections == true) && !inMainMenu)
462472
systemPrintf("ERROR PPL_SendAuxSpartn: %s\r\n", PPLReturnStatusToStr(result));
473+
474+
// Force print wrong key error
475+
else if (result == ePPL_IncorrectDynKey && !inMainMenu)
476+
systemPrintf("ERROR PPL_SendAuxSpartn: %s\r\n", PPLReturnStatusToStr(result));
477+
463478
return false;
464479
}
465480
lastSpartnToPpl = millis();

0 commit comments

Comments
 (0)