|
|
etVoiceModemPager Sample Program Source Code
NOTE: Source code in other development
environments provided with the appropriate zip file on the main page
for this sample. VB is shown here just as an example.
Private Function IsOnlyDataModem() As Boolean
Dim ModemMediaModes As Integer
' These are the minimal media modes expected for standard data modems
ModemMediaModes = LINEMEDIAMODE_INTERACTIVEVOICE + LINEMEDIAMODE_DATAMODEM
' Check to see if the selected device is a modem and it is a voice modem
If (InStr(1, etLine1.TAPITSP, "Modem", 1) > 0) And _
((etLine1.DeviceMediaModesAvailable And ModemMediaModes) = _
ModemMediaModes) Then
IsOnlyDataModem = True
Else
IsOnlyDataModem = False
End If
End Function
Private Function IsVoiceModem() As Boolean
Dim ModemMediaModes As Integer
Dim VoiceModemMediaModes As Integer
' These are the minimal media modes expected for standard data modems
ModemMediaModes = LINEMEDIAMODE_INTERACTIVEVOICE + LINEMEDIAMODE_DATAMODEM
' These are the minimal media modes expected for voice modems
VoiceModemMediaModes = ModemMediaModes + LINEMEDIAMODE_UNKNOWN + _
LINEMEDIAMODE_AUTOMATEDVOICE
' Check to see if the selected device is a modem and it is a voice modem
If (InStr(1, etLine1.TAPITSP, "Modem", 1) > 0) And _
((etLine1.DeviceMediaModesAvailable And VoiceModemMediaModes) >= _
VoiceModemMediaModes) Then
IsVoiceModem = True
Else
IsVoiceModem = False
End If
End Function
Private Sub Hangup()
' Disable the timer
TimerSendDigitDelay.Enabled = False
' Make sure that it is safe to hangup
If (etLine1.CallCount > 0) And _
(etLine1.CallHandle <> 0) And _
(etLine1.CallState <> LINECALLSTATE_IDLE) Then
' Hangup the call
etLine1.CallHangup
End If
End Sub
Private Sub ComboDevice_Click()
' Disable the Dial button
CommandDial.Enabled = False
TextStatus.Text = "Device not active..."
' Set the TAPI Line device
etLine1.DeviceName = ComboDevice.Text
' Check to see if the selected device is a Voice modem
If IsVoiceModem Then
' Active the TAPI Line device
etLine1.DeviceActive = True
If Not etLine1.DeviceActive Then
TextStatus.Text = "Error opening line device: " & _
etLine1.ErrorText
Else
' Enable the Dial button
CommandDial.Enabled = True
TextStatus.Text = "Idle"
End If
Else
' Check to see if the selected device is a modem
If IsOnlyDataModem Then
MsgBox ("This device is Data Modem!" & vbCrLf & _
"Use the etDataModemDial sample program.")
Else
MsgBox ("This device is not a modem!" & vbCrLf & _
"Use the etPager sample program.")
End If
End If
End Sub
Private Sub CommandDial_Click()
' Clear the status
TextStatus.Text = ""
etLine1.CallPhoneNumber = TextPhoneNumber.Text
If etLine1.CallPhoneNumber = "" Then
' No phone number found
TextStatus.Text = "No phone number"
' Go on to the next call
etLine1_OnIdle (etLine1.CallHandle)
Else
' Disable the Dail button
CommandDial.Enabled = False
' Dial
etLine1.CallDial
' Check for errors
If etLine1.ErrorNumber = 0 Then
TextStatus.Text = "Dialing - " & etLine1.CallPhoneNumber
Else
TextStatus.Text = "Error Dialing - " & etLine1.ErrorText
' Enable the Dail button
CommandDial.Enabled = True
End If
End If
End Sub
Private Sub etLine1_OnBusy(ByVal CallHandle As Long)
TextStatus.Text = "Busy"
' Do not call hangup because it will be called in the
' etLine.OnDisconnect event handler routine
End Sub
Private Sub etLine1_OnConnected(ByVal CallHandle As Long)
' Voice modems fire the etLine.OnConnect event as soon as dialing is
' complete. So there needs to be a delay before sending the DTMF tones
' (digits) for the Call Back Number.
' When calling a pager service they generally answer on the first or
' second ring and they tend to be consistant. So a timer is used to
' delay.
' This program deafults to a 5 second delay (5000 milliseconds).
' Testing may be required to determine the correct delay for each
' pager service.
TextStatus.Text = "Delaying Sending digits..."
TimerSendDigitDelay.Interval = Val(TextSendDigitsDelay.Text)
TimerSendDigitDelay.Enabled = True
End Sub
Private Sub etLine1_OnDigitsSent(ByVal CallHandle As Long)
' The digits have been sent
TextStatus.Text = "Sending digits... Complete"
Hangup
End Sub
Private Sub etLine1_OnDisconnected(ByVal CallHandle As Long)
Hangup
End Sub
Private Sub etLine1_OnIdle(ByVal CallHandle As Long)
' The call is complete
TextStatus.Text = "Idle"
' Enable the Dial button
CommandDial.Enabled = True
End Sub
Private Sub Form_Load()
'Enabled all ExceleTel TeleTools controls before using them
etLine1.Enabled = True
' Fill the combo box with all available devices
ComboDevice.Clear
etLine1.DeviceID = 0
For L = 0 To etLine1.DeviceCount - 1
ComboDevice.AddItem etLine1.DeviceList(L)
Next L
'Select the first device
If ComboDevice.ListCount > 0 Then
ComboDevice.Text = ComboDevice.List(0)
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'Close the etLine control when closing the form
etLine1.DeviceActive = False
End Sub
Private Sub TimerSendDigitDelay_Timer()
' Disable the timer
TimerSendDigitDelay.Enabled = False
' Send the DTMF tones for the Call Back Number
TextStatus.Text = "Sending digits..."
Call etLine1.CallSendDigits(TextCallBackNumber.Text, 0)
End Sub
|