//-------------------------------------------------------------------------------------------------- le_result_t pa_mrc_SetRadioPower ( le_onoff_t power ///< [IN] The power state. ) { char atcommand[ATCOMMAND_SIZE] ; if (power == LE_ON) { atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cfun=1"); } else if (power == LE_OFF) { atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cfun=0"); } else { return LE_FAULT; } return atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND), atcommand, NULL, NULL, 30000); }
//-------------------------------------------------------------------------------------------------- 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 SetIndicationHandler ( uint32_t mode ///< Unsolicited result mode ) { char atcommand[ATCOMMAND_SIZE] ; atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cgerep=%d",mode); le_result_t result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND), atcommand, NULL, NULL, 30000); if ( result == LE_OK ) { if (mode) { atmgr_SubscribeUnsolReq(atports_GetInterface(ATPORT_COMMAND), UnsolicitedEvent, "+CGEV:", false); } else { atmgr_UnSubscribeUnsolReq(atports_GetInterface(ATPORT_COMMAND),UnsolicitedEvent,"+CGEV:"); } } return result; }
//-------------------------------------------------------------------------------------------------- le_result_t pa_sim_EnterPUK ( pa_sim_PukType_t type, ///< [IN] puk type const pa_sim_Puk_t puk, ///< [IN] PUK code const pa_sim_Pin_t pin ///< [IN] new PIN code ) { atcmdsync_ResultRef_t resRef = NULL; char atcommand[ATCOMMAND_SIZE] ; atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cpin=%s,%s",puk,pin); le_result_t result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND), atcommand, &resRef, NULL, 30000); if ( result != LE_OK ) { le_mem_Release(resRef); return result; } le_sim_States_t simState=LE_SIM_STATE_UNKNOWN; char* line = atcmdsync_GetLine(resRef,0); if (CheckStatus(line,&simState)) { ReportStatus(NumCard,simState); } le_mem_Release(resRef); // release atcmdsync_SendCommandDefault return LE_OK; }
//-------------------------------------------------------------------------------------------------- le_result_t pa_sim_SelectCard ( uint32_t cardNum ///< [IN] The card number to be selected. ) { char atcommand[ATCOMMAND_SIZE] ; if ((cardNum==1) || (cardNum==2)) { atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+whcnf=4,%d",cardNum); } else { LE_DEBUG("This card number (%d) is not supported",cardNum); return LE_NOT_POSSIBLE; } le_result_t result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND), atcommand, NULL, NULL, 30000); if ( result != LE_OK ) { return result; } if (resetModem()!=LE_OK) { return LE_NOT_POSSIBLE; } NumCard = cardNum; return result; }
//-------------------------------------------------------------------------------------------------- le_result_t pa_sim_ChangePIN ( pa_sim_PinType_t type, ///< [IN] The code type const pa_sim_Pin_t oldcode, ///< [IN] Old code const pa_sim_Pin_t newcode ///< [IN] New code ) { atcmdsync_ResultRef_t resRef = NULL; char atcommand[ATCOMMAND_SIZE] ; if (type==PA_SIM_PIN) { atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cpwd=\"SC\",%s,%s",oldcode,newcode); } else if (type==PA_SIM_PIN2) { atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cpwd=\"P2\",%s,%s",oldcode,newcode); } else { return LE_BAD_PARAMETER; } le_result_t result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND), atcommand, &resRef, NULL, 30000); if ( result != LE_OK ) { le_mem_Release(resRef); return result; } le_sim_States_t simState=LE_SIM_STATE_UNKNOWN; char* line = atcmdsync_GetLine(resRef,0); if (CheckStatus(line,&simState)) { ReportStatus(NumCard,simState); } le_mem_Release(resRef); // Release atcmdsync_SendCommandDefault return LE_OK; }
//-------------------------------------------------------------------------------------------------- static le_result_t AttachGPRS ( bool toAttach ///< [IN] boolean value ) { char atcommand[ATCOMMAND_SIZE] ; atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cgatt=%d",toAttach); return atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND), atcommand, NULL, NULL, 30000); }
//-------------------------------------------------------------------------------------------------- le_result_t pa_mrc_ConfigureNetworkReg ( pa_mrc_NetworkRegSetting_t setting ///< [IN] The selected Network registration setting. ) { char atcommand[ATCOMMAND_SIZE] ; atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+creg=%d", setting); return atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND), atcommand, NULL, NULL, 30000); }
//-------------------------------------------------------------------------------------------------- static le_result_t ActivateContext ( uint32_t profileIndex, ///< [IN] The profile to read bool toActivate ///< [IN] activation boolean ) { char atcommand[ATCOMMAND_SIZE] ; atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cgact=%d,%d",toActivate,profileIndex); return atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND), atcommand, NULL, NULL, 30000); }
//-------------------------------------------------------------------------------------------------- le_result_t pa_mdc_WriteProfile ( uint32_t profileIndex, ///< [IN] The profile to write pa_mdc_ProfileData_t* profileDataPtr ///< [IN] The profile data ) { char atcommand[ATCOMMAND_SIZE] ; atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE, "at+cgdcont=%d,\"%s\",\"%s\"",profileIndex, "IP", profileDataPtr->apn); return atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND), atcommand, NULL, NULL, 30000); }
//-------------------------------------------------------------------------------------------------- le_result_t pa_common_SetWindIndicator ( uint32_t wind ) { atcmdsync_ResultRef_t resRef = NULL; char atcommand[ATCOMMAND_SIZE]; atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"AT+WIND=%d",wind); le_result_t result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND), atcommand, &resRef, NULL, 30000); le_mem_Release(resRef); return result; }
//-------------------------------------------------------------------------------------------------- le_result_t pa_mdc_GetGatewayAddress ( uint32_t profileIndex, ///< [IN] The profile to use le_mdmDefs_IpVersion_t ipVersion, ///< [IN] IP Version char* gatewayAddrStr, ///< [OUT] The gateway IP address in dotted format size_t gatewayAddrStrSize ///< [IN] The size in bytes of the address buffer ) { le_result_t result = LE_FAULT; char atcommand[ATCOMMAND_SIZE] ; char atintermediate[ATCOMMAND_SIZE]; atcmdsync_PrepareString(atintermediate,ATCOMMAND_SIZE,"+CGPADDR: %d,",profileIndex); const char* interRespPtr[] = {atintermediate,NULL}; atcmdsync_ResultRef_t atRespPtr = NULL; atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cgpaddr=%d",profileIndex); result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND), atcommand, &atRespPtr, interRespPtr, 30000); if ( result != LE_OK ) { le_mem_Release(atRespPtr); return result; } // If there is more than one line then it mean that the command is OK so the first line is // the intermediate one if (atcmdsync_GetNumLines(atRespPtr) == 2) { // it parse just the first line because of '\0' char* line = atcmdsync_GetLine(atRespPtr,0); uint32_t numParam = atcmd_CountLineParameter(line); // it parse just the first line because of '\0' if (FIND_STRING("+CGPADDR:",atcmd_GetLineParameter(line,1))) { if (numParam==3) { if(atoi(atcmd_GetLineParameter(line,2)) == profileIndex) { const char* pAddr = atcmd_GetLineParameter(line,3); size_t length = strlen(pAddr); if (length-2 < gatewayAddrStrSize) { atcmd_CopyStringWithoutQuote(gatewayAddrStr,pAddr,gatewayAddrStrSize); result = LE_OK; } else { result = LE_OVERFLOW; } } else { LE_WARN("This is not the good profile %d", atoi(atcmd_GetLineParameter(line,2))); result = LE_FAULT; } } else { LE_WARN("this pattern is not expected"); result = LE_FAULT; } } else { LE_WARN("this pattern is not expected"); result = LE_FAULT; } } le_mem_Release(atRespPtr); // Release atcmdsync_SendCommandDefaultExt return result; }
//-------------------------------------------------------------------------------------------------- le_result_t pa_mdc_ReadProfile ( uint32_t profileIndex, ///< [IN] The profile to read pa_mdc_ProfileData_t* profileDataPtr ///< [OUT] The profile data ) { le_result_t result = LE_FAULT; char atintermediate[ATCOMMAND_SIZE]; atcmdsync_PrepareString(atintermediate,ATCOMMAND_SIZE,"+CGDCONT: %d,",profileIndex); const char* interRespPtr[] = {atintermediate,NULL}; atcmdsync_ResultRef_t atRespPtr = NULL; result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND), "at+cgdcont?", &atRespPtr, interRespPtr, 30000); if ( result != LE_OK ) { le_mem_Release(atRespPtr); // Release atcmdsync_SendCommandDefaultExt return result; } // If there is more than one line then it mean that the command is OK so the first line is // the intermediate one if (atcmdsync_GetNumLines(atRespPtr) == 2) { // it parse just the first line because of '\0' char* line = atcmdsync_GetLine(atRespPtr,0); uint32_t numParam = atcmd_CountLineParameter(line); // it parse just the first line because of '\0' if ( FIND_STRING("+CGDCONT:",atcmd_GetLineParameter(line,1))) { if (numParam==7) { if(atoi(atcmd_GetLineParameter(line,2)) == profileIndex) { strncpy(profileDataPtr->apn, atcmd_GetLineParameter(line,4), PA_MDC_APN_MAX_BYTES); result = LE_OK; } else { LE_WARN("This is not the good profile %d", atoi(atcmd_GetLineParameter(line,2))); result = LE_FAULT; } } else { LE_WARN("this pattern is not expected"); result=LE_FAULT; } } else { LE_WARN("this pattern is not expected"); result=LE_FAULT; } } le_mem_Release(atRespPtr); // Release atcmdsync_SendCommandDefaultExt return result; }