@@ -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 ;
@@ -558,14 +572,14 @@ bool wifiLowLevelInit(bool persistent){
558572
559573 wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT ();
560574
561- // this code forces WiFi to go with Dynamic Buffers
562- // it bypasses sdkconfig definitions!
563- cfg.static_tx_buf_num = 0 ;
564- cfg.dynamic_tx_buf_num = 32 ;
565- cfg.tx_buf_type = 1 ;
566- cfg.cache_tx_buf_num = 1 ; // can't be zero!
567- cfg.static_rx_buf_num = 4 ;
568- cfg. dynamic_rx_buf_num = 32 ;
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+ }
569583
570584 esp_err_t err = esp_wifi_init (&cfg);
571585 if (err){
@@ -654,7 +668,6 @@ wifi_ps_type_t WiFiGenericClass::_sleepEnabled = WIFI_PS_MIN_MODEM;
654668
655669WiFiGenericClass::WiFiGenericClass ()
656670{
657-
658671}
659672
660673const char * WiFiGenericClass::getHostname ()
0 commit comments