//-------------------------------------------------------------------------------------------------- static void CGEVUnsolHandler ( void* reportPtr ) { atmgr_UnsolResponse_t* unsolPtr = reportPtr; uint32_t numParam=0; pa_mdc_SessionStateData_t *sessionStatePtr=NULL; LE_DEBUG("Handler received -%s-",unsolPtr->line); if ( ( FIND_STRING("+CGEV: NW DEACT", unsolPtr->line) ) || ( FIND_STRING("+CGEV: ME DEACT", unsolPtr->line) ) ) { numParam = atcmd_CountLineParameter(unsolPtr->line); if (numParam == 4) { sessionStatePtr = le_mem_ForceAlloc(NewSessionStatePool); sessionStatePtr->profileIndex = atoi(atcmd_GetLineParameter(unsolPtr->line,4)); sessionStatePtr->newState = LE_MDC_DISCONNECTED; SetCurrentDataSessionIndex(INVALID_PROFILE_INDEX); LE_DEBUG("Send Event for %d with state %d", sessionStatePtr->profileIndex,sessionStatePtr->newState); le_event_ReportWithRefCounting(NewSessionStateEvent,sessionStatePtr); } else { LE_WARN("this Response pattern is not expected -%s-",unsolPtr->line); } } }
//-------------------------------------------------------------------------------------------------- le_result_t pa_mdc_StartSessionIPV4 ( uint32_t profileIndex, ///< [IN] The profile to use pa_mdc_CallRef_t* callRefPtr ///< [OUT] Reference used for stopping the data session ) { le_result_t result=LE_NOT_POSSIBLE; if ( GetCurrentDataSessionIndex() != INVALID_PROFILE_INDEX ) { return LE_DUPLICATE; } // Always executed because: // - if GPRS is already attached it doesn't do anything and then it returns OK // - if GPRS is not attached it will attach it and then it returns OK on success if ( AttachGPRS(true) != LE_OK ) { return LE_NOT_POSSIBLE; } // Always executed because: // - if the context is already activated it doesn't do anything and then it returns OK // - if the context is not activated it will attach it and then it returns OK on success if ( ActivateContext(profileIndex,true) != LE_OK ) { return LE_NOT_POSSIBLE; } if ( (result = EstablishConnection(profileIndex)) != LE_OK ) { return LE_NOT_POSSIBLE; } if (result==LE_OK) { SetCurrentDataSessionIndex(profileIndex); memcpy(callRefPtr, &profileIndex, sizeof(void*)); } else { SetCurrentDataSessionIndex(INVALID_PROFILE_INDEX); } return result; }
//-------------------------------------------------------------------------------------------------- le_result_t pa_mdc_StartSessionIPV4 ( uint32_t profileIndex ///< [IN] The profile to use ) { le_result_t result=LE_FAULT; if ( GetCurrentDataSessionIndex() != INVALID_PROFILE_INDEX ) { return LE_DUPLICATE; } // Always executed because: // - if GPRS is already attached it doesn't do anything and then it returns OK // - if GPRS is not attached it will attach it and then it returns OK on success if ( AttachGPRS(true) != LE_OK ) { return LE_FAULT; } // Always executed because: // - if the context is already activated it doesn't do anything and then it returns OK // - if the context is not activated it will attach it and then it returns OK on success if ( ActivateContext(profileIndex,true) != LE_OK ) { return LE_FAULT; } if ( (result = EstablishConnection(profileIndex)) != LE_OK ) { SetCurrentDataSessionIndex(INVALID_PROFILE_INDEX); return LE_FAULT; } SetCurrentDataSessionIndex(profileIndex); return result; }
//-------------------------------------------------------------------------------------------------- static void MDCInternalHandler ( void* reportPtr ) { atmgr_UnsolResponse_t* unsolPtr = reportPtr; LE_DEBUG("Handler received -%s-",unsolPtr->line); if ( FIND_STRING("NO CARRIER", unsolPtr->line) ) { SetCurrentDataSessionIndex(INVALID_PROFILE_INDEX); atmgr_UnSubscribeUnsolReq(atports_GetInterface(ATPORT_COMMAND),InternalEventCall,"NO CARRIER"); } }
//-------------------------------------------------------------------------------------------------- le_result_t pa_mdc_StopSession ( uint32_t profileIndex ///< [IN] The profile to use ) { if ( GetCurrentDataSessionIndex() == INVALID_PROFILE_INDEX ) { return LE_FAULT; } // Stop the PDP connection on modem side if (StopPDPConnection() != LE_OK) { return LE_FAULT; } SetCurrentDataSessionIndex(INVALID_PROFILE_INDEX); return LE_OK; }
//-------------------------------------------------------------------------------------------------- le_result_t pa_mdc_StopSession ( pa_mdc_CallRef_t callRef ///< [IN] The call reference returned when starting the sessions ) { if ( GetCurrentDataSessionIndex() == INVALID_PROFILE_INDEX ) { return LE_NOT_POSSIBLE; } // Stop the PDP connection on modem side if (StopPDPConnection() != LE_OK) { return LE_NOT_POSSIBLE; } SetCurrentDataSessionIndex(INVALID_PROFILE_INDEX); return LE_OK; }
//-------------------------------------------------------------------------------------------------- le_result_t pa_mdc_StopSession ( uint32_t callRef ///< [IN] The call reference returned when starting the sessions ) { le_result_t result=LE_NOT_POSSIBLE; if ( GetCurrentDataSessionIndex() == INVALID_PROFILE_INDEX ) { return LE_DUPLICATE; } // Stop the PDP connection on modem side if ( (result = StopPDPConnection()) != LE_OK) { return LE_NOT_POSSIBLE; } if (result==LE_OK) { SetCurrentDataSessionIndex(INVALID_PROFILE_INDEX); } return result; }