Skip to content

Commit 59bf347

Browse files
authored
Merge branch 'release_candidate' into uptime
2 parents 3551796 + ee50be2 commit 59bf347

32 files changed

+837
-273
lines changed

Firmware/RTK_Surveyor/AP-Config/index.html

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -102,57 +102,73 @@ <h2>
102102
</div>
103103
<div class="collapse mb-2" id="collapseProfileConfig">
104104
<div class="card card-body">
105-
<div class="form-group row">
106-
<label for="profileNumber" class="box-margin20 col-sm-3 col-4 col-form-label">Profile Number</label>
107-
<div class="col-sm-8 col-7">
108-
<input type="number" class="form-control mb-2" id="profileNumber">
109-
<p id="profileNumberError" class="inlineError"></p>
110-
</div>
111-
</div>
112105

113-
<div class="form-group row">
114-
<label for="profileName" class="box-margin20 col-sm-3 col-4 col-form-label">Profile Name</label>
115-
<div class="col-sm-8 col-7">
116-
<input type="text" class="form-control" id="profileName">
117-
<p id="profileNameError" class="inlineError"></p>
118-
</div>
106+
<div class="form-group mt-2">
107+
Profile:
108+
<span class="tt" data-bs-placement="right"
109+
title="Select a profile and then assign settings to that profile. At reset, RTK device will use selected profile. Profile changes are saved when a different profile is selected or when 'Save Configuration' is pressed.">
110+
<span class="icon-info-circle text-primary ms-2"></span>
111+
</span>
119112
</div>
120113

121-
<div class="form-group row mt-2">
122-
<span id="activeProfiles" style="display:inline; margin-left:20px;"><Strong>Profiles</strong></span>
123-
</div>
124114
<div class="form-group row">
125-
<span id="profile0Name" style="display:inline; margin-left:40px;">1: 12345678901234567890123456789012345678901234567890</span>
115+
<span style="display:inline; margin-left:20px;">
116+
<input type="radio" name="profileRadio" value="0">
117+
<label id="profile0Name">Profile1</label>
118+
</span>
126119
</div>
127120
<div class="form-group row">
128-
<span id="profile1Name" style="display:inline; margin-left:40px;">2: 12345678901234567890123456789012345678901234567890</span>
121+
<span style="display:inline; margin-left:20px;">
122+
<input type="radio" name="profileRadio" value="1">
123+
<label id="profile1Name">12345678901234567890123456789012345678901234567890</label>
124+
</span>
129125
</div>
130126
<div class="form-group row">
131-
<span id="profile2Name" style="display:inline; margin-left:40px;">3: 12345678901234567890123456789012345678901234567890</span>
127+
<span style="display:inline; margin-left:20px;">
128+
<input type="radio" name="profileRadio" value="2">
129+
<label id="profile2Name">12345678901234567890123456789012345678901234567890</label>
130+
</span>
132131
</div>
133132
<div class="form-group row">
134-
<span id="profile3Name" style="display:inline; margin-left:40px;">4: 12345678901234567890123456789012345678901234567890</span>
133+
<span style="display:inline; margin-left:20px;">
134+
<input type="radio" name="profileRadio" value="3">
135+
<label id="profile3Name">12345678901234567890123456789012345678901234567890</label>
136+
</span>
135137
</div>
136138
<div class="form-group row">
137-
<span id="profile4Name" style="display:inline; margin-left:40px;">5: 12345678901234567890123456789012345678901234567890</span>
139+
<span style="display:inline; margin-left:20px;">
140+
<input type="radio" name="profileRadio" value="4">
141+
<label id="profile4Name">12345678901234567890123456789012345678901234567890</label>
142+
</span>
138143
</div>
139144
<div class="form-group row">
140-
<span id="profile5Name" style="display:inline; margin-left:40px;">6: 12345678901234567890123456789012345678901234567890</span>
145+
<span style="display:inline; margin-left:20px;">
146+
<input type="radio" name="profileRadio" value="5">
147+
<label id="profile5Name">12345678901234567890123456789012345678901234567890</label>
148+
</span>
141149
</div>
142150
<div class="form-group row">
143-
<span id="profile6Name" style="display:inline; margin-left:40px;">7: 12345678901234567890123456789012345678901234567890</span>
151+
<span style="display:inline; margin-left:20px;">
152+
<input type="radio" name="profileRadio" value="6">
153+
<label id="profile6Name">12345678901234567890123456789012345678901234567890</label>
154+
</span>
144155
</div>
145-
<div class="form-group row mb-3">
146-
<span id="profile7Name" style="display:inline; margin-left:40px;">8: 12345678901234567890123456789012345678901234567890</span>
156+
<div class="form-group row">
157+
<span style="display:inline; margin-left:20px;">
158+
<input type="radio" name="profileRadio" value="7">
159+
<label id="profile7Name">12345678901234567890123456789012345678901234567890</label>
160+
</span>
147161
</div>
148162

