@@ -255,15 +255,19 @@ 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
259+
258260void onWsEvent (AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len)
259261{
260262 if (type == WS_EVT_CONNECT) {
261- char settingsCSV[AP_CONFIG_SETTING_SIZE];
262- memset (settingsCSV, 0 , sizeof (settingsCSV));
263+ settingsCSV = (char *)malloc (AP_CONFIG_SETTING_SIZE);
264+ memset (settingsCSV, 0 , AP_CONFIG_SETTING_SIZE); // Clear any garbage from settings array
265+
263266 createSettingsString (settingsCSV);
264267 log_d (" Sending command: %s\n\r " , settingsCSV);
265268 client->text (settingsCSV);
266269 wifiSetState (WIFI_CONNECTED);
270+ free (settingsCSV);
267271 }
268272 else if (type == WS_EVT_DISCONNECT) {
269273 log_d (" Websocket client disconnected" );
@@ -272,6 +276,7 @@ void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventT
272276 else if (type == WS_EVT_DATA) {
273277 for (int i = 0 ; i < len; i++) {
274278 incomingSettings[incomingSettingsSpot++] = data[i];
279+ incomingSettingsSpot %= AP_CONFIG_SETTING_SIZE;
275280 }
276281 timeSinceLastIncomingSetting = millis ();
277282 }
@@ -675,9 +680,7 @@ void updateSettingWithValue(const char *settingName, const char* settingValueStr
675680 }
676681 else if (strcmp (settingName, " resetProfile" ) == 0 )
677682 {
678- // Overwrite our current settings with defaults
679- Settings tempSettings;
680- settings = tempSettings;
683+ settingsToDefaults (); // Overwrite our current settings with defaults
681684
682685 recordSystemSettings (); // Overwrite profile file and NVM with these settings
683686
0 commit comments