static void CommModuleHandleTimeToRegister(C1222AL* p) { C1222TransportConfig* pConfig = &p->transportConfig; if ( (C1222Misc_GetFreeRunningTimeInMS()-p->status.lastCMSegmentedMessagePromotion) < 20000 ) { return; // wait a bit to prevent overwriting a downstream partially assembled message // with the registration request } if ( p->status.timeToRegister && p->status.haveConfiguration && (!C1222AL_IsBusy(p)) && p->status.isReceivedMessageHandlingComplete && !p->status.isReceivedMessageComplete ) { if ( (C1222Misc_GetUIDLength(pConfig->esn) <= 2) && (C1222Misc_GetUIDLength(pConfig->nodeApTitle) <= 2) ) { p->status.registrationFailureReason = MFC_REG_ESN_INVALID; C1222AL_LogEvent(p, C1222EVENT_AL_ESN_INVALID); // should log something return; } if ( (C1222Misc_GetUIDLength(pConfig->esn) > C1222_ESN_LENGTH) || (C1222Misc_GetUIDLength(pConfig->nodeApTitle) > C1222_APTITLE_LENGTH) ) { p->status.registrationFailureReason = MFC_REG_ESN_OR_APTITLE_TOO_LONG; C1222AL_LogEvent(p, C1222EVENT_AL_ESN_OR_APTITLE_TOOLONG); // should log something return; } CommModuleSendRegistrationRequestToNetwork(p); p->status.state = ALS_REGISTERING; p->status.registrationInProgress = TRUE; p->status.registrationFailureReason = MFG_REG_DEREG_PENDING_OR_TIMEOUT; // pending or timeout p->status.lastRegistrationAttemptTime = C1222Misc_GetFreeRunningTimeInMS(); p->status.timeToRegister = FALSE; } }
static void CommModuleHandleAutoRegistration(C1222AL* p) { C1222TL* pTransport = (C1222TL*)(p->pTransport); Unsigned32 now = C1222Misc_GetFreeRunningTimeInMS(); Unsigned16 minutes; C1222TransportConfig* pConfig = &p->transportConfig; if ( !C1222TL_IsReady(pTransport) ) return; if ( C1222AL_IsBusy(p) ) return; if ( !p->status.isSynchronizedOrConnected ) { p->status.registrationFailureReason = MFC_REG_NOT_SYNCHRONIZED; p->status.timeToRegister = FALSE; return; } if ( !p->status.isRegistered ) { // in order to register, need an esn or an aptitle if ( (C1222Misc_GetUIDLength(pConfig->esn) <= 2) && (C1222Misc_GetUIDLength(pConfig->nodeApTitle) <= 2) ) { // an event here would be too busy since this will be called lots return; } // if not registered and auto registration is on, better register // we might want to implement a random delay here // TODO: !! if ( (now-(p->status.lastRegistrationAttemptTime)) > (p->status.registrationRetrySeconds*1000L) ) { C1222AL_LogEvent(p, C1222EVENT_AL_TIME_TO_REGISTER); p->status.timeToRegister = TRUE; } } else if ( p->registrationStatus.regPeriodMinutes != 0 ) { // currently registered - handle keep alive if ( p->registrationStatus.regCountDownMinutes == 0 ) { if ( p->status.state != ALS_REGISTERING ) { C1222AL_LogEvent(p, C1222EVENT_AL_TIME_TO_REFRESH_REGISTRATION); p->status.timeToRegister = TRUE; } } else { now = C1222Misc_GetFreeRunningTimeInMS(); minutes = (Unsigned16)((now - p->status.lastSuccessfulRegistrationTime)/60000L); if ( minutes < p->registrationStatus.regPeriodMinutes ) p->registrationStatus.regCountDownMinutes = (Unsigned16)(p->registrationStatus.regPeriodMinutes - minutes); else p->registrationStatus.regCountDownMinutes = 0; } } // else don't need to refresh registration }
Boolean C1222Stack_IsBusy(C1222Stack* pStack) { return C1222AL_IsBusy(&pStack->Xapplication); }