From 49390b2c7cc5cf51eaf7c7b42921dab21b4ea6e9 Mon Sep 17 00:00:00 2001 From: RobMeades Date: Tue, 24 Sep 2024 10:33:40 +0100 Subject: [PATCH] Hopefully fix issue where the registration status callback was not being called on re-connect of PPP. --- cell/src/u_cell_net.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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));