Connection Manager library for u-blox cellular modules. It manages the modem for keeping data connection always active.
Diff: CNReg.cpp
- Revision:
- 1:29ad1d1ac1f9
- Parent:
- 0:86284a262735
diff -r 86284a262735 -r 29ad1d1ac1f9 CNReg.cpp --- a/CNReg.cpp Tue Jan 12 09:08:15 2016 +0000 +++ b/CNReg.cpp Thu Jan 21 14:00:25 2016 +0000 @@ -28,14 +28,19 @@ statePS = MDMParser::REG_UNKNOWN; } -CNResp cnRegLoop(CNLib* cnLib, RegStatus* status){ +CNResp cnRegLoop(CNLib* cnLib, RegStatus* regStatus){ MDMParser::Reg newStateCS = cnLib->getNet()->csd; MDMParser::Reg newStatePS = cnLib->getNet()->psd; bool isRoamingRegister, isCSRegistered, hasCsRegister, hasCsDeRegister, isPSRegistered, hasPsRegister, hasPsDeRegister; + *regStatus = REG_NO_CHANGES; + int res; + TRACE("%s enter \r\n", __FUNCTION__); //read and set COPS if necessary - if (cnLib->getNet()->regStatus == MDMParser::COPS_UNKOWN) - cnLib->getNetworkInfo(); + if (cnLib->getNet()->regStatus == MDMParser::COPS_UNKOWN){ + res = cnLib->getNetworkInfo(); + if (!RESPOK(res)) return RES_ERROR; + } if (cnLib->getNet()->regStatus != MDMParser::COPS_AUTOMATIC_REG) cnLib->setNetAutoReg(); // poll registration info when timer expires @@ -64,15 +69,15 @@ if ((isCSRegistered && hasPsRegister) || (isPSRegistered && hasCsRegister) || \ (hasPsRegister && hasCsRegister) ){ TRACE("%s CS and PS have just registered\r\n", __FUNCTION__); - *status = REG_REGISTERED; + *regStatus = REG_REGISTERED; } else if (hasPsDeRegister || hasCsDeRegister){ TRACE("%s CS or PS are not registered\r\n", __FUNCTION__); - *status = REG_NOT_REGISTERED; + *regStatus = REG_NOT_REGISTERED; } }else{ INFO("%s Roaming not allowed\r\n", __FUNCTION__); - *status = REG_NOT_REGISTERED; + *regStatus = REG_NOT_REGISTERED; } //Perform action in base of registration status if (hasCsRegister){ @@ -83,18 +88,18 @@ } //Dump info if (getUtilDebugLevel() > 1 && (newStatePS != statePS || newStateCS != stateCS )){ - const char* txtStatus[] = { "unchanged", "registered", "NOT anymore registered"}; + const char* txtStatus[] = { "unchanged", "registered", "NOT registered"}; INFO("cn registration Dump\r\n"); - if (*status < sizeof(txtStatus)/sizeof(*txtStatus)) - INFO(" Status is now %s\r\n", txtStatus[*status]); + if (*regStatus < sizeof(txtStatus)/sizeof(*txtStatus)) + INFO(" Status is now %s\r\n", txtStatus[*regStatus]); INFO(" has CS Registered = %s, has CS DeRegistered = %s\r\n", BOOLTOSTR(hasCsRegister), BOOLTOSTR(hasCsDeRegister)); INFO(" is Roaming active = %s, polling Timer %d\r\n", \ BOOLTOSTR(isRoamingRegister), tmStatusPull.read()); - cnLib->dumpNetStatus(cnLib->getNet()); + //cnLib->dumpNetStatus(cnLib->getNet()); } //update status stateCS = newStateCS; statePS = newStatePS; - + return RES_OK; } \ No newline at end of file