Description
I noticed that right now, the begin()
method accepts an enumeration to switch between the primary serial port and softwareserial, and begin()
also calls the begin()
method on the chosen serial object. This approach is very inflexible, since:
- It doesn't allow use of other serial ports (like
Serial1
,AltSoftSerial
, etc.) - It requires
SoftwareSerial
to always be linked in, even if it is unused (which hijacks the PCINT ISRs on AVR).
Instead, it would be better to just let begin()
accept a Stream&
reference, and expect the sketch to call begin()
on that and specify the baudrate. For example, the xbee-arduino library also uses this approach:
https://github.com/andrewrapp/xbee-arduino/blob/master/XBee.cpp#L786-L788
https://github.com/andrewrapp/xbee-arduino/blob/master/examples/AtCommand/AtCommand.pde#L54-L55
With this library still being new, hopefully you'll consider this change now, before it would break too many existing sketches.