espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.48k stars 7.38k forks source link

Refactor request: Using WiFiSTAClass instead of WiFiClass #5653

Open olicooper opened 3 years ago

olicooper commented 3 years ago

Hardware:

Board: Lolin32 Lite Core Installation version: 1.0.6 IDE name: Platform.io

Description:

I would like to create a wrapper class around the wifi class to provide access to an external API. I don't need the access point/scanning functionality, I want to hide the wifi implementation and I need to reduce my compilation size so I created a class like this:

class WifiApiService : protected WiFiGenericClass, protected WiFiSTAClass { }

But when I compile, I see all classes (WiFiSTAClass, WiFiScanClass, WiFiAPClass) are still compiled too. There seems to be circular references in the files which makes them dependent on each other i.e. WiFiGenericClass imports WiFi.h and directly uses extern WiFiClass WiFi despite calling it 'Generic'.

Could this be refactored so we can import parts of the wifi stack instead of all of it? The library seems reasonably well organised so I imagine it shouldn't be too difficult to achieve?

VojtechBartoska commented 2 years ago

Hello @olicooper, we will take a look on this request. Thanks for contribution.