149163
<div class="form-group row">
150-
<label for="bootProfileName" class="box-margin20 col-sm-3 col-4 col-form-label">Boot Profile</label>
164+
<label for="profileName" class="box-margin20 col-sm-3 col-4 col-form-label">Profile Name:</label>
151165
<div class="col-sm-8 col-7">
152-
<input type="text" class="form-control" id="bootProfileNumber">
153-
<p id="bootProfileNumberError" class="inlineError"></p>
166+
<input type="text" class="form-control" id="profileName">
167+
<p id="profileNameError" class="inlineError"></p>
154168
</div>
169+
<p id="profileChangeMessage" class="inlineSuccess"></p>
155170
</div>
171+
156172
</div>
157173
</div>
158174

@@ -917,7 +933,7 @@ <h2>
917933

918934
<div id="surveyInRadio">
919935
<input type="radio" id="baseTypeSurveyIn" name="baseType" class="form-radio" checked>
920-
<label for="baseTypeSurveyIn"><strong>Survey-In</strong></label>
936+
<label for="baseTypeSurveyIn">Survey-In</label>
921937
<span class="tt" data-bs-placement="right"
922938
title="If the precise location of a base station is not known it may be obtained by ‘surveying’ the location. The base is fixed in one place and takes approximately 60 seconds worth of readings to obtain a best fit location based on the measurements. This method achieves ~30cm accurate position but can vary. Increasing the Minimum Observation Time and/or Required Mean Deviation will increase accuracy but only to a point. Better accuracy is achieved with long-term logging and post processing. Default: 60s and 5.0m. Limits: 60 to 900s, 1.0 to 5.0m.">
923939
<span class="icon-info-circle text-primary ms-2"></span>
@@ -947,7 +963,7 @@ <h2>
947963

