
Description | Cautions | synchronous processing | asynchronous processing | Errors | See Also
Name: |
int dx_setevtmsk(chdev,mask) | |
Inputs: |
int chdev |
|
unsigned int mask |
| |
Returns: |
0 if successful | |
-1 if failure | ||
Includes: |
srllib.h | |
dxxxlib.h | ||
Category: |
Call Status Transition Event | |
The dx_setevtmsk( ) function enables detection of Call Status Transition (CST) events. When you enable detection of a CST event and the event occurs, it will be placed on the event queue. You can collect the event by getting it or waiting for it with an event handling function, such as sr_waitevt( ), sr_waitevtEx( ), or dx_getevt( ). The dx_setevtmsk( ) function can be used by synchronous or asynchronous applications waiting for a CST event.
The function parameters are defined as follows:
Parameter |
Description | |
chdev |
specifies the valid channel device handle obtained when the channel was opened using dx_open( ). | |
mask |
specifies the events to enable. To enable multiple events, perform an OR operation on the bit masks of the events you want to enable. The first enabled CST event to occur will be returned. If an event is not specified in the mask, the event will be disabled. If an event is enabled, it will remain enabled until it is disabled through another function call. (Exception: See DM_DIGITS and DM_DIGOFF.) One or more of the following values can be specified: | |
DM_LCOFF |
| |
| ||
| ||
| ||
| ||
| ||
| ||
/* Set event mask to collect digits */ | ||
dx_setevtmsk(DM_DIGOFF); | ||
| ||
The following table outlines the synchronous or asynchronous handling of CST events:
Synchronous |
Asynchronous |
|
Call dx_setevtmsk( ) to enable CSTevents |
|
Use SRL to asynchronously wait for for TDX_CST events. |
|
|
If you call this function on a busy device, and specify DM_DIGITS as the mask argument, the function will fail.
#include <stdio.h>
#include <srllib.h>
#include <dxxxlib.h>
#include <windows.h>
main()
{
int chdev;
DX_EBLK eblk;
.
.
/* open a channel with chdev as descriptor */
if ((chdev = dx_open("dxxxB1C1",NULL)) == -1) {
/* process error */
}
.
.
/* Set event mask to receive ring events */
if (dx_setevtmsk(chdev, DM_RINGS) == -1) {
/* error setting event */
}
.
.
/* check for ring event, timeout set to 20 seconds */
if (dx_getevt(chdev,&eblk,20) == -1) {
/* error timeout */
}
if(eblk.ev_event==DE_RINGS) {
printf("Ring event occurred\n");
}
.
.
}
#include <stdio.h>
#include <srllib.h>
#include <dxxxlib.h>
#include <windows.h>
#define MAXCHAN 24
int cst_handler();
main()
{
int chdev[MAXCHAN];
char *chname;
int i, srlmode;
/* Set SRL to run in polled mode. */
srlmode = SR_POLLMODE;
if (sr_setparm(SRL_DEVICE, SR_MODEID, (void *)&srlmode) == -1) {
/* process error */
}
for (i=0; i<MAXCHAN; i++) {
/* Set chname to the channel name, e.g., dxxxB1C1, dxxxB1C2,... */
/* Open the device using dx_open( ). chdev[i] has channel device
* descriptor.
*/
if ((chdev[i] = dx_open(chname,NULL)) == -1) {
/* process error */
}
/* Use dx_setevtmsk() to enable call status transition events
* on this channel.
*/
if (dx_setevtmsk(chdev[i],
DM_LCOFF|DM_LCON|DM_RINGS|DM_SILOFF|DM_SILON|DM_WINK) == -1) {
/* process error */
}
/* Using sr_enbhdlr(), set up handler function to handle call status
* transition events on this channel.
*/
if (sr_enbhdlr(chdev[i], TDX_CST, cst_handler) == -1) {
/* process error */
}
/* Use sr_waitevt to wait for call status transition event.
* On receiving the transition event, TDX_CST, control is transferred
* to the handler function previously established using sr_enbhdlr().
*/
.
.
}
}
int cst_handler()
{
DX_CST *cstp;
/* sr_getevtdatap() points to the event that caused the call status
* transition.
*/
cstp = (DX_CST *)sr_getevtdatap();
switch (cstp->cst_event) {
case DE_RINGS:
printf("Ring event occurred on channel %s\n",
ATDX_NAMEP(sr_getevtdev()));
break;
case DE_WINK:
printf("Wink event occurred on channel %s\n",
ATDX_NAMEP(sr_getevtdev()));
break;
case DE_LCON:
printf("Loop current ON event occurred on channel %s\n",
ATDX_NAMEP(sr_getevtdev()));
break;
case DE_LCOFF:
.
.
}
/* Kick off next function in the state machine model. */
.
.
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 |
|
EDX_SYSTEM |
|
CST Event Handling and Retrieval:
Enabling User-Defined Tone Detection:
Click here to contact Dialogic Customer Engineering
Copyright 2002, Dialogic Corporation