From 3c792f427b013d337f353eec28933387d0c79d06 Mon Sep 17 00:00:00 2001 From: yulong Date: Wed, 12 Oct 2016 03:38:26 -0400 Subject: [PATCH] commponent bt:add bt_prf_task.c file for proceess the profile task event add bt_prf_task.h for defined the data & struct used for the profile task add prodile_sys.h defined the profile system data used for profile task modified component.mk --- .../bt/bluedroid/bta/sys/bta_sys_main.c | 4 +- .../bt/bluedroid/profiles/core/bt_prf_task.c | 72 +++++++++++++++++++ .../profiles/core/include/bt_prf_task.h | 46 ++++++++++++ .../profiles/core/include/profile_sys.h | 33 +++++++++ components/bt/component.mk | 2 + 5 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 components/bt/bluedroid/profiles/core/bt_prf_task.c create mode 100644 components/bt/bluedroid/profiles/core/include/bt_prf_task.h create mode 100644 components/bt/bluedroid/profiles/core/include/profile_sys.h diff --git a/components/bt/bluedroid/bta/sys/bta_sys_main.c b/components/bt/bluedroid/bta/sys/bta_sys_main.c index c5a94648c3..48e1ecd007 100755 --- a/components/bt/bluedroid/bta/sys/bta_sys_main.c +++ b/components/bt/bluedroid/bta/sys/bta_sys_main.c @@ -512,7 +512,7 @@ void bta_sys_event(BT_HDR *p_msg) UINT8 id; BOOLEAN freebuf = TRUE; - APPL_TRACE_EVENT("BTA got event 0x%x", p_msg->event); + APPL_TRACE_EVENT("BTA got event 0x%x\n", p_msg->event); /* get subsystem id from event */ id = (UINT8) (p_msg->event >> 8); @@ -524,7 +524,7 @@ void bta_sys_event(BT_HDR *p_msg) } else { - APPL_TRACE_WARNING("BTA got unregistered event id %d", id); + APPL_TRACE_WARNING("BTA got unregistered event id %d\n", id); } if (freebuf) diff --git a/components/bt/bluedroid/profiles/core/bt_prf_task.c b/components/bt/bluedroid/profiles/core/bt_prf_task.c new file mode 100644 index 0000000000..def36b1371 --- /dev/null +++ b/components/bt/bluedroid/profiles/core/bt_prf_task.c @@ -0,0 +1,72 @@ +/** + **************************************************************************************** + * + * @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); +} + + + + + diff --git a/components/bt/bluedroid/profiles/core/include/bt_prf_task.h b/components/bt/bluedroid/profiles/core/include/bt_prf_task.h new file mode 100644 index 0000000000..6cb30905e8 --- /dev/null +++ b/components/bt/bluedroid/profiles/core/include/bt_prf_task.h @@ -0,0 +1,46 @@ +/** + **************************************************************************************** + * + * @file bt_prf_task.h + * + * @brief Application entry point + * + * Copyright (C) Espressif 2016 + * Created by Yulong at 2016/10/11 + * + * + **************************************************************************************** + */ + +#include +#include "fixed_queue.h" + +#ifndef BT_PRF_TASK_H__ +#define BT_PRF_TASK_H__ + +/* Functions provided by btu_core.c +************************************ +*/ + + +void bt_prf_task_thread_handler(void *arg); + +void bt_prf_init_core(void); +void bt_prf_free_core(void); + +void bt_prf_StartUp(void); +void bt_prf_ShutDown(void); + +void bt_prf_task_start_up(void); +void bt_prf_task_shut_down(void); + +void bt_profile_msg_ready(fixed_queue_t *queue); + + + + + + + + +#endif /// BT_PRF_TASK_H__ diff --git a/components/bt/bluedroid/profiles/core/include/profile_sys.h b/components/bt/bluedroid/profiles/core/include/profile_sys.h new file mode 100644 index 0000000000..8337b504e4 --- /dev/null +++ b/components/bt/bluedroid/profiles/core/include/profile_sys.h @@ -0,0 +1,33 @@ +/** + **************************************************************************************** + * + * @file profile_sys.h + * + * @brief Application entry point + * + * Copyright (C) Espressif 2016 + * Created by Yulong at 2016/10/12 + * + * + **************************************************************************************** + */ + +#ifndef _PROFILE_SYS_H__ +#define _PROFILE_SYS_H__ + +enum +{ + PRF_ID_SYS, + PRF_ID_CONN, + PRF_ID_HIDD_LE, + PRF_ID_HIDH_LE, + PRF_ID_DISS_LE, + PRF_ID_DISC_LE, + PRF_ID_AIRSYNC_LE, + PRF_ID_ANCC_LE, + PRF_ID_BUT_LE +}; + + + +#endif ///_PROFILE_SYS_H__ \ No newline at end of file diff --git a/components/bt/component.mk b/components/bt/component.mk index cf2805bb7b..65dc664345 100644 --- a/components/bt/component.mk +++ b/components/bt/component.mk @@ -9,6 +9,7 @@ COMPONENT_ADD_INCLUDEDIRS := bluedroid/bta/include \ bluedroid/gki/include \ bluedroid/hci/include \ bluedroid/osi/include \ + bluedroid/profiles/core/include \ bluedroid/profiles/esp/include \ bluedroid/profiles/std/avrc/include \ bluedroid/profiles/std/battery/include \ @@ -48,6 +49,7 @@ COMPONENT_SRCDIRS := bluedroid/bta/dm \ bluedroid/hci \ bluedroid/main \ bluedroid/osi \ + bluedroid/profiles/core \ bluedroid/profiles/esp/ble_button \ bluedroid/profiles/esp/wechat_AirSync \ bluedroid/profiles/esp \