@@ -542,6 +542,20 @@ bool tcpipInit(){
542
542
* */
543
543
544
544
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
+
545
559
bool wifiLowLevelInit (bool persistent){
546
560
if (!lowLevelInitDone){
547
561
lowLevelInitDone = true ;
@@ -558,14 +572,14 @@ bool wifiLowLevelInit(bool persistent){
558
572
559
573
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT ();
560
574
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
+ }
569
583
570
584
esp_err_t err = esp_wifi_init (&cfg);
571
585
if (err){
@@ -654,7 +668,6 @@ wifi_ps_type_t WiFiGenericClass::_sleepEnabled = WIFI_PS_MIN_MODEM;
654
668
655
669
WiFiGenericClass::WiFiGenericClass ()
656
670
{
657
-
658
671
}
659
672
660
673
const char * WiFiGenericClass::getHostname ()
0 commit comments