Receive a call and identify caller ID

From openPicus Wiki
Jump to: navigation, search

Contents

What you are going to learn

This tutorial shows how to identify Caller ID on taskFlyport.c file, using GSM_Events.c functions.

FlyportPRO warning

This tutorial is made for Flyport modules but works on FlyportPRO as well. Just adapt the code since the pinout is slightly different.

Introduction to Voice Call

Flyport GPRS can perform voice calls, detect incoming calls and hang up.
NOTE: External circuitry is needed to connect microphone and headphones at GSM module. Microphone input and headphone output are provided on J2 connector; more info are available on SAGEMCOM website for further reference. Openpicus does not support any kind of voice call circuitry

How to use it

All the communication with GPRS Module is handled by GSMTask. Each GSM event (like connection changed, sms received, etc...) a function of GSM_Events.c file is automatically executed. Each type of event has a different function.
Flyport detects incoming calls using the OnRing event of GSM_Events.c file. On this example the function OnRing is modified in order to "inform" taskFlyport.c (user task) of the incoming call. Open the Serial Monitor utility on the IDE to have a feedback.
Each OnRing event sets the value of the detectedRing variable and writes the caller ID inside the detectedCallerID char array. The taskFlyport.c file read continuosly the detectedRing variable. If its value is TRUE a message is shown on Serial Monitor: Number Detected: +...

NOTE: On the Serial Monitor you will see also other debug messages. Those messages can be disabled using the Wizard of the IDE (unchecking "Debug messages on UART1")


Code example

Code changes for GSM_Events.c:

BOOL detectedRing = FALSE;
char detectedCallerID[25];
 
// INCOMING CALL
void OnRing(char* phoneNumber)
{
    #if defined(STACK_USE_UART)
    char buf[20];
    UARTWrite(1,"Event: On Ring\r\nPhone number: ");
    sprintf(buf, "%s", phoneNumber);
    UARTWrite(1,buf);
    UARTWrite(1,"\r\n");
    #endif
    detectedRing = TRUE;
    sprintf(detectedCallerID, "%s", phoneNumber);
}


Source code for taskFlyport.c:

#include "taskFlyport.h"
 
extern BOOL detectedRing;
extern char detectedCallerID[25];
 
void FlyportTask()
{
    vTaskDelay(20);
    UARTWrite(1,"Flyport Task Started...\r\n");
 
        //Wait for GSM Connection successfull
    do
    {
	UpdateConnStatus();
	while(LastExecStat() == OP_EXECUTION);
    }while((LastConnStatus() != REG_SUCCESS)&&(LastConnStatus() != ROAMING));
 
    vTaskDelay(20);
    UARTWrite(1,"Flyport registered on network!\r\n");
 
    while(1)
    {
	if(detectedRing == TRUE)
        {
            detectedRing = FALSE;
            vTaskDelay(20);
            UARTWrite(1, "Number Detected: ");
	    UARTWrite(1, detectedCallerID);
	    UARTWrite(1, "\r\n");
 	}
    }
}
Personal tools
Namespaces

Variants
Actions
START HERE
DEVELOPMENT
HARDWARE INFO
RESOURCES
PHASED OUT
Toolbox