adiStartSignalDetector

Starts detecting changes in incoming out-of-band signaling bits.

Supported board types

Prototype

DWORD adiStartSignalDetector ( CTAHD ctahd, unsigned initial, unsigned mask, unsigned timeon, unsigned timeoff)

Argument

Description

ctahd

Context handle returned by ctaCreateContext or ctaAttachContext.

initial

Mask indicating the expected incoming line state (refer to mask for possible values).

mask

Mask indicating the bits to monitor. For example, by setting this mask to ADI_A_BIT, all transitions of the A bit are reported and transitions of the other bits are ignored. The following constants are in adidef.h and can be combined using the OR operation to monitor any group of bits:

ADI_A_BIT

ADI_B_BIT

ADI_C_BIT

ADI_D_BIT

timeon

Deglitching (debounce) time (in milliseconds) for the ON state of the masked bits. The bit transition to HIGH is not reported unless it exceeds timeon.

timeoff

Deglitching (debounce) time (in milliseconds) for the OFF state of the masked bits. The bit transition to LOW is not reported unless it exceeds timeoff.

Return values

Return value

Description

SUCCESS

 

ADIERR_INVALID_CALL_STATE

Function not valid in the current call state.

CTAERR_FUNCTION_ACTIVE

Function already active.

CTAERR_FUNCTION_NOT_AVAIL

Necessary .dsp file was not downloaded to the board.

CTAERR_INVALID_CTAHD

Context handle is invalid.

CTAERR_INVALID_STATE

Function not valid in the current port state.

CTAERR_SVR_COMM

Server communication error.

Events

Event

Description

ADIEVN_SIGNALBIT_CHANGED

After the detector is started, if a bit transition is detected, the ADI service generates ADIEVN_SIGNALBIT_CHANGED with the value field set to the bit change and the size field set to the current state of the signaling bits.

The change is defined as follows:

0xA1
A bit went HI

0xB1
B bit went HI

0xC1
C bit went HI

0xD1
D bit went HI

0xA0
A bit went LO

0xB0
B bit went LO

0xC0
C bit went LO

0xD0
D bit went LO

The current state is a mask of the bits ADI_A_BIT, ADI_B_BIT, ADI_C_BIT, and ADI_D_BIT.

These messages are serialized with the transitions. You receive one event for each bit change.

ADIEVN_SIGNAL_DETECT_DONE

The value field can be set to any of the following:

CTAERR_xxx or ADIERR_xxx

Signal detector function failed.

CTA_REASON_STOPPED

Function stopped as a result of calling adiStopSignalDetector.

Details

AG 2000, AG 2000C, and AG 2000-BRI boards require signal.m54 to be loaded.

Use adiStartSignalDetector to enable detection of incoming out-of-band signaling bits. After this function is called, transitions of masked bits are reported as events, along with the current state of all bits.

If the line state does not match the value set in initial, an event is generated after qualification time, timeon, or timeoff.

Note: This function is incompatible with standard call control. Contexts running a standard protocol other than NOCC are usually excluded from using this function. Protocols usually use out-of-band signaling bits for call setup (detection of incoming calls) and call teardown (detection of hang-up). For more information about controlling calls under specific TCPs, refer to the Dialogic® NaturalAccess™ CAS API Developer's Manual.

For more information, refer to Performing low-level call control.

See also

adiQuerySignalState

Example

#define ALL_BITS (ADI_A_BIT|ADI_B_BIT|ADI_C_BIT|ADI_D_BIT)

int myMonitorSignal( CTAHD ctahd )
{
    CTA_EVENT event;
    /* start function to monitor all bit changes of 100 ms */
    if( adiStartSignalDetector( ctahd, 0, ALL_BITS, 100, 100 ) != SUCCESS )
        return MYFAILURE;

    while( 1 )
    {
       const char *pc;

       myGetEvent( &event );                  /* see ctaWaitEvent example */

       switch( event.id )
       {
           case ADIEVN_SIGNAL_DETECT_DONE:
               if( event.value == CTA_REASON_STOPPED )
                   return SUCCESS;
               else
                   return MYFAILURE;

           case ADIEVN_SIGNALBIT_CHANGED:
               switch( event.value )       /* value contains the change   */
               {                           /* size contains current state */
                   case 0xA1: pc = "A ON"; break;
                   case 0xB1: pc = "B ON"; break;
                   case 0xC1: pc = "C ON"; break;
                   case 0xD1: pc = "D ON"; break;
                   case 0xA0: pc = "A OFF"; break;
                   case 0xB0: pc = "B OFF"; break;
                   case 0xC0: pc = "C OFF"; break;
                   case 0xD0: pc = "D OFF"; break;
               }
               printf( "MVIP bit change: %s\tsignalling bits = 0x%x "
                         "(%c%c%c%c)\n",
                       pc, (event.value&0xf),
                      (event.size&0x8)?'A':'-', (event.size&0x4)?'B':'-',
                      (event.size&0x2)?'C':'-', (event.size&0x1)?'D':'-' );
               break;
           /* might include cases to handle disconnect event, DTMFs, etc. */
       }
    }
}