Skip to content

Commit 8ade18e

Browse files
committed
Hide PointPerfect menu options if disabled
1 parent 12938a9 commit 8ade18e

File tree

1 file changed

+46
-36
lines changed

1 file changed

+46
-36
lines changed

Firmware/RTK_Everywhere/menuPP.ino

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ ZtpResponse pointperfectTryZtpToken(StaticJsonDocument<256> &apiPost)
570570
ztpResponse = ZTP_SUCCESS;
571571
}
572572
} // JSON Derialized correctly
573-
} // HTTP Response was 200
573+
} // HTTP Response was 200
574574
} while (0);
575575

576576
// Free the allocated buffers
@@ -1286,27 +1286,27 @@ void menuPointPerfect()
12861286
if (settings.debugCorrections == true)
12871287
systemPrintf("settings.pointPerfectLBandTopic: %s\r\n", settings.pointPerfectLBandTopic);
12881288

1289-
systemPrint("Days until keys expire: ");
1290-
if (strlen(settings.pointPerfectCurrentKey) > 0)
1291-
{
1292-
if (online.rtc == false)
1289+
systemPrint("Days until keys expire: ");
1290+
if (strlen(settings.pointPerfectCurrentKey) > 0)
12931291
{
1294-
// If we don't have RTC we can't calculate days to expire
1295-
systemPrintln("No RTC");
1296-
}
1297-
else
1298-
{
1299-
int daysRemaining =
1300-
daysFromEpoch(settings.pointPerfectNextKeyStart + settings.pointPerfectNextKeyDuration + 1);
1301-
1302-
if (daysRemaining < 0)
1303-
systemPrintln("Expired");
1292+
if (online.rtc == false)
1293+
{
1294+
// If we don't have RTC we can't calculate days to expire
1295+
systemPrintln("No RTC");
1296+
}
13041297
else
1305-
systemPrintln(daysRemaining);
1298+
{
1299+
int daysRemaining =
1300+
daysFromEpoch(settings.pointPerfectNextKeyStart + settings.pointPerfectNextKeyDuration + 1);
1301+
1302+
if (daysRemaining < 0)
1303+
systemPrintln("Expired");
1304+
else
1305+
systemPrintln(daysRemaining);
1306+
}
13061307
}
1307-
}
1308-
else
1309-
systemPrintln("No keys");
1308+
else
1309+
systemPrintln("No keys");
13101310

13111311
// All units should be able to obtain corrections over IP
13121312
// Only units with an lband receiver can obtain LBand corrections
@@ -1318,22 +1318,25 @@ void menuPointPerfect()
13181318
else
13191319
systemPrintln("Disabled");
13201320

1321-
systemPrint("2) Toggle Auto Key Renewal: ");
1322-
if (settings.autoKeyRenewal == true)
1323-
systemPrintln("Enabled");
1324-
else
1325-
systemPrintln("Disabled");
1321+
if (pointPerfectIsEnabled())
1322+
{
1323+
systemPrint("2) Toggle Auto Key Renewal: ");
1324+
if (settings.autoKeyRenewal == true)
1325+
systemPrintln("Enabled");
1326+
else
1327+
systemPrintln("Disabled");
13261328

1327-
if (strlen(settings.pointPerfectCurrentKey) == 0 || strlen(settings.pointPerfectLBandTopic) == 0)
1328-
systemPrintln("3) Provision Device");
1329-
else
1330-
systemPrintln("3) Update Keys");
1329+
if (strlen(settings.pointPerfectCurrentKey) == 0 || strlen(settings.pointPerfectLBandTopic) == 0)
1330+
systemPrintln("3) Provision Device");
1331+
else
1332+
systemPrintln("3) Update Keys");
13311333

1332-
systemPrintln("4) Show device ID");
1334+
systemPrintln("4) Show device ID");
13331335

1334-
systemPrintln("c) Clear the Keys");
1336+
systemPrintln("c) Clear the Keys");
13351337

1336-
systemPrintln("k) Manual Key Entry");
1338+
systemPrintln("k) Manual Key Entry");
1339+
}
13371340

13381341
systemPrintln("x) Exit");
13391342

@@ -1363,11 +1366,11 @@ void menuPointPerfect()
13631366
}
13641367
}
13651368

1366-
else if (incoming == 2)
1369+
else if (incoming == 2 && pointPerfectIsEnabled())
13671370
{
13681371
settings.autoKeyRenewal ^= 1;
13691372
}
1370-
else if (incoming == 3)
1373+
else if (incoming == 3 && pointPerfectIsEnabled())
13711374
{
13721375
if (wifiNetworkCount() == 0)
13731376
{
@@ -1416,19 +1419,19 @@ void menuPointPerfect()
14161419

14171420
WIFI_STOP();
14181421
}
1419-
else if (incoming == 4)
1422+
else if (incoming == 4 && pointPerfectIsEnabled())
14201423
{
14211424
char hardwareID[13];
14221425
snprintf(hardwareID, sizeof(hardwareID), "%02X%02X%02X%02X%02X%02X", btMACAddress[0], btMACAddress[1],
14231426
btMACAddress[2], btMACAddress[3], btMACAddress[4], btMACAddress[5]);
14241427
systemPrintf("Device ID: %s\r\n", hardwareID);
14251428
}
1426-
else if (incoming == 'c')
1429+
else if (incoming == 'c' && pointPerfectIsEnabled())
14271430
{
14281431
settings.pointPerfectCurrentKey[0] = 0;
14291432
settings.pointPerfectNextKey[0] = 0;
14301433
}
1431-
else if (incoming == 'k')
1434+
else if (incoming == 'k' && pointPerfectIsEnabled())
14321435
{
14331436
menuPointPerfectKeys();
14341437
}
@@ -1450,6 +1453,13 @@ void menuPointPerfect()
14501453
clearBuffer(); // Empty buffer of any newline chars
14511454
}
14521455

1456+
bool pointPerfectIsEnabled()
1457+
{
1458+
if (settings.pointPerfectCorrectionsSource != POINTPERFECT_CORRECTIONS_DISABLED)
1459+
return (true);
1460+
return (false);
1461+
}
1462+
14531463
// Process any new L-Band from I2C
14541464
void updateLBand()
14551465
{

0 commit comments

Comments
 (0)