I want to activate bluetooth only for a while and when it is only necessary. Should it be better to suspend and resume the NimBLE freertos task based on :
Code: Select all
void vAFunction( void )
{
TaskHandle_t xHandle;
// Create a task, storing the handle.
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
// ...
// Use the handle to suspend the created task.
vTaskSuspend( xHandle );
// ...
// The created task will not run during this period, unless
// another task calls vTaskResume( xHandle ).
//...
// Resume the suspended task ourselves.
vTaskResume( xHandle );
// The created task will once again get microcontroller processing
// time in accordance with its priority within the system.
}
Code: Select all
void start_bt_task() {
nimble_port_init();
nimble_port_freertos_init(your_host_task_fn);
}
void stop_bt_task() {
nimble_port_stop();
nimble_port_deinit();
nimble_port_freertos_deinit();
}