Skip to content

Commit 8757c13

Browse files
authored
Merge pull request #222 from LeeLeahy2/profiles
Display the profile names and select the boot profile using WiFi Config
2 parents fd09046 + 41db95d commit 8757c13

File tree

5 files changed

+149
-4
lines changed

5 files changed

+149
-4
lines changed

Firmware/RTK_Surveyor/AP-Config/index.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,42 @@ <h2>
117117
<p id="profileNameError" class="inlineError"></p>
118118
</div>
119119
</div>
120+
121+
<div class="form-group row mt-2">
122+
<span id="activeProfiles" style="display:inline; margin-left:20px;"><Strong>Profiles</strong></span>
123+
</div>
124+
<div class="form-group row">
125+
<span id="profile0Name" style="display:inline; margin-left:40px;">1: 12345678901234567890123456789012345678901234567890</span>
126+
</div>
127+
<div class="form-group row">
128+
<span id="profile1Name" style="display:inline; margin-left:40px;">2: 12345678901234567890123456789012345678901234567890</span>
129+
</div>
130+
<div class="form-group row">
131+
<span id="profile2Name" style="display:inline; margin-left:40px;">3: 12345678901234567890123456789012345678901234567890</span>
132+
</div>
133+
<div class="form-group row">
134+
<span id="profile3Name" style="display:inline; margin-left:40px;">4: 12345678901234567890123456789012345678901234567890</span>
135+
</div>
136+
<div class="form-group row">
137+
<span id="profile4Name" style="display:inline; margin-left:40px;">5: 12345678901234567890123456789012345678901234567890</span>
138+
</div>
139+
<div class="form-group row">
140+
<span id="profile5Name" style="display:inline; margin-left:40px;">6: 12345678901234567890123456789012345678901234567890</span>
141+
</div>
142+
<div class="form-group row">
143+
<span id="profile6Name" style="display:inline; margin-left:40px;">7: 12345678901234567890123456789012345678901234567890</span>
144+
</div>
145+
<div class="form-group row mb-3">
146+
<span id="profile7Name" style="display:inline; margin-left:40px;">8: 12345678901234567890123456789012345678901234567890</span>
147+
</div>
148+
149+
<div class="form-group row">
150+
<label for="bootProfileName" class="box-margin20 col-sm-3 col-4 col-form-label">Boot Profile</label>
151+
<div class="col-sm-8 col-7">
152+
<input type="text" class="form-control" id="bootProfileNumber">
153+
<p id="bootProfileNumberError" class="inlineError"></p>
154+
</div>
155+
</div>
120156
</div>
121157
</div>
122158

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ function parseIncoming(msg) {
8484
|| id.includes("zedFirmwareVersion")
8585
|| id.includes("hardwareID")
8686
|| id.includes("daysRemaining")
87+
|| id.includes("profile0Name")
88+
|| id.includes("profile1Name")
89+
|| id.includes("profile2Name")
90+
|| id.includes("profile3Name")
91+
|| id.includes("profile4Name")
92+
|| id.includes("profile5Name")
93+
|| id.includes("profile6Name")
94+
|| id.includes("profile7Name")
8795
) {
8896
ge(id).innerHTML = val;
8997
}
@@ -124,6 +132,7 @@ function parseIncoming(msg) {
124132
//Force element updates
125133
ge("profileNumber").dispatchEvent(new CustomEvent('change'));
126134
ge("profileName").dispatchEvent(new CustomEvent('change'));
135+
ge("bootProfileNumber").dispatchEvent(new CustomEvent('change'));
127136
ge("measurementRateHz").dispatchEvent(new CustomEvent('change'));
128137
ge("baseTypeSurveyIn").dispatchEvent(new CustomEvent('change'));
129138
ge("baseTypeFixed").dispatchEvent(new CustomEvent('change'));
@@ -208,8 +217,9 @@ function validateFields() {
208217
errorCount = 0;
209218

210219
//Profile Config
211-
checkElementValue("profileNumber", 1, 4, "Must be between 1 and 4", "collapseProfileConfig");
220+
checkElementValue("profileNumber", 1, 8, "Must be between 1 and 8", "collapseProfileConfig");
212221
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");
213223

214224
//GNSS Config
215225
checkElementValue("measurementRateHz", 0.00012, 10, "Must be between 0.00012 and 10Hz", "collapseGNSSConfig");
@@ -459,6 +469,19 @@ function checkConstellations() {
459469
clearError("ubxConstellations");
460470
}
461471

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+
462485
function checkElementValue(id, min, max, errorText, collapseID) {
463486
value = ge(id).value;
464487
if (value < min || value > max) {

Firmware/RTK_Surveyor/Form.ino

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//Once connected to the access point for WiFi Config, the ESP32 sends current setting values in one long string to websocket
22
//After user clicks 'save', data is validated via main.js and a long string of values is returned.
33

4+
static uint8_t bootProfileNumber;
5+
46
//Start webserver in AP mode
57
void startWebServer()
68
{
@@ -280,6 +282,9 @@ void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventT
280282
void createSettingsString(char* settingsCSV)
281283
{
282284
#ifdef COMPILE_AP
285+
char tagText[32];
286+
char nameText[64];
287+
283288
//System Info
284289
stringRecord(settingsCSV, "platformPrefix", platformPrefix);
285290

@@ -407,6 +412,15 @@ void createSettingsString(char* settingsCSV)
407412
//Profiles
408413
stringRecord(settingsCSV, "profileNumber", profileNumber + 1);
409414
stringRecord(settingsCSV, "profileName", profileNames[profileNumber]);
415+
for (int index = 0; index < MAX_PROFILE_COUNT; index++)
416+
{
417+
sprintf(tagText, "profile%dName", index);
418+
sprintf(nameText, "%d: %s", index + 1, profileNames[index]);
419+
stringRecord(settingsCSV, tagText, nameText);
420+
}
421+
bootProfileNumber = profileNumber + 1;
422+
stringRecord(settingsCSV, "bootProfileNumber", bootProfileNumber);
423+
stringRecord(settingsCSV, "activeProfiles", activeProfiles);
410424

411425
//New settings not yet integrated
412426
//...
@@ -503,7 +517,14 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
503517
recordProfileNumber(profileNumber);
504518
}
505519
}
506-
520+
else if (strcmp(settingName, "bootProfileNumber") == 0)
521+
{
522+
if ((sscanf(settingValueStr, "%d", &bootProfileNumber) != 1)
523+
|| (bootProfileNumber < 1)
524+
|| (bootProfileNumber > (MAX_PROFILE_COUNT + 1)))
525+
bootProfileNumber = 1;
526+
Serial.printf("bootProfileNumber: %d\r\n", bootProfileNumber);
527+
}
507528
else if (strcmp(settingName, "enableNtripServer") == 0)
508529
settings.enableNtripServer = settingValueBool;
509530
else if (strcmp(settingName, "ntripServer_CasterHost") == 0)
@@ -579,6 +600,12 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
579600
{
580601
if (newAPSettings == true) recordSystemSettings(); //If we've recieved settings, record before restart
581602

603+
//Determine which profile to boot
604+
bootProfileNumber -= 1;
605+
if (bootProfileNumber != profileNumber)
606+
recordProfileNumber(bootProfileNumber);
607+
608+
//Reboot the machine
582609
ESP.restart();
583610
}
584611

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ AsyncWebSocket ws("/ws");
310310

311311
//Because the incoming string is longer than max len, there are multiple callbacks so we
312312
//use a global to combine the incoming
313-
#define AP_CONFIG_SETTING_SIZE 3500
313+
#define AP_CONFIG_SETTING_SIZE 5000
314314
char incomingSettings[AP_CONFIG_SETTING_SIZE];
315315
int incomingSettingsSpot = 0;
316316
unsigned long timeSinceLastIncomingSetting = 0;

Firmware/RTK_Surveyor/form.h

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ function parseIncoming(msg) {
107107
|| id.includes("zedFirmwareVersion")
108108
|| id.includes("hardwareID")
109109
|| id.includes("daysRemaining")
110+
|| id.includes("profile0Name")
111+
|| id.includes("profile1Name")
112+
|| id.includes("profile2Name")
113+
|| id.includes("profile3Name")
114+
|| id.includes("profile4Name")
115+
|| id.includes("profile5Name")
116+
|| id.includes("profile6Name")
117+
|| id.includes("profile7Name")
110118
) {
111119
ge(id).innerHTML = val;
112120
}
@@ -147,6 +155,7 @@ function parseIncoming(msg) {
147155
//Force element updates
148156
ge("profileNumber").dispatchEvent(new CustomEvent('change'));
149157
ge("profileName").dispatchEvent(new CustomEvent('change'));
158+
ge("bootProfileNumber").dispatchEvent(new CustomEvent('change'));
150159
ge("measurementRateHz").dispatchEvent(new CustomEvent('change'));
151160
ge("baseTypeSurveyIn").dispatchEvent(new CustomEvent('change'));
152161
ge("baseTypeFixed").dispatchEvent(new CustomEvent('change'));
@@ -231,8 +240,9 @@ function validateFields() {
231240
errorCount = 0;
232241

233242
//Profile Config
234-
checkElementValue("profileNumber", 1, 4, "Must be between 1 and 4", "collapseProfileConfig");
243+
checkElementValue("profileNumber", 1, 8, "Must be between 1 and 8", "collapseProfileConfig");
235244
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");
236246

237247
//GNSS Config
238248
checkElementValue("measurementRateHz", 0.00012, 10, "Must be between 0.00012 and 10Hz", "collapseGNSSConfig");
@@ -482,6 +492,19 @@ function checkConstellations() {
482492
clearError("ubxConstellations");
483493
}
484494

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+
485508
function checkElementValue(id, min, max, errorText, collapseID) {
486509
value = ge(id).value;
487510
if (value < min || value > max) {
@@ -896,6 +919,42 @@ static const char *index_html = R"=====(
896919
<p id="profileNameError" class="inlineError"></p>
897920
</div>
898921
</div>
922+
923+
<div class="form-group row mt-2">
924+
<span id="activeProfiles" style="display:inline; margin-left:20px;"><Strong>Profiles</strong></span>
925+
</div>
926+
<div class="form-group row">
927+
<span id="profile0Name" style="display:inline; margin-left:40px;">1: 12345678901234567890123456789012345678901234567890</span>
928+
</div>
929+
<div class="form-group row">
930+
<span id="profile1Name" style="display:inline; margin-left:40px;">2: 12345678901234567890123456789012345678901234567890</span>
931+
</div>
932+
<div class="form-group row">
933+
<span id="profile2Name" style="display:inline; margin-left:40px;">3: 12345678901234567890123456789012345678901234567890</span>
934+
</div>
935+
<div class="form-group row">
936+
<span id="profile3Name" style="display:inline; margin-left:40px;">4: 12345678901234567890123456789012345678901234567890</span>
937+
</div>
938+
<div class="form-group row">
939+
<span id="profile4Name" style="display:inline; margin-left:40px;">5: 12345678901234567890123456789012345678901234567890</span>
940+
</div>
941+
<div class="form-group row">
942+
<span id="profile5Name" style="display:inline; margin-left:40px;">6: 12345678901234567890123456789012345678901234567890</span>
943+
</div>
944+
<div class="form-group row">
945+
<span id="profile6Name" style="display:inline; margin-left:40px;">7: 12345678901234567890123456789012345678901234567890</span>
946+
</div>
947+
<div class="form-group row mb-3">
948+
<span id="profile7Name" style="display:inline; margin-left:40px;">8: 12345678901234567890123456789012345678901234567890</span>
949+
</div>
950+
951+
<div class="form-group row">
952+
<label for="bootProfileName" class="box-margin20 col-sm-3 col-4 col-form-label">Boot Profile</label>
953+
<div class="col-sm-8 col-7">
954+
<input type="text" class="form-control" id="bootProfileNumber">
955+
<p id="bootProfileNumberError" class="inlineError"></p>
956+
</div>
957+
</div>
899958
</div>
900959
</div>
901960

0 commit comments

Comments
 (0)