|
1 | 1 | //Once connected to the access point for WiFi Config, the ESP32 sends current setting values in one long string to websocket |
2 | 2 | //After user clicks 'save', data is validated via main.js and a long string of values is returned. |
3 | 3 |
|
| 4 | +static uint8_t bootProfileNumber; |
| 5 | + |
4 | 6 | //Start webserver in AP mode |
5 | 7 | void startWebServer() |
6 | 8 | { |
@@ -280,6 +282,9 @@ void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventT |
280 | 282 | void createSettingsString(char* settingsCSV) |
281 | 283 | { |
282 | 284 | #ifdef COMPILE_AP |
| 285 | + char tagText[32]; |
| 286 | + char nameText[64]; |
| 287 | + |
283 | 288 | //System Info |
284 | 289 | stringRecord(settingsCSV, "platformPrefix", platformPrefix); |
285 | 290 |
|
@@ -407,6 +412,15 @@ void createSettingsString(char* settingsCSV) |
407 | 412 | //Profiles |
408 | 413 | stringRecord(settingsCSV, "profileNumber", profileNumber + 1); |
409 | 414 | 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); |
410 | 424 |
|
411 | 425 | //New settings not yet integrated |
412 | 426 | //... |
@@ -503,7 +517,13 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr |
503 | 517 | recordProfileNumber(profileNumber); |
504 | 518 | } |
505 | 519 | } |
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 | + } |
507 | 527 | else if (strcmp(settingName, "enableNtripServer") == 0) |
508 | 528 | settings.enableNtripServer = settingValueBool; |
509 | 529 | else if (strcmp(settingName, "ntripServer_CasterHost") == 0) |
|
0 commit comments