/**************************************************************************** Outcome of the RFCOMM connect request or response. */ static void aghfpHandleRfcommConnectCfm(AGHFP *aghfp, rfcomm_connect_status status) { /* Check the status of the rfcomm connect cfm */ if (status == rfcomm_connect_success) { /* RFCOMM connection is up! Check which profile is supported by this task */ if (supportedProfileIsHsp(aghfp->supported_profile)) { /* HSP supported - SLC is up so tell the app */ aghfpSendSlcConnectCfmToApp(aghfp_connect_success, aghfp); } else if (supportedProfileIsHfp(aghfp->supported_profile)) { /* HFP supported - RFCOMM is up, so just wait for HF to send us some AT commends */ } else { /* This should never happen */ AGHFP_DEBUG_PANIC(("Unhandled profile type 0x%x\n", aghfp->supported_profile)); } /* Check for data in the buffer */ aghfpHandleReceivedData(aghfp, StreamSourceFromSink(aghfp->rfcomm_sink)); } else { /* RFCOMM connect failed - Tell the app. */ aghfpSendSlcConnectCfmToApp(convertRfcommConnectStatus(status), aghfp); } aghfp->rfcomm_lock = FALSE; }
/**************************************************************************** This function is called as a result of a message arriving when this library was not expecting it. */ static void handleUnexpected(aghfpUnexpectedReasonCode code, aghfp_state state, uint16 type) { state = state; type = type; code = code; AGHFP_DEBUG_PANIC(("aghfp handleUnexpected - Code 0x%x State 0x%x MsgId 0x%x\n", code, state, type)); }
void aghfpSendError(AGHFP *aghfp) { if (aghfp->rfcomm_sink) { aghfpSendAtCmd(aghfp, "ERROR"); } else { AGHFP_DEBUG_PANIC(("Couldn't send ERROR because there is no RFCOMM sink")); } }
/* Convert from the rfcomm_connect_status returned by the connection lib. */ static aghfp_connect_status convertRfcommConnectStatus(rfcomm_connect_status status) { switch (status) { case rfcomm_connect_success: return aghfp_connect_success; case rfcomm_connect_failed: return aghfp_connect_failed; case rfcomm_connect_pending: case rfcomm_connect_security_not_set: case rfcomm_connect_declined: case rfcomm_connect_channel_already_open: case rfcomm_connect_rejected_security: case rfcomm_connect_l2cap_error: /* TODO - Add more specific AGHFP error codes? */ return aghfp_connect_failed; case rfcomm_connect_channel_not_registered: return aghfp_connect_server_channel_not_registered; case rfcomm_connect_res_ack_timeout: return aghfp_connect_timeout; case rfcomm_connect_rejected: return aghfp_connect_rejected; /* also check L2CAP status */ case l2cap_connect_failed_security: return aghfp_connect_security_reject; default: /* All rfcomm disconnects should be handled above if we get this panic in debug lib */ AGHFP_DEBUG_PANIC(("Unhandled rfc connect status 0x%x\n", status)); /* Return generic connect fail in "release" lib variant */ return aghfp_connect_failed; } }