Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion Firmware/RTK_Surveyor/AP-Config/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,39 @@ <h2>
<div align="center" class="small">
<span id="rtkFirmwareVersion" style="display:inline;">RTK Firmware: v0.0</span> <br>
<span id="zedFirmwareVersion" style="display:inline;">ZED-F9P Firmware: v0.0</span> <br>
<span id="profileName" style="display:inline;">Profile Name: Default</span>
</div>
</div>

<hr class="mt-0">
<div style="margin-top:20px;">

<!-- --------- Profile Config --------- -->
<div class="d-grid gap-2">
<button class="btn btn-primary mt-3 toggle-btn" id="profileConfig" type="button" data-toggle="collapse"
data-target="#collapseProfileConfig" aria-expanded="false" aria-controls="collapseProfileConfig">
Profile Configuration <i id="profileCaret" class="caret-icon bi icon-caret-down"></i>
</button>
</div>
<div class="collapse mb-2" id="collapseProfileConfig">
<div class="card card-body">
<div class="form-group row">
<label for="profileNumber" class="box-margin20 col-sm-3 col-4 col-form-label">Profile Number</label>
<div class="col-sm-8 col-7">
<input type="number" class="form-control mb-2" id="profileNumber">
<p id="profileNumberError" class="inlineError"></p>
</div>
</div>

<div class="form-group row">
<label for="profileName" class="box-margin20 col-sm-3 col-4 col-form-label">Profile Name</label>
<div class="col-sm-8 col-7">
<input type="text" class="form-control" id="profileName">
<p id="profileNameError" class="inlineError"></p>
</div>
</div>
</div>
</div>

