예제 #1
0
/*
** Function: DigitDecoding (state)
**
** Description:
** called when current state is a DTMF being decoded and interrupt occurs
**
** Input Parameters:
** pState: pointer to channel state data structure
** eInput: interrupt that has occured
**
** Return:
**
*/
static void DigitDecoding (chanState *pState, ProslicInt eInput) {
    //this is the state when user is pressing keys on phone (DTMF)
    if (eInput == DTMF) {
        processDTMF(pState);
    }
    else if (eInput == LOOP_STATUS) {
        goOnHookState(pState);
    }
    else if (eInput>=PQ1 && eInput<=PQ6) {
        powerAlarm(pState);
    }
}
예제 #2
0
int pincodeProcessor() {
    
    static char command[50]; // 
    static short cmd_index = 0; // the index in the string to put the next received character
    static boolean dtmfProcessed = false;

    // If a DTMF tone is being detected:
    char detected = digitalRead(PIN_DTMF_DETECTED);//check if DTMF is being detected.  digitalRead: read the value for the specified digital PIN
    dtmfProcessed = (detected && dtmfProcessed);//dtmfProcess should be true if it is already true, and a DTMF tone still being detected

    if (!dtmfProcessed & detected) {//If DTMF is being detected and it hasn't been processed yet
        Serial.println("pincode inside !dtmfProcessed & detected");
	dtmfProcessed = true;
        char tone = 0;
        
	//Read which tone was detected by shifting in bits from the DTMF chip
        tone = shiftIn(PIN_DTMF_DATA, PIN_DTMF_ACK, LSBFIRST) & 0xF; //Keep only 4 lowest bits
        if(processDTMF(tone + '0') == 0){
		 Serial.println("pincode inside processDTMF");
		return 0;
		//playHappyTone();
	}else{
		return 1;
        	//playSadTone();
    }
    
    //If there is data on the serial port connected to the GSM moduel
/*    if(Serial2.available() >0){

        incoming_char = Serial2.read();
        Serial.print(incoming_char); //when one byte comes on the serial port from the GSM module, send to the PC

        if (incoming_char == '\r'){ //When we get carriage return, we know the line is finished and we can see what we got

            command[cmd_index] = '\0'; //terminate Command String
            processCommand(command);
            cmd_index = 0;//Start from the beginning
            
        }else if(cmd_index < 49){

            if(incoming_char != 10)//10 is the ascii code for line feed 
                command[cmd_index++] = incoming_char;

        }*/
    }
    return 0;
}
예제 #3
0
/*
** Function: dialtone (state)
**
** Description:
** called when current state is dialtone and interrupt occurs
**
** Input Parameters:
** pState: pointer to channel state data structure
** eInput: interrupt that has occured
**
** Return:
**
*/
static void DialTone (chanState *pState, ProslicInt eInput) {
    //this state is used when user picks up idle phone
    if (eInput==DTMF) { //user is dialing
        ProSLIC_ToneGenStop(pState->ProObj);
        pState->currentState = DigitDecoding;
        processDTMF(pState);

    }
    else if (eInput == LOOP_STATUS) {
        ProSLIC_DialPulseDetect(pState->ProObj,&pDCfg,&(pState->pulseDialData));
        goToPulseDialOnHkState (pState);
        //goOnHookState(pState);

    }
    else if (eInput>=PQ1 && eInput<=PQ6) {
        powerAlarm(pState);
    }

}