/******************************************************************************* ** ** Function btif_queue_remove_connect ** ** Description Remove connection request from connect Queue ** when connect request for same UUID is received ** from app. ** ** Returns void ** *******************************************************************************/ void btif_queue_remove_connect(uint16_t uuid, uint8_t check_connect_req) { connect_node_t node; memset(&node, 0, sizeof(connect_node_t)); node.uuid = uuid; btif_transfer_context(queue_int_handle_evt, check_connect_req, (char*)&node, sizeof(connect_node_t), NULL); }
static void bte_hf_client_evt(tBTA_HF_CLIENT_EVT event, tBTA_HF_CLIENT *p_data) { bt_status_t status; /* switch context to btif task context (copy full union size for convenience) */ status = btif_transfer_context(btif_hf_client_upstreams_evt, (uint16_t)event, (void*)p_data, sizeof(*p_data), NULL); /* catch any failed context transfers */ ASSERTC(status == BT_STATUS_SUCCESS, "context transfer failed", status); }
/******************************************************************************* ** ** Function btif_queue_connect ** ** Description Add a new connection to the queue and trigger the next ** scheduled connection. ** ** Returns BT_STATUS_SUCCESS if successful ** *******************************************************************************/ bt_status_t btif_queue_connect(uint16_t uuid, const bt_bdaddr_t *bda, btif_connect_cb_t connect_cb) { connect_node_t node; memset(&node, 0, sizeof(connect_node_t)); memcpy(&node.bda, bda, sizeof(bt_bdaddr_t)); node.uuid = uuid; node.connect_cb = connect_cb; return btif_transfer_context(queue_int_handle_evt, BTIF_QUEUE_CONNECT_EVT, (char *)&node, sizeof(connect_node_t), NULL); }
void btu_task_start_up(UNUSED_ATTR void *context) { BT_TRACE(TRACE_LAYER_BTU, TRACE_TYPE_API, "btu_task pending for preload complete event"); LOG_INFO(LOG_TAG, "Bluetooth chip preload is complete"); BT_TRACE(TRACE_LAYER_BTU, TRACE_TYPE_API, "btu_task received preload complete event"); /* Initialize the mandatory core stack control blocks (BTU, BTM, L2CAP, and SDP) */ btu_init_core(); /* Initialize any optional stack components */ BTE_InitStack(); bta_sys_init(); /* Initialise platform trace levels at this point as BTE_InitStack() and bta_sys_init() * reset the control blocks and preset the trace level with XXX_INITIAL_TRACE_LEVEL */ #if ( BT_USE_TRACES==TRUE ) module_init(get_module(BTE_LOGMSG_MODULE)); #endif // Inform the bt jni thread initialization is ok. btif_transfer_context(btif_init_ok, 0, NULL, 0, NULL); fixed_queue_register_dequeue(btu_bta_msg_queue, thread_get_reactor(bt_workqueue_thread), btu_bta_msg_ready, NULL); fixed_queue_register_dequeue(btu_hci_msg_queue, thread_get_reactor(bt_workqueue_thread), btu_hci_msg_ready, NULL); fixed_queue_register_dequeue(btu_general_alarm_queue, thread_get_reactor(bt_workqueue_thread), btu_general_alarm_ready, NULL); fixed_queue_register_dequeue(btu_oneshot_alarm_queue, thread_get_reactor(bt_workqueue_thread), btu_oneshot_alarm_ready, NULL); fixed_queue_register_dequeue(btu_l2cap_alarm_queue, thread_get_reactor(bt_workqueue_thread), btu_l2cap_alarm_ready, NULL); }
/******************************************************************************* ** ** Function btif_queue_connect ** ** Description Add a new connection to the queue and trigger the next ** scheduled connection. ** ** Returns BT_STATUS_SUCCESS if successful ** *******************************************************************************/ bt_status_t btif_queue_connect(uint16_t uuid, const bt_bdaddr_t *bda, btif_connect_cb_t *connect_cb, uint8_t queue_connect) { connect_node_t node; memset(&node, 0, sizeof(connect_node_t)); memcpy(&(node.bda), bda, sizeof(bt_bdaddr_t)); node.uuid = uuid; node.p_cb = connect_cb; return btif_transfer_context(queue_int_handle_evt, queue_connect, (char*)&node, sizeof(connect_node_t), NULL); }
static bt_status_t btpan_disconnect(const bt_bdaddr_t *bd_addr) { btpan_conn_t* conn = btpan_find_conn_addr(bd_addr->address); if(conn && conn->handle >= 0) { /* Inform the application that the disconnect has been initiated successfully */ btif_transfer_context(btif_in_pan_generic_evt, BTIF_PAN_CB_DISCONNECTING, (char *)bd_addr, sizeof(bt_bdaddr_t), NULL); BTA_PanClose(conn->handle); return BT_STATUS_SUCCESS; } return BT_STATUS_FAIL; }
static void bte_hd_evt(tBTA_HD_EVT event, tBTA_HD *p_data) { bt_status_t status; int param_len = 0; tBTIF_COPY_CBACK *p_copy_cback = NULL; BTIF_TRACE_API("%s event=%d", __FUNCTION__, event); switch (event) { case BTA_HD_ENABLE_EVT: case BTA_HD_DISABLE_EVT: case BTA_HD_UNREGISTER_APP_EVT: param_len = sizeof(tBTA_HD_STATUS); break; case BTA_HD_REGISTER_APP_EVT: param_len = sizeof(tBTA_HD_REG_STATUS); break; case BTA_HD_OPEN_EVT: case BTA_HD_CLOSE_EVT: case BTA_HD_VC_UNPLUG_EVT: param_len = sizeof(tBTA_HD_CONN); break; case BTA_HD_GET_REPORT_EVT: param_len += sizeof(tBTA_HD_GET_REPORT); break; case BTA_HD_SET_REPORT_EVT: param_len = sizeof(tBTA_HD_SET_REPORT) + p_data->set_report.len; p_copy_cback = set_report_copy_cb; break; case BTA_HD_SET_PROTOCOL_EVT: param_len += sizeof(p_data->set_protocol); break; case BTA_HD_INTR_DATA_EVT: param_len = sizeof(tBTA_HD_INTR_DATA) + p_data->intr_data.len; p_copy_cback = intr_data_copy_cb; break; } status = btif_transfer_context(btif_hd_upstreams_evt, (uint16_t)event, (void*)p_data, param_len, p_copy_cback); ASSERTC(status == BT_STATUS_SUCCESS, "context transfer failed", status); }
/******************************************************************************* ** ** Function connect_audio ** ** Description create an audio connection ** ** Returns bt_status_t ** *******************************************************************************/ static bt_status_t connect_audio( bt_bdaddr_t *bd_addr ) { CHECK_BTHF_INIT(); if (is_connected(bd_addr)) { BTA_AgAudioOpen(btif_hf_cb.handle); /* Inform the application that the audio connection has been initiated successfully */ btif_transfer_context(btif_in_hf_generic_evt, BTIF_HFP_CB_AUDIO_CONNECTING, (char *)bd_addr, sizeof(bt_bdaddr_t), NULL); return BT_STATUS_SUCCESS; } return BT_STATUS_FAIL; }
static void mce_dm_cback(tBTA_MCE_EVT event, tBTA_MCE *p_data, void *user_data) { switch (event) { case BTA_MCE_MAS_DISCOVERY_COMP_EVT: { int i; UINT16 param_len = sizeof(tBTA_MCE); /* include space for all p_srv_name copies including null-termination */ for (i = 0; i < p_data->mas_disc_comp.num_mas; i++) param_len += (p_data->mas_disc_comp.mas[i].srv_name_len + 1); /* need to deepy copy p_srv_name and null-terminate */ btif_transfer_context(btif_mce_mas_discovery_comp_evt, event, (char*)p_data, param_len, mas_discovery_comp_copy_cb); break; } } }
/******************************************************************************* ** ** Function connect_audio ** ** Description create an audio connection ** ** Returns bt_status_t ** *******************************************************************************/ static bt_status_t connect_audio( bt_bdaddr_t *bd_addr ) { CHECK_BTHF_CLIENT_SLC_CONNECTED(); if (is_connected(bd_addr)) { if (btif_hf_client_cb.peer_feat & BTA_HF_CLIENT_PEER_CODEC) { BTA_HfClientSendAT(btif_hf_client_cb.handle, BTA_HF_CLIENT_AT_CMD_BCC, 0, 0, NULL); } else { BTA_HfClientAudioOpen(btif_hf_client_cb.handle); } /* Inform the application that the audio connection has been initiated successfully */ btif_transfer_context(btif_in_hf_client_generic_evt, BTIF_HF_CLIENT_CB_AUDIO_CONNECTING, (char *)bd_addr, sizeof(bt_bdaddr_t), NULL); return BT_STATUS_SUCCESS; } return BT_STATUS_FAIL; }
static void bte_hf_evt(tBTA_AG_EVT event, tBTA_AG *p_data) { bt_status_t status; int param_len = 0; /* TODO: BTA sends the union members and not tBTA_AG. If using param_len=sizeof(tBTA_AG), we get a crash on memcpy */ if (BTA_AG_REGISTER_EVT == event) param_len = sizeof(tBTA_AG_REGISTER); else if (BTA_AG_OPEN_EVT == event) param_len = sizeof(tBTA_AG_OPEN); else if (BTA_AG_CONN_EVT == event) param_len = sizeof(tBTA_AG_CONN); else if ( (BTA_AG_CLOSE_EVT == event) || (BTA_AG_AUDIO_OPEN_EVT == event) || (BTA_AG_AUDIO_CLOSE_EVT == event)) param_len = sizeof(tBTA_AG_HDR); else if (p_data) param_len = sizeof(tBTA_AG_VAL); /* switch context to btif task context (copy full union size for convenience) */ status = btif_transfer_context(btif_hf_upstreams_evt, (uint16_t)event, (void*)p_data, param_len, NULL); /* catch any failed context transfers */ ASSERTC(status == BT_STATUS_SUCCESS, "context transfer failed", status); }
/******************************************************************************* ** ** Function btif_queue_advance ** ** Description Clear the queue's busy status and advance to the next ** scheduled connection. ** ** Returns void ** *******************************************************************************/ void btif_queue_advance() { btif_transfer_context(queue_int_handle_evt, BTIF_QUEUE_ADVANCE_EVT, NULL, 0, NULL); }
static void bta_pan_callback(tBTA_PAN_EVT event, tBTA_PAN *p_data) { btif_transfer_context(bta_pan_callback_transfer, event, (char*)p_data, sizeof(tBTA_PAN), NULL); }
/******************************************************************************* ** ** Function btif_queue_pending_retry ** ** Description Advance to the next scheduled connection. ** ** Returns void ** *******************************************************************************/ void btif_queue_pending_retry() { BTIF_TRACE_VERBOSE0("btif_queue_pending_retry"); btif_transfer_context(queue_int_handle_evt, BTIF_QUEUE_PENDING_CONECT_ADVANCE_EVT, NULL, 0, NULL); }
/* used to pass events to AV statemachine from other tasks */ void btif_dispatch_sm_event(btif_av_sm_event_t event, void *p_data, int len) { /* Switch to BTIF context */ btif_transfer_context(btif_av_handle_event, event, (char*)p_data, len, NULL); }