Skip to content

Commit e4e021b

Browse files
committed
Working:
Remove states STATE_KEYS_... Add updateProvisioning / provisioningSetState state machine with PD and DMW support Replace lBandForceGetKeys with forceKeyAttempt
1 parent c4de734 commit e4e021b

File tree

16 files changed

+1073
-784
lines changed

16 files changed

+1073
-784
lines changed

Firmware/RTK_Everywhere/AP-Config/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@
11501150
<label class="form-check-label" for="autoKeyRenewal">Auto Key Renewal </label>
11511151
<input class="form-check-input" type="checkbox" value="" id="autoKeyRenewal">
11521152
<span class="tt" data-bs-placement="right"
1153-
title="When keys drop below 28 days to expiry, automatically attempt to connect to 'Home' WiFi, once a day, to renew keys. Default: Enabled">
1153+
title="When keys drop below 28 days to expiry, automatically attempt to connect to 'Home' network, once a day, to renew keys. Default: Enabled">
11541154
<span class="icon-info-circle text-primary ms-2"></span>
11551155
</span>
11561156
</div>

Firmware/RTK_Everywhere/Begin.ino

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,14 +1082,6 @@ void beginSystemState()
10821082
// Return to either NTP, Base or Rover Not Started. The last state previous to power down.
10831083
systemState = settings.lastState;
10841084

1085-
// Begin process for getting new keys if corrections are enabled
1086-
// Because this is the only way to set online.lbandCorrections to true via
1087-
// STATE_KEYS_LBAND_CONFIGURE -> gnssApplyPointPerfectKeys -> zedApplyPointPerfectKeys
1088-
// TODO: we need to rethink this. We need correction keys for both ip and Lb.
1089-
// We should really restructure things so we use online.corrections...
1090-
if (settings.enablePointPerfectCorrections)
1091-
systemState = STATE_KEYS_STARTED;
1092-
10931085
// Explicitly set the default network type to avoid printing 'Hardware default'
10941086
// https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/issues/360
10951087
if(settings.defaultNetworkType == NETWORK_TYPE_USE_DEFAULT)
@@ -1112,9 +1104,6 @@ void beginSystemState()
11121104
// Return to either Base or Rover Not Started. The last state previous to power down.
11131105
systemState = settings.lastState;
11141106

1115-
if (settings.enablePointPerfectCorrections)
1116-
systemState = STATE_KEYS_STARTED; // Begin process for getting new keys
1117-
11181107
//If the setting is not set, override with default
11191108
if (settings.antennaPhaseCenter_mm == 0.0)
11201109
settings.antennaPhaseCenter_mm = present.antennaPhaseCenter_mm;

Firmware/RTK_Everywhere/Developer.ino

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ void mqttClientValidateTables() {}
118118

119119
#endif // COMPILE_MQTT_CLIENT
120120

121+
//----------------------------------------
122+
// HTTP Client
123+
//----------------------------------------
124+
125+
#ifndef COMPILE_HTTP_CLIENT
126+
127+
void httpClientPrintStatus() {}
128+
void httpClientUpdate() {}
129+
void httpClientValidateTables() {}
130+
131+
#endif // COMPILE_HTTP_CLIENT
132+
121133
//----------------------------------------
122134
// Web Server
123135
//----------------------------------------

Firmware/RTK_Everywhere/Display.ino

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -398,35 +398,6 @@ void displayUpdate()
398398
paintSystemTest();
399399
break;
400400

401-
case (STATE_KEYS_STARTED):
402-
paintRTCWait();
403-
break;
404-
case (STATE_KEYS_NEEDED):
405-
// Do nothing. Quick, fall through state.
406-
break;
407-
case (STATE_KEYS_EXPIRED):
408-
// Do nothing. Quick, fall through state.
409-
break;
410-
case (STATE_KEYS_DAYS_REMAINING):
411-
// Do nothing. Quick, fall through state.
412-
break;
413-
case (STATE_KEYS_LBAND_CONFIGURE):
414-
paintLBandConfigure();
415-
break;
416-
case (STATE_KEYS_LBAND_ENCRYPTED):
417-
// Do nothing. Quick, fall through state.
418-
break;
419-
case (STATE_KEYS_PROVISION_STARTED):
420-
setWiFiIcon(&iconPropertyList); // Blink WiFi in center
421-
paintGettingKeys();
422-
break;
423-
case (STATE_KEYS_PROVISION_SUCCESS):
424-
setWiFiIcon(&iconPropertyList); // Blink WiFi in center
425-
break;
426-
case (STATE_KEYS_PROVISION_FAIL):
427-
setWiFiIcon(&iconPropertyList); // Blink WiFi in center
428-
break;
429-
430401
case (STATE_ESPNOW_PAIRING_NOT_STARTED):
431402
paintEspNowPairing();
432403
break;
@@ -2798,7 +2769,7 @@ void paintLBandConfigure()
27982769

