//-------------------------------------------------------------------------------------------------- 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; }
//-------------------------------------------------------------------------------------------------- static le_result_t StartPPPInterface ( void ) { pid_t pid = fork(); if ( pid == -1) { return LE_FAULT; } else if ( pid == 0) // child process { char* args[] = { "pppd", /* argv[0], programme name. */ "usepeerdns", "updetach", AT_PPP, NULL /* list of argument must finished by NULL. */ }; // warn: pppd 2.4.5 with this patch: // http://code.google.com/p/wl500g/source/browse/trunk/ppp/115-debian-always_setsid.patch // does not work. // the modem hangup when the process is forked. // So need to use a pppd version without this patch. execvp("pppd", args); return 99; } else { int statchild; wait(&statchild); // wait for child to finished if (WIFEXITED(statchild)) { LE_DEBUG("Child's exit code %d\n", WEXITSTATUS(statchild)); if (WEXITSTATUS(statchild) == 0) { // Remove the NO CARRIER unsolicited atmgr_UnSubscribeUnsolReq (atports_GetInterface(ATPORT_COMMAND),InternalEventCall,"NO CARRIER"); return LE_OK; } else { return LE_FAULT; } } else { LE_WARN("Child did not terminate with exit\n"); return LE_FAULT; } } }
//-------------------------------------------------------------------------------------------------- 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"); } }
//-------------------------------------------------------------------------------------------------- static void SubscribeUnsolCREG ( pa_mrc_NetworkRegSetting_t mode ///< [IN] The selected Network registration mode. ) { atmgr_UnSubscribeUnsolReq(atports_GetInterface(ATPORT_COMMAND),EventUnsolicitedId,"+CREG:"); if ((mode==PA_MRC_ENABLE_REG_NOTIFICATION) || (mode==PA_MRC_ENABLE_REG_LOC_NOTIFICATION)) { atmgr_SubscribeUnsolReq(atports_GetInterface(ATPORT_COMMAND), EventUnsolicitedId, "+CREG:", false); } ThisMode=mode; }