/******************************************************************************* ** ** 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 btif_dut_mode_configure ** ** Description Configure Test Mode - 'enable' to 1 puts the device in test mode and 0 exits ** test mode ** ** Returns BT_STATUS_SUCCESS on success ** *******************************************************************************/ bt_status_t btif_dut_mode_configure(uint8_t enable) { BTIF_TRACE_DEBUG1("%s", __FUNCTION__); if (btif_core_state != BTIF_CORE_STATE_ENABLED) { BTIF_TRACE_ERROR0("btif_dut_mode_configure : Bluetooth not enabled"); return BT_STATUS_NOT_READY; } btif_dut_mode = enable; if (enable == 1) { btif_enable_test_mode(); } else { btif_disable_test_mode(); } return BT_STATUS_SUCCESS; }
bt_status_t btif_sock_init() { static volatile int binit; if(!binit) { //fix me, the process doesn't exit right now. don't set the init flag for now //binit = 1; BTIF_TRACE_DEBUG0("btsock initializing..."); btsock_thread_init(); int handle = btsock_thread_create(btsock_signaled, NULL); if(handle >= 0 && btsock_rfc_init(handle) == BT_STATUS_SUCCESS) { BTIF_TRACE_DEBUG0("btsock successfully initialized"); return BT_STATUS_SUCCESS; } } else BTIF_TRACE_ERROR0("btsock interface already initialized"); return BT_STATUS_FAIL; }
static void bta_pan_callback_transfer(UINT16 event, char *p_param) { tBTA_PAN *p_data = (tBTA_PAN *)p_param; switch(event) { case BTA_PAN_ENABLE_EVT: BTIF_TRACE_DEBUG0("BTA_PAN_ENABLE_EVT"); break; case BTA_PAN_SET_ROLE_EVT: { int btpan_role = bta_role_to_btpan(p_data->set_role.role); bt_status_t status = p_data->set_role.status == BTA_PAN_SUCCESS ? BT_STATUS_SUCCESS : BT_STATUS_FAIL; btpan_control_state_t state = btpan_role == 0 ? BTPAN_STATE_DISABLED : BTPAN_STATE_ENABLED; callback.control_state_cb(state, btpan_role, status, TAP_IF_NAME); break; } case BTA_PAN_OPENING_EVT: { btpan_conn_t* conn; bdstr_t bds; bd2str((bt_bdaddr_t*)p_data->opening.bd_addr, &bds); BTIF_TRACE_DEBUG2("BTA_PAN_OPENING_EVT handle %d, addr: %s", p_data->opening.handle, bds); conn = btpan_find_conn_addr(p_data->opening.bd_addr); asrt(conn != NULL); if (conn) { conn->handle = p_data->opening.handle; int btpan_conn_local_role = bta_role_to_btpan(conn->local_role); int btpan_remote_role = bta_role_to_btpan(conn->remote_role); callback.connection_state_cb(BTPAN_STATE_CONNECTING, BT_STATUS_SUCCESS, (const bt_bdaddr_t*)p_data->opening.bd_addr, btpan_conn_local_role, btpan_remote_role); } else BTIF_TRACE_ERROR0("connection not found"); break; } case BTA_PAN_OPEN_EVT: { /* debug("BTA_PAN_OPEN_EVT, open status:%d, bd_addr = [%02X:%02X:%02X:%02X:%02X:%02X]", */ /* p_data->open.status, */ /* p_data->open.bd_addr[0], p_data->open.bd_addr[1], p_data->open.bd_addr[2], */ /* p_data->open.bd_addr[3], p_data->open.bd_addr[4], p_data->open.bd_addr[5]); */ btpan_connection_state_t state; bt_status_t status; btpan_conn_t* conn = btpan_find_conn_handle(p_data->open.handle); ALOGI("%s: event = BTA_PAN_OPEN_EVT p_data->open.status %d", __FUNCTION__, p_data->open.status); if(p_data->open.status == BTA_PAN_SUCCESS) { state = BTPAN_STATE_CONNECTED; status = BT_STATUS_SUCCESS; } else { state = BTPAN_STATE_DISCONNECTED; status = BT_STATUS_FAIL; btpan_cleanup_conn(conn); } /* debug("BTA_PAN_OPEN_EVT handle:%d, conn:%p", p_data->open.handle, conn); */ /* debug("conn bta local_role:%d, bta remote role:%d", conn->local_role, conn->remote_role); */ int btpan_conn_local_role = bta_role_to_btpan(p_data->open.local_role); /* debug("bta local_role:%d, bta remote role:%d", p_data->open.local_role, p_data->open.peer_role); */ int btpan_remote_role = bta_role_to_btpan(p_data->open.peer_role); callback.connection_state_cb(state, status, (const bt_bdaddr_t*)p_data->open.bd_addr, btpan_conn_local_role, btpan_remote_role); break; } case BTA_PAN_CLOSE_EVT: { btpan_conn_t* conn = btpan_find_conn_handle(p_data->close.handle); ALOGI("%s: event = BTA_PAN_CLOSE_EVT handle %d", __FUNCTION__, p_data->close.handle); btpan_close_conn(conn); if(conn && conn->handle >= 0) { /* debug("BTA_PAN_CLOSE_EVT, conn local_role:%d, remote_role:%d", conn->local_role, conn->remote_role); */ int btpan_conn_local_role = bta_role_to_btpan(conn->local_role); int btpan_remote_role = bta_role_to_btpan(conn->remote_role); callback.connection_state_cb(BTPAN_STATE_DISCONNECTED, 0, (const bt_bdaddr_t*)conn->peer, btpan_conn_local_role, btpan_remote_role); btpan_cleanup_conn(conn); } else BTIF_TRACE_ERROR1("pan handle not found (%d)", p_data->close.handle); break; } default: BTIF_TRACE_WARNING1("Unknown pan event %d", event); break; } }