Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name clash of const char *TAG with Arduino core macro TAG. #670

Closed
everslick opened this issue May 28, 2024 · 5 comments · Fixed by #682
Closed

Name clash of const char *TAG with Arduino core macro TAG. #670

everslick opened this issue May 28, 2024 · 5 comments · Fixed by #682
Labels
bug Something isn't working

Comments

@everslick
Copy link

Easy to fix by renaming TAG to e.g. tag in:

nimble/esp_port/esp-hci/src/esp_nimble_hci.c
nimble/nimble/host/store/config/src/ble_store_nvs.c

@h2zero
Copy link
Owner

h2zero commented May 30, 2024

I've never heard of this issue before, this must be something to do with the new arduino core?

@everslick
Copy link
Author

everslick commented May 31, 2024

Not really, this is a feature that was implemented with PR espressif/arduino-esp32#4845 in 2021.

It allows redirecting logs from IDF and Arduino to your own logging mechanism by calling esp_log_set_vprintf() and defining USE_ESP_IDF_LOG. Additionally it allows setting the TAG define to give logs from IDF a unique tag name which then clashes with the TAG const in NimNLE-Arduino.

I also first thought it was CORE 3.0.0 that broke my build and reported this in Arduino CORE
espressif/arduino-esp32#9704.

@everslick
Copy link
Author

Please note that renaming TAG to something else does fix the build when a user defines USE_ESP_IDF_LOG, so at least the firmware compiles. But to make the LOG redirection work also for Nimble-Arduino, I had to make a small change in NimBLELog.h:

#if defined(CONFIG_NIMBLE_CPP_IDF) || defined(CONFIG_NIMBLE_CPP_LOG_IDF) // using esp-idf
#  include "esp_log.h"
#  ifndef CONFIG_NIMBLE_CPP_LOG_LEVEL
#    define CONFIG_NIMBLE_CPP_LOG_LEVEL 0
#  endif

#  define NIMBLE_CPP_LOG_PRINT(level, tag, format, ...) do { \
    if (CONFIG_NIMBLE_CPP_LOG_LEVEL >= level) \
      ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \
    } while(0)

I introduced the new CONFIG_NIMBLE_CPP_LOG_IDF define and I had to replace ESP_LOG_LEVEL_LOCAL with ESP_LOG_LEVEL. Now I could add:

#define CONFIG_NIMBLE_CPP_LOG_IDF
#define CONFIG_NIMBLE_CPP_LOG_LEVEL CORE_DEBUG_LEVEL

to nimconfig.h and all is good. ;-)

I'm not sure if this is the cleanest or correct way to do it, but now NimBLE logs also get logged correctly via my own logging mechanism.

@h2zero
Copy link
Owner

h2zero commented Jun 4, 2024

Okay, that makes sense now, thanks!. I will make that change shortly.

@h2zero h2zero added the bug Something isn't working label Jun 4, 2024
@everslick
Copy link
Author

Thank you very much! Also for maintaining this NimBLE fork! (which should be the canonical BLE lib in Ardunio, IMHO!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants