# adiStopProtocol

Stops the execution of a telephony protocol.

#### Supported board types

- AG

- CG

#### Prototype

DWORD adiStopProtocol ( CTAHD ctahd)

Argument | Description
ctahd | Context handle returned by ctaCreateContext or ctaAttachContext.

#### Return values

Return value | Description
SUCCESS |
CTAERR_FUNCTION_NOT_ACTIVE | Attempt made to stop a function that was not running.
CTAERR_INVALID_CTAHD | Context handle is invalid.
CTAERR_INVALID_STATE | Function not available in the current port state.
CTAERR_SVR_COMM | Server communication error.

#### Events

Event | Description
ADIEVN_STOPPROTOCOL_DONE | When the protocol stops, the ADI service generates a DONE event with the value field set to CTA_REASON_FINISHED.

#### Details

Use adiStopProtocol to stop a protocol previously started with adiStartProtocol. You can stop the running protocol from any state. If the protocol is in the middle of a call, the call is aborted (abnormally), the outgoing line signaling is set to ADI_CC_STATE_IDLE, and the incoming signaling is ignored. All functions executing on the context that require being in the connected state are automatically terminated with CTA_REASON_RELEASED.

When the DONE event is returned, you can start a new protocol.

#### Example

int myStopProtocol( CTAHD ctahd )
{
CTA_EVENT event;
if( adiStopProtocol( ctahd ) != SUCCESS )
return MYFAILURE;
while( 1 )
{
myGetEvent( &event ); /* see ctaWaitEvent example */
switch( event.id )
{
case ADIEVN_STOPPROTOCOL_DONE:
if( CTA_IS_ERROR( event.value ) )
return MYFAILURE; /* API error */
else
return SUCCESS; /* stopped normally */
break;
}
}
}