948964
<div id="fixedRadio">
949965
<input type="radio" id="baseTypeFixed" name="baseType" value="1" class="form-radio">
950-
<label for="baseTypeFixed"><strong>Fixed</strong> <span class="small">(Choose ECEF or
966+
<label for="baseTypeFixed">Fixed<span class="small">(Choose ECEF or
951967
Geodetic)</span></label>
952968
<span class="tt" data-bs-placement="right"
953969
title="If the location of the base is known it can be entered in either ECEF or Geodetic coordinates. In this mode the receiver will immediately begin outputting RTCM correction data. A fixed position is best obtained with PPP (please see our tutorial) or with post processing against a reference station. Default: SparkFun's location in Boulder, Colorado.">
@@ -1437,7 +1453,7 @@ <h2>
14371453
<hr>
14381454
<div class="row">
14391455
<div align="center" class="col-sm-5 offset-sm-1 col-12 offset-0 mb-2">
1440-
<button type="button" id="saveBtn" class="btn btn-secondary" onclick="validateFields()">Save
1456+
<button type="button" id="saveBtn" class="btn btn-secondary" onclick="saveConfig()">Save
14411457
Configuration <span class="icon-save ms-1"></span></button>
14421458
<p id="saveBtnError" class="inlineError"></p>
14431459
<p id="saveBtnSuccess" class="inlineSuccess"></p>

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

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ function parseIncoming(msg) {
9595
) {
9696
ge(id).innerHTML = val;
9797
}
98+
else if (id.includes("profileNumber")) {
99+
currentProfileNumber = val;
100+
$("input[name=profileRadio][value=" + currentProfileNumber + "]").prop('checked', true);
101+
}
98102
else if (id.includes("firmwareUploadComplete")) {
99103
firmwareUploadComplete();
100104
}
@@ -129,10 +133,9 @@ function parseIncoming(msg) {
129133
}
130134
//console.log("Settings loaded");
131135

136+
ge("profileChangeMessage").innerHTML = '';
137+
132138
//Force element updates
133-
ge("profileNumber").dispatchEvent(new CustomEvent('change'));
134-
ge("profileName").dispatchEvent(new CustomEvent('change'));
135-
ge("bootProfileNumber").dispatchEvent(new CustomEvent('change'));
136139
ge("measurementRateHz").dispatchEvent(new CustomEvent('change'));
137140
ge("baseTypeSurveyIn").dispatchEvent(new CustomEvent('change'));
138141
ge("baseTypeFixed").dispatchEvent(new CustomEvent('change'));
@@ -217,9 +220,7 @@ function validateFields() {
217220
errorCount = 0;
218221

219222
//Profile Config
220-
checkElementValue("profileNumber", 1, 8, "Must be between 1 and 8", "collapseProfileConfig");
221223
checkElementString("profileName", 1, 49, "Must be 1 to 49 characters", "collapseProfileConfig");
222-
checkBitMapValue("bootProfileNumber", 1, 8, "activeProfiles", "Must be an active profile between 1 and 8", "collapseProfileConfig");
223224

224225
//GNSS Config
225226
checkElementValue("measurementRateHz", 0.00012, 10, "Must be between 0.00012 and 10Hz", "collapseGNSSConfig");
@@ -438,31 +439,63 @@ function validateFields() {
438439
ge("externalPulsePolarity").value = 0;
439440
}
440441
}
442+
}
443+
444+
var currentProfileNumber = 0;
445+
446+
function changeConfig() {
447+
validateFields();
441448

442449
if (errorCount == 1) {
443450
showError('saveBtn', "Please clear " + errorCount + " error");
444451
clearSuccess('saveBtn');
452+
$("input[name=profileRadio][value=" + currentProfileNumber + "]").prop('checked', true);
445453
}
446454
else if (errorCount > 1) {
447455
showError('saveBtn', "Please clear " + errorCount + " errors");
448456
clearSuccess('saveBtn');
457+
$("input[name=profileRadio][value=" + currentProfileNumber + "]").prop('checked', true);
449458
}
450459
else {
451-
//Update the profile name
452-
profile = "profile" + ge("bootProfileNumber").value + "Name";
453-
console.log(ge("bootProfileNumber").value);
454-
console.log(profile);
455-
console.log(ge(profile).value);
456-
console.log(ge("profileName").value);
457-
ge(profile).value = ge("profileName").value;
458-
console.log(ge(profile).value);
459-
ge(profile).dispatchEvent(new CustomEvent('change'));
460+
ge("profileChangeMessage").innerHTML = 'Loading. Please wait...';
461+
462+
currentProfileNumber = document.querySelector('input[name=profileRadio]:checked').value;
463+
464+
sendData();
465+
clearError('saveBtn');
466+
showSuccess('saveBtn', "All saved!");
467+
468+
ws.send("setProfile," + currentProfileNumber + ",");
469+
470+
ge("collapseProfileConfig").classList.add('show');
471+
ge("collapseGNSSConfig").classList.add('show');
472+
collapseSection("collapseGNSSConfigMsg", "gnssMsgCaret");
473+
collapseSection("collapseBaseConfig", "baseCaret");
474+
collapseSection("collapseSensorConfig", "sensorCaret");
475+
collapseSection("collapsePPConfig", "pointPerfectCaret");
476+
collapseSection("collapsePortsConfig", "portsCaret");
477+
collapseSection("collapseSystemConfig", "systemCaret");
478+
}
479+
}
460480

481+
function saveConfig() {
482+
validateFields();
483+
484+
if (errorCount == 1) {
485+
showError('saveBtn', "Please clear " + errorCount + " error");
486+
clearSuccess('saveBtn');
487+
}
488+
else if (errorCount > 1) {
489+
showError('saveBtn', "Please clear " + errorCount + " errors");
490+
clearSuccess('saveBtn');
491+
}
492+
else {
461493
//Tell Arduino we're ready to save
462494
sendData();
463495
clearError('saveBtn');
464496
showSuccess('saveBtn', "All saved!");
465497
}
498+
466499
}
467500

