
Description | Termination Event | Cautions | Example | Errors | See Also
Name: |
int cc_Restart(linedev, mode) | |
Inputs: |
LINEDEV linedev |
|
unsigned long mode |
| |
Returns: |
0 on success | |
Includes: |
cclib.h | |
Category: |
System control | |
Mode: |
synchronous or asynchronous | |
Technology: |
BRI/2; BRI/SC; PRI (all protocols) | |
The cc_Restart( ) function resets the channel to Null state. This function typically is used after the recovery of trunk errors or alarm conditions, or when the application needs to reset the channel to NULL state.
When the cc_Restart( ) function is called, the following activities take place on the B channel specified in linedev. If the application is using the call waiting feature (BRI and Windows only) and a board device has been specified in linedev, the following activities will take place on all of the B channels associated with the board device. The activities take place in the order listed:
Parameter |
Description |
linedev: |
Specifies the line device handle for the channel or, for applications using the call waiting feature, the board device handle (BRI and Windows only). |
mode: |
Specifies asynchronous (EV_ASYNC) or synchronous (EV_SYNC) mode. NOTE: For synchronous applications, the cc_Restart( ) function must be issued by the same process as the device controlling process. |
In asynchronous mode, the application cannot call any call state-related function prior to CCEV_RESTART.
#include <windows.h> /* For Windows applications only */
#include <process.h>
#include <stdio.h>
#include <errno.h>
#include "srllib.h"
#include "dtilib.h"
#include "cclib.h"
#define ESC 27 /* ASCII ESC value */
#define SPACE ' ' /* ASCII space value */
void WaitCallThread(void *argp);
main()
{
short devhdl; /* device handle for B channel */
.
.
.
/* open the channel 1 device */
if ( cc_Open(&devhdl,"dtiB1T1", 0 ) < 0 )
exit(1); /* or different actions */
/* start a child thread */
if ( _beginthread( WaitCallThread ,0,(void *)&devhdl) < 0 )
exit(1);
.
.
while(1)
{
int keyin; /* key stroke */
printf("Press <SPACE> to make a call, or press <ESC> to quit\n");
keyin = getch();
if ( keyin == ESC )
break;
else if (keyin == SPACE)
makecall(devhdl); /* make a call */
/* else repeat the loop */
}
.
.
cc_Close(devhdl);
}
/******************************************************************
/* NAME: void WaitCallThread(devhdlptr)
/* DESCRIPTION: Waits for incoming call.
/* INPUT: devhdlptr - pointer to devhdl
/* RETURNS: none.
******************************************************************/
void WaitCallThread(void *devhdlptr)
{
short devhdl = *devhdlptr; /* device handle */
CRN crn; /* call reference number */
.
.
.
while(1)
{
.
.
.
/* wait for an incoming call */
if ( cc_WaitCall(devhdl,&crn,NULL,-1,EV_SYNC) < 0 )
procdevfail(devhdl);
if ( cc_AnswerCall(crn,0,EV_SYNC) < 0 )
callfail(crn);
.
.
.
.
}
.
.
.
}
/*
/* function to make an outbound call
*/
int makecall(short devhdl)
{
CRN crn; /* call reference number */
char *dialnum = "12019933000"; /* outgoing phone number */
.
.
.
/*
*This cc_Restart() allows the B channel line device to
*escape from cc_WaitCall(), or other multitasking
*functions.
*/
if ( cc_Restart(devhdl, EV_SYNC) < 0 )
procdevfail(devhdl);
/*
* Now it's safe to make a call. To avoid contention,
* a mechanism to prevent other multitasking functions
* from being invoked again, such as cc_WaitCall(),
* is recommended here.
*/
if ( cc_MakeCall(devhdl, &crn, dialnum, NULL, 20, EV_SYNC)
< 0 )
procdevfail(devhdl);
.
.
.
.
}
/* function to process error conditions */
int callfail(CRN crn)
{
LINEDEV ld;
cc_CRN2LineDev(crn,&ld);
procdevfail(ld);
}
int procdevfail(LINEDEV handle)
{
int reason;
char *msg;
reason = cc_CauseValue(handle);
cc_ResultMsg(handle, reason, &msg);
printf("reason = %x - %s\n",reason,msg);
}
If the function returns a value < 0 to indicate failure, use the cc_CauseValue( ) function to retrieve the reason code for the failure. The cc_ResultMsg( ) function can be used to interpret the reason code. Error codes are defined in the files ccerr.h, isdnerr.h, and isdncmd.h.
Error codes from the cc_Restart( ) function include the following:
Error Code |
Description |
ERR_ISDN_LIB | E_ISBADIF |
Bad interface number |
ERR_ISDN_LIB | E_ISBADCALLID |
Bad call identifier |
ERR_ISDN_LIB | E_ISBADTS |
Bad time slot |
None
Click here to contact Dialogic Customer Engineering
Copyright 2001, Dialogic Corporation