OVMS3-idf/components/bt/bluedroid/profiles/core/bt_prf_task.c
yulong 65445b21dd commponent bt:1.add bt_prf_act.c file for the state machine
2.add the bt_app_api.h file
	      3.modified the bt_prf_task.c==>added the free & start task function
2016-10-13 04:02:30 -04:00

114 lines
2.4 KiB
C

/**
****************************************************************************************
*
* @file bt_prf_task.c
*
* @brief Application entry point
*
* Copyright (C) Espressif 2016
* Created by Yulong at 2016/10/11
*
*
****************************************************************************************
*/
#include "bt_prf_task.h"
#include "allocator.h"
#include "thread.h"
#include "gki.h"
//thread_t *bt_workqueue_thread;
//static const char *BT_WORKQUEUE_NAME = "bt_workqueue";
xTaskHandle xProfileTaskHandle = NULL;
xQueueHandle xProfileQueue = 0;
// Communication queue between bt_proflie_task and app.
extern fixed_queue_t *bt_profile_msg_queue;
/*****************************************************************************
**
** Function bt_prf_task_thread_handler
**
** Description Process profile Task Thread.
******************************************************************************/
void bt_prf_task_thread_handler(void *arg)
{
//ke_event_clear(KE_EVENT_BTU_TASK_THREAD);
TaskEvt_t *e;
for (;;) {
if (pdTRUE == xQueueReceive(xProfileQueue, &e, (portTickType)portMAX_DELAY)) {
if (e->sig == SIG_BTU_WORK) {
fixed_queue_process(bt_profile_msg_queue);
}
else if (e->sig == SIG_BTU_START_UP) {
bt_prf_task_start_up();
}
osi_free(e);
}
}
}
void bt_profile_msg_ready(fixed_queue_t *queue) {
BT_HDR *p_msg;
while (!fixed_queue_is_empty(queue)) {
p_msg = (BT_HDR *)fixed_queue_dequeue(queue);
}
}
void bt_prf_task_start_up(void)
{
fixed_queue_register_dequeue(bt_profile_msg_queue, bt_profile_msg_ready);
}
void btu_task_shut_down(void)
{
fixed_queue_unregister_dequeue(bt_profile_msg_queue);
bt_prf_free_core();
}
void bt_prf_StartUp(void)
{
bt_profile_msg_queue = fixed_queue_new(SIZE_MAX);
if (bt_profile_msg_queue == NULL)
goto error_exit;
return;
error_exit:;
LOG_ERROR("%s Unable to allocate resources for bt_workqueue\n", __func__);
bt_prf_ShutDown();
}
void bt_prf_ShutDown(void)
{
btu_task_shut_down();
//thread_free(bt_workqueue_thread);
vTaskDelete(xProfileTaskHandle);
vQueueDelete(xProfileQueue);
bt_profile_msg_queue = NULL;
// bt_workqueue_thread = NULL;
xProfileTaskHandle = NULL;
xProfileQueue = 0;
}
void bt_prf_free_core(void)
{
}