diff --git a/components/bt/bluedroid/hci/hci_hal_h4.c b/components/bt/bluedroid/hci/hci_hal_h4.c index b3cd5d296..7fabf83a9 100755 --- a/components/bt/bluedroid/hci/hci_hal_h4.c +++ b/components/bt/bluedroid/hci/hci_hal_h4.c @@ -91,13 +91,14 @@ static void hci_hal_env_deinit(void) { fixed_queue_free(hci_hal_env.rx_q, hci_hal_env.allocator->free); } -static bool hal_open(const hci_hal_callbacks_t *upper_callbacks) { +static bool hal_open(const hci_hal_callbacks_t *upper_callbacks) +{ assert(upper_callbacks != NULL); callbacks = upper_callbacks; hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, SIZE_MAX); - xHciH4Queue = xQueueCreate(60, sizeof(void *)); + xHciH4Queue = xQueueCreate(60, sizeof(BtTaskEvt_t)); xTaskCreate(hci_hal_h4_rx_handler, "HciH4T", 4096+2048, NULL, configMAX_PRIORITIES - 3, &xHciH4TaskHandle); //register vhci host cb @@ -105,10 +106,6 @@ static bool hal_open(const hci_hal_callbacks_t *upper_callbacks) { return true; - -error: - interface.close(); - return false; } static void hal_close() { @@ -156,27 +153,25 @@ static uint16_t transmit_data(serial_data_type_t type, } // Internal functions -static void hci_hal_h4_rx_handler(void *arg) { - BtTaskEvt_t *e; +static void hci_hal_h4_rx_handler(void *arg) +{ + BtTaskEvt_t e; for (;;) { if (pdTRUE == xQueueReceive(xHciH4Queue, &e, (portTickType)portMAX_DELAY)) { - if (e->sig == 0xff) { + if (e.sig == 0xff) { fixed_queue_process(hci_hal_env.rx_q); } - osi_free(e); } } } void hci_hal_h4_task_post(void) { - BtTaskEvt_t *evt = (BtTaskEvt_t *)osi_malloc(sizeof(BtTaskEvt_t)); - if (evt == NULL) - return; + BtTaskEvt_t evt; - evt->sig = 0xff; - evt->par = 0; + evt.sig = 0xff; + evt.par = 0; if (xQueueSend(xHciH4Queue, &evt, 10/portTICK_RATE_MS) != pdTRUE) { LOG_ERROR("xHciH4Queue failed\n"); diff --git a/components/bt/bluedroid/hci/hci_layer.c b/components/bt/bluedroid/hci/hci_layer.c index d9c73d8b1..cc9a0ab84 100755 --- a/components/bt/bluedroid/hci/hci_layer.c +++ b/components/bt/bluedroid/hci/hci_layer.c @@ -111,7 +111,7 @@ int hci_start_up(void) { if (hci_layer_init_env()) goto error; - xHciHostQueue = xQueueCreate(60, sizeof(void *)); + xHciHostQueue = xQueueCreate(60, sizeof(BtTaskEvt_t)); xTaskCreate(hci_host_thread_handler, "HciHostT", (4096+2048), NULL, configMAX_PRIORITIES - 3, &xHciHostTaskHandle); packet_fragmenter->init(&packet_fragmenter_callbacks); @@ -139,15 +139,13 @@ void hci_shut_down(void) { void hci_host_task_post(void) { + BtTaskEvt_t evt; + if (hci_host_startup_flag == false) return; - BtTaskEvt_t *evt = (BtTaskEvt_t *)osi_malloc(sizeof(BtTaskEvt_t)); - if (evt == NULL) - return; - - evt->sig = 0xff; - evt->par = 0; + evt.sig = 0xff; + evt.par = 0; if (xQueueSend(xHciHostQueue, &evt, 10/portTICK_RATE_MS) != pdTRUE) { LOG_ERROR("xHciHostQueue failed\n"); @@ -223,12 +221,12 @@ static void hci_host_thread_handler(void *arg) * H4 type header added (1 byte). */ - BtTaskEvt_t *e; + BtTaskEvt_t e; for (;;) { if (pdTRUE == xQueueReceive(xHciHostQueue, &e, (portTickType)portMAX_DELAY)) { - if (e->sig == 0xff) { + if (e.sig == 0xff) { if (API_vhci_host_check_send_available()) { /*Now Target only allowed one packet per TX*/ BT_HDR *pkt = packet_fragmenter->fragment_current_packet(); @@ -243,7 +241,6 @@ static void hci_host_thread_handler(void *arg) } } } - osi_free(e); } } } diff --git a/components/bt/bluedroid/profiles/core/bt_prf_task.c b/components/bt/bluedroid/profiles/core/bt_prf_task.c index cf5c44177..3c32bb1f6 100644 --- a/components/bt/bluedroid/profiles/core/bt_prf_task.c +++ b/components/bt/bluedroid/profiles/core/bt_prf_task.c @@ -36,31 +36,28 @@ ******************************************************************************/ void bt_prf_task_thread_handler(void *arg) { - - BtTaskEvt_t *e; + BtTaskEvt_t e; + for (;;) { if (pdTRUE == xQueueReceive(xProfileQueue, &e, (portTickType)portMAX_DELAY)) { - if (e->sig == SIG_PRF_WORK) { + if (e.sig == SIG_PRF_WORK) { fixed_queue_process(bt_profile_msg_queue); LOG_ERROR("bt_prf_task_thread_handler\n"); } - else if (e->sig == SIG_PRF_START_UP) { + else if (e.sig == SIG_PRF_START_UP) { bt_prf_task_start_up(); } - osi_free(e); } } } void bt_prf_task_post(uint32_t sig) { - BtTaskEvt_t *evt = (BtTaskEvt_t *)osi_malloc(sizeof(BtTaskEvt_t)); - if (evt == NULL) - return; + BtTaskEvt_t evt; - evt->sig = sig; - evt->par = 0; + evt.sig = sig; + evt.par = 0; if (xQueueSend(xProfileQueue, &evt, 10/portTICK_RATE_MS) != pdTRUE) { ets_printf("xProfileQueue failed\n"); @@ -100,7 +97,7 @@ void bt_prf_StartUp(void) if (bt_profile_msg_queue == NULL) goto error_exit; - xProfileQueue = xQueueCreate(60, sizeof(void *)); + xProfileQueue = xQueueCreate(60, sizeof(BtTaskEvt_t)); xTaskCreate(bt_prf_task_thread_handler, "Bt_prf", 4096, NULL, configMAX_PRIORITIES - 1, &xProfileTaskHandle); bt_prf_task_post(SIG_PRF_START_UP); return; diff --git a/components/bt/bluedroid/stack/btu/btu_init.c b/components/bt/bluedroid/stack/btu/btu_init.c index 9ac18a86a..d8171aa91 100755 --- a/components/bt/bluedroid/stack/btu/btu_init.c +++ b/components/bt/bluedroid/stack/btu/btu_init.c @@ -193,7 +193,7 @@ void BTU_StartUp(void) if (btu_l2cap_alarm_queue == NULL) goto error_exit; - xBtuQueue = xQueueCreate(60, sizeof(void *)); + xBtuQueue = xQueueCreate(60, sizeof(BtTaskEvt_t)); xTaskCreate(btu_task_thread_handler, "BtuT", 8192, NULL, configMAX_PRIORITIES - 1, &xBtuTaskHandle); btu_task_post(SIG_BTU_START_UP); /* diff --git a/components/bt/bluedroid/stack/btu/btu_task.c b/components/bt/bluedroid/stack/btu/btu_task.c index 05231e08f..9e7996cea 100755 --- a/components/bt/bluedroid/stack/btu/btu_task.c +++ b/components/bt/bluedroid/stack/btu/btu_task.c @@ -304,14 +304,12 @@ static void btu_bta_alarm_process(TIMER_LIST_ENT *p_tle) { ******************************************************************************/ void btu_task_thread_handler(void *arg) { - //ke_event_clear(KE_EVENT_BTU_TASK_THREAD); - - BtTaskEvt_t *e; + BtTaskEvt_t e; for (;;) { if (pdTRUE == xQueueReceive(xBtuQueue, &e, (portTickType)portMAX_DELAY)) { - if (e->sig == SIG_BTU_WORK) { + if (e.sig == SIG_BTU_WORK) { fixed_queue_process(btu_hci_msg_queue); #if (defined(BTA_INCLUDED) && BTA_INCLUDED == TRUE) fixed_queue_process(btu_bta_msg_queue); @@ -321,10 +319,9 @@ void btu_task_thread_handler(void *arg) fixed_queue_process(btu_oneshot_alarm_queue); fixed_queue_process(btu_l2cap_alarm_queue); } - else if (e->sig == SIG_BTU_START_UP) { + else if (e.sig == SIG_BTU_START_UP) { btu_task_start_up(); } - osi_free(e); } } } @@ -332,12 +329,10 @@ void btu_task_thread_handler(void *arg) void btu_task_post(uint32_t sig) { - BtTaskEvt_t *evt = (BtTaskEvt_t *)osi_malloc(sizeof(BtTaskEvt_t)); - if (evt == NULL) - return; + BtTaskEvt_t evt; - evt->sig = sig; - evt->par = 0; + evt.sig = sig; + evt.par = 0; if (xQueueSend(xBtuQueue, &evt, 10/portTICK_RATE_MS) != pdTRUE) { LOG_ERROR("xBtuQueue failed\n"); diff --git a/examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app_core.c b/examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app_core.c index 0c3d8ef4e..ee57954c3 100644 --- a/examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app_core.c +++ b/examples/06_bluedroid_demos/components/bluedroid_demos/app_core/bt_app_core.c @@ -73,18 +73,18 @@ extern void ble_server_test(void); static void bt_app_task_handler(void *arg) { - BtTaskEvt_t *e; + BtTaskEvt_t e; UINT8 button_msg[2] = {0x01,0x00}; for (;;) { if (pdTRUE == xQueueReceive(xBtaApp1Queue, &e, (portTickType)portMAX_DELAY)) { - if (e->sig == 0xff) { + if (e.sig == 0xff) { fixed_queue_process(bta_app_msg_queue); fixed_queue_process(bt_app_general_alarm_queue); } #if (BUT_PROFILE_CFG) - // else if(e->sig == BUTTON_PRESS_EVT){ - // LOG_ERROR("button_press_event come in,button_value=%x\n",e->par); - // button_msg[1] = e->par; + // else if(e.sig == BUTTON_PRESS_EVT){ + // LOG_ERROR("button_press_event come in,button_value=%x\n",e.par); + // button_msg[1] = e.par; // button_msg_notify(2,button_msg); @@ -92,19 +92,15 @@ static void bt_app_task_handler(void *arg) #endif ///BUT_PROFILE_CFG } - osi_free(e); } } static void bt_app_task_post(void) { + BtTaskEvt_t evt; - BtTaskEvt_t *evt = (BtTaskEvt_t *)osi_malloc(sizeof(BtTaskEvt_t)); - if (evt == NULL) - return; - - evt->sig = 0xff; - evt->par = 0; + evt.sig = 0xff; + evt.par = 0; if (xQueueSend(xBtaApp1Queue, &evt, 10/portTICK_RATE_MS) != pdTRUE) { ets_printf("btdm_post failed\n"); @@ -188,7 +184,7 @@ void bt_app_task_start_up(void) goto error_exit; //ke_event_callback_set(KE_EVENT_BT_APP_TASK, &bt_app_task_handler); - xBtaApp1Queue = xQueueCreate(3, sizeof(void *)); + xBtaApp1Queue = xQueueCreate(3, sizeof(BtTaskEvt_t)); xTaskCreate(bt_app_task_handler, "BtaApp1T", 8192, NULL, configMAX_PRIORITIES - 3, xBtaApp1TaskHandle); fixed_queue_register_dequeue(bta_app_msg_queue, bta_app_msg_ready); diff --git a/examples/07_blufi/components/blufi/blufi_task.c b/examples/07_blufi/components/blufi/blufi_task.c index 49aa253bd..a1d0f0a2f 100644 --- a/examples/07_blufi/components/blufi/blufi_task.c +++ b/examples/07_blufi/components/blufi/blufi_task.c @@ -43,35 +43,31 @@ extern void ble_server_test(void); static void blufi_task(void *arg) { - BtTaskEvt_t *e; + BtTaskEvt_t e; for (;;) { if (pdTRUE == xQueueReceive(xBlufiTaskQueue, &e, (portTickType)portMAX_DELAY)) { - switch (e->sig) { + switch (e.sig) { case BLUFI_SIG_SWITCH_CONTEXT: - if (e->cb) { - ((BtTaskCb_t)e->cb)(e->arg); + if (e.cb) { + ((BtTaskCb_t)e.cb)(e.arg); } break; default: break; } - osi_free(e); } } } static int blufi_task_post(uint32_t sig, void *par, void *cb, void *arg) { + BtTaskEvt_t evt; - BtTaskEvt_t *evt = (BtTaskEvt_t *)osi_malloc(sizeof(BtTaskEvt_t)); - if (evt == NULL) - return -1; - - evt->sig = sig; - evt->par = par; - evt->cb = cb; - evt->arg = arg; + evt.sig = sig; + evt.par = par; + evt.cb = cb; + evt.arg = arg; if (xQueueSend(xBlufiTaskQueue, &evt, 10/portTICK_RATE_MS) != pdTRUE) { LOG_ERROR("Blufi Post failed\n"); @@ -97,7 +93,7 @@ static void blufi_task_deinit(void) static void blufi_task_init(void) { - xBlufiTaskQueue = xQueueCreate(10, sizeof(void *)); + xBlufiTaskQueue = xQueueCreate(10, sizeof(BtTaskEvt_t)); xTaskCreate(blufi_task, "BlUFI", 8192, NULL, configMAX_PRIORITIES - 3, xBlufiTaskHandle); }