diff --git a/platform/wiced/btstack_run_loop_wiced.c b/platform/wiced/btstack_run_loop_wiced.c index 77e558238..282869fff 100644 --- a/platform/wiced/btstack_run_loop_wiced.c +++ b/platform/wiced/btstack_run_loop_wiced.c @@ -78,7 +78,15 @@ static void btstack_run_loop_wiced_set_timer(btstack_timer_source_t *ts, uint32_ ts->timeout = btstack_run_loop_wiced_get_time_ms() + timeout_in_ms + 1; } -// schedules execution similar to wiced_rtos_send_asynchronous_event for worker threads +// TODO: use wiced mutex to protect list of callbacks in run_loop_base +static void btstack_run_loop_wiced_execute_on_main_thread_new(btstack_context_callback_registration_t * callback_registration){ + function_call_t message; + message.fn = callback_registration->callback; + message.arg = callback_registration->context; + wiced_rtos_push_to_queue(&btstack_run_loop_queue, &message, WICED_NEVER_TIMEOUT); +} + +// @deprecated use btstack_run_loop_execute_on_main_thread instead void btstack_run_loop_wiced_execute_code_on_main_thread(wiced_result_t (*fn)(void *arg), void * arg){ function_call_t message; message.fn = fn; @@ -113,7 +121,6 @@ static void btstack_run_loop_wiced_execute(void) { } } - static void btstack_run_loop_wiced_trigger_exit(void){ run_loop_exit_requested = true; } @@ -126,7 +133,7 @@ static void btstack_run_loop_wiced_btstack_run_loop_init(void){ } /** - * @brief Provide btstack_run_loop_posix instance for use with btstack_run_loop_init + * @brief Provide btstack_run_loop_wiced instance for use with btstack_run_loop_init */ const btstack_run_loop_t * btstack_run_loop_wiced_get_instance(void){ return &btstack_run_loop_wiced; @@ -144,7 +151,7 @@ static const btstack_run_loop_t btstack_run_loop_wiced = { &btstack_run_loop_wiced_execute, &btstack_run_loop_base_dump_timer, &btstack_run_loop_wiced_get_time_ms, - NULL, /* poll data sources from irq */ NULL, - btstack_run_loop_wiced_trigger_exit + &btstack_run_loop_wiced_execute_on_main_thread_new, + &btstack_run_loop_wiced_trigger_exit }; diff --git a/platform/wiced/btstack_run_loop_wiced.h b/platform/wiced/btstack_run_loop_wiced.h index 5316c4c89..a814345f2 100644 --- a/platform/wiced/btstack_run_loop_wiced.h +++ b/platform/wiced/btstack_run_loop_wiced.h @@ -41,8 +41,8 @@ * Functions relevant for BTstack WICED port */ -#ifndef btstack_run_loop_WICED_H -#define btstack_run_loop_WICED_H +#ifndef BTSTACK_RUN_LOOP_WICED_H +#define BTSTACK_RUN_LOOP_WICED_H #include "btstack_config.h" #include "btstack_run_loop.h" @@ -53,12 +53,13 @@ extern "C" { #endif /** - * @brief Provide btstack_run_loop_posix instance for use with btstack_run_loop_init + * @brief Provide btstack_run_loop_wiced instance for use with btstack_run_loop_init */ const btstack_run_loop_t * btstack_run_loop_wiced_get_instance(void); /* * @brief Execute code on BTstack run loop. Can be used to control BTstack from a different thread + * @deprecated use btstack_run_loop_execute_on_main_thread instead */ void btstack_run_loop_wiced_execute_code_on_main_thread(wiced_result_t (*fn)(void *arg), void * arg); @@ -68,4 +69,4 @@ void btstack_run_loop_wiced_execute_code_on_main_thread(wiced_result_t (*fn)(voi } #endif -#endif // btstack_run_loop_WICED_H +#endif // BTSTACK_RUN_LOOP_WICED_H