Skip to content

Commit c6f9eb1

Browse files
committed
Prevent PP key update if SSID is empty
1 parent 082ec69 commit c6f9eb1

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

Firmware/RTK_Surveyor/menuPP.ino

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -940,39 +940,51 @@ void menuPointPerfect()
940940
else if (incoming == '5')
941941
{
942942
#ifdef COMPILE_WIFI
943-
wifiStart(settings.home_wifiSSID, settings.home_wifiPW);
944-
945-
unsigned long startTime = millis();
946-
while (wifiGetStatus() != WL_CONNECTED)
943+
if (strlen(settings.home_wifiSSID) == 0)
947944
{
948-
delay(500);
949-
Serial.print(".");
950-
if (millis() - startTime > 8000) break; //Give up after 8 seconds
945+
Serial.println("Error: Please enter SSID before getting keys");
951946
}
952-
953-
if (wifiGetStatus() == WL_CONNECTED)
947+
else
954948
{
949+
wifiStart(settings.home_wifiSSID, settings.home_wifiPW);
955950

956-
Serial.println();
957-
Serial.print("WiFi connected: ");
958-
Serial.println(wifiGetIpAddress());
959-
960-
//Check if we have certificates
961-
char fileName[80];
962-
sprintf(fileName, "/%s_%s_%d.txt", platformFilePrefix, "certificate", profileNumber);
963-
if (LittleFS.exists(fileName) == false)
951+
unsigned long startTime = millis();
952+
while (wifiGetStatus() != WL_CONNECTED)
964953
{
965-
provisionDevice(); //Connect to ThingStream API and get keys
954+
delay(500);
955+
Serial.print(".");
956+
if (millis() - startTime > 15000)
957+
{
958+
Serial.println("Error: No WiFi available");
959+
break;
960+
}
966961
}
967-
else if (strlen(settings.pointPerfectCurrentKey) == 0 || strlen(settings.pointPerfectLBandTopic) == 0)
962+
963+
if (wifiGetStatus() == WL_CONNECTED)
968964
{
969-
provisionDevice(); //Connect to ThingStream API and get keys
970-
}
971-
else
972-
updatePointPerfectKeys();
973965

966+
Serial.println();
967+
Serial.print("WiFi connected: ");
968+
Serial.println(wifiGetIpAddress());
969+
970+
//Check if we have certificates
971+
char fileName[80];
972+
sprintf(fileName, "/%s_%s_%d.txt", platformFilePrefix, "certificate", profileNumber);
973+
if (LittleFS.exists(fileName) == false)
974+
{
975+
provisionDevice(); //Connect to ThingStream API and get keys
976+
}
977+
else if (strlen(settings.pointPerfectCurrentKey) == 0 || strlen(settings.pointPerfectLBandTopic) == 0)
978+
{
979+
provisionDevice(); //Connect to ThingStream API and get keys
980+
}
981+
else
982+
updatePointPerfectKeys();
983+
984+
}
985+
974986
wifiStop();
975-
}
987+
} //End strlen SSID check
976988
#endif
977989
}
978990
else if (incoming == '6')

0 commit comments

Comments
 (0)