static bool cbPollCreg ( adl_atResponse_t *Rsp ) { ascii *rsp; ascii regStateString [ 3 ]; s32 regStateInt; TRACE ( ( NORMAL_TRACE_LEVEL, "(cbPollCreg) Enter." ) ) ; rsp = ( ascii * ) adl_memGet ( Rsp->StrLength ); wm_strRemoveCRLF ( rsp, Rsp->StrData, Rsp->StrLength ); TRACE ( ( NORMAL_TRACE_LEVEL, rsp ) ) ; wm_strGetParameterString ( regStateString, Rsp->StrData, 2 ); regStateInt = wm_atoi ( regStateString ); TRACE ( ( NORMAL_TRACE_LEVEL, regStateString ) ) ; if ( REG_STATE_REG == regStateInt || REG_STATE_ROAM == regStateInt ) { TRACE( ( NORMAL_TRACE_LEVEL, "(cbPollCreg) Registered on GPRS network." ) ) ; /* Registration is complete so open and start bearer */ OpenAndStartBearer ( ) ; } else { /* Not ready yet, we'll check again later. Set a one-off timer. */ adl_tmrSubscribe ( FALSE, CREG_POLLING_PERIOD, ADL_TMR_TYPE_100MS, (adl_tmrHandler_t ) PollCreg ); } adl_memRelease(rsp); return FALSE; }
void adl_main(adl_InitType_e initType) { s8 flashHandle = -1; u8 counter = 1; flashHandle = adl_flhSubscribe(PERSISTENT_COUNTER, 1); if (adl_flhExist(PERSISTENT_COUNTER, 0) == 0) { adl_flhWrite(PERSISTENT_COUNTER, 0, sizeof(counter), &counter); } else { adl_flhRead(PERSISTENT_COUNTER, 0, sizeof(counter), &counter); counter++; adl_flhWrite(PERSISTENT_COUNTER, 0, sizeof(counter), &counter); } if (initType == ADL_INIT_REBOOT_FROM_EXCEPTION) { wm_sprintf(ltsc_Temp, "\r\nA Fatal Error Occurred Test is restarting (%d)", counter); adl_atSendResponse(ADL_AT_UNS, ltsc_Temp); } else { wm_sprintf(ltsc_Temp, "\r\nTest modbus starting(%d) in 15s...'%d'", counter, initType); adl_atSendResponse(ADL_AT_UNS, ltsc_Temp); } UART_Init(); // The application will switch the UART to data mode n seconds later, so the user has 15s to enter adl_tmrSubscribe(FALSE, 150, ADL_TMR_TYPE_100MS, MAIN_StartAppTimerHandler); }
bool poll_creg_handler (adl_atResponse_t *Rsp) { ascii *rsp; ascii regStateString[3]; s32 regStateInt; info("Warten auf GPRS Verbindung..."); rsp = (ascii *)adl_memGet(Rsp->StrLength); wm_strRemoveCRLF(rsp, Rsp->StrData, Rsp->StrLength); wm_strGetParameterString(regStateString, Rsp->StrData, 2); regStateInt = wm_atoi(regStateString); if ( 1 == regStateInt || 5 ==regStateInt) { initGprs(); } else { /* Not ready yet, we'll check again later. Set a one-off timer. */ adl_tmrSubscribe( FALSE, 10, ADL_TMR_TYPE_100MS, poll_creg); } return FALSE; }
static bool poll_creg_callback(adl_atResponse_t *Rsp) { ascii *rsp; ascii regStateString[3]; s32 regStateInt; TRACE (( 1, "(poll_creg_callback) Enter." )); rsp = (ascii *)adl_memGet(Rsp->StrLength); wm_strRemoveCRLF(rsp, Rsp->StrData, Rsp->StrLength); wm_strGetParameterString(regStateString, Rsp->StrData, 2); regStateInt = wm_atoi(regStateString); if ( 1 == regStateInt || 5 ==regStateInt) { TRACE (( 1, "(poll_creg_callback) Registered on GPRS network." )); open_and_start_bearer(); } else { /* Not ready yet, we'll check again later. Set a one-off timer. */ adl_tmrSubscribe( FALSE, CREG_POLLING_PERIOD, ADL_TMR_TYPE_100MS, poll_creg); } return FALSE; }
void main_task(void) { adl_tmrSubscribe(veFalse, 100, ADL_TMR_TYPE_100MS, startup); }