
Description | Cautions | Example | Errors | See Also
Name: |
int dx_gtcallid (chdev, bufferp) | |
Inputs: |
int chdev |
|
|
unsigned char *bufferp |
|
Returns: |
0 success | |
|
-1 error return code | |
Includes: |
srllib.h | |
|
dxxxlib.h | |
Category: |
Caller ID | |
Mode: |
synchronous | |
The dx_gtcallid( ) function returns the calling line Directory Number (DN) sent by the Central Office (CO).
This function has the following parameters:
Parameter |
Description |
chdev: |
Channel device handle. |
bufferp: |
Pointer to where to return calling line Directory Number (DN). |
On successful completion, a NULL terminated string containing the caller's phone number (DN) is placed in the buffer.
Caller ID information is available for the call from the moment the ring event is generated (if the ring event is set to occur on or after the second ring (CLASS, ACLIP) or set to occur on or after the first ring (CLIP, JCLIP) until either of the following occurs:
Based on the Caller ID options provided by the CO and for applications that require only the calling line Directory Number (DN), issue the dx_gtcallid( ) function to get the calling line DN.
If the call is not answered and the ring event is received before the Caller ID information has been received from the CO, Caller ID information will not be available until the beginning of the second ring (CLASS, ACLIP) or the beginning of the first ring (CLIP, JCLIP).
Based on the Caller ID options provided by the CO and for applications that require additional Caller ID information, issue the dx_gtextcallid( ) function for each type of Caller ID message required. As an argument in the dx_gtextcallid( ) function, the type of Caller ID message to access is specified (infotype).
To allow the reception of Caller ID information from the Central Office before answering a call (application channel goes off-hook):
/*$ dx_gtcallid( ) example $*/
#include <windows.h>
#include <sys/types.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/* Dialogic Includes */
#include "srllib.h"
#include "dxxxlib.h"
int main()
{
int numRings = 2; /* In the US */
int ringTimeout = 20; /* 20 seconds */
int chdev; /* Channel descriptor */
unsigned short parmval;
unsigned char buffer[81];
/* Open channel */
if ((chdev=dx_open("dxxxB1C1", NULL)) == -1) {
/* process error */
exit(0);
}
/* Enable the caller ID functionality */
parmval = DX_CALLIDENABLE;
if (dx_setparm(chdev, DXCH_CALLID, (void *) &parmval) == -1) {
/* process error */
exit(0);
}
/******************************************************************
* Set the number of rings required for a RING event to permit
* receipt of the caller ID information. In the US, caller ID
* information is transmitted between the first and second rings
******************************************************************/
parmval = numRings; /* 2 in the US */
if (dx_setparm(chdev, DXCH_RINGCNT, &parmval) == -1) {
/* process error */
exit(0);
}
/* Put the channel onhook */
if (dx_sethook(chdev, DX_ONHOOK, EV_SYNC) == -1) {
/* process error */
exit (0);
}
/* Wait for 2 rings and go offhook (timeout after 20 seconds) */
if (dx_wtring(chdev, numRings, DX_OFFHOOK, ringTimeout) == -1) {
/* process error */
}
/* Get just the caller ID */
if (dx_gtcallid(chdev, buffer) == -1) {
/* Can check the specific error code */
if (ATDV_LASTERR(chdev) == EDX_CLIDBLK) {
printf("Caller ID information blocked \n");
}
else if (ATDV_LASTERR(chdev) == EDX_CLIDOOA) {
printf("Caller out of area \n");
}
else {
/* Or print the pre-formatted error message */
printf("Error: %s \n", ATDV_ERRMSGP(chdev));
}
}
else {
printf("Caller ID = %s\n", buffer);
}
/*************************************************************
* If the message is an MDM (Multiple Data Message), then
* additional information is available.
* First get the frame and check the frame type. If Class MDM,
* get and print additional information from submessages.
*************************************************************/
if ( dx_gtextcallid(chdev,CLIDINFO_FRAMETYPE, buffer) != -1) {
if(buffer[0] == CLASSFRAME_MDM) {
/* Get and print the date and time */
if (dx_gtextcallid(chdev, MCLASS_DATETIME, buffer) == -1) {
/* process error */
printf("Error: %s\n", ATDV_ERRMSGP(chdev));
}
else {
printf("Date/Time = %s\n", buffer);
}
/* Get and print the caller name */
if (dx_gtextcallid(chdev, MCLASS_NAME, buffer) == -1) {
/* process error */
printf("Error: %s\n", ATDV_ERRMSGP(chdev));
}
else {
printf("Caller Name = %s\n", buffer);
}
/* Get and print the Dialed Number */
if (dx_gtextcallid(chdev, MCLASS_DDN, buffer) == -1) {
/* process error */
printf("Error: %s\n", ATDV_ERRMSGP(chdev));
}
else {
printf("Dialed Number = %s\n", buffer);
}
}
else {
printf("Submessages not available - not an MDM message\n");
}
}
dx_close(chdev);
return(0);
}
If this function returns -1 to indicate failure, use ATDV_LASTERR( ) and ATDV_ERRMSGP( ) to retrieve one of the following error reasons:
EDX_BADPARM |
Invalid parameter |
EDX_BUSY |
Channel is busy |
EDX_CLIDBLK |
Caller ID is blocked or private or withheld |
EDX_CLIDINFO |
Caller ID information not sent or Caller ID information invalid |
EDX_CLIDOOA |
Caller ID is out of area |
EDX_SYSTEM |
Error from operating system; use dx_fileerrno( ) to obtain error value |
Click here to contact Dialogic Customer Engineering
Copyright 2002, Dialogic Corporation