dreed47 / WifiMQTTManager

ESP32/ESP8266 library for managing your IoT devices.
GNU General Public License v3.0
82 stars 33 forks source link

Please don't Serial.begin() in ctor #16

Open alterscape opened 4 years ago

alterscape commented 4 years ago

I was experiencing problems with a sketch using this library -- it appeared to silently fail before the first line of my sketch (incidentally, Serial.begin()). In the course of troubleshooting, I read the implementation and noticed that Serial.begin() is called in the constructor. Considering Serial output isn't used that I can see in the constructor, would you consider removing that line? It would be a breaking change for people who count on that behavior now, but would make the library much more paradigmatic.

It might be worth adding a setter/getter so that a pointer to the user's preferred Serial implementation could be passed in once initialized outside the library (for devices that include multiple hardware serial, etc).

I'd be happy to take a crack at this and submit a pull request, but wanted to make sure there was any interest first.

dreed47 commented 4 years ago

pull request welcome. I wont have too much time to do this myself right now.