@@ -542,6 +542,20 @@ bool tcpipInit(){
542542 * */
543543
544544static 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+
545559bool 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
645669WiFiGenericClass::WiFiGenericClass ()
646670{
647-
648671}
649672
650673const char * WiFiGenericClass::getHostname ()
0 commit comments