int TimerManager::NewTimer(Service* s, unsigned deltawhen, TimerHandlercpp handler, const char* event_descrip, unsigned period) { if ( !s ) { dprintf( D_DAEMONCORE,"DaemonCore NewTimer() called with c++ pointer & NULL Service*\n"); return -1; } return( NewTimer(s,deltawhen,(TimerHandler)NULL,handler,(Release)NULL,(Releasecpp)NULL,event_descrip,period,NULL) ); }
int TimerManager::NewTimer (const Timeslice ×lice,TimerHandler handler,const char * event_descrip) { return NewTimer(NULL,0,handler,(TimerHandlercpp)NULL,(Release)NULL,(Releasecpp)NULL,event_descrip,0,×lice); }
void PPconnectionHandler(SignalType * Signal) { switch (Signal->Event) { case APPLICATION_PRIMITIVE: { switch (Signal->SubEvent) { case MSFInd: { AppMSFType* msfInd = (AppMSFType*) Signal; char* msf = mem_malloc(msfInd->length + 1, 100); memcpy(msf, getAppMSFTypeIE(msfInd), msfInd->length); msf[msfInd->length] = '\0'; PrintStatus(0, msf); if (strlen(msf) > 4) { if (memcmp(msf, "DIAL", 4) == 0) { char *number = &msf[4]; if (strlen(number) < 5) { TimerType * timer = NewTimer(APPLICATION_PROCESS_ID_PP, WAIT_CONNECTION, 0); StartTimer(timer, 200); /* wait 2 sec before dialing call*/ memcpy(numberToDial, number, strlen(number)); numberToDial[strlen(number)] = '\0'; } } } mem_free(msf); break; } } } break; case IWU_PRIMITIVE: { switch (Signal->SubEvent) { case CC_SETUP_prim: { char* ptr; char CallingPartyNo[INFO_BUFSIZE]; CcSetupPrimType *CcSetupPrim = (CcSetupPrimType *) Signal; CallingPartyNoType *CallingPartyNoPtr; SignalIEType *SignalIE; TimerType * timer = NewTimer(APPLICATION_PROCESS_ID_PP, OFFHOOKTIMER, 0); StartTimer(timer, 200); /* wait 2 sec before accepting call*/ CallingPartyNoPtr = (CallingPartyNoType *) FindInfoElement(CallingPartyNoId, getCcSetupPrimTypeIE(CcSetupPrim) - 2, CcSetupPrim-> SignalHeader. SignalLength - sizeof(CcSetupPrimType) + 2); GetCallingPartyNo(CallingPartyNoPtr, CallingPartyNo, 32); SignalIE = (SignalIEType *) FindInfoElement(SignalId, getCcSetupPrimTypeIE(CcSetupPrim) - 2, CcSetupPrim->SignalHeader. SignalLength - sizeof(CcSetupPrimType) + 2); if (SignalIE) { } else { PrintStatus(0, "No SignalIE! EXTERNAL_RING"); } Signal->SignalLength = sizeof(CcAlertingPrimType); SendSignal(Signal, IWU_PROCESS_ID, IWU_PRIMITIVE, CC_ALERTING_prim); ptr = StringPrint(StatusString, "CallingPartyNo ["); ptr = StringPrint(ptr, CallingPartyNo); ptr = StringPrint(ptr, "]"); PrintStatus(0, StatusString); connected = 1; return; } case CC_RELEASE_COM_prim: break; case CC_RELEASE_prim: { SignalType* stopAudio; Signal->SignalLength = sizeof(CcReleaseComPrimType); SendSignal(Signal, IWU_PROCESS_ID, IWU_PRIMITIVE, CC_RELEASE_COM_prim); NewSignal(sizeof(SignalType), (void**) &stopAudio); SendSignal((SignalType*) stopAudio, DSP_PROCESS_ID, STOPAUDIO_EVENT, 0); return; } case CC_CONNECT_ACK_prim: { EeReadDataReqType *EeReadDataReq; NewSignal(sizeof(EeReadDataReqType) + sizeof(void *), (void **) &EeReadDataReq); EeReadDataReq->ReturnTIPD = TIPD_APPLICATION; EeReadDataReq->DataTypes = EEDT_ANYADDRESS; /* getEeReadDataReqTypeDataPtr(EeReadDataReq)[0] = (void *) &eepromData; */ memset(&eepromData, 0x00, 1); setAddressData(EEP_UserDataArea, 1); SendSignal((SignalType *) EeReadDataReq, EE_PROCESS_ID, EE_PRIMITIVE, EE_READ_DATA_req); setSignalHandler(APPLICATION_PROCESS_ID_PP, EEPROMWriteReadTestHandler, 0); } break; case CC_CONNECT_prim: { if (firsttime) { UByte * tmp; /* UByte cnt;*/ /*MuteTransmitter();*/ /*for (cnt=0; cnt < 6; cnt++)*/ { tmp = pp_get_speech_buffer(0); if (tmp != 0) { UByte count; char* ptr; ptr = StringPrint(StatusString, "***Buffer: ["); ptr = StrPrintHexAddr(ptr, (unsigned long) tmp); for (count = 0; count < 40; count++) { tmp[count] = 0x00; } tmp[0] = 0xCA; tmp[1] = 0xFE; tmp[2] = 0xBA; tmp[3] = 0xBE; tmp[4] = 0; tmp[5] = 0; tmp[6] = 0xff; tmp[7] = 0xff; ptr = StringPrint(ptr, "]"); PrintStatus(0, StatusString); { TimerType* connectionTimer = NewTimer(APPLICATION_PROCESS_ID_PP, PEIODICTIMER, 0); StartTimer(connectionTimer, 500); /* Wait 1 sec*/ PrintStatus(0, "start the timer"); } } else { PrintStatus(0, "tmp==0"); } } firsttime = 0; } } case CC_INFO_prim: /*do not break*/ break; case CC_SETUP_ACK_prim: break; case CC_CALL_PROC_prim: break; case CC_ALERTING_prim: break; case SS_SETUP_prim: handle_ss_setup(Signal); break; case SS_FACILITY_prim: handle_ss_facility(Signal); break; default: { char* ptr; ptr = StringPrint(StatusString, "Unknown IWU_PRIMITIVE [0x"); ptr = StrPrintHexByte(ptr, Signal->SubEvent); ptr = StringPrint(ptr, "]"); PrintStatus(0, StatusString); } } } break; case TIME_OUT_EVENT: { switch (Signal->SubEvent) { case SENDMSFTIMER: { /* PrintStatus(0, "Sending MSF");*/ /* SendMsfMessage("2001", "OK!");*/ } break; case WAIT_CONNECTION: { callUser_PP(numberToDial, 0); setSignalHandler(APPLICATION_PROCESS_ID_PP, PPDialingHandler, 0); } break; case OFFHOOKTIMER: { if (connected) { PrintStatus(0, "Accepting call!"); off_hook(); } } break; case PEIODICTIMER: { UByte * tmp; TimerType* connectionTimer = NewTimer(APPLICATION_PROCESS_ID_PP, PEIODICTIMER, 0); PrintStatus(0, "PEIODICTIMER"); StartTimer(connectionTimer, 500); /* Wait 1 sec*/ tmp = pp_get_speech_buffer(1); if (tmp != 0) { int c; char* ptr; ptr = StringPrint(StatusString, "***Buffer: ["); ptr = StrPrintHexAddr(ptr, (unsigned long) tmp); ptr = StringPrint(ptr, "-"); for (c = 0; c < 8; c++) { ptr = StrPrintHexByte(ptr, tmp[c]); ptr = StringPrint(ptr, ","); } ptr = StringPrint(ptr, "]"); PrintStatus(0, StatusString); } else { PrintStatus(0, "tmp==0"); } } break; default: { PrintStatus(0, "Unknown TIME_OUT_EVENT in connection handler"); } } } break; default: { PrintStatus(0, "Unknown event to connection handler"); } } DeleteBuffer(Signal); }
int TimerManager::NewTimer(unsigned deltawhen, TimerHandler handler, const char* event_descrip, unsigned period) { return( NewTimer((Service *)NULL,deltawhen,handler,(TimerHandlercpp)NULL,(Release)NULL,(Releasecpp)NULL,event_descrip,period,NULL) ); }
void ApplicationSignalHandler_PP(SignalType * Signal) { switch (Signal->Event) { case IWU_PRIMITIVE: { switch (Signal->SubEvent) { case OM_SUBS_STATUS_ind: { OmSubsStatusIndType *OmSubsStatusInd = (OmSubsStatusIndType *) Signal; if (OmSubsStatusInd->Status) { OmSubsSelectReqType *OmSubsSelectReq; NewBuffer(sizeof(OmSubsSelectReqType), (void **) &OmSubsSelectReq); OmSubsSelectReq->SignalHeader.SignalLength = sizeof(OmSubsSelectReqType); OmSubsSelectReq->SubsNo = 0; InjectSignal((SignalType *) OmSubsSelectReq, IWU_PROCESS_ID, IWU_PRIMITIVE, OM_SUBS_SELECT_req, 0); switch (OmSubsStatusInd->Status) { case SS_Locked: { setSignalHandler(APPLICATION_PROCESS_ID_PP, PPNotSubscribedHandler, 0); } break; case SS_Locked | SS_Subscripted: case SS_Subscripted: { setSignalHandler(APPLICATION_PROCESS_ID_PP, PPAlreadySubscribedHandler, 0); } break; } } } } } break; case INITIALIZE_EVENT: { TimerType * timer = NewTimer(APPLICATION_PROCESS_ID_PP, WAIT_FOR_INIT, 0); StartTimer(timer, 200); } break; case TIME_OUT_EVENT: { switch (Signal->SubEvent) { case WAIT_FOR_INIT: { SignalType * ActivateSignal; EeReadDataReqType *EeReadDataReq; ProcessIdType ProcessId = IWU_PROCESS_ID; EventType Event = ACTIVATE_EVENT; SubEventType SubEvent = 0; NewSignal(sizeof(SignalType), (void**) &ActivateSignal); InjectSignal(ActivateSignal, ProcessId, Event, SubEvent, 0); NewSignal(offsetof(EeReadDataReqType, DataTypes) + sizeof(U16Bits) + 2 * sizeof(void *), (void **) &EeReadDataReq); EeReadDataReq->ReturnTIPD = PD_LCE; EeReadDataReq->SubsNo = 0; EeReadDataReq->DataTypes = EEDT_Ipei; getEeReadDataReqTypeDataPtr(EeReadDataReq)[0] = (void *) &HandsetIPEI[0]; InjectSignal((SignalType *) EeReadDataReq, EE_PROCESS_ID, EE_PRIMITIVE, EE_READ_DATA_req, 0); } } } } DeleteBuffer(Signal); }