Skip to content

Commit 1b4e515

Browse files
committed
Merge branch 'release_candidate' into Resolve_#267
2 parents 82fb96d + 3f68aeb commit 1b4e515

File tree

6 files changed

+84
-53
lines changed

6 files changed

+84
-53
lines changed

Firmware/RTK_Everywhere/AP-Config/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@
806806
<button class="btn btn-md btn-outline-primary mt-3 toggle-btn"
807807
type="button" data-toggle="collapse" data-target="#ntripServerConfig0"
808808
aria-expanded="false" aria-controls="ntripServerConfig0">
809-
NTRIP Server 0 <i class="caret-icon bi icon-caret-down"></i>
809+
NTRIP Server 1 <i class="caret-icon bi icon-caret-down"></i>
810810
</button>
811811
</div>
812812

@@ -879,7 +879,7 @@
879879
<button class="btn btn-md btn-outline-primary mt-3 toggle-btn"
880880
type="button" data-toggle="collapse" data-target="#ntripServerConfig1"
881881
aria-expanded="false" aria-controls="ntripServerConfig1">
882-
NTRIP Server 1 <i class="caret-icon bi icon-caret-down"></i>
882+
NTRIP Server 2 <i class="caret-icon bi icon-caret-down"></i>
883883
</button>
884884
</div>
885885

@@ -952,7 +952,7 @@
952952
<button class="btn btn-md btn-outline-primary mt-3 toggle-btn"
953953
type="button" data-toggle="collapse" data-target="#ntripServerConfig2"
954954
aria-expanded="false" aria-controls="ntripServerConfig2">
955-
NTRIP Server 2 <i class="caret-icon bi icon-caret-down"></i>
955+
NTRIP Server 3 <i class="caret-icon bi icon-caret-down"></i>
956956
</button>
957957
</div>
958958