468501
function checkConstellations() {
@@ -659,6 +692,13 @@ function firmwareUploadComplete() {
659692

660693
document.addEventListener("DOMContentLoaded", (event) => {
661694

695+
var radios = document.querySelectorAll('input[name=profileRadio]');
696+
for(var i = 0, max = radios.length; i < max; i++) {
697+
radios[i].onclick = function() {
698+
changeConfig();
699+
}
700+
}
701+
662702
ge("measurementRateHz").addEventListener("change", function () {
663703
ge("measurementRateSec").value = 1.0 / ge("measurementRateHz").value;
664704
});

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void beginSD()
227227
while (tries < maxTries)
228228
{
229229
if (sdPresent() == true) break;
230-
log_d("SD present failed. Trying again %d out of %d", tries + 1, maxTries);
230+
//log_d("SD present failed. Trying again %d out of %d", tries + 1, maxTries);
231231

232232
//Max power up time is 250ms: https://www.kingston.com/datasheets/SDCIT-specsheet-64gb_en.pdf
233233
//Max current is 200mA average across 1s, peak 300mA

Firmware/RTK_Surveyor/Form.ino

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void startWebServer()
1414
{
1515
csd_t csd;
1616
sd->card()->readCSD(&csd); //Card Specific Data
17-
sdCardSizeMB = 0.000512 * sdCardCapacity(&csd);
17+
sdCardSizeMB = 0.000512 * sd->card()->sectorCount();
1818
sd->volumeBegin();
1919

2020
//Find available cluster/space
@@ -410,8 +410,8 @@ void createSettingsString(char* settingsCSV)
410410
stringRecord(settingsCSV, "enableExternalHardwareEventLogging", settings.enableExternalHardwareEventLogging);
411411

412412
//Profiles
413-
stringRecord(settingsCSV, "profileNumber", profileNumber + 1);
414-
stringRecord(settingsCSV, "profileName", profileNames[profileNumber]);
413+
stringRecord(settingsCSV, "profileName", profileNames[profileNumber]); //Must come before profile number so AP config page JS has name before number
414+
stringRecord(settingsCSV, "profileNumber", profileNumber);
415415
for (int index = 0; index < MAX_PROFILE_COUNT; index++)
416416
{
417417
sprintf(tagText, "profile%dName", index);
@@ -507,8 +507,8 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
507507
else if (strcmp(settingName, "profileNumber") == 0)
508508
{
509509
if ((sscanf(settingValueStr, "%d", &newProfileNumber) == 1)
510-
&& (newProfileNumber >= 1) && (newProfileNumber <= MAX_PROFILE_COUNT)
511-
&& (profileNumber != newProfileNumber))
510+
&& (newProfileNumber >= 1) && (newProfileNumber <= MAX_PROFILE_COUNT)
511+
&& (profileNumber != newProfileNumber))
512512
{
513513
profileNumber = newProfileNumber - 1;
514514

@@ -520,10 +520,10 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
520520
else if (strcmp(settingName, "bootProfileNumber") == 0)
521521
{
522522
if ((sscanf(settingValueStr, "%d", &bootProfileNumber) != 1)
523-
|| (bootProfileNumber < 1)
524-
|| (bootProfileNumber > (MAX_PROFILE_COUNT + 1)))
523+
|| (bootProfileNumber < 1)
524+
|| (bootProfileNumber > (MAX_PROFILE_COUNT + 1)))
525525
bootProfileNumber = 1;
526-
Serial.printf("bootProfileNumber: %d\r\n", bootProfileNumber);
526+
Serial.printf("bootProfileNumber: %d\r\n", bootProfileNumber);
527527
}
528528
else if (strcmp(settingName, "enableNtripServer") == 0)
529529
settings.enableNtripServer = settingValueBool;
@@ -608,6 +608,21 @@ Serial.printf("bootProfileNumber: %d\r\n", bootProfileNumber);
608608
//Reboot the machine
609609
ESP.restart();
610610
}
611+
else if (strcmp(settingName, "setProfile") == 0)
612+
{
613+
//Change to new profile
614+
changeProfileNumber(settingValue);
615+
616+
//Load new profile into system
617+
loadSettings();
618+
619+
//Send settings to browser
620+
char settingsCSV[AP_CONFIG_SETTING_SIZE];
621+
memset(settingsCSV, 0, sizeof(settingsCSV));
622+
createSettingsString(settingsCSV);
623+
log_d("Sending command: %s\n\r", settingsCSV);
624+
ws.textAll(String(settingsCSV));
625+
}
611626

612627
//Check for bulk settings (constellations and message rates)
613628
//Must be last on else list
@@ -741,7 +756,7 @@ bool parseIncomingSettings()
741756
headPtr = commaPtr + 1;
742757
}
743758

744-
log_d("settingName: %s value: %s", settingName, valueStr);
759+
//log_d("settingName: %s value: %s", settingName, valueStr);
745760

746761
updateSettingWithValue(settingName, valueStr);
747762
}

0 commit comments

Comments
 (0)