Skip to content

Commit ccb192a

Browse files
committed
Validate the bootProfileNumber in WiFi Config
1 parent f7d2265 commit ccb192a

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

Firmware/RTK_Surveyor/AP-Config/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ <h2>
119119
</div>
120120

121121
<div class="form-group row mt-2">
122-
<span id="profileList" style="display:inline; margin-left:20px;"><Strong>Profiles</strong></span>
122+
<span id="activeProfiles" style="display:inline; margin-left:20px;"><Strong>Profiles</strong></span>
123123
</div>
124124
<div class="form-group row">
125125
<span id="profile0Name" style="display:inline; margin-left:40px;">1: 12345678901234567890123456789012345678901234567890</span>

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ function parseIncoming(msg) {
132132
//Force element updates
133133
ge("profileNumber").dispatchEvent(new CustomEvent('change'));
134134
ge("profileName").dispatchEvent(new CustomEvent('change'));
135+
ge("bootProfileNumber").dispatchEvent(new CustomEvent('change'));
135136
ge("measurementRateHz").dispatchEvent(new CustomEvent('change'));
136137
ge("baseTypeSurveyIn").dispatchEvent(new CustomEvent('change'));
137138
ge("baseTypeFixed").dispatchEvent(new CustomEvent('change'));
@@ -218,6 +219,7 @@ function validateFields() {
218219
//Profile Config
219220
checkElementValue("profileNumber", 1, 8, "Must be between 1 and 8", "collapseProfileConfig");
220221
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");
221223

222224
//GNSS Config
223225
checkElementValue("measurementRateHz", 0.00012, 10, "Must be between 0.00012 and 10Hz", "collapseGNSSConfig");
@@ -467,6 +469,19 @@ function checkConstellations() {
467469
clearError("ubxConstellations");
468470
}
469471

472+
function checkBitMapValue(id, min, max, bitMap, errorText, collapseID) {
473+
value = ge(id).value;
474+
mask = ge(bitMap).value;
475+
if ((value < min) || (value > max) || ((mask & (1 << value)) == 0)) {
476+
ge(id + 'Error').innerHTML = 'Error: ' + errorText;
477+
ge(collapseID).classList.add('show');
478+
errorCount++;
479+
}
480+
else {
481+
clearError(id);
482+
}
483+
}
484+
470485
function checkElementValue(id, min, max, errorText, collapseID) {
471486
value = ge(id).value;
472487
if (value < min || value > max) {

Firmware/RTK_Surveyor/Form.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
523523
|| (bootProfileNumber < 1)
524524
|| (bootProfileNumber > (MAX_PROFILE_COUNT + 1)))
525525
bootProfileNumber = 1;
526+
Serial.printf("bootProfileNumber: %d\r\n", bootProfileNumber);
526527
}
527528
else if (strcmp(settingName, "enableNtripServer") == 0)
528529
settings.enableNtripServer = settingValueBool;

Firmware/RTK_Surveyor/form.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ function parseIncoming(msg) {
155155
//Force element updates
156156
ge("profileNumber").dispatchEvent(new CustomEvent('change'));
157157
ge("profileName").dispatchEvent(new CustomEvent('change'));
158+
ge("bootProfileNumber").dispatchEvent(new CustomEvent('change'));
158159
ge("measurementRateHz").dispatchEvent(new CustomEvent('change'));
159160
ge("baseTypeSurveyIn").dispatchEvent(new CustomEvent('change'));
160161
ge("baseTypeFixed").dispatchEvent(new CustomEvent('change'));
@@ -241,6 +242,7 @@ function validateFields() {
241242
//Profile Config
242243
checkElementValue("profileNumber", 1, 8, "Must be between 1 and 8", "collapseProfileConfig");
243244
checkElementString("profileName", 1, 49, "Must be 1 to 49 characters", "collapseProfileConfig");
245+
checkBitMapValue("bootProfileNumber", 1, 8, "activeProfiles", "Must be an active profile between 1 and 8", "collapseProfileConfig");
244246

245247
//GNSS Config
246248
checkElementValue("measurementRateHz", 0.00012, 10, "Must be between 0.00012 and 10Hz", "collapseGNSSConfig");
@@ -490,6 +492,19 @@ function checkConstellations() {
490492
clearError("ubxConstellations");
491493
}
492494

495+
function checkBitMapValue(id, min, max, bitMap, errorText, collapseID) {
496+
value = ge(id).value;
497+
mask = ge(bitMap).value;
498+
if ((value < min) || (value > max) || ((mask & (1 << value)) == 0)) {
499+
ge(id + 'Error').innerHTML = 'Error: ' + errorText;
500+
ge(collapseID).classList.add('show');
501+
errorCount++;
502+
}
503+
else {
504+
clearError(id);
505+
}
506+
}
507+
493508
function checkElementValue(id, min, max, errorText, collapseID) {
494509
value = ge(id).value;
495510
if (value < min || value > max) {
@@ -906,7 +921,7 @@ static const char *index_html = R"=====(
906921
</div>
907922

908923
<div class="form-group row mt-2">
909-
<span id="profileList" style="display:inline; margin-left:20px;"><Strong>Profiles</strong></span>
924+
<span id="activeProfiles" style="display:inline; margin-left:20px;"><Strong>Profiles</strong></span>
910925
</div>
911926
<div class="form-group row">
912927
<span id="profile0Name" style="display:inline; margin-left:40px;">1: 12345678901234567890123456789012345678901234567890</span>

0 commit comments

Comments
 (0)