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

Allows spiram malloc with wifi dynamic buffers - better free heap #5791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion 25 libraries/WiFi/src/WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,20 @@ bool tcpipInit(){
* */

static bool lowLevelInitDone = false;
bool WiFiGenericClass::_wifiUseStaticBuffers = false;

bool WiFiGenericClass::useStaticBuffers(){
return _wifiUseStaticBuffers;
}

void WiFiGenericClass::useStaticBuffers(bool bufferMode){
if (lowLevelInitDone) {
log_w("WiFi already started. Call WiFi.mode(WIFI_MODE_NULL) before setting Static Buffer Mode.");
}
_wifiUseStaticBuffers = bufferMode;
}


bool wifiLowLevelInit(bool persistent){
if(!lowLevelInitDone){
lowLevelInitDone = true;
Expand All @@ -557,6 +571,16 @@ bool wifiLowLevelInit(bool persistent){
}

wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();

SuGlider marked this conversation as resolved.
Show resolved Hide resolved
if(!WiFiGenericClass::useStaticBuffers()) {
cfg.static_tx_buf_num = 0;
cfg.dynamic_tx_buf_num = 32;
cfg.tx_buf_type = 1;
cfg.cache_tx_buf_num = 1; // can't be zero!
cfg.static_rx_buf_num = 4;
cfg.dynamic_rx_buf_num = 32;
}

esp_err_t err = esp_wifi_init(&cfg);
if(err){
log_e("esp_wifi_init %d", err);
Expand Down Expand Up @@ -644,7 +668,6 @@ wifi_ps_type_t WiFiGenericClass::_sleepEnabled = WIFI_PS_MIN_MODEM;

WiFiGenericClass::WiFiGenericClass()
{

}

const char * WiFiGenericClass::getHostname()
Expand Down
4 changes: 4 additions & 0 deletions 4 libraries/WiFi/src/WiFiGeneric.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,16 @@ class WiFiGenericClass
static bool hostname(const String& aHostname) { return setHostname(aHostname.c_str()); }

static esp_err_t _eventCallback(arduino_event_t *event);

static void useStaticBuffers(bool bufferMode);
static bool useStaticBuffers();

protected:
static bool _persistent;
static bool _long_range;
static wifi_mode_t _forceSleepLastMode;
static wifi_ps_type_t _sleepEnabled;
static bool _wifiUseStaticBuffers;

static int setStatusBits(int bits);
static int clearStatusBits(int bits);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.