27992770
void paintGettingKeys()
28002771
{
2801-
displayMessage("Getting Keys", 0);
2772+
displayMessage("Getting Keys", 2000);
28022773
}
28032774

28042775
void paintGettingEthernetIP()

Firmware/RTK_Everywhere/HTTP_Client.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ void httpClientUpdate()
261261
{
262262
// Shutdown the HTTP client when the mode or setting changes
263263
DMW_st(httpClientSetState, httpClientState);
264+
264265
if (!httpClientModeNeeded)
265266
{
266267
if (httpClientState > HTTP_CLIENT_OFF)
@@ -567,7 +568,7 @@ void httpClientUpdate()
567568
}
568569

569570
// The ZTP HTTP POST is complete. We either can not or do not want to continue.
570-
// Hang here until httpClientModeNeeded is set to false by pointperfectProvisionDevice
571+
// Hang here until httpClientModeNeeded is set to false by updateProvisioning
571572
case HTTP_CLIENT_COMPLETE: {
572573
// Determine if the network has failed
573574
if (networkIsShuttingDown(NETWORK_USER_HTTP_CLIENT))

Firmware/RTK_Everywhere/MQTT_Client.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@ void mqttClientReceiveMessage(int messageSize)
377377

378378
settings.pointPerfectNextKeyDuration = (1000LL * 60 * 60 * 24 * 28) - 1; // Assume next key duration is 28 days
379379

380+
settings.lastKeyAttempt = rtc.getEpoch(); // Mark it
381+
382+
recordSystemSettings(); // Record these settings to unit
383+
380384
if (settings.debugCorrections == true)
381385
pointperfectPrintKeyInformation();
382386
}

Firmware/RTK_Everywhere/Network.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,8 @@ void networkUpdate()
12791279
tcpServerUpdate(); // Turn on the TCP server as needed
12801280
DMW_c("udpServerUpdate");
12811281
udpServerUpdate(); // Turn on the UDP server as needed
1282+
DMW_c("httpClientUpdate");
1283+
httpClientUpdate(); // Process any Point Perfect HTTP messages
12821284

12831285
// Display the IP addresses
12841286
DMW_c("networkPeriodicallyDisplayIpAddress");

Firmware/RTK_Everywhere/RTK_Everywhere.ino

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181

8282
bool RTK_CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC = false; // Flag used by the special build of libmbedtls (libmbedcrypto) to select external memory
8383

84-
bool httpClientModeNeeded = false; // This is set to true by pointperfectProvisionDevice
84+
volatile bool httpClientModeNeeded = false; // This is set to true by updateProvisioning
8585

8686
#define THINGSTREAM_SERVER "api.thingstream.io" //!< the thingstream Rest API server domain
8787
#define THINGSTREAM_ZTPPATH "/ztp/pointperfect/credentials" //!< ZTP rest api
@@ -411,7 +411,6 @@ int64_t ARPECEFZ;
411411
uint16_t ARPECEFH;
412412

413413
const byte haeNumberOfDecimals = 8; // Used for printing and transmitting lat/lon
414-
bool lBandForceGetKeys; // Used to allow key update from display
415414
unsigned long rtcmLastPacketReceived; // Time stamp of RTCM coming in (from BT, NTRIP, etc)
416415
// Monitors the last time we received RTCM. Proctors PMP vs RTCM prioritization.
417416

@@ -815,6 +814,8 @@ unsigned long lastGnssToPpl = 0;
815814
// Command processing
816815
int commandCount;
817816
int16_t *commandIndex;
817+
818+
volatile bool forceKeyAttempt = false; // Set to true to force a key provisioning attempt
818819
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
819820

820821
// Display boot times
@@ -1238,6 +1239,9 @@ void loop()
12381239
DMW_c("updateCorrectionsPriorities");
12391240
updateCorrectionsPriorities(); // Update registeredCorrectionsSources, delete expired sources
12401241

1242+
DMW_c("updateProvisioning");
1243+
updateProvisioning(); // Check if we should attempt to connect to PointPerfect to get keys / certs / correction topic etc.
1244+
12411245
delay(10); // A small delay prevents panic if no other I2C or functions are called
12421246
}
12431247

0 commit comments

Comments
 (0)