Intel 05-1832-002 IP Phone User Manual


 
260 Voice API for Windows Operating Systems Library Reference — November 2003
dx_gtcallid( ) — return the calling line Directory Number
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.
*************************************************************/