I keep getting mails by various people about detecting caller id using D4PCI and Dialogic API. I remember I too had to try hard once and finally contacted Dialogic support for getting ideas how caller ID could be detected using D4/PCI analog CTI board from Dialogic. I think the same procedure should work for Donjin Analog boards as well as any kind of Analog CTI boards, for that matter.
So the steps for detecting Caller ID in D4PCI board is :
1. As soon as you detect RINGING, do not connect or answer the call. But start detecting digit using appropriate API function. For example dx_getdig();
2. Important part is the settings in DV_TPT structure which is used in dx_getdig() function. Here is how I have been configuring:
- End of DX_MAXDTMF should be configured to be length of expected Caller ID length.
- DX_MAXTIME should be configured to be delay between two rings.
- Since DTMF digits for Caller ID are sent together quickly by the PBX, one may take advantage of the option DX_IDDTIME ( Inter-digit Pause).
3. As soon as one comes out of from dx_getdig() function either because of DX_MAXDTMF,DX_MAXTIME or DX_IDDTIME, one should check if Caller ID is detected or not!
So these are the three simple steps for detecting Caller ID using D4PCI board. Here is the C++ code snippet:-
// Allocate memory
memset( tpt, 0, (sizeof( DV_TPT ) * 3) );
/* Terminate GetDigits on Receiving MAXDTMF Digits, Interdigit Pause and MAxrime */
tpt[ 0 ].tp_type = IO_CONT;
tpt[ 0 ].tp_termno = DX_MAXDTMF;
//tpt[ 0 ].tp_length = MAXDTMF;
tpt[ 0 ].tp_length = digits; // Number of digits of expected caller ID
tpt[ 0 ].tp_flags = TF_MAXDTMF;
// Terminate dx_getdig function after 3 second Interdigit pause
tpt[ 1 ].tp_type = IO_CONT;
tpt[ 1 ].tp_termno = DX_IDDTIME;
tpt[ 1 ].tp_length = 30; // Gap in betwwen digits
tpt[ 1 ].tp_flags = TF_IDDTIME;
/* Terminate GetDigits after 8 Seconds */
tpt[ 2 ].tp_type = IO_EOT;
tpt[ 2 ].tp_termno = DX_MAXTIME;
tpt[ 2 ].tp_length = 80; // Maximum time
tpt[ 2 ].tp_flags = TF_MAXTIME;
if (dx_getdig( voiceh_handle, tpt, &(dtbuf),(unsigned short)ASYNC ) == -1 )
printf(“getdtmfs return 0x%Xn”, ATDV_LASTERR(pline->voiceh));
So here are few facts I have realised:-
1. D4PCI board ( or any analog board in that matter ) may not detect caller ID all the time completely (all the digits) all the time. It has nothing to do with the Dialogic CTI board though. The reason can be explained as below :
Normally, caller ID is presented in the form of DTMF ( Dual Tone Multiple Frequency) digits after the first ring and before the second ring.
I have observed that, some times, analog board fails to detect the first ring and detects the ring from the second ring only. It this case, any CTI application would miss the caller ID completely. Some other times, the analog board (D4PCI or equivalent analog CTI boards) would detect the ring at the end of first ring cadence which may result in missing first few caller ID digits.
So, detecting caller id perfectly using analog board may depend on PBX being used. If any one knows any better technique, it will be great to share here.