WifWaf / MH-Z19

For Arduino Boards (&ESP32). Additional Examples/Commands., Hardware/Software Serial
GNU Lesser General Public License v3.0
194 stars 39 forks source link

library fails with CORE_DEBUG_LEVEL=3 #50

Open hpsaturn opened 1 year ago

hpsaturn commented 1 year ago

Overview

The library fails when the debug level is increased, when you define CORE_DEBUG_LEVEL=3 for example, its necessary pass the TAG like this: '-D TAG_MHZ19="MHZ19"' on PlatformIO ini file for example.

.pio/libdeps/M5STICKCPLUS/MH-Z19/src/MHZ19.cpp: In member function 'void MHZ19::begin(Stream&)':
.pio/libdeps/M5STICKCPLUS/MH-Z19/src/MHZ19.cpp:37:18: error: 'TAG_MHZ19' was not declared in this scope
         ESP_LOGE(TAG_MHZ19, "Initial communication errorCode recieved");
WifWaf commented 1 year ago

ESP_LOGX and the TAG_MHZ19 definition, both require the ESP32 definition to be set, so that's quite odd.

It might be worth moving the lines below to the top of the .cpp file, just in case they are being compiled differently. https://github.com/WifWaf/MH-Z19/blob/49658e5938669c5a54b6b8456611d0afbb5b90b0/src/MHZ19.h#L8-L11

I'll try and look at this soon if no luck, otherwise I'll push the fix.