/******************************************************************************* ** ** Function btif_disable_bluetooth ** ** Description Inititates shutdown of Bluetooth system. ** Any active links will be dropped and device entering ** non connectable/discoverable mode ** ** Returns void ** *******************************************************************************/ bt_status_t btif_disable_bluetooth(void) { tBTA_STATUS status; if (!btif_is_enabled()) { BTIF_TRACE_ERROR0("btif_disable_bluetooth : not yet enabled"); return BT_STATUS_NOT_READY; } bte_main_disable(); GKI_destroy_task(BTIF_TASK); bte_main_shutdown(); BTIF_TRACE_DEBUG0("BTIF DISABLE BLUETOOTH"); btif_core_state = BTIF_CORE_STATE_DISABLED; HAL_CBACK(bt_hal_cbacks, adapter_state_changed_cb, BT_STATE_OFF); return BT_STATUS_SUCCESS; }
/****************************************************************************** ** ** Function bte_main_shutdown ** ** Description BTE MAIN API - Shutdown code for BTE chip/stack ** ** Returns None ** ******************************************************************************/ void bte_main_shutdown(void) { #if (BLE_INCLUDED == TRUE) BTA_VendorCleanup(); #endif bte_main_disable(); osi_deinit(); }
/****************************************************************************** ** ** Function bte_main_shutdown ** ** Description BTE MAIN API - Shutdown code for BTE chip/stack ** ** Returns None ** ******************************************************************************/ void bte_main_shutdown(void) { //data_dispatcher_register_default(hci_layer_get_interface()->event_dispatcher, NULL); hci->set_data_queue(NULL); fixed_queue_unregister_dequeue(btu_hci_msg_queue); fixed_queue_free(btu_hci_msg_queue, NULL); btu_hci_msg_queue = NULL; /* module_clean_up(get_module(STACK_CONFIG_MODULE)); module_clean_up(get_module(COUNTER_MODULE)); module_clean_up(get_module(GKI_MODULE)); */ #if (BLE_INCLUDED == TRUE) BTA_VendorCleanup(); #endif bte_main_disable(); gki_clean_up(); }
static void btif_task(UINT32 params) { UINT16 event; BT_HDR *p_msg; BTIF_TRACE_DEBUG0("btif task starting"); btif_associate_evt(); for(;;) { /* wait for specified events */ event = GKI_wait(0xFFFF, 0); /* * Wait for the trigger to init chip and stack. This trigger will * be received by btu_task once the UART is opened and ready */ if (event == BT_EVT_TRIGGER_STACK_INIT) { BTIF_TRACE_DEBUG0("btif_task: received trigger stack init event"); btif_enable_bluetooth_evt(BT_STATE_ON); } /* * Failed to initialize controller hardware, reset state and bring * down all threads */ if (event == BT_EVT_HARDWARE_INIT_FAIL) { BTIF_TRACE_DEBUG0("btif_task: hardware init failed"); bte_main_disable(); GKI_task_self_cleanup(BTIF_TASK); bte_main_shutdown(); btif_dut_mode = 0; btif_core_state = BTIF_CORE_STATE_DISABLED; HAL_CBACK(bt_hal_cbacks,adapter_state_changed_cb,BT_STATE_OFF); break; } if (event & EVENT_MASK(GKI_SHUTDOWN_EVT)) break; if(event & TASK_MBOX_1_EVT_MASK) { while((p_msg = GKI_read_mbox(BTU_BTIF_MBOX)) != NULL) { BTIF_TRACE_VERBOSE1("btif task fetched event %x", p_msg->event); switch (p_msg->event) { case BT_EVT_CONTEXT_SWITCH_EVT: btif_context_switched(p_msg); break; case BT_EVT_RX: btif_mp_test_evt(p_msg); break; case BT_EVT_MP_NOTIFY_BTIF: btif_mp_notify_evt(p_msg); break; default: BTIF_TRACE_ERROR1("unhandled btif event (%d)", p_msg->event & BT_EVT_MASK); break; } GKI_freebuf(p_msg); } } } btif_disassociate_evt(); BTIF_TRACE_DEBUG0("btif task exiting"); }