Reading Channel Status for Analog Ports

The Dialogic Diva Software Development Kit (SDK) includes two samples that demonstrate how the channel status (up, down, activating, etc) can be read: ShowDeviceStatus and ShowDeviceStatusEvents. 

These samples show how to read status information specific to digital (PRI/E1/T1 and ISDN BRI) Dialogic Diva Media Boards, but they do not address analog boards such as the Dialogic Diva Analog/4P Media Board. 

This article describes a way to read analog-specific status messages. You can take the code in this article and add it to ShowDeviceStatus to make a version of the sample that works for both digital and analog boards.

First, you need to detect if a particular line device belongs to a Diva analog media board or a Diva digital media board:

BOOL IsAnalog(DWORD i) {   BOOL analog;     analog = DivaCheckDeviceCapabilities( i, DivaDevCapsAnalogBased );     return analog; }

 

The input parameter 'i' is the line device number.  Dialog Diva Media Board line device numbers start with 1 and go up to the maximum value returned by DivaGetNumLineDevices.

Having identified a Diva analog media board, you can create a function that retrieves status information specific to Diva analog boards using the type DivaDST_PotsLineStatus.

void PrintAnalogStatus ( DWORD i ) {   DivaDeviceStatusValue Value;   char statename[32]={0};   DWORD Result, j, maxchans=4;   DivaLineDeviceInfo d;     // first find out how many channels there are on the board   d.Size = sizeof(d);   Result = DivaGetLineDeviceInfo( i, &d );   if(Result==DivaSuccess)   {     maxchans = d.Channels;   }       // now find the status for each channel in turn   for(j=0;j<maxchans;j++)   {       Value.PotsLineState.Channel = j+1;     Result = DivaGetLineDeviceStatus ( i, DivaDST_PotsLineStatus, &Value, sizeof ( Value ) );     if ( Result == DivaSuccess )     {       switch(Value.PotsLineState.Status)       {       case DivaPotsLineDown: lstrcpy(statename,"DivaPotsLineDown"); break;       case DivaPotsLineHookOff: lstrcpy(statename,"DivaPotsLineHookOff"); break;       case DivaPotsLineIdle: lstrcpy(statename,"DivaPotsLineIdle"); break;       case DivaPotsLineRing: lstrcpy(statename,"DivaPotsLineRing"); break;       case DivaPotsLinePolarityReverse: lstrcpy(statename,"DivaPotsLinePolarityReverse"); break;       }       printf ( "Device %d.%d, POTS Status:     %ld (%s)\n", i,Value.PotsLineState.Channel, Value.PotsLineState.Status, statename );     }     else       printf ( "Error %d reading PotsLineState\n", Result );   } }

NOTE

A Diva Analog/4P Media Board (which has 4 separate analog phone line interfaces) appears in the program as a single line device that has four channels on the same line device. This is why the code iterates 'maxchans' times, to get the status for each channel in turn. The Diva Analog/8P Media Board has 8 channels on one line device, and the Diva Analog/2P Media Board has 2 channels on one line device.

 

The phone line status for line device 'i'  can be retrieved by this line:

Result = DivaGetLineDeviceStatus ( i, DivaDST_PotsLineStatus, &Value, sizeof ( Value ) );

 

The 'Value' parameter selects the channel. 'Value' is a structure that contains PotsLineState.Channel  (set before the function call) and PotsLineState.Status (returned by the function call).

Finally, you can add the new functionality to the program by changing the main loop to call different status functions depending on the line device type:

 

Return to Documentation Home I Return to Sangoma Support