philbowles / PangolinMQTT

PangolinMQTT - ArduinoIDE client library for ESP8266, ESP32 and STM32-NUCLEO
Other
71 stars 21 forks source link

Compile errors with NO_GLOBAL_SERIAL defined due to Serial.printf vs PANGO_PRINT #8

Closed leifclaesson closed 2 years ago

leifclaesson commented 4 years ago

A few places in both PANGO.cpp and PangolinMQTT.cpp reference Serial directly, rather than PANGO_PRINT, which fails due to Serial not being defined if a project is compiled with NO_GLOBAL_SERIAL, commonly used when you run out of pins on the ESP8266 and need to reuse the serial port pins. :)

I realize the library is in alpha-state so it's probably way too early for a pull request -- figured I'd just mentioned it here instead.

philbowles commented 4 years ago

Thanks for this I will look at excluding any Serials if NO_GLOBAL_SERIAL is defined

leifclaesson commented 4 years ago

Ah! I get it now. I hadn't considered that it might be intentional, to let certain error messages through even when not debugging.

In that case, may I suggest an alternative solution -- PANGO_PRINT with a severity level?

Because, in my own projects, even on projects where I've set NO_GLOBAL_SERIAL, I still have debug console output through telnet. If you make a lambda hook for critical messages, I'll hook it to my console so that I'll see them.

philbowles commented 4 years ago

Yes, you got it...dumphex is always available (even when not in debug mode), as it shows the contents of the packet. It is a simple job to #ifdef that out though.