@@ -1025,7 +1025,7 @@
10251025
<button class="btn btn-md btn-outline-primary mt-3 toggle-btn"
10261026
type="button" data-toggle="collapse" data-target="#ntripServerConfig3"
10271027
aria-expanded="false" aria-controls="ntripServerConfig3">
1028-
NTRIP Server 3 <i class="caret-icon bi icon-caret-down"></i>
1028+
NTRIP Server 4 <i class="caret-icon bi icon-caret-down"></i>
10291029
</button>
10301030
</div>
10311031

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

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ function sendData() {
481481
//Check boxes, radio buttons
482482
//Remove file manager files
483483
clsElements = document.querySelectorAll(".form-check-input:not(.fileManagerCheck), .form-radio");
484-
485484
for (let x = 0; x < clsElements.length; x++) {
486485
settingCSV += clsElements[x].id + "," + clsElements[x].checked + ",";
487486
}
@@ -688,10 +687,10 @@ function validateFields() {
688687
}
689688

690689
if (ge("enableNtripServer").checked == true) {
691-
checkElementString("ntripServerCasterHost_0", 1, 30, "Must be 1 to 30 characters", "collapseBaseConfigNTRIP");
690+
checkElementString("ntripServerCasterHost_0", 1, 49, "Must be 1 to 49 characters", "collapseBaseConfigNTRIP");
692691
checkElementValue("ntripServerCasterPort_0", 1, 99999, "Must be 1 to 99999", "collapseBaseConfigNTRIP");
693-
checkElementString("ntripServerMountPoint_0", 1, 30, "Must be 1 to 30 characters", "collapseBaseConfigNTRIP");
694-
checkElementString("ntripServerMountPointPW_0", 1, 30, "Must be 1 to 30 characters", "collapseBaseConfigNTRIP");
692+
checkElementString("ntripServerMountPoint_0", 1, 49, "Must be 1 to 49 characters", "collapseBaseConfigNTRIP");
693+
checkElementString("ntripServerMountPointPW_0", 1, 49, "Must be 1 to 49 characters", "collapseBaseConfigNTRIP");
695694
}
696695
else {
697696
clearElement("ntripServerCasterHost_0", "rtk2go.com");
@@ -732,14 +731,14 @@ function validateFields() {
732731
}
733732

734733
//WiFi Config
735-
checkElementString("wifiNetwork_0SSID", 0, 50, "Must be 0 to 50 characters", "collapseWiFiConfig");
736-
checkElementString("wifiNetwork_0Password", 0, 50, "Must be 0 to 50 characters", "collapseWiFiConfig");
737-
checkElementString("wifiNetwork_1SSID", 0, 50, "Must be 0 to 50 characters", "collapseWiFiConfig");
738-
checkElementString("wifiNetwork_1Password", 0, 50, "Must be 0 to 50 characters", "collapseWiFiConfig");
739-
checkElementString("wifiNetwork_2SSID", 0, 50, "Must be 0 to 50 characters", "collapseWiFiConfig");
740-
checkElementString("wifiNetwork_2Password", 0, 50, "Must be 0 to 50 characters", "collapseWiFiConfig");
741-
checkElementString("wifiNetwork_3SSID", 0, 50, "Must be 0 to 50 characters", "collapseWiFiConfig");
742-
checkElementString("wifiNetwork_3Password", 0, 50, "Must be 0 to 50 characters", "collapseWiFiConfig");
734+
checkElementString("wifiNetwork_0SSID", 0, 49, "Must be 0 to 49 characters", "collapseWiFiConfig");
735+
checkElementString("wifiNetwork_0Password", 0, 49, "Must be 0 to 49 characters", "collapseWiFiConfig");
736+
checkElementString("wifiNetwork_1SSID", 0, 49, "Must be 0 to 49 characters", "collapseWiFiConfig");
737+
checkElementString("wifiNetwork_1Password", 0, 49, "Must be 0 to 49 characters", "collapseWiFiConfig");
738+
checkElementString("wifiNetwork_2SSID", 0, 49, "Must be 0 to 49 characters", "collapseWiFiConfig");
739+
checkElementString("wifiNetwork_2Password", 0, 49, "Must be 0 to 49 characters", "collapseWiFiConfig");
740+
checkElementString("wifiNetwork_3SSID", 0, 49, "Must be 0 to 49 characters", "collapseWiFiConfig");
741+
checkElementString("wifiNetwork_3Password", 0, 49, "Must be 0 to 49 characters", "collapseWiFiConfig");
743742
if (ge("enableTcpClient").checked == true) {
744743
checkElementString("tcpClientPort", 1, 65535, "Must be 1 to 65535", "collapseWiFiConfig");
745744
}
@@ -1009,7 +1008,7 @@ function checkElementIPAddress(id, errorText, collapseID) {
10091008

10101009
function checkElementCasterUser(id, badUserName, errorText, collapseID) {
10111010
if (ge("ntripClientCasterHost").value.toLowerCase() == "rtk2go.com") {
1012-
checkElementString(id, 1, 50, errorText, collapseID);
1011+
checkElementString(id, 1, 49, errorText, collapseID);
10131012
}
10141013
else
10151014
clearError(id);

Firmware/RTK_Everywhere/Display.ino

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2060,6 +2060,10 @@ void displayWiFiConfig()
20602060
else if (WiFi.getMode() == WIFI_AP)
20612061
snprintf(mySSID, sizeof(mySSID), "%s", "RTK Config");
20622062

2063+
// If we are in AP+STA mode, still display RTK Config
2064+
else if (WiFi.getMode() == WIFI_AP_STA)
2065+
snprintf(mySSID, sizeof(mySSID), "%s", "RTK Config");
2066+
20632067
else
20642068
snprintf(mySSID, sizeof(mySSID), "%s", "Error");
20652069
}
@@ -2093,7 +2097,7 @@ void displayWiFiConfig()
20932097

20942098
#ifdef COMPILE_AP
20952099
IPAddress myIpAddress;
2096-
if (WiFi.getMode() == WIFI_AP)
2100+
if ((WiFi.getMode() == WIFI_AP) || (WiFi.getMode() == WIFI_AP_STA))
20972101
myIpAddress = WiFi.softAPIP();
20982102
else
20992103
myIpAddress = WiFi.localIP();

Firmware/RTK_Everywhere/WiFi.ino

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ void wifiUpdate()
388388
break;
389389
}
390390

391-
// Process DNS when we are in AP mode for captive portal
392-
if (WiFi.getMode() == WIFI_AP && settings.enableCaptivePortal)
391+
// Process DNS when we are in AP mode or AP+STA mode for captive portal
392+
if (((WiFi.getMode() == WIFI_AP) || (WiFi.getMode() == WIFI_AP_STA)) && settings.enableCaptivePortal)
393393
{
394394
dnsServer.processNextRequest();
395395
}
@@ -435,7 +435,7 @@ void wifiStop()
435435
MDNS.end();
436436

437437
// Stop the DNS server if we were using the captive portal
438-
if (WiFi.getMode() == WIFI_AP && settings.enableCaptivePortal)
438+
if (((WiFi.getMode() == WIFI_AP) || (WiFi.getMode() == WIFI_AP_STA)) && settings.enableCaptivePortal)
439439
dnsServer.stop();
440440

441441
// Stop the other network clients and then WiFi
@@ -486,16 +486,40 @@ bool wifiIsConnected()
486486
// Attempts a connection to all provided SSIDs
487487
// Returns true if successful
488488
// Gives up if no SSID detected or connection times out
489+
// If useAPSTAMode is true, do an extra check and go from WIFI_AP mode to WIFI_AP_STA mode
489490
bool wifiConnect(unsigned long timeout)
491+
{
492+
return wifiConnect(timeout, false, nullptr);
493+
}
494+
bool wifiConnect(unsigned long timeout, bool useAPSTAMode, bool *wasInAPmode)
490495
{
491496
if (wifiIsConnected())
492497
return (true); // Nothing to do
493498

494499
displayWiFiConnect();
495500

496-
// Before we can issue esp_wifi_() commands WiFi must be started
497-
if (WiFi.getMode() != WIFI_STA)
498-
WiFi.mode(WIFI_STA);
501+
// If otaUpdate or otaCheckVersion wants to use WIFI_AP_STA mode
502+
if (useAPSTAMode && (wasInAPmode != nullptr))
503+
{
504+
*wasInAPmode = (WiFi.getMode() == WIFI_AP);
505+
506+
if (*wasInAPmode)
507+
{
508+
systemPrintln("wifiConnect: changing from WIFI_AP to WIFI_AP_STA");
509+
WiFi.mode(WIFI_AP_STA); // Change mode from WIFI_AP to WIFI_AP_STA
510+
}
511+
else
512+
{
513+
systemPrintln("wifiConnect: was not in WIFI_AP mode. Going to WIFI_STA");
514+
WiFi.mode(WIFI_STA); // Must have been off - or already in STA mode?
515+
}
516+
}
517+
else
518+
{
519+
// Before we can issue esp_wifi_() commands WiFi must be started
520+
if (WiFi.getMode() != WIFI_STA)
521+
WiFi.mode(WIFI_STA);
522+
}
499523

500524
// Verify that the necessary protocols are set
501525
uint8_t protocols = 0;

Firmware/RTK_Everywhere/menuCommands.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ bool updateSettingWithValue(const char *settingName, const char *settingValueStr
719719
char newVersionCSV[100];
720720

721721
// Get firmware version from server
722+
// otaCheckVersion will call wifiConnect if needed
722723
if (otaCheckVersion(reportedVersion, sizeof(reportedVersion)))
723724
{
724725
// We got a version number, now determine if it's newer or not
@@ -756,7 +757,7 @@ bool updateSettingWithValue(const char *settingName, const char *settingValueStr
756757
sendStringToWebsocket((char *)"gettingNewFirmware,1,");
757758

758759
apConfigFirmwareUpdateInProcess = true;
759-
otaUpdate();
760+
otaUpdate(); // otaUpdate will call wifiConnect if needed. Also does previouslyConnected check
760761

761762
// We get here if WiFi failed to connect
762763
sendStringToWebsocket((char *)"gettingNewFirmware,ERROR,");

Firmware/RTK_Everywhere/menuFirmware.ino

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,34 +103,29 @@ void menuFirmware()
103103

104104
bool previouslyConnected = wifiIsConnected();
105105

106-
// Attempt to connect to local WiFi
107-
if (wifiConnect(10000) == true)
106+
// Get firmware version from server
107+
// otaCheckVersion will call wifiConnect if needed
108+
if (otaCheckVersion(reportedVersion, sizeof(reportedVersion)))
108109
{
109-
// Get firmware version from server
110-
if (otaCheckVersion(reportedVersion, sizeof(reportedVersion)))
110+
// We got a version number, now determine if it's newer or not
111+
char currentVersion[21];
112+
getFirmwareVersion(currentVersion, sizeof(currentVersion), enableRCFirmware);
113+
if (isReportedVersionNewer(reportedVersion, &currentVersion[1]) == true ||
114+
FIRMWARE_VERSION_MAJOR == 99 || settings.debugFirmwareUpdate == true)
111115
{
112-
// We got a version number, now determine if it's newer or not
113-
char currentVersion[21];
114-
getFirmwareVersion(currentVersion, sizeof(currentVersion), enableRCFirmware);
115-
if (isReportedVersionNewer(reportedVersion, &currentVersion[1]) == true ||
116-
FIRMWARE_VERSION_MAJOR == 99 || settings.debugFirmwareUpdate == true)
117-
{
118-
systemPrintln("New version detected");
119-
newOTAFirmwareAvailable = true;
120-
}
121-
else
122-
{
123-
systemPrintln("No new firmware available");
124-
}
116+
systemPrintln("New version detected");
117+
newOTAFirmwareAvailable = true;
125118
}
126119
else
127120
{
128-
// Failed to get version number
129-
systemPrintln("Failed to get version number from server.");
121+
systemPrintln("No new firmware available");
130122
}
131123
}
132124
else
133-
systemPrintln("Firmware update failed to connect to WiFi.");
125+
{
126+
// Failed to get version number
127+
systemPrintln("Failed to get version number from server.");
128+
}
134129

135130
if (previouslyConnected == false)
136131
WIFI_STOP();
@@ -165,14 +160,9 @@ void menuFirmware()
165160

166161
else if ((incoming == 'u') && newOTAFirmwareAvailable)
167162
{
168-
bool previouslyConnected = wifiIsConnected();
169-
170-
otaUpdate();
163+
otaUpdate(); // otaUpdate will call wifiConnect if needed. Also does previouslyConnected check
171164

172165
// We get here if WiFi failed or the server was not available
173-
174-
if (previouslyConnected == false)
175-
WIFI_STOP();
176166
}
177167

178168
else if (incoming == 'x')
@@ -481,7 +471,9 @@ bool otaCheckVersion(char *versionAvailable, uint8_t versionAvailableLength)
481471
#ifdef COMPILE_WIFI
482472
bool previouslyConnected = wifiIsConnected();
483473

484-
if (wifiConnect(10000) == true)
474+
bool wasInAPmode;
475+
476+
if (wifiConnect(10000, true, &wasInAPmode) == true) // Use WIFI_AP_STA if already in WIFI_AP mode
485477
{
486478
char versionString[21];
487479
getFirmwareVersion(versionString, sizeof(versionString), enableRCFirmware);
@@ -517,6 +509,11 @@ bool otaCheckVersion(char *versionAvailable, uint8_t versionAvailableLength)
517509
systemPrintln("WiFi not available.");
518510
}
519511

512+
// If we were in WIFI_AP mode, return to WIFI_AP mode
513+
// There may be some overlap with systemState STATE_WIFI_CONFIG ? Not sure...
514+
if (wasInAPmode)
515+
WiFi.mode(WIFI_AP);
516+
520517
if (systemState != STATE_WIFI_CONFIG)
521518
{
522519
// WIFI_STOP() turns off the entire radio including the webserver. We need to turn off Station mode only.
@@ -578,9 +575,15 @@ void otaUpdate()
578575
#ifdef COMPILE_WIFI
579576
bool previouslyConnected = wifiIsConnected();
580577

581-
if (wifiConnect(10000) == true)
578+
bool wasInAPmode;
579+
580+
if (wifiConnect(10000, true, &wasInAPmode) == true) // Use WIFI_AP_STA if already in WIFI_AP mode
582581
overTheAirUpdate();
583582

583+
// Update failed. If we were in WIFI_AP mode, return to WIFI_AP mode
584+
if (wasInAPmode)
585+
WiFi.mode(WIFI_AP);
586+
584587
// Update failed. If WiFi was originally off, turn it off again
585588
if (previouslyConnected == false)
586589
WIFI_STOP();

0 commit comments

Comments
 (0)