Hi,
I have couple of question regarding ble_app_hrs_freertos example (sdk 14.2)
- Possible bug - in main() , erase_bonds is a local variable (defined on the stack). Its pointer is passed as a task context to the softdevice_task (through nrf_sdh_freertos_init() --> xTaskCreate())
However, Task handler run is deferred and one can not assure that this pointer is still valid as it is not static/global.
Its ppossible that its being used this way intentionally as main() never exits and its local variables are never popped out of stack. I'll appreciate if this could be confirmed/corrected. - During initialization a logger_thread task is created. This task has priority of 1 but its suspended in its while(1) loop.
It only resumes in vApplicationIdleHook() which runs in Idle task context with priority 0.
Doesn't this make logger_thread() practically priority 0 ? Can its logic run within vApplicationIdleHook() context with the same effect in order to save task creation and its associated resources ? How/whether it will affect power optimization ?
To turn current code-static void logger_thread(void * arg) { UNUSED_PARAMETER(arg); while (1) { NRF_LOG_FLUSH(); vTaskSuspend(NULL); // Suspend myself } } #endif //NRF_LOG_ENABLED /**@brief A function which is hooked to idle task. * @note Idle hook must be enabled in FreeRTOS configuration (configUSE_IDLE_HOOK). */ void vApplicationIdleHook( void ) { vTaskResume(m_logger_thread); }
To this code// remove static void logger_thread(void * arg) void vApplicationIdleHook( void ) { NRF_LOG_FLUSH(); // Is this one blocking? }
Thanks