@@ -255,7 +255,6 @@ static void handleFirmwareFileUpload(AsyncWebServerRequest *request, String file
255255// Events triggered by web sockets
256256#ifdef COMPILE_WIFI
257257#ifdef COMPILE_AP
258- char *settingsCSV; // Push large array onto heap
259258
260259void onWsEvent (AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len)
261260{
@@ -492,18 +491,13 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
492491{
493492#ifdef COMPILE_AP
494493 char * ptr;
495- int newProfileNumber;
496494 double settingValue = strtod (settingValueStr, &ptr);
497495
498496 bool settingValueBool = false ;
499497 if (strcmp (settingValueStr, " true" ) == 0 ) settingValueBool = true ;
500498
501499 if (strcmp (settingName, " maxLogTime_minutes" ) == 0 )
502- {
503- newAPSettings = true ; // Mark settings as new to force record before reset
504500 settings.maxLogTime_minutes = settingValue;
505- }
506-
507501 else if (strcmp (settingName, " maxLogLength_minutes" ) == 0 )
508502 settings.maxLogLength_minutes = settingValue;
509503 else if (strcmp (settingName, " measurementRateHz" ) == 0 )
@@ -560,19 +554,6 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
560554 strcpy (settings.profileName , settingValueStr);
561555 setProfileName (profileNumber);
562556 }
563- else if (strcmp (settingName, " profileNumber" ) == 0 )
564- {
565- if ((sscanf (settingValueStr, " %d" , &newProfileNumber) == 1 )
566- && (newProfileNumber >= 1 ) && (newProfileNumber <= MAX_PROFILE_COUNT)
567- && (profileNumber != newProfileNumber))
568- {
569- profileNumber = newProfileNumber - 1 ;
570-
571- // Switch to a new profile
572- setSettingsFileName ();
573- recordProfileNumber (profileNumber);
574- }
575- }
576557 else if (strcmp (settingName, " enableNtripServer" ) == 0 )
577558 settings.enableNtripServer = settingValueBool;
578559 else if (strcmp (settingName, " ntripServer_CasterHost" ) == 0 )
@@ -657,11 +638,12 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
657638 factoryReset ();
658639 else if (strcmp (settingName, " exitAndReset" ) == 0 )
659640 {
660- if (newAPSettings == true ) recordSystemSettings (); // If we've received settings, record before restart
641+ Serial. println ( " Reset after AP Config " );
661642
662- // Reboot the machine
663643 ESP.restart ();
664644 }
645+
646+
665647 else if (strcmp (settingName, " setProfile" ) == 0 )
666648 {
667649 // Change to new profile
@@ -670,12 +652,13 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
670652 // Load new profile into system
671653 loadSettings ();
672654
673- // Send settings to browser
674- char settingsCSV[ AP_CONFIG_SETTING_SIZE] ;
675- memset (settingsCSV, 0 , sizeof (settingsCSV));
655+ // Send new settings to browser. Re-use settingsCSV to avoid stack.
656+ settingsCSV = ( char *) malloc ( AP_CONFIG_SETTING_SIZE) ;
657+ memset (settingsCSV, 0 , AP_CONFIG_SETTING_SIZE); // Clear any garbage from settings array
676658 createSettingsString (settingsCSV);
677659 log_d (" Sending command: %s\n\r " , settingsCSV);
678660 ws.textAll (String (settingsCSV));
661+ free (settingsCSV);
679662 }
680663 else if (strcmp (settingName, " resetProfile" ) == 0 )
681664 {
@@ -686,12 +669,13 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
686669 // Get bitmask of active profiles
687670 activeProfiles = loadProfileNames ();
688671
689- // Send settings to browser
690- char settingsCSV[ AP_CONFIG_SETTING_SIZE] ;
691- memset (settingsCSV, 0 , sizeof (settingsCSV));
672+ // Send new settings to browser. Re-use settingsCSV to avoid stack.
673+ settingsCSV = ( char *) malloc ( AP_CONFIG_SETTING_SIZE) ;
674+ memset (settingsCSV, 0 , AP_CONFIG_SETTING_SIZE); // Clear any garbage from settings array
692675 createSettingsString (settingsCSV);
693676 log_d (" Sending command: %s\n\r " , settingsCSV);
694677 ws.textAll (String (settingsCSV));
678+ free (settingsCSV);
695679 }
696680 else if (strcmp (settingName, " forgetEspNowPeers" ) == 0 )
697681 {
0 commit comments