Skip to content

Commit eb3e4e5

Browse files
committed
Malloc large arrays to free RAM.
Move large arrays to reduce RAM footprint. This allowed WiFi casting to work when all subsystems are compiled. Fix WiFi subnet
1 parent d75eeae commit eb3e4e5

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

Firmware/RTK_Surveyor/Form.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ void startWebServer()
3333
ntripClientStop(true);
3434
wifiStartAP();
3535

36+
incomingSettings = (char*)malloc(AP_CONFIG_SETTING_SIZE);
37+
3638
//Clear any garbage from settings array
37-
memset(incomingSettings, 0, sizeof(incomingSettings));
39+
memset(incomingSettings, 0, AP_CONFIG_SETTING_SIZE);
3840

3941
ws.onEvent(onWsEvent);
4042
server.addHandler(&ws);

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const int FIRMWARE_VERSION_MAJOR = 2;
2626
const int FIRMWARE_VERSION_MINOR = 4;
2727

2828
#define COMPILE_WIFI //Comment out to remove WiFi functionality
29-
//#define COMPILE_AP //Requires WiFi. Comment out to remove Access Point functionality
29+
#define COMPILE_AP //Requires WiFi. Comment out to remove Access Point functionality
3030
#define COMPILE_ESPNOW //Requires WiFi. Comment out to remove ESP-Now functionality.
3131
#define COMPILE_BT //Comment out to remove Bluetooth functionality
3232
#define COMPILE_L_BAND //Comment out to remove L-Band functionality
@@ -159,8 +159,8 @@ LoggingType loggingType = LOGGING_UNKNOWN;
159159

160160
#endif
161161

162-
char certificateContents[2000]; //Holds the contents of the keys prior to MQTT connection
163-
char keyContents[2000];
162+
char *certificateContents; //Holds the contents of the keys prior to MQTT connection
163+
char *keyContents;
164164
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
165165

166166
//GNSS configuration
@@ -328,7 +328,7 @@ AsyncWebSocket ws("/ws");
328328
//Because the incoming string is longer than max len, there are multiple callbacks so we
329329
//use a global to combine the incoming
330330
#define AP_CONFIG_SETTING_SIZE 5000
331-
char incomingSettings[AP_CONFIG_SETTING_SIZE];
331+
char *incomingSettings;
332332
int incomingSettingsSpot = 0;
333333
unsigned long timeSinceLastIncomingSetting = 0;
334334
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Firmware/RTK_Surveyor/States.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ void updateSystemState()
622622

623623
//Clear buffer
624624
incomingSettingsSpot = 0;
625-
memset(incomingSettings, 0, sizeof(incomingSettings));
625+
memset(incomingSettings, 0, AP_CONFIG_SETTING_SIZE);
626626
}
627627
}
628628
}

Firmware/RTK_Surveyor/WiFi.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ void wifiStartAP()
167167

168168
#ifdef COMPILE_ESPNOW
169169
// Return protocol to default settings (no WIFI_PROTOCOL_LR for ESP NOW)
170-
esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N);
170+
esp_wifi_set_protocol(WIFI_IF_AP, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N);
171171
#endif
172172

173173
IPAddress local_IP(192, 168, 4, 1);
174174
IPAddress gateway(192, 168, 1, 1);
175-
IPAddress subnet(255, 255, 0, 0);
175+
IPAddress subnet(255, 255, 255, 0);
176176

177177
WiFi.softAPConfig(local_IP, gateway, subnet);
178178
if (WiFi.softAP("RTK Config") == false) //Must be short enough to fit OLED Width

0 commit comments

Comments
 (0)