//-------------------------------------------------------------------------------------------------- static le_result_t StartPDPConnection ( uint32_t profileIndex ///< [IN] The profile identifier ) { char atcommand[ATCOMMAND_SIZE] ; atcmd_Ref_t atReqRef=NULL; atcmdsync_ResultRef_t atresRef; const char* finalRespOkPtr[] = { "CONNECT" , NULL }; const char* finalRespKoPtr[] = { "NO CARRIER", "TIMEOUT", NULL}; atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"ATD*99***%d#",profileIndex); atReqRef = atcmdsync_PrepareStandardCommand(atcommand, NULL, finalRespOkPtr, finalRespKoPtr, 30000); atresRef = atcmdsync_SendCommand(atports_GetInterface(ATPORT_PPP),atReqRef); le_result_t result = atcmdsync_CheckCommandResult(atresRef,finalRespOkPtr,finalRespKoPtr); le_mem_Release(atReqRef); le_mem_Release(atresRef); return result; }
//-------------------------------------------------------------------------------------------------- static le_result_t resetModem ( void ) { atcmdsync_ResultRef_t resRef=NULL; const char* finalRespOkPtr[] = {"+WIND: 4",NULL }; const char* finalRespKoPtr[] = {"ERROR","+CME ERROR:","+CMS ERROR:","TIMEOUT",NULL}; atcmd_Ref_t atReqRef = atcmd_Create(); atcmd_AddCommand(atReqRef,"at+cfun=1",false); atcmd_AddData (atReqRef,NULL,0); atcmd_SetTimer (atReqRef,30000,atcmdsync_GetTimerExpiryHandler()); atcmd_AddIntermediateResp (atReqRef,atcmdsync_GetIntermediateEventId(),NULL); atcmd_AddFinalResp(atReqRef,atcmdsync_GetFinalEventId(),finalRespOkPtr); atcmd_AddFinalResp(atReqRef,atcmdsync_GetFinalEventId(),finalRespKoPtr); resRef = atcmdsync_SendCommand(atports_GetInterface(ATPORT_COMMAND),atReqRef); le_result_t result = atcmdsync_CheckCommandResult(resRef,finalRespOkPtr,finalRespKoPtr); le_mem_Release(atReqRef); // Release e_atmgr_Object_CreateATCommand le_mem_Release(resRef); // Release le_pa_at_SendSync return result; }
//-------------------------------------------------------------------------------------------------- le_result_t pa_sim_GetState ( le_sim_States_t* statePtr ///< [OUT] SIM state ) { int32_t result=LE_NOT_POSSIBLE; atcmd_Ref_t atReqRef; atcmdsync_ResultRef_t resRef = NULL; const char* finalRespOkPtr[] = {"OK","+CPIN:",NULL}; const char* finalRespKoPtr[] = {"ERROR","+CME ERROR:","+CMS ERROR:","TIMEOUT",NULL}; if (!statePtr) { LE_DEBUG("One parameter is NULL"); return LE_BAD_PARAMETER; } *statePtr=LE_SIM_STATE_UNKNOWN; atReqRef = atcmd_Create(); atcmd_AddCommand(atReqRef,"at+cpin?",false); atcmd_AddData(atReqRef,NULL,0); atcmd_SetTimer(atReqRef,30000,atcmdsync_GetTimerExpiryHandler()); atcmd_AddIntermediateResp (atReqRef,atcmdsync_GetIntermediateEventId(),NULL); atcmd_AddFinalResp(atReqRef,atcmdsync_GetFinalEventId(),finalRespOkPtr); atcmd_AddFinalResp(atReqRef,atcmdsync_GetFinalEventId(),finalRespKoPtr); resRef = atcmdsync_SendCommand(atports_GetInterface(ATPORT_COMMAND),atReqRef); char* line = atcmdsync_GetFinalLine(resRef); // Check timeout if (FIND_STRING("TIMEOUT",line)) { LE_WARN("Modem failed"); le_mem_Release(atReqRef); le_mem_Release(resRef); return LE_TIMEOUT; } if (CheckStatus(line,statePtr)) { ReportStatus(NumCard,*statePtr); result = LE_OK; } le_mem_Release(atReqRef); // Release atcmdsync_SetCommand le_mem_Release(resRef); // Release atcmdsync_SendCommand return result; }