/******************************************************************************* ** ** Function bta_hl_co_get_mdep_config ** ** Description This function is called to get the supported feature ** configuration for the specified mdep index and it also assigns ** the MDEP ID for the specified mdep index ** ** Parameters app_id - HDP application ID ** mdep_idx - the mdep index ** mdep_id - the assigned MDEP ID for the specified medp_idx ** p_mdl_cfg (output) - pointer to the MDEP configuration ** ** ** Returns Bloolean - TRUE success *******************************************************************************/ BOOLEAN bta_hl_co_get_mdep_config(UINT8 app_id, UINT8 mdep_idx, tBTA_HL_MDEP_ID mdep_id, tBTA_HL_MDEP_CFG *p_mdep_cfg) { UINT8 idx ; UINT8 app_idx; BOOLEAN success = FALSE; BTIF_TRACE_DEBUG4("%s app_id=%d mdep_idx=%d mdep_id=%d", __FUNCTION__, app_id,mdep_idx,mdep_id ); if (btif_hl_find_app_idx(app_id, &app_idx)) { idx = mdep_idx -1; p_btif_hl_cb->acb[app_idx].sup_feature.mdep[idx].mdep_id = mdep_id; memcpy(p_mdep_cfg, &p_btif_hl_cb->acb[app_idx].sup_feature.mdep[idx].mdep_cfg, sizeof(tBTA_HL_MDEP_CFG)); success = TRUE; } BTIF_TRACE_DEBUG4("%s success=%d mdep_idx=%d mdep_id=%d", __FUNCTION__, success, mdep_idx, mdep_id ); return success; }
/******************************************************************************* ** ** Function bta_hl_co_get_tx_data ** ** Description Get the data to be sent ** ** Parameters app_id - HDP application ID ** mdl_handle - MDL handle ** buf_size - the size of the buffer ** p_buf - the buffer pointer ** evt - the evt to be passed back to the HL in the ** bta_hl_ci_get_tx_data call-in function ** ** Returns Void ** *******************************************************************************/ void bta_hl_co_get_tx_data (UINT8 app_id, tBTA_HL_MDL_HANDLE mdl_handle, UINT16 buf_size, UINT8 *p_buf, UINT16 evt) { UINT8 app_idx, mcl_idx, mdl_idx; btif_hl_mdl_cb_t *p_dcb; tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL; BTIF_TRACE_DEBUG4("%s app_id=%d mdl_handle=0x%x buf_size=%d", __FUNCTION__, app_id, mdl_handle, buf_size); if (btif_hl_find_mdl_idx_using_handle(mdl_handle, &app_idx, &mcl_idx, &mdl_idx)) { p_dcb = BTIF_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx); if (p_dcb->tx_size <= buf_size ) { memcpy(p_buf, p_dcb->p_tx_pkt, p_dcb->tx_size); btif_hl_free_buf((void **) &p_dcb->p_tx_pkt); p_dcb->tx_size = 0; status = BTA_HL_STATUS_OK; } } bta_hl_ci_get_tx_data(mdl_handle, status, evt); }
/******************************************************************************* ** ** Function bta_hl_co_get_echo_config ** ** Description This function is called to get the echo test ** maximum APDU size configurations ** ** Parameters app_id - HDP application ID ** p_echo_cfg (output) - pointer to the Echo test maximum APDU size ** configuration ** ** Returns Bloolean - TRUE success *******************************************************************************/ BOOLEAN bta_hl_co_get_echo_config(UINT8 app_id, tBTA_HL_ECHO_CFG *p_echo_cfg) { UINT8 app_idx; BOOLEAN success = FALSE; btif_hl_app_cb_t *p_acb; tBTA_HL_SUP_FEATURE *p_sup; BTIF_TRACE_DEBUG2("%s app_id=%d",__FUNCTION__, app_id ); if (btif_hl_find_app_idx(app_id, &app_idx)) { p_acb = BTIF_HL_GET_APP_CB_PTR(app_idx); p_sup = &p_acb->sup_feature; p_echo_cfg->max_rx_apdu_size = p_sup->echo_cfg.max_rx_apdu_size; p_echo_cfg->max_tx_apdu_size = p_sup->echo_cfg.max_tx_apdu_size; success = TRUE; } BTIF_TRACE_DEBUG4("%s success=%d max tx_size=%d rx_size=%d", __FUNCTION__, success, p_echo_cfg->max_tx_apdu_size, p_echo_cfg->max_rx_apdu_size ); return success; }
// rfc_slot_t* accept_rs = create_srv_accept_rfc_slot(srv_rs, p_open->rem_bda,p_opne->handle, p_open->new_listen_handle); static inline rfc_slot_t* create_srv_accept_rfc_slot(rfc_slot_t* srv_rs, const bt_bdaddr_t* addr, int open_handle, int new_listen_handle) { rfc_slot_t *accept_rs = alloc_rfc_slot(addr, srv_rs->service_name, srv_rs->service_uuid, srv_rs->scn, 0, FALSE); clear_slot_flag(&accept_rs->f); accept_rs->f.server = FALSE; accept_rs->f.connected = TRUE; accept_rs->security = srv_rs->security; accept_rs->mtu = srv_rs->mtu; accept_rs->role = srv_rs->role; accept_rs->rfc_handle = open_handle; accept_rs->rfc_port_handle = BTA_JvRfcommGetPortHdl(open_handle); //now update listen rfc_handle of server slot srv_rs->rfc_handle = new_listen_handle; srv_rs->rfc_port_handle = BTA_JvRfcommGetPortHdl(new_listen_handle); BTIF_TRACE_DEBUG4("create_srv_accept__rfc_slot(open_handle: 0x%x, new_listen_handle:" "0x%x) accept_rs->rfc_handle:0x%x, srv_rs_listen->rfc_handle:0x%x" ,open_handle, new_listen_handle, accept_rs->rfc_port_handle, srv_rs->rfc_port_handle); asrt(accept_rs->rfc_port_handle != srv_rs->rfc_port_handle); //now swap the slot id uint32_t new_listen_id = accept_rs->id; accept_rs->id = srv_rs->id; srv_rs->id = new_listen_id; return accept_rs; }
/******************************************************************************* ** ** Function bta_hl_co_put_rx_data ** ** Description Put the received data ** ** Parameters app_id - HDP application ID ** mdl_handle - MDL handle ** data_size - the size of the data ** p_data - the data pointer ** evt - the evt to be passed back to the HL in the ** bta_hl_ci_put_rx_data call-in function ** ** Returns Void ** *******************************************************************************/ void bta_hl_co_put_rx_data (UINT8 app_id, tBTA_HL_MDL_HANDLE mdl_handle, UINT16 data_size, UINT8 *p_data, UINT16 evt) { UINT8 app_idx, mcl_idx, mdl_idx; btif_hl_mdl_cb_t *p_dcb; tBTA_HL_STATUS status = BTA_HL_STATUS_FAIL; int r; BTIF_TRACE_DEBUG4("%s app_id=%d mdl_handle=0x%x data_size=%d", __FUNCTION__,app_id, mdl_handle, data_size); if (btif_hl_find_mdl_idx_using_handle(mdl_handle, &app_idx, &mcl_idx, &mdl_idx)) { p_dcb = BTIF_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx); if ((p_dcb->p_rx_pkt = (UINT8 *)btif_hl_get_buf(data_size)) != NULL) { memcpy(p_dcb->p_rx_pkt, p_data, data_size); if (p_dcb->p_scb) { BTIF_TRACE_DEBUG4("app_idx=%d mcl_idx=0x%x mdl_idx=0x%x data_size=%d", app_idx, mcl_idx, mdl_idx, data_size); r = send(p_dcb->p_scb->socket_id[1], p_dcb->p_rx_pkt, data_size, 0); if (r == data_size) { BTIF_TRACE_DEBUG1("socket send success data_size=%d", data_size); status = BTA_HL_STATUS_OK; } else { BTIF_TRACE_ERROR2("socket send failed r=%d data_size=%d",r, data_size); } } btif_hl_free_buf((void **) &p_dcb->p_rx_pkt); } } bta_hl_ci_put_rx_data(mdl_handle, status, evt); }
/***************************************************************************** ** Local uinput helper functions ******************************************************************************/ int send_event (int fd, uint16_t type, uint16_t code, int32_t value) { struct uinput_event event; BTIF_TRACE_DEBUG4("%s type:%u code:%u value:%d", __FUNCTION__, type, code, value); memset(&event, 0, sizeof(event)); event.type = type; event.code = code; event.value = value; return write(fd, &event, sizeof(event)); }
void send_key (int fd, uint16_t key, int pressed) { BTIF_TRACE_DEBUG4("%s fd:%d key:%u pressed:%d", __FUNCTION__, fd, key, pressed); if (fd < 0) { return; } BTIF_TRACE_DEBUG3("AVRCP: Send key %d (%d) fd=%d", key, pressed, fd); send_event(fd, EV_KEY, key, pressed); send_event(fd, EV_SYN, SYN_REPORT, 0); }
/* Generic reject response */ static void send_reject_response (UINT8 rc_handle, UINT8 label, UINT8 pdu, UINT8 status) { UINT8 ctype = AVRC_RSP_REJ; tAVRC_RESPONSE avrc_rsp; BT_HDR *p_msg = NULL; memset (&avrc_rsp, 0, sizeof(tAVRC_RESPONSE)); avrc_rsp.rsp.opcode = opcode_from_pdu(pdu); avrc_rsp.rsp.pdu = pdu; avrc_rsp.rsp.status = status; if (AVRC_STS_NO_ERROR == (status = AVRC_BldResponse(rc_handle, &avrc_rsp, &p_msg)) ) { BTIF_TRACE_DEBUG4("%s:Sending error notification to handle:%d. pdu:%s,status:0x%02x", __FUNCTION__, rc_handle, dump_rc_pdu(pdu), status); BTA_AvMetaRsp(rc_handle, label, ctype, p_msg); } }
/*************************************************************************** * Function send_metamsg_rsp * * - Argument: * rc_handle RC handle corresponding to the connected RC * label Label of the RC response * code Response type * pmetamsg_resp Vendor response * * - Description: Remote control metamsg response handler (AVRCP 1.3) * ***************************************************************************/ static void send_metamsg_rsp (UINT8 rc_handle, UINT8 label, tBTA_AV_CODE code, tAVRC_RESPONSE *pmetamsg_resp) { UINT8 ctype; tAVRC_STS status; if (!pmetamsg_resp) { BTIF_TRACE_WARNING1("%s: Invalid response received from application", __FUNCTION__); return; } BTIF_TRACE_EVENT5("+%s: rc_handle: %d, label: %d, code: 0x%02x, pdu: %s", __FUNCTION__, rc_handle, label, code, dump_rc_pdu(pmetamsg_resp->rsp.pdu)); if (pmetamsg_resp->rsp.status != AVRC_STS_NO_ERROR) { ctype = AVRC_RSP_REJ; } else { if ( code < AVRC_RSP_NOT_IMPL) { if (code == AVRC_CMD_NOTIF) { ctype = AVRC_RSP_INTERIM; } else if (code == AVRC_CMD_STATUS) { ctype = AVRC_RSP_IMPL_STBL; } else { ctype = AVRC_RSP_ACCEPT; } } else { ctype = code; } } /* if response is for register_notification, make sure the rc has actually registered for this */ if((pmetamsg_resp->rsp.pdu == AVRC_PDU_REGISTER_NOTIFICATION) && (code == AVRC_RSP_CHANGED)) { BOOLEAN bSent = FALSE; UINT8 event_id = pmetamsg_resp->reg_notif.event_id; BOOLEAN bNotify = (btif_rc_cb.rc_connected) && (btif_rc_cb.rc_notif[event_id-1].bNotify); /* de-register this notification for a CHANGED response */ btif_rc_cb.rc_notif[event_id-1].bNotify = FALSE; BTIF_TRACE_DEBUG4("%s rc_handle: %d. event_id: 0x%02d bNotify:%u", __FUNCTION__, btif_rc_cb.rc_handle, event_id, bNotify); if (bNotify) { BT_HDR *p_msg = NULL; tAVRC_STS status; if (AVRC_STS_NO_ERROR == (status = AVRC_BldResponse(btif_rc_cb.rc_handle, pmetamsg_resp, &p_msg)) ) { BTIF_TRACE_DEBUG3("%s Sending notification to rc_handle: %d. event_id: 0x%02d", __FUNCTION__, btif_rc_cb.rc_handle, event_id); bSent = TRUE; BTA_AvMetaRsp(btif_rc_cb.rc_handle, btif_rc_cb.rc_notif[event_id-1].label, ctype, p_msg); } else { BTIF_TRACE_WARNING2("%s failed to build metamsg response. status: 0x%02x", __FUNCTION__, status); } } if (!bSent) { BTIF_TRACE_DEBUG2("%s: Notification not sent, as there are no RC connections or the \ CT has not subscribed for event_id: %s", __FUNCTION__, dump_rc_notification_event_id(event_id)); }