Contact Info

Crumbtrail

ActiveXperts.com » Serial Port Component » AT Commands » DTMF Paging

How to send a DTMF page using a GSM modem

What are DTMF tones ?

There are companies which have a telephone system which can be controlled by DTMF tones (for instance: pager systems). To use these services you need to have a phone which is capable to send DTMF tones. DTMF stands for Dual Tone Multiple Frequency. When a key on the phone is pressed during a phone call this character is send using DTMF. The following characters can be send using DTMF: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,* and #.

The DTMF keypad is laid out in a 4×4 matrix, with each row representing a low frequency, and each column representing a high frequency (see table). Pressing a single key such as '1' will send a sinusoidal tone of the two frequencies 697 and 1209 hertz (Hz). The original keypads had levers inside, so each button activated two contacts. The multiple tones are the reason for calling the system multifrequency. These tones are then decoded by the switching center to determine which key was pressed.

 1209Hz 1336Hz 1477Hz 1633Hz
697Hz 1 2 3 A
770 4 5 6 B
852Hz 7 8 9 C
941Hz * 0 # D

How to send DTMF tones

Of course you can send DTMF phones using your fixed line phone or cellphone, but if you want to automate the sending of these tones over a phone connection, it becomes difficult because most modems can only send DTMF to dial a number, but when the connection is made, there is no way to send these tones. Some GSM modems do have this featuresuch as the WaveCom and the Multitech GSM modems.

Sending DTMF tones using a WaveCom or Multitech GSM modem

The following code sample demonstrates how to send a numeric text message to a pager using a GSM modem. The sample checks if there is a PIN code on the SIM card in the GSM modem and sets the code.

If the code is correct, the modem will dial the number in voice mode, waits till the connection has been established and sends the DTMF code. Finally, the connection is terminated.

The following AT Commands are used:

ATDxxxxxxxxxxxxxxx;

The ATD command is used to dial a number. The semi-colon at the end of this number indicates that this connection has to be setup as a voice call. When leaving this semi-colon, the connection is set up as a data call.

AT+VTD=xx

This command is optional, and is used to set the DTMF tone duration in 100mS steps.

AT+VTS=x

To send the actual DTMF code, you have to call this command for every digit sent. To send, for instance "*1234#", you have to send:

AT+VTD=*;+VTD=1;+VTD=2;+VTD=3;+VTD=4;+VTD=#

ATH0

Terminates the phone connection (hangup).

You need to have the SMS and MMS Toolkit installed to run this VBScript code:

Option Explicit

Dim objGsm
Dim strResponse

Set objGsm = CreateObject ( "ActiveXperts.SmsProtocolGsm" )

objGsm.Device        = "COM1"
objGsm.DeviceSpeed   = "115200"
objGsm.LogFile       = "C:\DTMF.TXT"

WScript.Echo "Sending AT&D0"
strResponse = objGsm.SendCommand ( "AT&D0", 1000 )    ' Do not release the call when DTR is switched to LOW
WScript.Echo( "Response : " & strResponse )

WScript.Echo "Sending ATE0"
strResponse = objGsm.SendCommand ( "ATE0",  1000 )     ' Switch off echo
WScript.Echo( "Response : " & strResponse )

objGsm.EnterPin      "0000"          ' Optional, only required when there is a PIN code on the SIM card

If ( objGsm.LastError <> 0 ) Then
    WScript.Echo "EnterPin: ERROR #" & objGsm.LastError & " (" & objGsm.GetErrorDescription ( objGsm.LastError ) & ")"
    WScript.Quit
End If

' optional delay to wait until the GSM modem is connected to the network
'WScript.Sleep ( 5000 )                 

WScript.Echo "Setting up connection to remote party..."

' Dial to remote party, and wait for max 10 seconds for an 'OK' response

strResponse = objGsm.SendCommand ( "ATD+31647134225;", 10000 )     

If ( objGsm.LastError <> 0 ) Then
    WScript.Echo "SendCommand: ERROR #" & objGsm.LastError & " (" & objGsm.GetErrorDescription ( objGsm.LastError ) & ")"
    WScript.Quit
End If

WScript.Echo( "Response : " & strResponse )
WScript.Sleep ( 1000 )

WScript.Echo "Sending DTMF..."

' Send the DTMF code ( *1234# ), modem does not respond to this command, so no error handling

objGsm.SendCommand "AT+VTD=5;+VTS=*;+VTS=1;+VTS=2;+VTS=3;+VTS=4;+VTS=#", 5000 

' Wait 2 seconds till the DTMF code has been processed by the remote party

WScript.Sleep( 2000 )       

WScript.Echo "Hanging up..."

strResponse = objGsm.SendCommand ( "ATH0", 2000 )

WScript.Echo( "Response : " & strResponse )
WScript.Echo ( "Ready" )