Skip to content

Commit c99cc01

Browse files
committed
Output "Account Expired" if device is detected as deactivated.
1 parent f99b8ff commit c99cc01

File tree

2 files changed

+44
-32
lines changed

2 files changed

+44
-32
lines changed

Firmware/RTK_Surveyor/Display.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,6 +1888,11 @@ void displayNoSSIDs(uint16_t displayTime)
18881888
displayMessage("No SSIDs", displayTime);
18891889
}
18901890

1891+
void displayAccountExpired(uint16_t displayTime)
1892+
{
1893+
displayMessage("Account Expired", displayTime);
1894+
}
1895+
18911896
void displayRoverStart(uint16_t displayTime)
18921897
{
18931898
if (online.display == true)

Firmware/RTK_Surveyor/menuPP.ino

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,27 @@ bool pointperfectProvisionDevice()
317317

318318
if (httpResponseCode != 200)
319319
{
320-
systemPrintf("HTTP response error %d: ", httpResponseCode);
321-
systemPrintln(response);
320+
// If a device has been deactivated, response will be: "HTTP response error 403: No plan for device
321+
// device:9f49e97f-e6a7-4a08-8d58-ac7ecdc90e23"
322+
if (response.indexOf("No plan for device") >= 0)
323+
{
324+
char hardwareID[13];
325+
snprintf(hardwareID, sizeof(hardwareID), "%02X%02X%02X%02X%02X%02X", lbandMACAddress[0],
326+
lbandMACAddress[1], lbandMACAddress[2], lbandMACAddress[3], lbandMACAddress[4],
327+
lbandMACAddress[5]);
328+
329+
systemPrintf("This device's L-Band subscription has lapsed or is not white-listed. Please contact "
330+
"support@sparkfun.com to renew the L-Band "
331+
"subscription. Please reference device ID: %s\r\n",
332+
hardwareID);
333+
334+
displayAccountExpired(5000);
335+
}
336+
else
337+
{
338+
systemPrintf("HTTP response error %d: ", httpResponseCode);
339+
systemPrintln(response);
340+
}
322341
break;
323342
}
324343
else
@@ -466,7 +485,8 @@ bool checkCertificates()
466485
if (keyContents)
467486
free(keyContents);
468487

469-
systemPrintln("Stored certificates are valid!");
488+
if (settings.debugPpCertificate)
489+
systemPrintln("Stored certificates are valid!");
470490
return (validCertificates);
471491
}
472492

@@ -576,47 +596,34 @@ bool pointperfectUpdateKeys()
576596
mqttClient.setCallback(mqttCallback);
577597
mqttClient.setServer(settings.pointPerfectBrokerHost, 8883);
578598

579-
if (settings.debugLBand == true)
580-
systemPrintf("Connecting to MQTT broker: %s\r\n", settings.pointPerfectBrokerHost);
599+
systemPrintf("Attempting to connect to MQTT broker: %s\r\n", settings.pointPerfectBrokerHost);
581600

582-
// Loop until we're connected or until the maximum retries are exceeded
583-
mqttMessageReceived = false;
584-
int maxTries = 3;
585-
do
601+
if (mqttClient.connect(settings.pointPerfectClientID))
586602
{
587-
systemPrint("MQTT connecting...");
588-
589-
// Attempt to the key broker
590-
if (mqttClient.connect(settings.pointPerfectClientID))
591-
{
592-
// Successful connection
593-
systemPrintln("connected");
603+
// Successful connection
604+
systemPrintln("MQTT connected");
594605

595-
// Originally the provisioning process reported the '/pp/key/Lb' channel which fails to respond with
596-
// keys. Looks like they fixed it to /pp/ubx/0236/Lb.
597-
mqttClient.subscribe(settings.pointPerfectLBandTopic);
598-
break;
599-
}
600-
601-
// Retry the connection attempt
602-
if (--maxTries)
603-
{
604-
systemPrint(".");
605-
if (settings.debugLBand == true)
606-
systemPrintf("failed, status code: %d try again in 1 second\r\n", mqttClient.state());
607-
delay(1000);
608-
}
609-
} while (maxTries);
606+
// Originally the provisioning process reported the '/pp/key/Lb' channel which fails to respond with
607+
// keys. Looks like they fixed it to /pp/ubx/0236/Lb.
608+
mqttClient.subscribe(settings.pointPerfectLBandTopic);
609+
break;
610+
}
610611

611612
// Check for connection failure
612613
if (mqttClient.connected() == false)
613614
{
614-
systemPrintln("failed!");
615+
systemPrintln("Failed to connect to MQTT Broker");
616+
617+
// MQTT does not provide good error reporting.
618+
// Throw out everything and attempt to provision the device to get better error checking.
619+
pointperfectProvisionDevice();
615620
break;
616621
}
617622

618623
systemPrint("Waiting for keys");
619624

625+
mqttMessageReceived = false;
626+
620627
// Wait for callback
621628
startTime = millis();
622629
while (1)

0 commit comments

Comments
 (0)