
Description | Cautions | Example 1: | Example 2: | Errors | See Also
Name: |
int dx_wink(chdev,mode) | |
Inputs: |
int chdev |
|
unsigned short mode |
| |
Returns: |
0 if successful | |
-1 if failure | ||
Includes: |
srllib.h | |
dxxxlib.h | ||
Category: |
I/O | |
Mode: |
synchronous/asynchronous | |
The dx_wink( ) function generates an outbound wink on the specified channel. A wink from a Voice board is a momentary rise of the A signaling bit, which corresponds to a wink on an E&M line. This is used for signaling T-1 spans. A wink's typical duration of 150 to 250 milliseconds used for communication purposes between the called and calling stations.
Asynchronous Operation
To run this function asynchronously set the mode field to EV_ASYNC. When running asynchronously, this function will return 0 to indicate it has initiated successfully, and will generate a TDX_WINK termination event to indicate completion. Use the SRL Event Management functions to handle the termination event.
Synchronous Operation
By default, this function runs synchronously, and will return a 0 to indicate that it has completed successfully.
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( ). |
|
|
mode |
specifies whether to run dx_wink( ) asynchronously or synchronously. Specify one of the following: |
|
|
EV_ASYNC: |
Run dx_wink( ) asynchronously. |
|
|
EV_SYNC: |
Run dx_wink( ) synchronously (default). |
|
|
||
Setting Delay Prior to Wink
The default delay prior to generating the outbound wink is 150 ms. To change the delay, use the dx_setparm( ) function to enter a value for the DXCH_WINKDLY parameter where:
delay = the value entered x 10 ms
The syntax of the function is:
int delay;
delay = 15;
dx_setparm(dev,DXCH_WINKDLY,(void*)&delay)
If delay = 15, then DXCH_WINKDLY = 15 x 10 or 150 ms.
Setting Wink Duration
The default outbound wink duration is 150 ms. To change the wink duration, use the dx_setparm( ) function to enter a value for the DXCH_WINKLEN parameter where:
duration = the value entered x 10 ms
The syntax of the function is:
int duration;
duration = 15;
dx_setparm(dev,DXCH_WINKLEN,(void*)&duration)
If duration = 15, then DXCH_WINKLEN = 15 x 10 or 150 ms.
Receiving an Inbound Wink
To receive an inbound wink on a channel:
A typical sequence of events for an inbound wink is:
Make sure the channel is on-hook when dx_wink( ) is called.
Example 1: Using dx_wink( ) in synchronous mode.
#include <srllib.h>
#include <dxxxlib.h>
#include <windows.h>
main()
{
int chdev;
DV_TPT tpt;
DV_DIGIT digitp;
char buffer[8];
/* open a channel with chdev as descriptor */
if ((chdev = dx_open("dxxxB1C1",NULL)) == -1) {
/* process error */
}
/* set hookstate to on-hook and wink */
if (dx_sethook(chdev,DX_ONHOOK,EV_SYNC) == -1) {
/* process error */
}
if (dx_wink(chdev,EV_SYNC) == -1) {
/* error winking channel */
}
dx_clrtpt(&tpt,1);
/* set up DV_TPT */
tpt.tp_type = IO_EOT; /* only entry in the table */
tpt.tp_termno = DX_MAXDTMF; /* Maximum digits */
tpt.tp_length = 1; /* terminate on the first digit */
tpt.tp_flags = TF_MAXDTMF; /* Use the default flags */
/* get digits while on-hook */
if (dx_getdig(chdev,&tpt, &digitp, EV_SYNC) == -1) {
/* error getting digits */
}
/* now we can go off-hook and continue */
if ( dx_sethook(chdev,DX_OFFHOOK,EV_SYNC)== -1) {
/* process error */
}
.
.
}
Example 2: Using dx_wink( ) in asynchronous mode.
#include <stdio.h>
#include <srllib.h>
#include <dxxxlib.h>
#include <windows.h>
#define MAXCHAN 24
int wink_handler();
main()
{
int i, chdev[MAXCHAN];
char *chnamep;
int 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 chnamep to the channel name - e.g., dxxxB1C1 */
/* open the channel with dx_open( ). Obtain channel device
* descriptor in chdev[i]
*/
if ((chdev[i] = dx_open(chnamep,NULL)) == -1) {
/* process error */
}
/* Using sr_enbhdlr(), set up handler function to handle wink
* completion events on this channel.
*/
if (sr_enbhdlr(chdev[i], TDX_WINK, wink_handler) == -1) {
/* process error */
}
/* Before issuing dx_wink(), ensure that the channel is onhook,
* else the wink will fail.
*/
if(dx_sethook(chdev[i], DX_ONHOOK, EV_ASYNC)==-1){
/* error setting channel on-hook */
}
/* Use sr_waitevt( ) to wait for the completion of dx_sethook( ). */
if (dx_wink(chdev[i], EV_ASYNC) == -1) {
/* error winking channel */
}
}
/* Use sr_waitevt() to wait for the completion of wink.
* On receiving the completion event, TDX_WINK, control is transferred
* to the handler function previously established using sr_enbhdlr().
*/
.
.
}
int wink_handler()
{
printf("wink completed on channel %s\n", ATDX_NAMEP(sr_getevtdev()));
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 |
|
Related Functions:
Handling and Retrieving dx_wink Termination Events:
Handling outbound winks:
Handling inbound winks:
Click here to contact Dialogic Customer Engineering
Copyright 2002, Dialogic Corporation