<!-- --------- GNSS Config --------- -->
<div class="d-grid gap-2">
<button class="btn btn-primary toggle-btn" type="button" data-toggle="collapse"
Expand Down
8 changes: 7 additions & 1 deletion Firmware/RTK_Surveyor/AP-Config/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ function parseIncoming(msg) {
|| id.includes("sdUsedSpace")
|| id.includes("rtkFirmwareVersion")
|| id.includes("zedFirmwareVersion")
|| id.includes("profileName")
|| id.includes("hardwareID")
|| id.includes("daysRemaining")
) {
Expand Down Expand Up @@ -123,6 +122,8 @@ function parseIncoming(msg) {
//console.log("Settings loaded");

//Force element updates
ge("profileNumber").dispatchEvent(new CustomEvent('change'));
ge("profileName").dispatchEvent(new CustomEvent('change'));
ge("measurementRateHz").dispatchEvent(new CustomEvent('change'));
ge("baseTypeSurveyIn").dispatchEvent(new CustomEvent('change'));
ge("baseTypeFixed").dispatchEvent(new CustomEvent('change'));
Expand Down Expand Up @@ -195,6 +196,7 @@ function collapseSection(section, caret) {

function validateFields() {
//Collapse all sections
collapseSection("collapseProfileConfig", "profileCaret");
collapseSection("collapseGNSSConfig", "gnssCaret");
collapseSection("collapseGNSSConfigMsg", "gnssMsgCaret");
collapseSection("collapseBaseConfig", "baseCaret");
Expand All @@ -205,6 +207,10 @@ function validateFields() {

errorCount = 0;

//Profile Config
checkElementValue("profileNumber", 1, 4, "Must be between 1 and 4", "collapseProfileConfig");
checkElementString("profileName", 1, 49, "Must be 1 to 49 characters", "collapseProfileConfig");

//GNSS Config
checkElementValue("measurementRateHz", 0.00012, 10, "Must be between 0.00012 and 10Hz", "collapseGNSSConfig");
checkConstellations();
Expand Down
22 changes: 19 additions & 3 deletions Firmware/RTK_Surveyor/Form.ino
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,8 @@ void createSettingsString(char* settingsCSV)
stringRecord(settingsCSV, "enableExternalHardwareEventLogging", settings.enableExternalHardwareEventLogging);

//Profiles
char apProfileName[50];
sprintf(apProfileName, "Profile Name: %s", settings.profileName);
stringRecord(settingsCSV, "profileName", apProfileName);
stringRecord(settingsCSV, "profileNumber", profileNumber + 1);
stringRecord(settingsCSV, "profileName", profileNames[profileNumber]);

//New settings not yet integrated
//...
Expand All @@ -423,6 +422,7 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
{
#ifdef COMPILE_AP
char* ptr;
int newProfileNumber;
double settingValue = strtod(settingValueStr, &ptr);

bool settingValueBool = false;
Expand Down Expand Up @@ -486,7 +486,23 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
else if (strcmp(settingName, "enableExternalHardwareEventLogging") == 0)
settings.enableExternalHardwareEventLogging = settingValueBool;
else if (strcmp(settingName, "profileName") == 0)
{
strcpy(settings.profileName, settingValueStr);
strcpy(profileNames[profileNumber], settingValueStr);
}
else if (strcmp(settingName, "profileNumber") == 0)
{
if ((sscanf(settingValueStr, "%d", &newProfileNumber) == 1)
&& (newProfileNumber >= 1) && (newProfileNumber <= MAX_PROFILE_COUNT)
&& (profileNumber != newProfileNumber))
{
profileNumber = newProfileNumber - 1;

//Switch to a new profile
setSettingsFileName();
recordProfileNumber(profileNumber);
}
}

else if (strcmp(settingName, "enableNtripServer") == 0)
settings.enableNtripServer = settingValueBool;
Expand Down
19 changes: 12 additions & 7 deletions Firmware/RTK_Surveyor/NVM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ void loadSettings()
Serial.printf("Profile '%s' loaded\n\r", profileNames[profileNumber]);
}

//Set the settingsFileName used many places
void setSettingsFileName()
{
sprintf(settingsFileName, "/%s_Settings_%d.txt", platformFilePrefix, profileNumber);
}

//Load only LFS settings without recording
//Used at very first boot to test for resetCounter
void loadSettingsPartial()
Expand All @@ -43,7 +49,7 @@ void loadSettingsPartial()
loadProfileNumber();

//Set the settingsFileName used many places
sprintf(settingsFileName, "/%s_Settings_%d.txt", platformFilePrefix, profileNumber);
setSettingsFileName();

loadSystemSettingsFromFileLFS(settingsFileName, &settings);
}
Expand Down Expand Up @@ -911,9 +917,8 @@ void loadProfileNumber()
if (!fileProfileNumber)
{
log_d("profileNumber.txt not found");
profileNumber = 0;
settings.updateZEDSettings = true; //Force module update
recordProfileNumber(profileNumber); //Record profile
recordProfileNumber(0); //Record profile
}
else
{
Expand All @@ -925,24 +930,24 @@ void loadProfileNumber()
if (profileNumber >= MAX_PROFILE_COUNT)
{
log_d("ProfileNumber invalid. Going to zero.");
profileNumber = 0;
settings.updateZEDSettings = true; //Force module update
recordProfileNumber(profileNumber); //Record profile
recordProfileNumber(0); //Record profile
}

log_d("Using profile #%d", profileNumber);
}

//Record the given profile number as well as a config bool
void recordProfileNumber(uint8_t profileNumber)
void recordProfileNumber(uint8_t newProfileNumber)
{
profileNumber = newProfileNumber;
File fileProfileNumber = LittleFS.open("/profileNumber.txt", FILE_WRITE);
if (!fileProfileNumber)
{
log_d("profileNumber.txt failed to open");
return;
}
fileProfileNumber.write(profileNumber);
fileProfileNumber.write(newProfileNumber);
fileProfileNumber.close();
}

Expand Down
37 changes: 35 additions & 2 deletions Firmware/RTK_Surveyor/form.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ function parseIncoming(msg) {
|| id.includes("sdUsedSpace")
|| id.includes("rtkFirmwareVersion")
|| id.includes("zedFirmwareVersion")
|| id.includes("profileName")
|| id.includes("hardwareID")
|| id.includes("daysRemaining")
) {
Expand Down Expand Up @@ -146,6 +145,8 @@ function parseIncoming(msg) {
//console.log("Settings loaded");

//Force element updates
ge("profileNumber").dispatchEvent(new CustomEvent('change'));
ge("profileName").dispatchEvent(new CustomEvent('change'));
ge("measurementRateHz").dispatchEvent(new CustomEvent('change'));
ge("baseTypeSurveyIn").dispatchEvent(new CustomEvent('change'));
ge("baseTypeFixed").dispatchEvent(new CustomEvent('change'));
Expand Down Expand Up @@ -218,6 +219,7 @@ function collapseSection(section, caret) {

function validateFields() {
//Collapse all sections
collapseSection("collapseProfileConfig", "profileCaret");
collapseSection("collapseGNSSConfig", "gnssCaret");
collapseSection("collapseGNSSConfigMsg", "gnssMsgCaret");
collapseSection("collapseBaseConfig", "baseCaret");
Expand All @@ -228,6 +230,10 @@ function validateFields() {

errorCount = 0;

//Profile Config
checkElementValue("profileNumber", 1, 4, "Must be between 1 and 4", "collapseProfileConfig");
checkElementString("profileName", 1, 49, "Must be 1 to 49 characters", "collapseProfileConfig");

//GNSS Config
checkElementValue("measurementRateHz", 0.00012, 10, "Must be between 0.00012 and 10Hz", "collapseGNSSConfig");
checkConstellations();
Expand Down Expand Up @@ -860,12 +866,39 @@ static const char *index_html = R"=====(
<div align="center" class="small">
<span id="rtkFirmwareVersion" style="display:inline;">RTK Firmware: v0.0</span> <br>
<span id="zedFirmwareVersion" style="display:inline;">ZED-F9P Firmware: v0.0</span> <br>
<span id="profileName" style="display:inline;">Profile Name: Default</span>
</div>
</div>

<hr class="mt-0">
<div style="margin-top:20px;">

<!-- --------- Profile Config --------- -->
<div class="d-grid gap-2">
<button class="btn btn-primary mt-3 toggle-btn" id="profileConfig" type="button" data-toggle="collapse"
data-target="#collapseProfileConfig" aria-expanded="false" aria-controls="collapseProfileConfig">
Profile Configuration <i id="profileCaret" class="caret-icon bi icon-caret-down"></i>
</button>
</div>
<div class="collapse mb-2" id="collapseProfileConfig">
<div class="card card-body">
<div class="form-group row">
<label for="profileNumber" class="box-margin20 col-sm-3 col-4 col-form-label">Profile Number</label>
<div class="col-sm-8 col-7">
<input type="number" class="form-control mb-2" id="profileNumber">
<p id="profileNumberError" class="inlineError"></p>
</div>
</div>

<div class="form-group row">
<label for="profileName" class="box-margin20 col-sm-3 col-4 col-form-label">Profile Name</label>
<div class="col-sm-8 col-7">
<input type="text" class="form-control" id="profileName">
<p id="profileNameError" class="inlineError"></p>
</div>
</div>
</div>
</div>

<!-- --------- GNSS Config --------- -->
<div class="d-grid gap-2">
<button class="btn btn-primary toggle-btn" type="button" data-toggle="collapse"
Expand Down