Hello there!
I am working on an ANT+ project, and - as I have taken a fairly unexplored development approach, namely integrating nRF5-SDK Code into a main application written in Rust, I am running into a roadblock.
I need to disable logging, as logging is completely taken care of by the Rust side, and Callbacks into the Rust side are used for logging using the `defmt` logging framework. That part works just fine, but because of that, if logging is enabled on the nRF5-SDK side, a stack overflow happens in the logging code, breaking the program.
I tried disabling logging by setting
#define NRF_SDH_ANT_LOG_LEVEL 0 #define NRF_SDH_ANT_LOG_ENABLED 0 #define NRF_LOG_DEFAULT_LEVEL 0 #define NRF_LOG_ENABLED 0
in various orders (some set to 0, all set to 0, ...). This did exactly what I wanted and disabled logging, but broke the Softdevice Startup Procedure:
void ant_start() {
info("Starting ANT");
ant_channel_config_t conf = {
...
};
info("Enabling Softdevice...");
ret_code_t ret = nrf_sdh_enable_request();
APP_ERROR_CHECK(ret);
ASSERT(nrf_sdh_is_enabled());
info("Enabling ANT...");
ret = nrf_sdh_ant_enable(); // works with logging enabled, but returns 0x7 without it
log_nrf_ret_t("ant enable ret", ret);
APP_ERROR_CHECK(ret);
info("Initializing Channel...");
ret = ant_channel_init(&conf);
log_nrf_ret_t("Channel initialized.", ret);
APP_ERROR_CHECK(ret);
}
0x7 seems to be the error code for `Invalid Parameter`, but this line works just fine with logging enabled. However, no matter which way, if `NRF_SDH_ANT_LOG_ENABLED` or any "higher-level" logging configuration value is 0, this breaks.
I have to admit, I'm kind of lost on how to solve this. My two current ideas are to either write a custom logging driver for my Rust-based logging implementation, but as I have never done this, I don't know if this would work. Does that sound like a possible solution? Or is there something I'm overlooking?
Any help would be much appreciated. If you need more information, I'd be happy to supply that too.
Best wishes,
Yannik



