Skip to content

Commit 7797280

Browse files
committed
Check PP response contains the expected fields. Retry if PP is still activating the device on plan
1 parent c69ddb2 commit 7797280

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Firmware/RTK_Everywhere/HTTP_Client.ino

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,17 @@ void httpClientUpdate()
522522
break;
523523
}
524524

525+
// Check if the JSON blob contains a certificate and private key
526+
// If this is the first time this device has connected to ThingStream, they
527+
// will not be present and we need to retry
528+
// httpClientConnectLimitReached will prevent excessive retries
529+
if (((const char *)((*jsonZtp)["certificate"]) == nullptr) || ((const char *)((*jsonZtp)["privateKey"]) == nullptr))
530+
{
531+
systemPrintln("ERROR - certificate or privateKey not found!\r\n");
532+
httpClientRestart(); // Try again - allow time for ThingStream to finish activating the device on plan
533+
break;
534+
}
535+
525536
strncpy(tempHolderPtr, (const char *)((*jsonZtp)["certificate"]), MQTT_CERT_SIZE - 1);
526537
recordFile("certificate", tempHolderPtr, strlen(tempHolderPtr));
527538

@@ -613,6 +624,17 @@ void httpClientUpdate()
613624
// We received a JSON blob containing NTRIP credentials
614625
systemPrintf("PointPerfect response: %s\r\n", response.c_str());
615626

627+
// Check if the JSON blob contains rtcmCredentials
628+
// If this is the first time this device has connected to ThingStream, rtcmCredentials
629+
// will not be present and we need to retry
630+
// httpClientConnectLimitReached will prevent excessive retries
631+
if ((const char *)((*jsonZtp)["rtcmCredentials"]) == nullptr)
632+
{
633+
systemPrintln("ERROR - rtcmCredentials not found!\r\n");
634+
httpClientRestart(); // Try again - allow time for ThingStream to finish activating the device on plan
635+
break;
636+
}
637+
616638
strncpy(settings.ntripClient_CasterHost, (const char *)((*jsonZtp)["rtcmCredentials"]["endpoint"]),
617639
sizeof(settings.ntripClient_CasterHost));
618640
settings.ntripClient_CasterPort = (*jsonZtp)["rtcmCredentials"]["httpPort"];

0 commit comments

Comments
 (0)