Skip to content

Commit c66a4f9

Browse files
authored
Merge pull request #670 from sparkfun/pr/662
Merging PR 662 with changes
2 parents 041c84a + 970b8ad commit c66a4f9

File tree

9 files changed

+438
-474
lines changed

9 files changed

+438
-474
lines changed

Firmware/RTK_Everywhere/AP-Config/src/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,6 +2424,7 @@ function newFirmwareVersion(firmwareVersion) {
24242424
return;
24252425
}
24262426

2427+
showMsg('firmwareCheckNewMsg', "New firmware available!");
24272428
ge("btnGetNewFirmware").innerHTML = "Update to v" + firmwareVersion;
24282429
ge("btnGetNewFirmware").disabled = false;
24292430
ge("firmwareUpdateProgressBar").value = 0;

Firmware/RTK_Everywhere/Network.ino

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,6 @@ void networkInterfaceInternetConnectionLost(NetIndex_t index)
12981298
return;
12991299
}
13001300

1301-
// Mark this network as offline
13021301
bitMask = 1 << index;
13031302

13041303
// If we are currently running a start sequence, do nothing
@@ -1310,6 +1309,7 @@ void networkInterfaceInternetConnectionLost(NetIndex_t index)
13101309
return;
13111310
}
13121311

1312+
// Mark this network as offline
13131313
networkHasInternet_bm &= ~bitMask;
13141314
if (settings.debugNetworkLayer)
13151315
systemPrintf("%s does NOT have internet access\r\n", networkInterfaceTable[index].name);
@@ -2399,14 +2399,11 @@ void networkUpdate()
23992399

24002400
// Display the IP address of the highest priority network
24012401
index = networkPriorityTable[networkPriority];
2402-
if ((index < NETWORK_OFFLINE)
2403-
&& networkInterfaceHasInternet(index)
2404-
&& networkInterfaceTable[index].netif->hasIP())
2402+
if ((index < NETWORK_OFFLINE) && networkInterfaceHasInternet(index) &&
2403+
networkInterfaceTable[index].netif->hasIP())
24052404
{
24062405
ipAddress = networkInterfaceTable[index].netif->localIP();
2407-
systemPrintf("%s: %s%s\r\n",
2408-
networkInterfaceTable[index].name,
2409-
ipAddress.toString().c_str(),
2406+
systemPrintf("%s: %s%s\r\n", networkInterfaceTable[index].name, ipAddress.toString().c_str(),
24102407
networkInterfaceTable[index].netif->isDefault() ? " (default)" : "");
24112408
}
24122409
else

Firmware/RTK_Everywhere/States.ino

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ void stateUpdate()
445445
// Allow for 750ms before we parse buffer for all data to arrive
446446
if (millis() - timeSinceLastIncomingSetting > 750)
447447
{
448+
bool changed;
449+
448450
currentlyParsingData =
449451
true; // Disallow new data to flow from websocket while we are parsing the current data
450452

@@ -453,7 +455,12 @@ void stateUpdate()
453455
systemWrite(incomingSettings[x]);
454456
systemPrintln();
455457

458+
//Create temporary copy of Settings, so that we can check if they change while parsing
459+
//Useful for detecting when we need to change WiFi station settings
460+
webServerSettingsClone();
461+
456462
parseIncomingSettings();
463+
457464
settings.gnssConfiguredOnce = false; // On the next boot, reapply all settings
458465
settings.gnssConfiguredBase = false;
459466
settings.gnssConfiguredRover = false;

Firmware/RTK_Everywhere/WebServer.ino

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static const char *const webServerStateNames[] = {
5252
static const int webServerStateEntries = sizeof(webServerStateNames) / sizeof(webServerStateNames[0]);
5353

5454
static uint8_t webServerState;
55+
static struct Settings * webServerPreviousSettings;
5556

5657
// Once connected to the access point for WiFi Config, the ESP32 sends current setting values in one long string to
5758
// websocket After user clicks 'save', data is validated via main.js and a long string of values is returned.
@@ -1124,6 +1125,35 @@ void webServerSetState(uint8_t newState)
11241125
reportFatalError("Web Server: Invalid web config state");
11251126
}
11261127

1128+
//----------------------------------------
1129+
// Check the web server settings and free the settings structure
1130+
//----------------------------------------
1131+
bool webServerSettingsCheckAndFree()
1132+
{
1133+
bool changed;
1134+
1135+
changed = false;
1136+
if (webServerPreviousSettings)
1137+
{
1138+
changed = wifiCheckSettings(webServerPreviousSettings);
1139+
rtkFree(webServerPreviousSettings, "WebServer previous settings");
1140+
webServerPreviousSettings = nullptr;
1141+
}
1142+
return changed;
1143+
}
1144+
1145+
//----------------------------------------
1146+
// Allocate the settings structure and clone the settings
1147+
//----------------------------------------
1148+
void webServerSettingsClone()
1149+
{
1150+
webServerPreviousSettings = (struct Settings *) rtkMalloc(sizeof(settings), "WebServer previous settings");
1151+
if (webServerPreviousSettings == nullptr)
1152+
systemPrintln("ERROR: Web Server failed to allocate previous settings!\r\n");
1153+
else
1154+
memcpy(webServerPreviousSettings, &settings, sizeof(settings));
1155+
}
1156+
11271157
//----------------------------------------
11281158
// Start the Web Server state machine
11291159
//----------------------------------------
@@ -1143,9 +1173,9 @@ void webServerStart()
11431173
systemPrintln("Web Server: Starting");
11441174

11451175
// Start the network
1146-
if (settings.wifiConfigOverAP == false)
1176+
if ((settings.wifiConfigOverAP == false) || networkHasInternet())
11471177
networkConsumerAdd(NETCONSUMER_WEB_CONFIG, NETWORK_ANY, __FILE__, __LINE__);
1148-
else
1178+
if (settings.wifiConfigOverAP)
11491179
networkSoftApConsumerAdd(NETCONSUMER_WEB_CONFIG, __FILE__, __LINE__);
11501180
webServerSetState(WEBSERVER_STATE_WAIT_FOR_NETWORK);
11511181
}

0 commit comments

Comments
 (0)