Override `extra_flags` Generates Warnings


I am trying to bring a new board into my ecosystem, the Lolin S2-Mini. When I started this of course I thought if it looked like the D1, the port should be easy. Right? Yeah … :slight_smile:

Anyway, I use the TelnetSpy library to overload Serial to provide a telnet connection. I get the following error on compile:

.pio/libdeps/lolin_s2_mini/TelnetSpy/TelnetSpy.cpp: In constructor 'TelnetSpy::TelnetSpy()':
.pio/libdeps/lolin_s2_mini/TelnetSpy/TelnetSpy.cpp:43:13: error: cannot convert 'USBCDC*' to 'HardwareSerial*' in assignment
  usedSer = &Serial;

and here is the relevant section:

I did a little digging and found that the USB CDC is a new-ish implementation. So then I found this:

I thought to myself, “self, why not disable that?” So I dutifully added those lines to the pio.ini:

build_flags =

So I can compile, but I get thousands (maybe not thousands, but a lot) of warnings about the redefine:

<command-line>: warning: "ARDUINO_USB_CDC_ON_BOOT" redefined
<command-line>: note: this is the location of the previous definition

I realize just making an error go away may not be the right way to go, so I guess that’s my first question. Am I going about this correctly? If so, is there any way to “undefine” the json settings before I define again? Without creating a new board type of course.

Everyone likes answering their own question.

I guess ultimately this boiled down to the differences between Serial on a UART and Serial on USBCDC. A collaborator listened to me complain and something clicked for him, so here are his changes to the library I was working with. Maybe these will help someone: