Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 67c9914

Browse filesBrowse files
authored
Allows spiram malloc with wifi dynamic buffers - better free heap (espressif#5791)
Summary Modifies WiFi lib to allow dynamic buffer allocation along with SPIRAM MALLOC enabled This gives more heap space to the users Related PR in Arduino Lib Builder: espressif/esp32-arduino-lib-builder#47 Impact WiFi will work the same as it was in version 1.0.6, restoring free heap. close espressif#5630 close espressif#5474 close espressif#5699 close espressif#5697
1 parent 951c8be commit 67c9914
Copy full SHA for 67c9914

File tree

Expand file treeCollapse file tree

2 files changed

+28
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+28
-1
lines changed

‎libraries/WiFi/src/WiFiGeneric.cpp

Copy file name to clipboardExpand all lines: libraries/WiFi/src/WiFiGeneric.cpp
+24-1Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,20 @@ bool tcpipInit(){
542542
* */
543543

544544
static bool lowLevelInitDone = false;
545+
bool WiFiGenericClass::_wifiUseStaticBuffers = false;
546+
547+
bool WiFiGenericClass::useStaticBuffers(){
548+
return _wifiUseStaticBuffers;
549+
}
550+
551+
void WiFiGenericClass::useStaticBuffers(bool bufferMode){
552+
if (lowLevelInitDone) {
553+
log_w("WiFi already started. Call WiFi.mode(WIFI_MODE_NULL) before setting Static Buffer Mode.");
554+
}
555+
_wifiUseStaticBuffers = bufferMode;
556+
}
557+
558+
545559
bool wifiLowLevelInit(bool persistent){
546560
if(!lowLevelInitDone){
547561
lowLevelInitDone = true;
@@ -557,6 +571,16 @@ bool wifiLowLevelInit(bool persistent){
557571
}
558572

559573
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
574+
575+
if(!WiFiGenericClass::useStaticBuffers()) {
576+
cfg.static_tx_buf_num = 0;
577+
cfg.dynamic_tx_buf_num = 32;
578+
cfg.tx_buf_type = 1;
579+
cfg.cache_tx_buf_num = 1; // can't be zero!
580+
cfg.static_rx_buf_num = 4;
581+
cfg.dynamic_rx_buf_num = 32;
582+
}
583+
560584
esp_err_t err = esp_wifi_init(&cfg);
561585
if(err){
562586
log_e("esp_wifi_init %d", err);
@@ -644,7 +668,6 @@ wifi_ps_type_t WiFiGenericClass::_sleepEnabled = WIFI_PS_MIN_MODEM;
644668

645669
WiFiGenericClass::WiFiGenericClass()
646670
{
647-
648671
}
649672

650673
const char * WiFiGenericClass::getHostname()

‎libraries/WiFi/src/WiFiGeneric.h

Copy file name to clipboardExpand all lines: libraries/WiFi/src/WiFiGeneric.h
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,16 @@ class WiFiGenericClass
179179
static bool hostname(const String& aHostname) { return setHostname(aHostname.c_str()); }
180180

181181
static esp_err_t _eventCallback(arduino_event_t *event);
182+
183+
static void useStaticBuffers(bool bufferMode);
184+
static bool useStaticBuffers();
182185

183186
protected:
184187
static bool _persistent;
185188
static bool _long_range;
186189
static wifi_mode_t _forceSleepLastMode;
187190
static wifi_ps_type_t _sleepEnabled;
191+
static bool _wifiUseStaticBuffers;
188192

189193
static int setStatusBits(int bits);
190194
static int clearStatusBits(int bits);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.