diff --git a/cell/src/u_cell_net.c b/cell/src/u_cell_net.c index 88c3085c..1661a4aa 100644 --- a/cell/src/u_cell_net.c +++ b/cell/src/u_cell_net.c @@ -318,6 +318,7 @@ static void setNetworkStatus(uCellPrivateInstance_t *pInstance, uCellNetRegistationStatus_t *pStatus; bool printAllowed = true; uCellNetRat_t previousRat = pInstance->rat[regType]; + bool forceRegistrationStatusCallback = false; #if U_CFG_OS_CLIB_LEAKS // If we're in a URC and the C library leaks memory // when printf() is called from a dynamically @@ -451,6 +452,12 @@ static void setNetworkStatus(uCellPrivateInstance_t *pInstance, activateContextCallback, pInstance); } pInstance->profileState = U_CELL_PRIVATE_PROFILE_STATE_SHOULD_BE_UP; + // After having successfully re-registered we can end up + // falling into the logic below concerning the order of + // +CxREG URCs, when in fact we really _must_ call the + // users registration callback in this case, they need to + // know. Hence we force it to be caleld. + forceRegistrationStatusCallback = true; } } @@ -478,12 +485,13 @@ static void setNetworkStatus(uCellPrivateInstance_t *pInstance, // the user we're not registered when we are, so don't call the // callback for a "not registered" +CGREG/+CEREG if there is still // a "registered" +CGREG/+CEREG. - if (((regType == U_CELL_PRIVATE_NET_REG_TYPE_CGREG) && - !U_CELL_NET_STATUS_MEANS_REGISTERED(pInstance->networkStatus[U_CELL_PRIVATE_NET_REG_TYPE_CGREG]) && - U_CELL_NET_STATUS_MEANS_REGISTERED(pInstance->networkStatus[U_CELL_PRIVATE_NET_REG_TYPE_CEREG])) || - ((regType == U_CELL_PRIVATE_NET_REG_TYPE_CEREG) && - !U_CELL_NET_STATUS_MEANS_REGISTERED(pInstance->networkStatus[U_CELL_PRIVATE_NET_REG_TYPE_CEREG]) && - U_CELL_NET_STATUS_MEANS_REGISTERED(pInstance->networkStatus[U_CELL_PRIVATE_NET_REG_TYPE_CGREG]))) { + if (!forceRegistrationStatusCallback && + (((regType == U_CELL_PRIVATE_NET_REG_TYPE_CGREG) && + !U_CELL_NET_STATUS_MEANS_REGISTERED(pInstance->networkStatus[U_CELL_PRIVATE_NET_REG_TYPE_CGREG]) && + U_CELL_NET_STATUS_MEANS_REGISTERED(pInstance->networkStatus[U_CELL_PRIVATE_NET_REG_TYPE_CEREG])) || + ((regType == U_CELL_PRIVATE_NET_REG_TYPE_CEREG) && + !U_CELL_NET_STATUS_MEANS_REGISTERED(pInstance->networkStatus[U_CELL_PRIVATE_NET_REG_TYPE_CEREG]) && + U_CELL_NET_STATUS_MEANS_REGISTERED(pInstance->networkStatus[U_CELL_PRIVATE_NET_REG_TYPE_CGREG])))) { // We remain registered on a PS domain, nothing more to do } else { pStatus = (uCellNetRegistationStatus_t *) pUPortMalloc(sizeof(*pStatus));